]> _ Git - fluidbook-toolbox.git/commitdiff
wait #4213 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 12 Jul 2022 09:12:24 +0000 (11:12 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 12 Jul 2022 09:12:24 +0000 (11:12 +0200)
app/Fields/FluidbookChapters.php
app/SubForms/FluidbookChapter.php
resources/views/fields/fluidbook_chapter_level.blade.php

index 0afd5aabb1b9441137455a9365728afda22da521..1f2966bd53e22d1b6a827a34ef886e0a476c3b3e 100644 (file)
@@ -14,6 +14,39 @@ class FluidbookChapters extends BunchOfFieldsMultiple
 
     public function getDefaultAttributes()
     {
-        return array_merge(parent::getDefaultAttributes(), ["add_label" => __('Nouveau chapĂ®tre')]);
+        return array_merge(parent::getDefaultAttributes(), ["add_label" => __('Nouveau chapitre')]);
+    }
+
+    public function filterValue($value)
+    {
+        if (!$value) {
+            return $value;
+        }
+        $v = json_decode($value, true);
+        if (!$v) {
+            return $value;
+        }
+        $res = [];
+        foreach ($v as $k=>$chapter) {
+            $chapter['type'] = 'regular';
+            $chapter['label'] = trim($chapter['label']);
+            if ($chapter['label'] === '----') {
+                $chapter['label'] = '';
+                $chapter['type'] = 'separator';
+            } else if ($chapter['label'] === '--') {
+                $chapter['label'] = '';
+                $chapter['type'] = 'forcecut';
+            } else if ($chapter['label'] === '++') {
+                $chapter['label'] = '';
+                $chapter['type'] = 'nocut';
+            } else if (str_starts_with($chapter['label'], '!!!')) {
+                $chapter['label'] = substr($chapter['label'], 3);
+                $chapter['type'] = 'column_head';
+            }
+            $res[$k]=$chapter;
+        }
+
+
+        return parent::filterValue(json_encode($res));
     }
 }
index 210c736dd6eb8d6e535ad9f686d8e919bb1c2e9d..a3846ba8576f59d92a4ff3be7d51d9ea3b1a2c00 100644 (file)
@@ -27,7 +27,7 @@ class FluidbookChapter extends SubForm
                 'separator' => __('SĂ©parateur') . ' (----)',
             ]
         ]);
-        $this->addField('level', FluidbookChapterLevel::class, __('Niveau'), ['default' => 1, 'min' => 1, 'max' => 4]);
+        $this->addField('level', FluidbookChapterLevel::class, __('Niveau'), ['default' => 1, 'min' => 0, 'max' => 3]);
 
     }
 }
index f482130f08fae3c4cf304cab64a7b5431407671d..9ac99dd142d94cb7f716e08893bb9525502f5787 100644 (file)
                 display: inline-block;
             }
 
-            .item[data-level="1"] {
+            .item[data-level="0"] {
                 padding-left: 0;
             }
 
-            .item[data-level="2"] {
+            .item[data-level="1"] {
                 padding-left: 20px;
             }
 
-            .item[data-level="3"] {
+            .item[data-level="2"] {
                 padding-left: 40px;
             }
 
-            .item[data-level="4"] {
+            .item[data-level="3"] {
                 padding-left: 60px;
             }
         </style>