From d0066e462829a2d29d3c2c86522664978a5f16f9 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 28 Feb 2020 18:10:30 +0100 Subject: [PATCH] wip #3439 @0.5 --- src/app/Console/Commands/InstallCommand.php | 2 + .../CubistRedirectToAdminController.php | 19 ++++ .../Operations/BulkPublishOperation.php | 13 ++- .../Controllers/CubistMagicController.php | 5 +- .../app/Http/Controllers/PageController.php | 10 ++ .../views/buttons/bulk_offline.blade.php | 2 +- .../views/buttons/bulk_publish.blade.php | 96 +++++++++---------- 7 files changed, 90 insertions(+), 57 deletions(-) create mode 100644 src/app/Http/Controllers/CubistRedirectToAdminController.php create mode 100644 src/resources/install/app/Http/Controllers/PageController.php diff --git a/src/app/Console/Commands/InstallCommand.php b/src/app/Console/Commands/InstallCommand.php index 3411686..ae00f84 100644 --- a/src/app/Console/Commands/InstallCommand.php +++ b/src/app/Console/Commands/InstallCommand.php @@ -32,6 +32,8 @@ class InstallCommand extends CubistCommand 'php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="config"', 'php artisan vendor:publish --provider="Backpack\PermissionManager\PermissionManagerServiceProvider"', 'php artisan backpack:add-sidebar-content "
  • Authentication
  • "', + // Revisions + 'cp vendor/venturecraft/revisionable/src/migrations/2013_04_09_062329_create_revisions_table.php database/migrations/', ], 'Install dev dependencies' => ['composer require --dev ' . implode(' ', $devPackages)], "Dropzone" => 'php artisan gaspertrix:backpack:dropzone:install', diff --git a/src/app/Http/Controllers/CubistRedirectToAdminController.php b/src/app/Http/Controllers/CubistRedirectToAdminController.php new file mode 100644 index 0000000..f0b34c0 --- /dev/null +++ b/src/app/Http/Controllers/CubistRedirectToAdminController.php @@ -0,0 +1,19 @@ +_bulk) { - $this->crud->enableBulkActions(); - $this->crud->addButton('bottom', 'bulk_publish', 'view', CubistBackpackServiceProvider::NAMESPACE . '::buttons.bulk_publish', 'begining'); - $this->crud->addButton('bottom', 'bulk_offline', 'view', CubistBackpackServiceProvider::NAMESPACE . '::buttons.bulk_offline', 'begining'); - } + $this->crud->operation('list', function () { + if($this->crud->getModel() instanceof CubistMagicPageModel) { + $this->crud->enableBulkActions(); + $this->crud->addButton('bottom', 'bulk_publish', 'view', CubistBackpackServiceProvider::NAMESPACE . '::buttons.bulk_publish', 'begining'); + $this->crud->addButton('bottom', 'bulk_offline', 'view', CubistBackpackServiceProvider::NAMESPACE . '::buttons.bulk_offline', 'begining'); + } + }); } } diff --git a/src/app/Magic/Controllers/CubistMagicController.php b/src/app/Magic/Controllers/CubistMagicController.php index 8ac2ae9..0c6fc4e 100644 --- a/src/app/Magic/Controllers/CubistMagicController.php +++ b/src/app/Magic/Controllers/CubistMagicController.php @@ -59,7 +59,6 @@ class CubistMagicController extends CubistCrudController public function setup() { - dd('setup'); $this->crud->setModel($this->_modelNamespace); $this->_postSetModel(); @@ -217,7 +216,7 @@ class CubistMagicController extends CubistCrudController $this->getModelInstance()->onBeforeStore($this, $request); // your additional operations before save here - $redirect_location = parent::storeCrud($request); + $redirect_location = parent::store(); // your additional operations after save here // use $this->data['entry'] or $this->crud->entry return $redirect_location; @@ -235,7 +234,7 @@ class CubistMagicController extends CubistCrudController $this->getModelInstance()->onBeforeUpdate($this, $request); // your additional operations before save here - $redirect_location = parent::updateCrud($request); + $redirect_location = parent::update(); // your additional operations after save here // use $this->data['entry'] or $this->crud->entry return $redirect_location; diff --git a/src/resources/install/app/Http/Controllers/PageController.php b/src/resources/install/app/Http/Controllers/PageController.php new file mode 100644 index 0000000..8881bfd --- /dev/null +++ b/src/resources/install/app/Http/Controllers/PageController.php @@ -0,0 +1,10 @@ +hasAccess('update') && $crud->bulk_actions) +@if ($crud->hasAccess('update') && $crud->get('list.bulkActions')) Put offline @endif diff --git a/src/resources/views/buttons/bulk_publish.blade.php b/src/resources/views/buttons/bulk_publish.blade.php index 911d8ea..7cab5a7 100644 --- a/src/resources/views/buttons/bulk_publish.blade.php +++ b/src/resources/views/buttons/bulk_publish.blade.php @@ -1,58 +1,58 @@ -@if ($crud->hasAccess('update') && $crud->bulk_actions) - Publish +@if ($crud->hasAccess('update') && $crud->get('list.bulkActions')) + Publish @endif @push('after_scripts') - + crud.checkedItems = []; + crud.table.ajax.reload(); + }, + error: function (result) { + // Show an alert with the result + new PNotify({ + title: "Publishing failed", + text: "One or more entries could not be published. Please try again.", + type: "warning" + }); + } + }); + } + } + } + @endpush -- 2.39.5