]> _ Git - cubist_cms-back.git/commitdiff
wip #6693 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 2 Feb 2024 12:08:56 +0000 (13:08 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 2 Feb 2024 12:08:56 +0000 (13:08 +0100)
13 files changed:
src/app/Console/Commands/MenuGenerate.php
src/app/Console/Commands/OptimizeClearCommand.php [new file with mode: 0644]
src/app/CubistBackpackServiceProvider.php
src/app/Magic/Fields/CMSTemplate.php
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/CubistMagicPageModel.php
src/app/Template/FirstRedirection.php
src/app/Template/InternalRedirection.php
src/app/Template/Navigation.php
src/app/Template/Redirection.php
src/app/Template/TemplateAbstract.php
src/app/Template/Undefined.php [new file with mode: 0644]
src/resources/views/fields/select2_from_array.blade.php

index 8f84a1194260bc3411d1d346a80d29137c43692a..657e9161e191d777527858084595c27d14800e26 100644 (file)
@@ -11,7 +11,8 @@ class MenuGenerate extends CubistCommand
     public function handle()
     {
 
-        Artisan::call('config:cache');
+
+
         $items = config('backpack.menu.items');
 
         $res = '';
diff --git a/src/app/Console/Commands/OptimizeClearCommand.php b/src/app/Console/Commands/OptimizeClearCommand.php
new file mode 100644 (file)
index 0000000..2c34c78
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+namespace Cubist\Backpack\Console\Commands;
+
+class OptimizeClearCommand extends \Illuminate\Foundation\Console\OptimizeClearCommand
+{
+    public function handle()
+    {
+        parent::handle();
+
+        collect([
+            'menu' => fn() => $this->callSilent('cubist:menu:generate') == 0,
+        ])->each(fn($task, $description) => $this->components->task($description, $task));
+
+        $this->newLine();
+    }
+}
index 1e3e0fb512c9cb11b9203fb92a4cfe0bdd885401..dd714d9e52f33de8a075801ebd4b4b442ac313a6 100644 (file)
@@ -10,6 +10,7 @@ use Cubist\Backpack\Console\Commands\GenerateCommand;
 use Cubist\Backpack\Console\Commands\InstallCommand;
 use Cubist\Backpack\Console\Commands\LocaleCopy;
 use Cubist\Backpack\Console\Commands\LocaleSlugReset;
+use Cubist\Backpack\Console\Commands\OptimizeClearCommand;
 use Cubist\Backpack\Console\Commands\PrecacheCommand;
 use Cubist\Backpack\Console\Commands\RefreshComposedAttributesCommand;
 use Cubist\Backpack\Console\Commands\SearchIndexCommand;
@@ -90,8 +91,10 @@ class CubistBackpackServiceProvider extends ServiceProvider
             RefreshComposedAttributesCommand::class,
             SearchIndexCommand::class,
             LocaleCopy::class,
-            LocaleSlugReset::class
+            LocaleSlugReset::class,
+            OptimizeClearCommand::class,
         ]);
+
     }
 
     public function provides()
index 3c85211c088b0ec359b48a83ed1ae1d7976819e4..b17cc306ed3d1169eb443e62cfdf6f0eb8fb26f9 100644 (file)
@@ -13,15 +13,14 @@ class CMSTemplate extends SelectFromArray
     protected $_allowNull = false;
     protected $_translatable = false;
 
-    protected function _postSetAttributes()
+    public function getOptions()
     {
-        parent::_postSetAttributes();
         $templates = TemplateAbstract::getTemplates();
 
         $options = [];
         foreach ($templates as $name => $template) {
             $options[Str::snake($name)] = $template->getName();
         }
-        $this->setAttribute('options', $options);
+        return $options;
     }
 }
index 5be3e005ca1746e2f6ddcd9bb93a65964a08452f..c78da5e00b42e353f45d1acc5d4a5ab8df3b61ca 100644 (file)
@@ -80,7 +80,7 @@ class CMSPage extends CubistMagicNestedModel
     }
 
 
