]> _ Git - fluidbook-toolbox.git/commitdiff
wait #4213 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Jun 2022 15:42:58 +0000 (17:42 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Jun 2022 15:42:58 +0000 (17:42 +0200)
app/Fields/FluidbookChapters.php [new file with mode: 0644]
app/Models/FluidbookPublication.php
app/SubForms/FluidbookChapter.php [new file with mode: 0644]
resources/views/fields/fluidbook_chapters.blade.php [new file with mode: 0644]

diff --git a/app/Fields/FluidbookChapters.php b/app/Fields/FluidbookChapters.php
new file mode 100644 (file)
index 0000000..981a2a9
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Fields;
+
+use App\SubForms\FluidbookChapter;
+use Cubist\Backpack\Magic\Fields\BunchOfFieldsMultiple;
+
+class FluidbookChapters extends BunchOfFieldsMultiple
+{
+    protected $_adminType = 'fluidbook_chapters';
+    protected $_viewNamespace='fields';
+    protected $_bunch = FluidbookChapter::class;
+    protected $_show_empty = false;
+}
index b94b66a00360ce7b3438c4d9b43ed2726d015d29..cf96f2907bc38b202b9f50f0739e34dd49728d78 100644 (file)
@@ -3,6 +3,7 @@
 
 namespace App\Models;
 
+use App\Fields\FluidbookChapters;
 use App\Fields\FluidbookLocale;
 use App\Fields\FluidbookTitle;
 use App\Fields\User;
@@ -56,14 +57,14 @@ class FluidbookPublication extends ToolboxModel
         $this->addField('page_numbers', Textarea::class, __('Numérotation'));
 
         $this->addField('section_theme', FormBigSection::class, __('Thème graphique'));
-        $this->addField('theme', \App\Fields\FluidbookTheme::class,__('Thème'));
+        $this->addField('theme', \App\Fields\FluidbookTheme::class, __('Thème'));
 
         $this->addField('section_locale', FormBigSection::class, __('Langue'));
         $this->addField('locale', FluidbookLocale::class, __('Langue principale'), ['default' => 'fr', 'allows_null' => false, 'filter' => true, 'filter_label' => 'Langue', 'column' => true, 'column_label' => '<i class="la la-language"></i>']);
         $this->addField('translations', \App\Fields\FluidbookTranslationOverwrite::class, __('Traductions personnalisées'));
 
         $this->addField('section_chapters', FormBigSection::class, __('Sommaire'));
-        $this->addField('chapters', Textarea::class, __('Sommaire'));
+        $this->addField('chapters', FluidbookChapters::class);
 
         $this->addField('section_settings', FormSuperSection::class, __('Paramètres'));
 
diff --git a/app/SubForms/FluidbookChapter.php b/app/SubForms/FluidbookChapter.php
new file mode 100644 (file)
index 0000000..1da327c
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+namespace App\SubForms;
+
+use Cubist\Backpack\Magic\Fields\Color;
+use Cubist\Backpack\Magic\Fields\Hidden;
+use Cubist\Backpack\Magic\Fields\SelectFromArray;
+use Cubist\Backpack\Magic\Fields\Text;
+use Cubist\Backpack\Magic\SubForm;
+
+class FluidbookChapter extends SubForm
+{
+    public function init()
+    {
+        parent::init();
+
+
+        $when = ['type' => ['regular', 'column_head']];
+        $this->addField('label', Text::class, __('Nom du chapitre'), ['when' => $when]);
+        $this->addField('page', Text::class, __('Page'), ['when' => $when]);
+        $this->addField('color', Color::class, __('Couleur'), ['when' => $when]);
+        $this->addField('type', SelectFromArray::class, __('Type'), ['default' => 'regular', 'options' =>
+            [
+                'regular' => __('Chapitre normal'),
+                'column_head' => __('Titre de colonne') . ' (!!!)',
+                'nocut' => __('Empêcher un passage à la colonne suivante') . ' (++)',
+                'forcecut' => __('Forcer un passage à la colonne suivante') . ' (--)',
+                'separator' => __('Séparateur') . ' (----)',
+            ]
+        ]);
+        $this->addField('level', Hidden::class, __('Niveau'));
+
+    }
+}
diff --git a/resources/views/fields/fluidbook_chapters.blade.php b/resources/views/fields/fluidbook_chapters.blade.php
new file mode 100644 (file)
index 0000000..23358c5
--- /dev/null
@@ -0,0 +1,30 @@
+@if (!isset($seenFluidbookChapters))
+    @php $seenFluidbookChapters=true;@endphp
+    @push('crud_fields_scripts')
+        <script>
+
+        </script>
+    @endpush
+
+    @push('crud_fields_styles')
+        <style>
+            .bunchmultiple_oneline .bunchmultiple__wrapper .item .legend .legendsize .form-group[data-name="label"] {
+                width: calc(100% - 330px);
+            }
+
+            .bunchmultiple_oneline .bunchmultiple__wrapper .item .legend .legendsize .form-group[data-name="page"] {
+                width: 100px;
+            }
+
+            .bunchmultiple_oneline .bunchmultiple__wrapper .item .legend .legendsize .form-group[data-name="color"] {
+                width: 70px;
+            }
+
+            .bunchmultiple_oneline .bunchmultiple__wrapper .item .legend .legendsize .form-group[data-name="type"] {
+                width: 160px;
+            }
+        </style>
+    @endpush
+@endif
+@include('cubist_back::fields.bunch_oneline_multiple')
+