Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b02eb1d
wip
pxpm Apr 1, 2025
418cf70
Apply fixes from StyleCI
StyleCIBot Apr 1, 2025
b5b07e8
wip
pxpm Apr 25, 2025
991a0e0
Apply fixes from StyleCI
StyleCIBot Apr 25, 2025
b31eafd
wip
pxpm May 2, 2025
5524612
Apply fixes from StyleCI
StyleCIBot May 2, 2025
e0489aa
wip
pxpm May 12, 2025
f614449
fix demo filter in icons that makes no sense
tabacitu May 20, 2025
89b5957
wip
pxpm May 21, 2025
7d55d65
Apply fixes from StyleCI
StyleCIBot May 21, 2025
08b2a1c
WIP add datatable widget in places where it makes sense
tabacitu May 26, 2025
9e6671d
Apply fixes from StyleCI
StyleCIBot May 26, 2025
4725ef3
wip
pxpm May 27, 2025
bc51492
Apply fixes from StyleCI
StyleCIBot May 27, 2025
7bbd80b
better demo of datatables component
tabacitu May 27, 2025
f9ccb77
filters that make more sense
tabacitu May 27, 2025
e561494
wip
pxpm May 30, 2025
24e288d
Apply fixes from StyleCI
StyleCIBot May 30, 2025
0e50d52
wip
pxpm May 30, 2025
c78d7e9
Apply fixes from StyleCI
StyleCIBot May 30, 2025
de0139c
wip
pxpm Jun 4, 2025
833b807
Apply fixes from StyleCI
StyleCIBot Jun 4, 2025
b008940
wip
pxpm Jun 4, 2025
88052f6
Apply fixes from StyleCI
StyleCIBot Jun 4, 2025
425cd30
prettier DataTable component on dashboard
tabacitu Jun 5, 2025
bad1775
Apply fixes from StyleCI
StyleCIBot Jun 5, 2025
2267923
add datatable widget to other themes as well
tabacitu Jun 5, 2025
dbccf98
Merge branch 'datatables-component-example' of https://github.com/Lar…
tabacitu Jun 5, 2025
9eb9cfe
wip
pxpm Jun 5, 2025
4f0acac
remove datatable title from dashboard, was not needed
tabacitu Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better demo of datatables component
  • Loading branch information
tabacitu committed May 27, 2025
commit 7bbd80b308d0848916a0116e47bff0eac7474b44
16 changes: 11 additions & 5 deletions app/Http/Controllers/Admin/IconCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ public function setup()
protected function setupListOperation()
{
$this->crud->addColumns(['name', 'icon']);
$this->crud->addFilter([ // dropdown filter
'name' => 'my_filter',
'type' => 'text',
'label'=> 'Icon',

$this->crud->addFilter([
'type' => 'date_range',
'name' => 'created_at',
'label' => 'Created At',
], null, function ($value) {
$value = json_decode($value, true);

// if the filter is active
$this->crud->addClause('where', 'icon', 'LIKE', "%$value%");
if ($value) {
$this->crud->addClause('where', 'created_at', '>=', $value['from']);
$this->crud->addClause('where', 'created_at', '<=', $value['to']);
}
});
}

Expand Down
28 changes: 16 additions & 12 deletions app/Http/Controllers/Admin/MonsterCrudController.php
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads-up, the CaveCrudController and StoryCrudController throw an AjaxUploader error

Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,22 @@ public function setupShowOperation()
'type' => 'datatable',
'controller' => 'App\Http\Controllers\Admin\IconCrudController',
'name' => 'icon_crud',
'section' => 'after_content',
'content' => [
'header' => 'Icons for this monster',
],
'wrapper' => ['class'=> 'mb-3'],
]);

$this->crud->setOperationSetting('tabsEnabled', true);
$this->setupListOperation();

$this->crud->set('show.contentClass', 'col-md-12');
$this->crud->addColumn([
Widget::add([
'type' => 'datatable',
'name' => 'products_datatable',
'label' => 'Products (Datatable)',
'controller' => 'App\Http\Controllers\Admin\ProductCrudController',
'name' => 'products_datatable',
'section' => 'after_content',
'content' => [
'header' => 'Products for this monster',
],
'wrapper' => ['class'=> 'mb-3'],
'configure' => function ($crud, $entry = null) {
// Customize which columns to show
$crud->removeAllColumns();
Expand All @@ -322,11 +326,11 @@ public function setupShowOperation()
}
},
]);
$this->crud->addColumn([
'type' => 'datatable',
'name' => 'icon_crud',
'controller' => 'App\Http\Controllers\Admin\IconCrudController',
]);

$this->crud->setOperationSetting('tabsEnabled', true);
$this->setupListOperation();

$this->crud->set('show.contentClass', 'col-md-12');

$this->crud->addColumn([ // EasyMDE
'name' => 'easymde',
Expand Down
18 changes: 18 additions & 0 deletions app/Http/Controllers/Admin/PetShop/InvoiceCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ protected function setupListOperation()
CRUD::column('due_date');
CRUD::column('total');

CRUD::filter('series')
->type('dropdown')
->values(\App\Models\PetShop\Invoice::select('series')->distinct()->pluck('series', 'series')->toArray())
->label('Series')
->placeholder('Search by series')
->whenActive(function ($value) {
CRUD::addClause('where', 'series', '=', $value);
});

CRUD::filter('issuance_date')
->type('date_range')
->label('Issuance Date')
->placeholder('Search by issuance date')
->whenActive(function ($value) {
$dates = json_decode($value);
CRUD::addClause('whereBetween', 'issuance_date', [$dates->from, $dates->to]);
});

$this->runCustomViews();
}

Expand Down
24 changes: 10 additions & 14 deletions app/Http/Controllers/Admin/PetShop/OwnerCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ protected function setupShowOperation()
// 'subheader' => 'This is a list of all pets owned by this owner.',
],
// MUST-DO: How the fuck do I make this only show related pets?!?!
// 'configure' => function ($crud, $entry = null) {
// 'configure' => function ($crud, $parent) {
// // only show the pets of this owner (owner is an n-n relationship)
// if ($entry) {
// $crud->addClause('whereHas', 'owners', function ($query) use ($entry) {
// $query->where('id', $entry->id);
// if ($parent) {
// $crud->addClause('whereHas', 'owners', function ($query) use ($parent) {
// $query->where('id', $parent->id);
// });
// }
// },
Expand All @@ -153,16 +153,12 @@ protected function setupShowOperation()
'header' => 'Invoices for this owner',
],
// MUST-DO: How the fuck do I make this only show related pets?!?!
'configure' => function ($crud, $entry = null) {
// only show the pets of this owner (owner is an n-n relationship)
if ($entry) {
$crud->addClause('where', 'owner_id', $entry->id);
}
},
// SHOULD-DO: maybe we do something like this?!
// 'query' => function ($query, $entry) {
// return $query->where('owner_id', $entry->id);
// }
// 'configure' => function ($crud, $parent) {
// // only show the pets of this owner (owner is an n-n relationship)
// if ($parent) {
// $crud->addClause('where', 'owner_id', $$parent->id);
// }
// },
]);
}
}