Skip to content

Commit

Permalink
Merge pull request #88 from balajidharma/2.x-Changes
Browse files Browse the repository at this point in the history
2.x changes
  • Loading branch information
balajidharma authored Oct 17, 2024
2 parents 09e4e01 + 9c00b55 commit 9d669d2
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 67 deletions.
15 changes: 6 additions & 9 deletions app/Grid/Admin/CategoryItemGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ public function columns()
return [
[
'attribute' => 'name',
'label' => 'Name',
'label' => __('Name'),
'sortable' => true,
'filter' => 'like',
'searchable' => true,
],
[
'attribute' => 'slug',
'label' => __('Slug'),
'type' => 'text',
'form_options' => function ($model) {
return [
'type' => 'text',
'label' => __('Slug'),
'help_block' => [
'text' => 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.',
],
Expand All @@ -44,11 +43,10 @@ public function columns()
],
[
'attribute' => 'enabled',
'label' => 'Enabled',
'label' => __('Enabled'),
'type' => 'checkbox',
'form_options' => function ($model) {
return [
'type' => 'checkbox',
'label' => __('Enabled'),
'value' => 1,
'default_value' => 1,
];
Expand All @@ -57,10 +55,10 @@ public function columns()
[
'attribute' => 'parent_id',
'label' => __('Parent Item'),
'type' => 'choice',
'form_options' => function ($model) {
$item_options = Category::selectOptions($this->addtional['type']->id, null, true);
return [
'type' => 'choice',
'choices' => $item_options,
'label' => __('Parent Item'),
'selected' => $this->model->parent_id ?? null,
Expand All @@ -75,11 +73,10 @@ public function columns()
[
'attribute' => 'weight',
'label' => __('Weight'),
'type' => 'number',
'form_options' => function ($model) {
return [
'type' => 'number',
'wrapper' => ['class' => 'form-control py-2 w-40'],
'label' => __('Weight'),
'hide' => $this->addtional['type']->is_flat ? true : false,
];
},
Expand Down
9 changes: 4 additions & 5 deletions app/Grid/Admin/CategoryTypeGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function columns()
return [
[
'attribute' => 'id',
'label' => 'ID',
'label' => __('ID'),
'sortable' => true,
'searchable' => true,
'form_options' => function($model) {
Expand All @@ -31,7 +31,7 @@ public function columns()
],
[
'attribute' => 'name',
'label' => 'Name',
'label' => __('Name'),
'sortable' => true,
'filter' => 'like',
'searchable' => true,
Expand All @@ -56,7 +56,7 @@ public function columns()
],
[
'attribute' => 'items',
'label' => '# of Items',
'label' => __('# of Items'),
'list' => [
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
'route' => 'admin.category.type.item.index',
Expand All @@ -72,13 +72,12 @@ public function columns()
'label' => __('Use Flat Category'),
'sortable' => true,
'searchable' => true,
'type' => 'checkbox',
'value' => function($model) {
return $model->is_flat ? __('Yes') : __('No');
},
'form_options' => function($model) {
return [
'type' => 'checkbox',
'label' => __('Use Flat Category'),
'value' => 1,
'checked' => $model ? $model->is_flat : false,
];
Expand Down
29 changes: 9 additions & 20 deletions app/Grid/Admin/MediaGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ public function columns()
return [
[
'attribute' => 'type',
'filable' => true,
'fillable' => true,
'label' => __('Type'),
'type' => 'select',
'value' => function ($model) {
return $model->variant_name;
},
'form_options' => function ($model) {
$type = media_type_as_options();
return [
'type' => 'select',
'choices' => $type,
'label' => __('Type'),
'default_value' => $model ? $model->variant_name : null,
];
},
],
[
'attribute' => 'filename',
'filable' => true,
'label' => 'Name',
'fillable' => true,
'label' => __('Name'),
'sortable' => true,
'filter' => 'like',
'searchable' => true,
'type' => 'text',
'list' => [
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
'route' => 'admin.media.show',
Expand All @@ -51,28 +51,22 @@ public function columns()
'form_options' => function ($model) {
return [
'attribute' => 'name',
'type' => 'text',
'label' => __('Name'),
'default_value' => $model ? $model->filename : null,
];
}
],
[
'attribute' => 'alt',
'label' => __('Alternative Text'),
'filable' => true,
'fillable' => true,
'list' => false,
'form_options' => function ($model) {
return [
'type' => 'text',
'label' => __('Alternative Text'),
];
}
'type' => 'text',
],
[
'attribute' => 'file',
'label' => __('File'),
'filable' => true,
'fillable' => true,
'type' => 'file',
'value' => function ($model) {
if($model->aggregate_type != 'image'){
$file = media_type_icon($model);
Expand All @@ -81,11 +75,6 @@ public function columns()
}
return '<div class="avatar"><div class="w-32 rounded">'.$file.'</div><div>';
},
'form_options' => function ($model) {
return [
'type' => 'file',
];
}
],
[
'attribute' => 'created_at',
Expand Down
6 changes: 3 additions & 3 deletions app/Grid/Admin/MenuGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function columns()
return [
[
'attribute' => 'id',
'label' => 'ID',
'label' => __('ID'),
'sortable' => true,
'searchable' => true,
'form_options' => function($model) {
Expand All @@ -31,7 +31,7 @@ public function columns()
],
[
'attribute' => 'name',
'label' => 'Name',
'label' => __('Name'),
'sortable' => true,
'filter' => 'like',
'searchable' => true,
Expand All @@ -56,7 +56,7 @@ public function columns()
],
[
'attribute' => 'items',
'label' => '# of Items',
'label' => __('# of Items'),
'list' => [
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
'route' => 'admin.menu.item.index',
Expand Down
22 changes: 8 additions & 14 deletions app/Grid/Admin/MenuItemGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function columns()
return [
[
'attribute' => 'name',
'label' => 'Name',
'label' => __('Name'),
'sortable' => true,
'filter' => 'like',
'searchable' => true,
Expand All @@ -31,7 +31,6 @@ public function columns()
'label' => __('Link'),
'form_options' => function ($model) {
return [
'label' => __('Link'),
'help_block' => [
'text' => 'You can also enter an internal path such as /home or an external URL such as http://example.com. Add prefix <admin> to link for admin page. Enter <nolink> to display link text only.',
],
Expand All @@ -44,11 +43,10 @@ public function columns()
],
[
'attribute' => 'enabled',
'label' => 'Enabled',
'label' => __('Enabled'),
'type' => 'checkbox',
'form_options' => function ($model) {
return [
'type' => 'checkbox',
'label' => __('Enabled'),
'value' => 1,
'default_value' => 1,
];
Expand All @@ -57,12 +55,11 @@ public function columns()
[
'attribute' => 'parent_id',
'label' => __('Parent Item'),
'type' => 'choice',
'form_options' => function ($model) {
$item_options = MenuItem::selectOptions($this->addtional['menu']->id, null, true);
return [
'type' => 'choice',
'choices' => $item_options,
'label' => __('Parent Item'),
'selected' => $this->model->parent_id ?? null,
'empty_value' => '-ROOT-',
'help_block' => [
Expand All @@ -74,21 +71,19 @@ public function columns()
[
'attribute' => 'weight',
'label' => __('Weight'),
'type' => 'number',
'form_options' => function ($model) {
return [
'type' => 'number',
'wrapper' => ['class' => 'form-control py-2 w-40'],
'label' => __('Weight'),
];
},
],
[
'attribute' => 'icon',
'label' => __('Icon'),
'type' => 'textarea',
'form_options' => function ($model) {
return [
'type' => 'textarea',
'label' => __('Icon'),
'attr' => [
'rows' => 3,
'class' => 'textarea input-bordered w-full',
Expand All @@ -99,21 +94,20 @@ public function columns()
[
'attribute' => 'roles',
'label' => __('Roles'),
'filable' => true,
'fillable' => true,
'type' => 'choice',
'form_options' => function ($model) {
$roles = Role::all();
$itemHasRoles = [];
if ($model) {
$itemHasRoles = array_column(json_decode($model->roles, true), 'name');
}
return [
'type' => 'choice',
'choices' => $roles->pluck('name', 'name')->toArray(),
'choice_options' => [
'wrapper' => ['class' => 'col-span-4 sm:col-span-2 md:col-span-1'],
],
'choices_wrapper' => ['class' => 'grid grid-cols-4 gap-4'],
'label' => __('Roles'),
'label_attr' => ['class' => 'inline-block text-xl sm:text-2xl font-extrabold text-slate-900 tracking-tight py-4 block sm:inline-block flex'],
'selected' => $itemHasRoles,
'expanded' => true,
Expand Down
6 changes: 3 additions & 3 deletions app/Grid/Admin/PermissionGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function columns()
{
return [
[
'label' => '#',
'label' => __('#'),
'attribute' => 'label',
'list' => [
'class' => 'BalajiDharma\LaravelCrud\Column\SerialColumn',
Expand All @@ -28,7 +28,7 @@ public function columns()
],
[
'attribute' => 'id',
'label' => 'ID',
'label' => __('ID'),
'sortable' => true,
'searchable' => true,
'list' => [
Expand All @@ -40,7 +40,7 @@ public function columns()
],
[
'attribute' => 'name',
'label' => 'Name',
'label' => __('Name'),
'sortable' => true,
'filter' => 'like',
'searchable' => true,
Expand Down
9 changes: 4 additions & 5 deletions app/Grid/Admin/RoleGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function columns()
return [
[
'attribute' => 'id',
'label' => 'ID',
'label' => __('ID'),
'sortable' => true,
'searchable' => true,
'list' => [
Expand All @@ -33,7 +33,7 @@ public function columns()
],
[
'attribute' => 'name',
'label' => 'Name',
'label' => __('Name'),
'sortable' => true,
'filter' => 'like',
'searchable' => true,
Expand All @@ -46,9 +46,9 @@ public function columns()
],
[
'attribute' => 'permissions',
'label' => 'Permissions',
'label' => __('Permissions'),
'type' => 'choice',
'filable' => true,
'fillable' => true,
'list' => [
'class' => 'BalajiDharma\LaravelCrud\Column\ListColumn',
'attribute' => 'name'
Expand All @@ -75,7 +75,6 @@ public function columns()
'wrapper' => ['class' => 'col-span-4 sm:col-span-2 md:col-span-1'],
],
'choices_wrapper' => ['class' => 'grid grid-cols-4 gap-4'],
'label' => __('Permissions'),
'label_attr' => ['class' => 'inline-block text-xl sm:text-2xl font-extrabold text-slate-900 tracking-tight py-4 block sm:inline-block flex'],
'selected' => $roleHasPermissions,
'expanded' => true,
Expand Down
Loading

0 comments on commit 9d669d2

Please sign in to comment.