-    public function onCreating():bool
+    public function onCreating(): bool
     {
         $this->useTemplateIfNotSet(request('template'));
         return $this->onCreating();
@@ -99,13 +99,13 @@ class CMSPage extends CubistMagicNestedModel
 //        parent::onBeforeEdit($controller, $id);
 //    }
 
-    public function onSaving():bool
+    public function onSaving(): bool
     {
         $this->useTemplateIfNotSet(request('template'));
         return $this->onSaving();
     }
 
-    public function onUpdating():bool
+    public function onUpdating(): bool
     {
         $this->useTemplateIfNotSet(request('template'));
         return $this->onUpdating();
@@ -197,14 +197,21 @@ class CMSPage extends CubistMagicNestedModel
         }
     }
 
+
     public function create(array $attributes = [])
     {
+        if (!isset($attributes['template']) || !$attributes['template']) {
+            $attributes['template']='unset';
+        }
         $this->useTemplate($attributes['template']);
         return parent::create($attributes);
     }
 
     public function update(array $attributes = [], array $options = [])
     {
+        if (!isset($attributes['template']) || !$attributes['template']) {
+            $attributes['template']='unset';
+        }
         $this->useTemplate($attributes['template']);
         return parent::update($attributes, $options);
     }
@@ -215,8 +222,7 @@ class CMSPage extends CubistMagicNestedModel
             $this->useTemplateIfNotSet($attributes['template']);
         }
 
-        $res = parent::setRawAttributes($attributes, $sync);
-        return $res;
+        return parent::setRawAttributes($attributes, $sync);
     }
 
     public static function getPagesList($variant = null)
@@ -258,6 +264,6 @@ class CMSPage extends CubistMagicNestedModel
         if ($this instanceof CMSPage) {
             $this->useTemplate();
         }
-        parent::copyTranslations($from, $to, $overwrite); // TODO: Change the autogenerated stub
+        parent::copyTranslations($from, $to, $overwrite);
     }
 }
index cdd0f6c481d4f4a29e2b76e55f10a38ff36e63df..a36b0d5af3645341c248f202af9fb11431ca9959 100644 (file)
@@ -90,9 +90,9 @@ class CubistMagicPageModel extends CubistMagicTranslatableModel
 
         $this->addFieldAtEnd([
             'name' => 'meta_title',
-            'label' => trans('backpack::pagemanager.meta_title'),
+            'label' => 'Titre ',
             'type' => 'Text',
-            'hint' => 'Si vide, le titre court est utilisé' . ' ' . 'Longueur recommandée : 60 caractères',
+            'hint' => 'Contenu de la balise &lt;title&gt;. Si vide, le titre court est utilisé' . ' ' . 'Longueur recommandée : 60 caractères',
             'tab' => $tab,
             'fake' => true,
             'store_in' => 'seo',
@@ -100,9 +100,9 @@ class CubistMagicPageModel extends CubistMagicTranslatableModel
 
         $this->addFieldAtEnd([
             'name' => 'meta_description',
-            'label' => trans('backpack::pagemanager.meta_description'),
+            'label' => 'Description',
             'type' => 'Textarea',
-            'hint' => 'Longueur recommandée : 160 caractères',
+            'hint' => 'Contenu de &lt;meta name="description"&gt;. Longueur recommandée : 160 caractères',
             'tab' => $tab,
             'fake' => true,
             'store_in' => 'seo',
@@ -115,6 +115,7 @@ class CubistMagicPageModel extends CubistMagicTranslatableModel
             'default' => true,
             'tab' => $tab,
             'fake' => true,
+            'translatable'=>false,
             'store_in' => 'seo',
         ]);
 
@@ -125,6 +126,7 @@ class CubistMagicPageModel extends CubistMagicTranslatableModel
             'hint' => 'Liste des URL alternatives correspondant à cette page. Peut être utilisé lors de la migration. Si un visiteur tape une de ces URL, il sera redirigé vers cette page.',
             'tab' => $tab,
             'fake' => true,
+            'translatable'=>false,
             'store_in' => 'seo']);
     }
 
index 2eaaa504e5d49d4bfc63632877539cdd701756de..dbe504b0782dee74e5ead3597353f861ddf9c8a1 100644 (file)
@@ -20,4 +20,9 @@ class FirstRedirection extends Redirection
     {
 
     }
