Skip to content

Commit 1043efa

Browse files
Merge branch 'develop'
* develop: style changes #53 - fixedFooter is displayed for HasOne, BelongsTo, MorphIne relations - only set fixedFooter for Grid #52 - Font Awesome brand icon not showing Now able to use fab & fas prefix for icons. to show brands / solid icons. #46 - Decimal mask not displaying correctly (Input mask.js) Fixing decimal issues #48 - Switcher issue Fix switch for inline edit. Also set to 0 when its turned of. Apply fixes from StyleCI Fixing issue #51 - First tab is always active in Tab Widgets - prevent numbered tabs error - fixed issues with active tabs.
2 parents 91d52ef + 839f43e commit 1043efa

File tree

12 files changed

+122
-92
lines changed

12 files changed

+122
-92
lines changed

resources/assets/inputmask/inputmask.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/open-admin/css/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/open-admin/css/styles.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/open-admin/scss/fontawesome.scss

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
$fa-font-path: "../../fontawesome/webfonts";
2-
$fa-css-prefix: "icon";
3-
@import "../../fontawesome/scss/fontawesome";
4-
@import "../../fontawesome/scss/solid";
5-
@import "../../fontawesome/scss/brands";
6-
[class^="icon-"]:before,
7-
[class*=" icon-"]:before {
8-
font-family: "Font Awesome 5 Free";
1+
$fa-font-path: '../../fontawesome/webfonts';
2+
$fa-css-prefix: 'icon';
3+
@import '../../fontawesome/scss/fontawesome';
4+
@import '../../fontawesome/scss/solid';
5+
@import '../../fontawesome/scss/brands';
6+
7+
[class^='icon-']:before,
8+
[class*=' icon-']:before,
9+
.far [class^='icon-']:before,
10+
.far [class*=' icon-']:before {
11+
font-family: 'Font Awesome 5 Free';
912
font-style: normal;
1013
font-weight: normal;
1114
speak: never;
@@ -39,8 +42,17 @@ $fa-css-prefix: "icon";
3942
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
4043
}
4144

45+
.fas:before {
46+
font-family: 'Font Awesome 5 Free';
47+
font-weight: 900;
48+
}
49+
50+
.fab:before {
51+
font-family: 'Font Awesome 5 Brands';
52+
}
53+
4254
/* icons in dropdown menu's */
43-
.dropdown-item i[class^="icon-"]:before,
44-
.dropdown-item i[class*=" icon-"]:before {
45-
margin-right:8px;
55+
.dropdown-item i[class^='icon-']:before,
56+
.dropdown-item i[class*=' icon-']:before {
57+
margin-right: 8px;
4658
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
<script>
22
document.querySelectorAll('.{{ $class }}').forEach(checkbox => {
3-
checkbox.addEventListener("change",function(target){
3+
checkbox.addEventListener('change', function(target) {
44
55
var key = this.dataset.key;
6-
var value = this.checked;
7-
var url = "{{ $resource }}/" + key;
6+
var value = this.checked ? 'on' : 'off';
7+
var url = '{{ $resource }}/' + key;
88
var obj = {
9-
method : 'post',
10-
data : {
11-
_method: 'PUT',
12-
'{{ $name }}': value,
9+
method: 'post',
10+
data: {
11+
_method: 'PUT',
12+
'{{ $name }}': value,
1313
'after-save': 'exit'
1414
}
1515
}
16-
17-
admin.ajax.request(url,obj,function(result){
18-
if (result.status){
16+
17+
admin.ajax.request(url, obj, function(result) {
18+
if (result.status) {
1919
admin.toastr.success(result.data);
20-
}else{
20+
} else {
2121
admin.toastr.warning(result.data);
2222
}
2323
});
2424
})
2525
});
26-
</script>
26+
</script>
Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
11
<div {!! $attributes !!}>
22
<ul class="nav nav-tabs">
33

4-
@foreach($tabs as $id => $tab)
5-
@if($tab['type'] == \OpenAdmin\Admin\Widgets\Tab::TYPE_CONTENT)
6-
<li class="nav-item"><a class="nav-link {{ $tab['active'] ? 'active' : '' }}" href="#{{ $tab['title'] }}" data-bs-toggle="tab">{{ $tab['title'] }}</a></li>
4+
@foreach ($tabs as $i => $tab)
5+
@if ($tab['type'] == \OpenAdmin\Admin\Widgets\Tab::TYPE_CONTENT)
6+
<li class="nav-item"><a class="nav-link {{ $active === $i ? 'active' : '' }}" href="#{{ $tab['ref'] }}"
7+
data-bs-toggle="tab">{{ $tab['title'] }}</a></li>
78
@elseif($tab['type'] == \OpenAdmin\Admin\Widgets\Tab::TYPE_LINK)
8-
<li class="nav-item"><a class="nav-link {{ $tab['active'] ? 'active' : '' }}" href="{{ $tab['href'] }}">{{ $tab['title'] }}</a></li>
9+
<li class="nav-item"><a class="nav-link {{ $active === $i ? 'active' : '' }}"
10+
href="{{ $tab['href'] }}">{{ $tab['title'] }}</a></li>
911
@endif
1012
@endforeach
1113

1214
@if (!empty($dropDown))
13-
<li class="dropdown">
14-
<a class="dropdown-toggle" data-bs-toggle="dropdown" href="#">
15-
Dropdown <span class="caret"></span>
16-
</a>
17-
<ul class="dropdown-menu">
18-
@foreach($dropDown as $link)
19-
<li role="presentation"><a role="menuitem" tabindex="-1" href="{{ $link['href'] }}">{{ $link['name'] }}</a></li>
20-
@endforeach
21-
</ul>
22-
</li>
15+
<li class="dropdown">
16+
<a class="dropdown-toggle" data-bs-toggle="dropdown" href="#">
17+
Dropdown <span class="caret"></span>
18+
</a>
19+
<ul class="dropdown-menu">
20+
@foreach ($dropDown as $link)
21+
<li role="presentation"><a role="menuitem" tabindex="-1"
22+
href="{{ $link['href'] }}">{{ $link['name'] }}</a></li>
23+
@endforeach
24+
</ul>
25+
</li>
2326
@endif
2427
<li class="pull-right header">{{ $title }}</li>
2528
</ul>
2629
<div class="tab-content">
27-
@foreach($tabs as $id => $tab)
28-
<div class="card-body tab-pane {{ $tab['active'] ? 'active' : '' }}" id="{{ $tab['title'] }}">
29-
@php($content = \Illuminate\Support\Arr::get($tab, 'content'))
30-
@if($content instanceof \Illuminate\Contracts\Support\Renderable)
30+
@foreach ($tabs as $i => $tab)
31+
<div class="card-body tab-pane {{ $active === $i ? 'active' : '' }}" id="{{ $tab['ref'] }}">
32+
@php($content = \Illuminate\Support\Arr::get($tab, 'content'))
33+
@if ($content instanceof \Illuminate\Contracts\Support\Renderable)
3134
{!! $content->render() !!}
3235
@else
3336
{!! $content !!}
3437
@endif
35-
</div>
38+
</div>
3639
@endforeach
3740

3841
</div>
39-
</div>
42+
</div>

src/Form.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ protected function ajaxResponse($message)
424424
// ajax but not pjax
425425
if ($request->ajax() && !$request->pjax()) {
426426
return response()->json([
427-
'status' => true,
428-
'message' => $message,
429-
'display' => $this->applayFieldDisplay(),
427+
'status' => true,
428+
'message' => $message,
429+
'display' => $this->applayFieldDisplay(),
430430
]);
431431
}
432432

@@ -516,9 +516,9 @@ protected function getRelationInputs($inputs = []): array
516516
$relations = [];
517517

518518
foreach ($inputs as $column => $value) {
519-
if ((method_exists($this->model, $column) ||
520-
method_exists($this->model, $column = Str::camel($column))) &&
521-
!method_exists(Model::class, $column)
519+
if ((method_exists($this->model, $column)
520+
|| method_exists($this->model, $column = Str::camel($column)))
521+
&& !method_exists(Model::class, $column)
522522
) {
523523
$relation = call_user_func([$this->model, $column]);
524524

@@ -605,7 +605,7 @@ public function update($id, $data = null)
605605
protected function redirectAfterStore()
606606
{
607607
$resourcesPath = $this->resource(0);
608-
$key = $this->model->getKey();
608+
$key = $this->model->getKey();
609609

610610
return $this->redirectAfterSaving($resourcesPath, $key);
611611
}
@@ -702,7 +702,7 @@ protected function handleColumnUpdates($id, $data)
702702
protected function handleEditable(array $input = []): array
703703
{
704704
if (array_key_exists('_editable', $input)) {
705-
$name = $input['name'];
705+
$name = $input['name'];
706706
$value = $input['value'];
707707

708708
Arr::forget($input, ['pk', 'value', 'name']);
@@ -768,7 +768,7 @@ protected function updateRelation($relationsData)
768768
|| $relation instanceof Relations\BelongsTo;
769769

770770
$isRelationUpdate = true;
771-
$prepared = $this->prepareUpdate([$name => $values], $oneToOneRelation, $isRelationUpdate);
771+
$prepared = $this->prepareUpdate([$name => $values], $oneToOneRelation, $isRelationUpdate);
772772

773773
if (empty($prepared)) {
774774
continue;
@@ -851,8 +851,8 @@ protected function prepareUpdate(array $updates, $oneToOneRelation = false, $isR
851851
foreach ($this->fields() as $field) {
852852
$columns = $field->column();
853853

854-
if ($this->isInvalidColumn($columns, $oneToOneRelation || $field->isJsonType) ||
855-
(in_array($columns, $this->relation_fields) && !$isRelationUpdate)) {
854+
if ($this->isInvalidColumn($columns, $oneToOneRelation || $field->isJsonType)
855+
|| (in_array($columns, $this->relation_fields) && !$isRelationUpdate)) {
856856
continue;
857857
}
858858

@@ -883,8 +883,8 @@ protected function prepareUpdate(array $updates, $oneToOneRelation = false, $isR
883883
protected function isInvalidColumn($columns, $containsDot = false): bool
884884
{
885885
foreach ((array) $columns as $column) {
886-
if ((!$containsDot && Str::contains($column, '.')) ||
887-
($containsDot && !Str::contains($column, '.'))) {
886+
if ((!$containsDot && Str::contains($column, '.'))
887+
|| ($containsDot && !Str::contains($column, '.'))) {
888888
return true;
889889
}
890890
}
@@ -1089,7 +1089,6 @@ public function validationMessages($input)
10891089
if (!$validator = $field->getValidator($input)) {
10901090
continue;
10911091
}
1092-
10931092
if (($validator instanceof Validator) && !$validator->passes()) {
10941093
$failedValidators[] = $validator;
10951094
}
@@ -1136,14 +1135,14 @@ public function getRelations(): array
11361135
if (Str::contains($column, '.')) {
11371136
list($relation) = explode('.', $column);
11381137

1139-
if (method_exists($this->model, $relation) &&
1140-
!method_exists(Model::class, $relation) &&
1141-
$this->model->$relation() instanceof Relations\Relation
1138+
if (method_exists($this->model, $relation)
1139+
&& !method_exists(Model::class, $relation)
1140+
&& $this->model->$relation() instanceof Relations\Relation
11421141
) {
11431142
$relations[] = $relation;
11441143
}
1145-
} elseif (method_exists($this->model, $column) &&
1146-
!method_exists(Model::class, $column)
1144+
} elseif (method_exists($this->model, $column)
1145+
&& !method_exists(Model::class, $column)
11471146
) {
11481147
$relations[] = $column;
11491148
}
@@ -1448,7 +1447,7 @@ public function input($key, $value = null)
14481447
*
14491448
* @return $this
14501449
*/
1451-
public function column($width, \Closure $closure): self
1450+
public function column($width, Closure $closure): self
14521451
{
14531452
$width = $width < 1 ? round(12 * $width) : $width;
14541453

src/Form/Field/File.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class File extends Field
2121
'/vendor/open-admin/fields/file-upload/file-upload.js',
2222
];
2323

24-
public $type = 'file';
24+
public $type = 'file';
2525
public $readonly = false;
2626

2727
/**
@@ -48,7 +48,7 @@ public function defaultDirectory()
4848
}
4949

5050
/**
51-
* {@inheritdoc}
51+
* @inheritdoc
5252
*/
5353
public function getValidator(array $input)
5454
{
@@ -81,7 +81,7 @@ public function getValidator(array $input)
8181
return false;
8282
}
8383

84-
$rules[$this->column] = $fieldRules;
84+
$rules[$this->column] = $fieldRules;
8585
$attributes[$this->column] = $this->label;
8686

8787
return \validator($input, $rules, $this->getValidationMessages(), $attributes);
@@ -214,8 +214,8 @@ protected function setupScripts()
214214
$this->setType();
215215
$this->attribute('id', $id);
216216
$this->options['storageUrl'] = $this->storageUrl();
217-
$json_options = json_encode($this->options);
218-
$this->script = <<<JS
217+
$json_options = json_encode($this->options);
218+
$this->script = <<<JS
219219
var FileUpload_{$id} = new FileUpload(document.querySelector('#{$id}'),{$json_options});
220220
JS;
221221
}

src/Form/Field/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Image extends File
1111
use ImageField;
1212

1313
/**
14-
* {@inheritdoc}
14+
* @inheritdoc
1515
*/
1616
protected $view = 'admin::form.file';
1717

@@ -71,7 +71,7 @@ public function prepare($file)
7171
*/
7272
public function guessPreviewType($file)
7373
{
74-
$extra = parent::guessPreviewType($file);
74+
$extra = parent::guessPreviewType($file);
7575
$extra['type'] = 'image';
7676

7777
return $extra;

src/Form/Tab.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,27 @@ protected function collectFields(\Closure $content)
104104
public function getTabs()
105105
{
106106
// If there is no active tab, then active the first.
107-
if ($this->tabs->filter(function ($tab) {
107+
$activeTabs = $this->tabs->filter(function ($tab) {
108108
return $tab['active'];
109-
})->isEmpty()) {
110-
$first = $this->tabs->first();
111-
$first['active'] = true;
109+
});
112110

111+
// if empty only first
112+
if ($activeTabs->isEmpty()) {
113+
$first = $this->tabs->first();
114+
$first['active'] = true;
113115
$this->tabs->offsetSet(0, $first);
114116
}
115117

118+
// if multiple only first
119+
if ($activeTabs->count() > 1) {
120+
foreach ($this->tabs as $i => $tab) {
121+
if ($activeTabs[0] != $tab) {
122+
$tab['active'] = false;
123+
$this->tabs->offsetSet($i, $tab);
124+
}
125+
}
126+
}
127+
116128
return $this->tabs;
117129
}
118130

0 commit comments

Comments
 (0)