From 57cb96c0263a0e52b0b0baa1fd7ff3609ea139a5 Mon Sep 17 00:00:00 2001 From: Mohammad Emran Date: Sun, 12 Mar 2023 11:46:55 +0600 Subject: [PATCH 01/10] Add Livewire widget --- src/resources/views/base/widgets/livewire.blade.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/resources/views/base/widgets/livewire.blade.php diff --git a/src/resources/views/base/widgets/livewire.blade.php b/src/resources/views/base/widgets/livewire.blade.php new file mode 100644 index 0000000000..5cff82e1a8 --- /dev/null +++ b/src/resources/views/base/widgets/livewire.blade.php @@ -0,0 +1,12 @@ +@php + // defaults; backwards compatibility with Backpack 4.0 widgets + $widget['wrapper']['class'] = $widget['wrapper']['class'] ?? $widget['wrapperClass'] ?? 'col-sm-6 col-lg-3'; +@endphp + +@includeWhen(!empty($widget['wrapper']), 'backpack::widgets.inc.wrapper_start') + +
$value) {{ $key }}="{{ $value }}" @endforeach> + @livewire($widget['component'], $widget['params'] ?? []) +
+ +@includeWhen(!empty($widget['wrapper']), 'backpack::widgets.inc.wrapper_end') From dcdc9fb66cee7259a144be6c9a1aec1fa510a34f Mon Sep 17 00:00:00 2001 From: Mohammad Emran Date: Sun, 12 Mar 2023 12:18:09 +0600 Subject: [PATCH 02/10] Add dedicated class option --- src/resources/views/base/widgets/livewire.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/views/base/widgets/livewire.blade.php b/src/resources/views/base/widgets/livewire.blade.php index 5cff82e1a8..39a069f69d 100644 --- a/src/resources/views/base/widgets/livewire.blade.php +++ b/src/resources/views/base/widgets/livewire.blade.php @@ -5,7 +5,7 @@ @includeWhen(!empty($widget['wrapper']), 'backpack::widgets.inc.wrapper_start') -
$value) {{ $key }}="{{ $value }}" @endforeach> +
$value) {{ $key }}="{{ $value }}" @endforeach> @livewire($widget['component'], $widget['params'] ?? [])
From af12e6bccd63342f115796e2080068babd6cfcb6 Mon Sep 17 00:00:00 2001 From: Mohammad Emran Date: Mon, 13 Mar 2023 18:22:11 +0600 Subject: [PATCH 03/10] Load Livewire style and scripts, once! --- src/resources/views/base/widgets/livewire.blade.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/resources/views/base/widgets/livewire.blade.php b/src/resources/views/base/widgets/livewire.blade.php index 39a069f69d..59654e4626 100644 --- a/src/resources/views/base/widgets/livewire.blade.php +++ b/src/resources/views/base/widgets/livewire.blade.php @@ -10,3 +10,11 @@
@includeWhen(!empty($widget['wrapper']), 'backpack::widgets.inc.wrapper_end') + +@pushOnce('after_styles') + @livewireStyles +@endPushOnce + +@pushOnce('after_scripts') + @livewireScripts +@endPushOnce From 0528d90573a8d975f83b74e3d2754f5ae4fd1951 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 13 Mar 2023 12:22:36 +0000 Subject: [PATCH 04/10] Apply fixes from StyleCI [ci skip] [skip ci] --- .../Controllers/Operations/ShowOperation.php | 1 - src/app/Library/CrudPanel/CrudPanel.php | 2 + src/app/Library/CrudPanel/CrudPanelFacade.php | 1 + src/app/Library/CrudPanel/Traits/AutoSet.php | 4 +- src/app/Library/CrudPanel/Traits/Create.php | 2 +- .../Library/CrudPanel/Traits/SaveActions.php | 1 - src/app/Library/CrudPanel/Traits/Update.php | 2 +- src/app/Models/Traits/HasFakeFields.php | 2 +- .../Traits/HasIdentifiableAttribute.php | 1 - .../SpatieTranslatable/HasTranslations.php | 2 +- .../fields/checklist_dependency.blade.php | 87 +++++++++---------- src/resources/views/crud/reorder.blade.php | 14 +-- src/routes/backpack/base.php | 70 +++++++-------- tests/Unit/CrudPanel/CrudPanelMacroTest.php | 6 +- .../CrudTrait/CrudTraitFakeFieldsTest.php | 1 + 15 files changed, 98 insertions(+), 98 deletions(-) diff --git a/src/app/Http/Controllers/Operations/ShowOperation.php b/src/app/Http/Controllers/Operations/ShowOperation.php index 1b3cdc9ac3..68f7a7daad 100644 --- a/src/app/Http/Controllers/Operations/ShowOperation.php +++ b/src/app/Http/Controllers/Operations/ShowOperation.php @@ -119,7 +119,6 @@ protected function removeColumnsThatDontBelongInsideShowOperation() { // cycle through columns foreach ($this->crud->columns() as $key => $column) { - // remove any autoset relationship columns if (array_key_exists('model', $column) && array_key_exists('autoset', $column) && $column['autoset']) { $this->crud->removeColumn($column['key']); diff --git a/src/app/Library/CrudPanel/CrudPanel.php b/src/app/Library/CrudPanel/CrudPanel.php index 9a02d4a7dc..5636f77280 100644 --- a/src/app/Library/CrudPanel/CrudPanel.php +++ b/src/app/Library/CrudPanel/CrudPanel.php @@ -148,6 +148,7 @@ private function getSchema() * DEPRECATION NOTICE: This method is no longer used and will be removed in future versions of Backpack * * @deprecated + * * @codeCoverageIgnore * * @return bool @@ -318,6 +319,7 @@ public function getFirstOfItsTypeInArray($type, $array) * - place in the correct section above (CREATE, READ, UPDATE, DELETE, ACCESS, MANIPULATION) * * @deprecated + * * @codeCoverageIgnore */ public function sync($type, $fields, $attributes) diff --git a/src/app/Library/CrudPanel/CrudPanelFacade.php b/src/app/Library/CrudPanel/CrudPanelFacade.php index 4fc2c32696..95465a7a46 100644 --- a/src/app/Library/CrudPanel/CrudPanelFacade.php +++ b/src/app/Library/CrudPanel/CrudPanelFacade.php @@ -24,6 +24,7 @@ * @method static addColumns(array $columns) * @method static afterColumn(string $targetColumn) * @method static setValidation($class) + * * @mixin CrudPanel */ class CrudPanelFacade extends Facade diff --git a/src/app/Library/CrudPanel/Traits/AutoSet.php b/src/app/Library/CrudPanel/Traits/AutoSet.php index 3ef4aab3bd..6593f6dc80 100644 --- a/src/app/Library/CrudPanel/Traits/AutoSet.php +++ b/src/app/Library/CrudPanel/Traits/AutoSet.php @@ -132,9 +132,9 @@ protected function inferFieldTypeFromDbColumnType($fieldName) case 'set': return 'text'; - // case 'enum': + // case 'enum': // return 'enum'; - // break; + // break; case 'boolean': return 'boolean'; diff --git a/src/app/Library/CrudPanel/Traits/Create.php b/src/app/Library/CrudPanel/Traits/Create.php index e2cbc866c5..39150dca2b 100644 --- a/src/app/Library/CrudPanel/Traits/Create.php +++ b/src/app/Library/CrudPanel/Traits/Create.php @@ -102,7 +102,7 @@ private function createRelationsForItem($item, $formattedRelations) switch ($relationType) { case 'HasOne': case 'MorphOne': - $this->createUpdateOrDeleteOneToOneRelation($relation, $relationMethod, $relationDetails); + $this->createUpdateOrDeleteOneToOneRelation($relation, $relationMethod, $relationDetails); break; case 'HasMany': case 'MorphMany': diff --git a/src/app/Library/CrudPanel/Traits/SaveActions.php b/src/app/Library/CrudPanel/Traits/SaveActions.php index 9eba3ddd7a..8bd13ed4b3 100644 --- a/src/app/Library/CrudPanel/Traits/SaveActions.php +++ b/src/app/Library/CrudPanel/Traits/SaveActions.php @@ -253,7 +253,6 @@ public function getVisibleSaveActions() */ public function getCurrentSaveAction($saveOptions) { - //get save action from session if exists, or get the developer defined order $saveAction = session($this->getCurrentOperation().'.saveAction', $this->getFallBackSaveAction()); if (isset($saveOptions[$saveAction])) { diff --git a/src/app/Library/CrudPanel/Traits/Update.php b/src/app/Library/CrudPanel/Traits/Update.php index a785bfb6e0..9d9327721a 100644 --- a/src/app/Library/CrudPanel/Traits/Update.php +++ b/src/app/Library/CrudPanel/Traits/Update.php @@ -283,7 +283,7 @@ private function getSubfieldsValues($subfields, $relatedModel) $iterator = $iterator->$part; } - Arr::set($result, $name, (is_a($iterator, 'Illuminate\Database\Eloquent\Model', true) ? $this->getModelWithFakes($iterator)->getAttributes() : $iterator)); + Arr::set($result, $name, is_a($iterator, 'Illuminate\Database\Eloquent\Model', true) ? $this->getModelWithFakes($iterator)->getAttributes() : $iterator); } } } diff --git a/src/app/Models/Traits/HasFakeFields.php b/src/app/Models/Traits/HasFakeFields.php index e09e753d21..038a78e45b 100644 --- a/src/app/Models/Traits/HasFakeFields.php +++ b/src/app/Models/Traits/HasFakeFields.php @@ -30,7 +30,7 @@ public function addFakes($columns = ['extras']) $column_contents = json_decode($column_contents); } - if ((is_array($column_contents) || is_object($column_contents) || $column_contents instanceof Traversable)) { + if (is_array($column_contents) || is_object($column_contents) || $column_contents instanceof Traversable) { foreach ($column_contents as $fake_field_name => $fake_field_value) { $this->setAttribute($fake_field_name, $fake_field_value); } diff --git a/src/app/Models/Traits/HasIdentifiableAttribute.php b/src/app/Models/Traits/HasIdentifiableAttribute.php index d4bc437155..98ebe15706 100644 --- a/src/app/Models/Traits/HasIdentifiableAttribute.php +++ b/src/app/Models/Traits/HasIdentifiableAttribute.php @@ -64,7 +64,6 @@ private static function guessIdentifiableColumnName() // that is NOT indexed (usually primary, foreign keys) foreach ($columns as $columnName => $columnProperties) { if (! in_array($columnName, $indexedColumns)) { - //check for convention "field<_id>" in case developer didn't add foreign key constraints. if (strpos($columnName, '_id') !== false) { continue; diff --git a/src/app/Models/Traits/SpatieTranslatable/HasTranslations.php b/src/app/Models/Traits/SpatieTranslatable/HasTranslations.php index ede0af77b8..51dd071852 100644 --- a/src/app/Models/Traits/SpatieTranslatable/HasTranslations.php +++ b/src/app/Models/Traits/SpatieTranslatable/HasTranslations.php @@ -206,7 +206,7 @@ public function __call($method, $parameters) return parent::__call($method, $parameters); break; - // do not translate any other methods + // do not translate any other methods default: return parent::__call($method, $parameters); break; diff --git a/src/resources/views/crud/fields/checklist_dependency.blade.php b/src/resources/views/crud/fields/checklist_dependency.blade.php index bce0f18674..7d35c62515 100644 --- a/src/resources/views/crud/fields/checklist_dependency.blade.php +++ b/src/resources/views/crud/fields/checklist_dependency.blade.php @@ -13,58 +13,57 @@ getModel(); - //short name for dependency fields - $primary_dependency = $field['subfields']['primary']; - $secondary_dependency = $field['subfields']['secondary']; + //short name for dependency fields + $primary_dependency = $field['subfields']['primary']; + $secondary_dependency = $field['subfields']['secondary']; - //all items with relation - $dependencies = $primary_dependency['model']::with($primary_dependency['entity_secondary'])->get(); + //all items with relation + $dependencies = $primary_dependency['model']::with($primary_dependency['entity_secondary'])->get(); - $dependencyArray = []; + $dependencyArray = []; - //convert dependency array to simple matrix ( primary id as key and array with secondaries id ) - foreach ($dependencies as $primary) { - $dependencyArray[$primary->id] = []; - foreach ($primary->{$primary_dependency['entity_secondary']} as $secondary) { - $dependencyArray[$primary->id][] = $secondary->id; - } + //convert dependency array to simple matrix ( primary id as key and array with secondaries id ) + foreach ($dependencies as $primary) { + $dependencyArray[$primary->id] = []; + foreach ($primary->{$primary_dependency['entity_secondary']} as $secondary) { + $dependencyArray[$primary->id][] = $secondary->id; } + } - $old_primary_dependency = old_empty_or_null($primary_dependency['name'], false) ?? false; - $old_secondary_dependency = old_empty_or_null($secondary_dependency['name'], false) ?? false; - - //for update form, get initial state of the entity - if (isset($id) && $id) { + $old_primary_dependency = old_empty_or_null($primary_dependency['name'], false) ?? false; + $old_secondary_dependency = old_empty_or_null($secondary_dependency['name'], false) ?? false; + //for update form, get initial state of the entity + if (isset($id) && $id) { //get entity with relations for primary dependency - $entity_dependencies = $entity_model->with($primary_dependency['entity']) - ->with($primary_dependency['entity'].'.'.$primary_dependency['entity_secondary']) - ->find($id); - - $secondaries_from_primary = []; - - //convert relation in array - $primary_array = $entity_dependencies->{$primary_dependency['entity']}->toArray(); - - $secondary_ids = []; - //create secondary dependency from primary relation, used to check what checkbox must be checked from second checklist - if ($old_primary_dependency) { - foreach ($old_primary_dependency as $primary_item) { - foreach ($dependencyArray[$primary_item] as $second_item) { - $secondary_ids[$second_item] = $second_item; - } - } - } else { //create dependencies from relation if not from validate error - foreach ($primary_array as $primary_item) { - foreach ($primary_item[$secondary_dependency['entity']] as $second_item) { - $secondary_ids[$second_item['id']] = $second_item['id']; - } - } - } - } + $entity_dependencies = $entity_model->with($primary_dependency['entity']) + ->with($primary_dependency['entity'].'.'.$primary_dependency['entity_secondary']) + ->find($id); + + $secondaries_from_primary = []; + + //convert relation in array + $primary_array = $entity_dependencies->{$primary_dependency['entity']}->toArray(); + + $secondary_ids = []; + //create secondary dependency from primary relation, used to check what checkbox must be checked from second checklist + if ($old_primary_dependency) { + foreach ($old_primary_dependency as $primary_item) { + foreach ($dependencyArray[$primary_item] as $second_item) { + $secondary_ids[$second_item] = $second_item; + } + } + } else { //create dependencies from relation if not from validate error + foreach ($primary_array as $primary_item) { + foreach ($primary_item[$secondary_dependency['entity']] as $second_item) { + $secondary_ids[$second_item['id']] = $second_item['id']; + } + } + } + } - //json encode of dependency matrix - $dependencyJson = json_encode($dependencyArray); + //json encode of dependency matrix + $dependencyJson = json_encode($dependencyArray); ?>
diff --git a/src/resources/views/crud/reorder.blade.php b/src/resources/views/crud/reorder.blade.php index 4fbd7e0f58..f6fc4c7bba 100644 --- a/src/resources/views/crud/reorder.blade.php +++ b/src/resources/views/crud/reorder.blade.php @@ -71,13 +71,13 @@ function tree_element($entry, $key, $all_entries, $crud)
    all())->sortBy('lft')->keyBy($crud->getModel()->getKeyName()); - $root_entries = $all_entries->filter(function ($item) { - return $item->parent_id == 0; - }); - foreach ($root_entries as $key => $entry) { - $root_entries[$key] = tree_element($entry, $key, $all_entries, $crud); - } - ?> + $root_entries = $all_entries->filter(function ($item) { + return $item->parent_id == 0; + }); + foreach ($root_entries as $key => $entry) { + $root_entries[$key] = tree_element($entry, $key, $all_entries, $crud); + } + ?>
{{-- /.card --}} diff --git a/src/routes/backpack/base.php b/src/routes/backpack/base.php index 4ca46ff60d..d12548bb36 100644 --- a/src/routes/backpack/base.php +++ b/src/routes/backpack/base.php @@ -13,43 +13,43 @@ */ Route::group( -[ - 'namespace' => 'Backpack\CRUD\app\Http\Controllers', - 'middleware' => config('backpack.base.web_middleware', 'web'), - 'prefix' => config('backpack.base.route_prefix'), -], -function () { - // if not otherwise configured, setup the auth routes - if (config('backpack.base.setup_auth_routes')) { - // Authentication Routes... - Route::get('login', 'Auth\LoginController@showLoginForm')->name('backpack.auth.login'); - Route::post('login', 'Auth\LoginController@login'); - Route::get('logout', 'Auth\LoginController@logout')->name('backpack.auth.logout'); - Route::post('logout', 'Auth\LoginController@logout'); + [ + 'namespace' => 'Backpack\CRUD\app\Http\Controllers', + 'middleware' => config('backpack.base.web_middleware', 'web'), + 'prefix' => config('backpack.base.route_prefix'), + ], + function () { + // if not otherwise configured, setup the auth routes + if (config('backpack.base.setup_auth_routes')) { + // Authentication Routes... + Route::get('login', 'Auth\LoginController@showLoginForm')->name('backpack.auth.login'); + Route::post('login', 'Auth\LoginController@login'); + Route::get('logout', 'Auth\LoginController@logout')->name('backpack.auth.logout'); + Route::post('logout', 'Auth\LoginController@logout'); - // Registration Routes... - Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('backpack.auth.register'); - Route::post('register', 'Auth\RegisterController@register'); + // Registration Routes... + Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('backpack.auth.register'); + Route::post('register', 'Auth\RegisterController@register'); - // if not otherwise configured, setup the password recovery routes - if (config('backpack.base.setup_password_recovery_routes', true)) { - Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('backpack.auth.password.reset'); - Route::post('password/reset', 'Auth\ResetPasswordController@reset'); - Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('backpack.auth.password.reset.token'); - Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('backpack.auth.password.email')->middleware('backpack.throttle.password.recovery:'.config('backpack.base.password_recovery_throttle_access')); + // if not otherwise configured, setup the password recovery routes + if (config('backpack.base.setup_password_recovery_routes', true)) { + Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('backpack.auth.password.reset'); + Route::post('password/reset', 'Auth\ResetPasswordController@reset'); + Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('backpack.auth.password.reset.token'); + Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('backpack.auth.password.email')->middleware('backpack.throttle.password.recovery:'.config('backpack.base.password_recovery_throttle_access')); + } } - } - // if not otherwise configured, setup the dashboard routes - if (config('backpack.base.setup_dashboard_routes')) { - Route::get('dashboard', 'AdminController@dashboard')->name('backpack.dashboard'); - Route::get('/', 'AdminController@redirect')->name('backpack'); - } + // if not otherwise configured, setup the dashboard routes + if (config('backpack.base.setup_dashboard_routes')) { + Route::get('dashboard', 'AdminController@dashboard')->name('backpack.dashboard'); + Route::get('/', 'AdminController@redirect')->name('backpack'); + } - // if not otherwise configured, setup the "my account" routes - if (config('backpack.base.setup_my_account_routes')) { - Route::get('edit-account-info', 'MyAccountController@getAccountInfoForm')->name('backpack.account.info'); - Route::post('edit-account-info', 'MyAccountController@postAccountInfoForm')->name('backpack.account.info.store'); - Route::post('change-password', 'MyAccountController@postChangePasswordForm')->name('backpack.account.password'); - } -}); + // if not otherwise configured, setup the "my account" routes + if (config('backpack.base.setup_my_account_routes')) { + Route::get('edit-account-info', 'MyAccountController@getAccountInfoForm')->name('backpack.account.info'); + Route::post('edit-account-info', 'MyAccountController@postAccountInfoForm')->name('backpack.account.info.store'); + Route::post('change-password', 'MyAccountController@postChangePasswordForm')->name('backpack.account.password'); + } + }); diff --git a/tests/Unit/CrudPanel/CrudPanelMacroTest.php b/tests/Unit/CrudPanel/CrudPanelMacroTest.php index e8c02771ac..da828979db 100644 --- a/tests/Unit/CrudPanel/CrudPanelMacroTest.php +++ b/tests/Unit/CrudPanel/CrudPanelMacroTest.php @@ -25,8 +25,8 @@ public function testThrowsErrorIfMacroExists() } catch (\Throwable $e) { } $this->assertEquals( - new \Symfony\Component\HttpKernel\Exception\HttpException(500, 'Cannot register \'setModel\' macro. \'setModel()\' already exists on Backpack\CRUD\app\Library\CrudPanel\CrudPanel'), - $e - ); + new \Symfony\Component\HttpKernel\Exception\HttpException(500, 'Cannot register \'setModel\' macro. \'setModel()\' already exists on Backpack\CRUD\app\Library\CrudPanel\CrudPanel'), + $e + ); } } diff --git a/tests/Unit/CrudTrait/CrudTraitFakeFieldsTest.php b/tests/Unit/CrudTrait/CrudTraitFakeFieldsTest.php index 1449a69c95..d54fe998ed 100644 --- a/tests/Unit/CrudTrait/CrudTraitFakeFieldsTest.php +++ b/tests/Unit/CrudTrait/CrudTraitFakeFieldsTest.php @@ -8,6 +8,7 @@ * Class CrudTraitFakeFieldsTest. * * @group CrudTraitFakeFields + * * @covers Backpack\CRUD\app\Models\Traits\HasFakeFields */ class CrudTraitFakeFieldsTest extends BaseCrudTraitTest From 53543e9774cd419f53c4222dd971058aa9566a4a Mon Sep 17 00:00:00 2001 From: "Pedro X." Date: Fri, 29 Sep 2023 18:18:31 +0100 Subject: [PATCH 05/10] wip --- src/resources/views/{base => ui}/widgets/livewire.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/resources/views/{base => ui}/widgets/livewire.blade.php (75%) diff --git a/src/resources/views/base/widgets/livewire.blade.php b/src/resources/views/ui/widgets/livewire.blade.php similarity index 75% rename from src/resources/views/base/widgets/livewire.blade.php rename to src/resources/views/ui/widgets/livewire.blade.php index 59654e4626..468daf1ed9 100644 --- a/src/resources/views/base/widgets/livewire.blade.php +++ b/src/resources/views/ui/widgets/livewire.blade.php @@ -3,13 +3,13 @@ $widget['wrapper']['class'] = $widget['wrapper']['class'] ?? $widget['wrapperClass'] ?? 'col-sm-6 col-lg-3'; @endphp -@includeWhen(!empty($widget['wrapper']), 'backpack::widgets.inc.wrapper_start') +@includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_start'))
$value) {{ $key }}="{{ $value }}" @endforeach> @livewire($widget['component'], $widget['params'] ?? [])
-@includeWhen(!empty($widget['wrapper']), 'backpack::widgets.inc.wrapper_end') +@includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_end')) @pushOnce('after_styles') @livewireStyles From e0e5a2a5f86d646976b0c0d7f5b6dc6284e5d2ba Mon Sep 17 00:00:00 2001 From: "Pedro X." Date: Fri, 29 Sep 2023 19:19:21 +0100 Subject: [PATCH 06/10] update widget to use basset --- src/resources/views/ui/widgets/livewire.blade.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/resources/views/ui/widgets/livewire.blade.php b/src/resources/views/ui/widgets/livewire.blade.php index 468daf1ed9..41c0a6de3c 100644 --- a/src/resources/views/ui/widgets/livewire.blade.php +++ b/src/resources/views/ui/widgets/livewire.blade.php @@ -6,15 +6,19 @@ @includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_start'))
$value) {{ $key }}="{{ $value }}" @endforeach> - @livewire($widget['component'], $widget['params'] ?? []) + @livewire($widget['content'], $widget['parameters'] ?? [])
@includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_end')) -@pushOnce('after_styles') +@bassetBlock('livewire-styles.css') +@push('after_styles') @livewireStyles -@endPushOnce +@endpush +@endBassetBlock -@pushOnce('after_scripts') +@bassetBlock('livewire-scripts.js') +@push('after_scripts') @livewireScripts -@endPushOnce +@endpush +@endBassetBlock From a5ae7c8e40f136c120d9f3396b79b265b6c4bab9 Mon Sep 17 00:00:00 2001 From: "Pedro X." Date: Fri, 29 Sep 2023 20:22:13 +0100 Subject: [PATCH 07/10] fix basset blocks --- src/resources/views/ui/widgets/livewire.blade.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/resources/views/ui/widgets/livewire.blade.php b/src/resources/views/ui/widgets/livewire.blade.php index 41c0a6de3c..631b393416 100644 --- a/src/resources/views/ui/widgets/livewire.blade.php +++ b/src/resources/views/ui/widgets/livewire.blade.php @@ -11,14 +11,17 @@ @includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_end')) -@bassetBlock('livewire-styles.css') @push('after_styles') +@bassetBlock('livewire-styles.css') @livewireStyles -@endpush @endBassetBlock +@endpush + -@bassetBlock('livewire-scripts.js') @push('after_scripts') +@bassetBlock('livewire-scripts.js') @livewireScripts -@endpush @endBassetBlock +@endpush + + From e178c9a9011d3442268f8abc8b18d5ac46e9bbcb Mon Sep 17 00:00:00 2001 From: "Pedro X." Date: Fri, 29 Sep 2023 21:47:01 +0100 Subject: [PATCH 08/10] remove basset --- .../views/ui/widgets/livewire.blade.php | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/resources/views/ui/widgets/livewire.blade.php b/src/resources/views/ui/widgets/livewire.blade.php index 631b393416..805a27c09c 100644 --- a/src/resources/views/ui/widgets/livewire.blade.php +++ b/src/resources/views/ui/widgets/livewire.blade.php @@ -11,17 +11,15 @@ @includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_end')) -@push('after_styles') -@bassetBlock('livewire-styles.css') - @livewireStyles -@endBassetBlock -@endpush - - -@push('after_scripts') -@bassetBlock('livewire-scripts.js') - @livewireScripts -@endBassetBlock -@endpush - +@if($widget['livewireAssets'] ?? true) + @pushOnce('after_styles') + @livewireStyles + @endPushOnce +@endif + +@if($widget['livewireAssets'] ?? true) + @pushOnce('after_scripts') + @livewireScripts + @endpushOnce +@endif From 66fd4f9e1040a204581b9ee4f845c27aa90fd4c1 Mon Sep 17 00:00:00 2001 From: "Pedro X." Date: Fri, 29 Sep 2023 22:10:38 +0100 Subject: [PATCH 09/10] false by default --- src/resources/views/ui/widgets/livewire.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resources/views/ui/widgets/livewire.blade.php b/src/resources/views/ui/widgets/livewire.blade.php index 805a27c09c..a810500278 100644 --- a/src/resources/views/ui/widgets/livewire.blade.php +++ b/src/resources/views/ui/widgets/livewire.blade.php @@ -11,13 +11,13 @@ @includeWhen(!empty($widget['wrapper']), backpack_view('widgets.inc.wrapper_end')) -@if($widget['livewireAssets'] ?? true) +@if($widget['livewireAssets'] ?? false) @pushOnce('after_styles') @livewireStyles @endPushOnce @endif -@if($widget['livewireAssets'] ?? true) +@if($widget['livewireAssets'] ?? false) @pushOnce('after_scripts') @livewireScripts @endpushOnce From b518bb065986c51555765e6a7028845f2eddbf24 Mon Sep 17 00:00:00 2001 From: "Pedro X." Date: Fri, 29 Sep 2023 22:24:31 +0100 Subject: [PATCH 10/10] cleanup --- src/resources/views/ui/widgets/livewire.blade.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/resources/views/ui/widgets/livewire.blade.php b/src/resources/views/ui/widgets/livewire.blade.php index a810500278..d00b70d4b1 100644 --- a/src/resources/views/ui/widgets/livewire.blade.php +++ b/src/resources/views/ui/widgets/livewire.blade.php @@ -15,9 +15,7 @@ @pushOnce('after_styles') @livewireStyles @endPushOnce -@endif - -@if($widget['livewireAssets'] ?? false) + @pushOnce('after_scripts') @livewireScripts @endpushOnce