+
+    public function showInDropDown()
+    {
+        return true;
+    }
 }
index 82de3a8b170c1b28ce2cf94c29a1a2624ed39828..21a02dac77590ce2b504103ac17b91dad3890faa 100644 (file)
@@ -22,4 +22,9 @@ class InternalRedirection extends Redirection
             ]
         );
     }
+
+    public function showInDropDown()
+    {
+        return true;
+    }
 }
index ec367b6fdd6fdac52493489c29480410863b6a7b..33facbe8de6548308901c212e535114f2e25265f 100644 (file)
@@ -26,5 +26,9 @@ class Navigation extends TemplateAbstract
         return '* Navigation';
     }
 
+    public function showInDropDown()
+    {
+        return true;
+    }
 
 }
index 22ceed75e2bbc1d59015e33e2c9f5e4120bff10b..7b8ed8e3b3a70a8f4c7d334139bd3ae112394719 100644 (file)
@@ -31,4 +31,9 @@ class Redirection extends TemplateAbstract
     {
         return '* Redirection externe';
     }
+
+    public function showInDropDown()
+    {
+        return true;
+    }
 }
index 9737c10032ec596ec6b3315e14039417772714b6..ba73d58a9906bd1f3f7e5e2ab3e231a4b56c2f86 100644 (file)
@@ -97,11 +97,13 @@ class TemplateAbstract
             self::$_templates = [];
             $roots = [__DIR__ => 'Cubist\\Backpack\\Template', app_path() . '/Templates' => 'App\\Templates'];
             foreach ($roots as $templates_root => $prefix) {
+
                 if (!file_exists($templates_root)) {
                     continue;
                 }
                 $dr = opendir($templates_root);
                 while ($file = readdir($dr)) {
+
                     if ($file == '.' || $file == '..' || is_dir($templates_root . '/' . $file)) {
                         continue;
                     }
diff --git a/src/app/Template/Undefined.php b/src/app/Template/Undefined.php
new file mode 100644 (file)
index 0000000..c400dff
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+namespace Cubist\Backpack\Template;
+
+class Undefined extends TemplatePage
+{
+    public function showInDropDown()
+    {
+        return true;
+    }
+}
index 55044bc2cf849ae84e87ca2c636dc398b65f3a84..61ec50df6a4404af829b807b8d0ef921f0cedae6 100644 (file)
@@ -91,21 +91,23 @@ if($ajax){
 {{-- ########################################## --}}
 {{-- Extra CSS and JS for this particular field --}}
 {{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
-@if ($crud->checkIfFieldIsFirstOfItsType($field))
+
+
     {{-- FIELD CSS - will be loaded in the after_styles section --}}
     @push('crud_fields_styles')
-        <!-- include select2 css-->
-        <link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet"
-              type="text/css"/>
-        <link
-                href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}"
-                rel="stylesheet" type="text/css"/>
+    {{-- include select2 css --}}
+    @basset('https://unpkg.com/select2@4.0.13/dist/css/select2.min.css')
+    @basset('https://unpkg.com/select2-bootstrap-theme@0.1.0-beta.10/dist/select2-bootstrap.min.css')
     @endpush
 
     {{-- FIELD JS - will be loaded in the after_scripts section --}}
     @push('crud_fields_scripts')
-        <!-- include select2 js -->
-        <script src="{{ asset('packages/select2/dist/js/select2.min.js') }}"></script>
+    {{-- include select2 js --}}
+    @basset('https://unpkg.com/select2@4.0.13/dist/js/select2.full.min.js')
+    @if (app()->getLocale() !== 'en')
+        @basset('https://unpkg.com/select2@4.0.13/dist/js/i18n/' . str_replace('_', '-', app()->getLocale()) . '.js')
+    @endif
+    @bassetBlock('backpack/pro/fields/select2-from-array-field.js')
         <script>
             jQuery(document).ready(function ($) {
                 $(document).on('cubist.bunchmultiple.added', function () {
@@ -152,8 +154,7 @@ if($ajax){
                 showSelectedValue();
             }
         </script>
+    @endBassetBlock
     @endpush
-
-@endif
 {{-- End of Extra CSS and JS --}}
 {{-- ########################################## --}}