]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5383 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Aug 2022 18:10:04 +0000 (20:10 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Aug 2022 18:10:04 +0000 (20:10 +0200)
app/Console/Commands/WorkshopMigration.php
app/Fields/FluidbookChapters.php
app/SubForms/FluidbookChapter.php
resources/views/fields/fluidbook_chapters.blade.php

index c7a7b663659a42a31ef997425d47f01d41a444a6..c63d841dbd695903ccc573b29f404d4e8c9eb7ab 100644 (file)
@@ -34,7 +34,7 @@ class WorkshopMigration extends CubistCommand
         $actions = [
             //'Backup current database' => 'backup',
             'Migrate magic models' => 'migrate',
-            'Import documents' => 'importDocuments',
+            //'Import documents' => 'importDocuments',
             'Import publications' => 'importPublications',
             'Clean caches' => 'cleanCache'
         ];
@@ -207,6 +207,8 @@ class WorkshopMigration extends CubistCommand
                     $date = new \DateTime();
                     $date->setTimestamp($data);
                     $data = $date;
+                } else if ($k === 'chapters') {
+                    $data = $this->_normalizeChapters($data);
                 }
                 if (isset($mapValues[$data])) {
                     $data = $mapValues[$data];
@@ -232,5 +234,40 @@ class WorkshopMigration extends CubistCommand
         }
     }
 
+    public function _normalizeChapters($value)
+    {
+        if (!$value) {
+            return $value;
+        }
+        if (is_string($value)) {
+            $v = json_decode($value, true);
+        } else {
+            $v = $value;
+        }
+        if (!$v) {
+            return $value;
+        }
+        $res = [];
+        foreach ($v as $k => $chapter) {
+            $chapter['decoration'] = 'regular';
+            $chapter['label'] = trim($chapter['label']);
+            if ($chapter['label'] === '----') {
+                $chapter['label'] = '';
+                $chapter['decoration'] = 'separator';
+            } else if ($chapter['label'] === '--') {
+                $chapter['label'] = '';
+                $chapter['decoration'] = 'forcecut';
+            } else if ($chapter['label'] === '++') {
+                $chapter['label'] = '';
+                $chapter['decoration'] = 'nocut';
+            } else if (str_starts_with($chapter['label'], '!!!')) {
+                $chapter['label'] = substr($chapter['label'], 3);
+                $chapter['decoration'] = 'column_head';
+            }
+            $res[$k] = $chapter;
+        }
+
 
+        return $res;
+    }
 }
index b300d23ea71bb28ff752df065ab46d67ec1e38cb..9d197ab0b5a8212a3513ddd0ad5c6cbb0cbf55e6 100644 (file)
@@ -17,40 +17,5 @@ class FluidbookChapters extends BunchOfFieldsMultiple
         return array_merge(parent::getDefaultAttributes(), ["add_label" => __('Nouveau chapitre')]);
     }
 
-    public function filterValue($value)
-    {
-        if (!$value) {
-            return $value;
-        }
-        if (is_string($value)) {
-            $v = json_decode($value, true);
-        } else {
-            $v = $value;
-        }
-        if (!$v) {
-            return $value;
-        }
-        $res = [];
-        foreach ($v as $k => $chapter) {
-            $chapter['decoration'] = 'regular';
-            $chapter['label'] = trim($chapter['label']);
-            if ($chapter['label'] === '----') {
-                $chapter['label'] = '';
-                $chapter['decoration'] = 'separator';
-            } else if ($chapter['label'] === '--') {
-                $chapter['label'] = '';
-                $chapter['decoration'] = 'forcecut';
-            } else if ($chapter['label'] === '++') {
-                $chapter['label'] = '';
-                $chapter['decoration'] = 'nocut';
-            } else if (str_starts_with($chapter['label'], '!!!')) {
-                $chapter['label'] = substr($chapter['label'], 3);
-                $chapter['decoration'] = 'column_head';
-            }
-            $res[$k] = $chapter;
-        }
-
 
-        return parent::filterValue(json_encode($res));
-    }
 }
index f97a746517c23498d5428311795d92dee807ffc0..7e39870558e80a1180a6c000796eba9dce3708f7 100644 (file)
@@ -29,6 +29,5 @@ class FluidbookChapter extends SubForm
             ]
         ]);
         $this->addField('level', FluidbookChapterLevel::class, __('Niveau'), ['default' => 1, 'min' => 0, 'max' => 3]);
-
     }
 }
index 95a712ca44d973ff5373523ae75668244e219abf..32e4358dcf99b8a5979505f8f751ed20841fb5de 100644 (file)
@@ -68,8 +68,8 @@
 @endif
 
 @php
-    $additionalButtons='<a href="#" class="btn btn-sm btn-secondary chaptersImportExcel"><i class="la la-file-excel"></i> '.__('Remplacer par le contenu d\'un fichier excel').'</a>';
-    $additionalButtons.='<a href="#" class="btn btn-sm btn-success chaptersExportExcel"><i class="la la-file-excel"></i> '.__('Exporter au format excel').'</a>';
+        $additionalButtons='<a href="#" class="btn btn-sm btn-secondary chaptersImportExcel"><i class="la la-file-excel"></i> '.__('Remplacer par le contenu d\'un fichier excel').'</a>';
+        $additionalButtons.='<a href="#" class="btn btn-sm btn-success chaptersExportExcel"><i class="la la-file-excel"></i> '.__('Exporter au format excel').'</a>';
 @endphp
 @include('cubist_back::fields.bunch_oneline_multiple')
 @php