From: Vincent Vanwaelscappel Date: Tue, 12 Jul 2022 09:12:24 +0000 (+0200) Subject: wait #4213 @0.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=96cf251765763eff0bfdc1b5a5700ec06a18cdf7;p=fluidbook-toolbox.git wait #4213 @0.75 --- diff --git a/app/Fields/FluidbookChapters.php b/app/Fields/FluidbookChapters.php index 0afd5aabb..1f2966bd5 100644 --- a/app/Fields/FluidbookChapters.php +++ b/app/Fields/FluidbookChapters.php @@ -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)); } } diff --git a/app/SubForms/FluidbookChapter.php b/app/SubForms/FluidbookChapter.php index 210c736dd..a3846ba85 100644 --- a/app/SubForms/FluidbookChapter.php +++ b/app/SubForms/FluidbookChapter.php @@ -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]); } } diff --git a/resources/views/fields/fluidbook_chapter_level.blade.php b/resources/views/fields/fluidbook_chapter_level.blade.php index f482130f0..9ac99dd14 100644 --- a/resources/views/fields/fluidbook_chapter_level.blade.php +++ b/resources/views/fields/fluidbook_chapter_level.blade.php @@ -40,19 +40,19 @@ 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; }