소스 검색

https://assistance.opentalent.fr/browse/V8-1804

Olivier Massot 4 년 전
부모
커밋
461ef87491

+ 10 - 8
ot_templating/Classes/Controller/OtCustomizerController.php

@@ -38,9 +38,6 @@ class OtCustomizerController extends SelectedSiteController {
         $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
         $this->view->assign('currentTemplate', $templateRepository->getTemplate($this->currentRootUid));
         $this->view->assign('preferences', $templateRepository->getTemplatePreferences($this->currentRootUid));
-
-        $args = $this->request->getArguments();
-        $this->view->assign('preferencesUpdated', $args['preferencesUpdated']);
     }
 
     /**
@@ -66,6 +63,8 @@ class OtCustomizerController extends SelectedSiteController {
         // Clear the site's cache
         OtCacheManager::clearSiteCache($this->currentRootUid);
 
+        $this->addFlashMessage('Le thème a bien été modifié');
+
         $this->forward('index');
     }
 
@@ -81,7 +80,10 @@ class OtCustomizerController extends SelectedSiteController {
             $prefs['themeColor'] = $args['themeColor'];
         }
         if (isset($args['displayCarousel'])) {
-            $prefs['displayCarousel'] = $args['displayCarousel'];
+            $prefs['displayCarousel'] = $args['displayCarousel'] ? 1 : 0;
+        }
+        if (isset($args['displayBreadcrumb'])) {
+            $prefs['displayBreadcrumb'] = $args['displayBreadcrumb'] ? 1 : 0;
         }
 
         // applies the change in the database
@@ -94,17 +96,17 @@ class OtCustomizerController extends SelectedSiteController {
                 )
             )
             ->set('tx_opentalent_template_preferences', json_encode($prefs))
-            ->execute()
-        ;
+            ->execute();
 
         // Clear the site's cache
         OtCacheManager::clearSiteCache($this->currentRootUid);
 
+        $this->addFlashMessage('Les préférences ont bien été enregistrées');
+
         $this->forward(
             'index',
             'OtCustomizer',
-            'OtTemplating',
-            ['preferencesUpdated'=>'1']
+            'OtTemplating'
         );
     }
 }

+ 7 - 4
ot_templating/Classes/Templating/TemplateRepository.php

@@ -41,7 +41,8 @@ class TemplateRepository
 
     CONST defaultPreferences = [
         'themeColor' => 'lightblue',
-        'displayCarousel' => '1'
+        'displayCarousel' => '1',
+        'displayBreadcrumb' => '1',
     ];
 
     /**
@@ -83,9 +84,11 @@ class TemplateRepository
             ->execute()
             ->fetchColumn(0);
 
-        if ($templatePreferences==='') {
-            return self::defaultPreferences;
+        if ($templatePreferences !== '') {
+            $templatePreferences = json_decode($templatePreferences, true);
+        } else {
+            $templatePreferences = [];
         }
-        return json_decode($templatePreferences, true);
+        return array_merge(self::defaultPreferences, $templatePreferences);;
     }
 }

+ 2 - 1
ot_templating/Resources/Private/Partials/Classic/Breadcrumb.html

@@ -4,4 +4,5 @@
     -- Breadcrumb ViewHelper --
     Voir: https://fluidtypo3.org/viewhelpers/vhs/master/Page/BreadCrumbViewHelper.html
 --></f:comment>
-{v:page.breadCrumb(class: 'breadcrumb', linkCurrent: FALSE)}
+
+{v:page.breadCrumb(class: 'breadcrumb', linkCurrent: FALSE)}

+ 4 - 2
ot_templating/Resources/Private/Partials/Classic/Header.html

@@ -24,6 +24,8 @@
     <f:comment><!-- Render the navbar defined in partial/Navbar.html--></f:comment>
     <f:render partial="Classic/Menu" />
 
-    <f:comment><!-- Render the breadcrumb defined in partial/Breadcrumb.html--></f:comment>
-    <f:render partial="Classic/Breadcrumb" />
+    <f:if condition="{ot:template.getPreference(key: 'displayBreadcrumb')}==1">
+        <f:comment><!-- Render the breadcrumb defined in partial/Breadcrumb.html--></f:comment>
+        <f:render partial="Classic/Breadcrumb" />
+    </f:if>
 </header>

+ 3 - 1
ot_templating/Resources/Private/Partials/Modern/Header.html

@@ -21,4 +21,6 @@
     <f:render partial="Modern/Carousel" arguments="{_all}" />
 </f:if>
 
-<f:render partial="Modern/Breadcrumb" />
+<f:if condition="{ot:template.getPreference(key: 'displayBreadcrumb')}==1">
+    <f:render partial="Modern/Breadcrumb" />
+</f:if>

+ 8 - 6
ot_templating/Resources/Private/Templates/OtCustomizer/Index.html

@@ -3,10 +3,7 @@
 
 <f:layout name="Backend/Default" />
 
-
-
 <f:section name="content">
-
     <div class="ot-be-module ot-customizer">
         <div class="templates">
             <h3>Thèmes disponibles</h3>
@@ -75,6 +72,13 @@
                                      checked="{preferences.displayCarousel}"
                     />
                 </div>
+                <div class="form-group">
+                    <label>Afficher le fil d'arianne</label>
+                    <f:form.checkbox name="displayBreadcrumb"
+                                     value="2"
+                                     checked="{preferences.displayBreadcrumb}"
+                    />
+                </div>
 
                 <div class="actions">
                     <f:form.button type="submit" class="ot-btn">
@@ -82,9 +86,7 @@
                     </f:form.button>
                 </div>
 
-                <f:if condition="{preferencesUpdated}==1">
-                    <p class="success-msg">Préférences mises à jour</p>
-                </f:if>
+                <f:flashMessages />
             </f:form>
         </div>
     </div>

+ 5 - 1
ot_templating/Resources/Public/assets/Backend/style/ot_customizer.css

@@ -78,7 +78,6 @@
 .ot-customizer .customizer form {
     display: flex;
     flex-direction: column;
-    width: 80%;
 }
 
 .ot-customizer .customizer .form-group {
@@ -103,4 +102,9 @@
     display: flex;
     flex-direction: row;
     justify-content: flex-end;
+    margin-bottom: 14px;
+}
+
+.ot-customizer .customizer form .typo3-messages {
+    margin-top: 14px;
 }