]> _ Git - pmi.git/commitdiff
wip #2843 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Jul 2019 18:26:58 +0000 (20:26 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Jul 2019 18:26:58 +0000 (20:26 +0200)
app/Models/Page.php
app/SubForms/HomeSolution.php
app/Templates/Home.php

index d8fb4b3e33d3eadda88301fe025c6c7b68ab9c51..8b7effd66dd1f87180d7ffae6a272b29fe0f8d17 100644 (file)
@@ -1,207 +1,9 @@
 <?php
 
-
 namespace App\Models;
 
 use Cubist\Backpack\app\Magic\Models\CMSPage;
-use Lavary\Menu\Menu;
 
 class Page extends CMSPage
 {
-    public static function makeMenus()
-    {
-
-        if (Menu::exists('primary')) {
-            return;
-        }
-        $productsSubMenus = [
-
-            // Left panel
-            [
-                'title' => 'Capteurs',
-                'links' => [
-                    'Force' => 'products/force',
-                    'Couple' => 'products/couple',
-                    'Déplacement' => 'products/deplacement',
-                    'Accélération' => 'products/acceleration',
-                    'Inclinaison' => 'products/inclinaison',
-                    'Pression' => 'products/pression',
-                ],
-            ],
-
-            // Right panel
-            [
-                'title' => 'Systèmes de mesure',
-                'links' => [
-                    'Roue dynamométrique' => 'products/roue',
-                    'Contrôle de fermeture d’ouvrants' => 'products/cdfdo',
-                    'Contrôle de taraudage' => 'products/cdt',
-                    'Collecteurs tournant' => 'products/ct',
-                    'Télémétrie' => 'products/telemetrie',
-                    'Acquisition de données' => 'products/add',
-                ],
-            ],
-        ];
-
-        $tree = Page::getTree();
-
-        $main = $tree['#main'];
-
-        $nav_items = [];
-        foreach ($main['children'] as $name => $item) {
-            $submenus = null;
-            if ($name == 'products') {
-                $submenus = $productsSubMenus;
-            } else {
-                $links = [];
-
-                foreach ($item['children'] as $key => $child) {
-                    $links[$child['element']->title] = $child['element']->slug;
-                }
-
-                if (count($links) > 0) {
-                    $submenus = [['links' => $links]];
-                }
-            }
-            $s = ['url' => $item['element']->slug];
-            if (null !== $submenus) {
-                $s['submenus'] = $submenus;
-            }
-
-            $nav_items[$item['element']->title] = $s;
-        }
-
-//        // Hard coded menu structure until we have dynamic data from the CMS
-//        $nav_items = [
-//
-//            'Products' => [
-//                'url' => 'products',
-//                'submenus' => [
-//
-//                    // Left panel
-//                    [
-//                        'title' => 'Capteurs',
-//                        'links' => [
-//                            'Force' => 'products/force',
-//                            'Couple' => 'products/couple',
-//                            'Déplacement' => 'products/deplacement',
-//                            'Accélération' => 'products/acceleration',
-//                            'Inclinaison' => 'products/inclinaison',
-//                            'Pression' => 'products/pression',
-//                        ],
-//                    ],
-//
-//                    // Right panel
-//                    [
-//                        'title' => 'Systèmes de mesure',
-//                        'links' => [
-//                            'Roue dynamométrique' => 'products/roue',
-//                            'Contrôle de fermeture d’ouvrants' => 'products/cdfdo',
-//                            'Contrôle de taraudage' => 'products/cdt',
-//                            'Collecteurs tournant' => 'products/ct',
-//                            'Télémétrie' => 'products/telemetrie',
-//                            'Acquisition de données' => 'products/add',
-//                        ],
-//                    ],
-//                ],
-//            ],
-//
-//            'Solutions' => [
-//                'url' => 'solutions',
-//                'submenus' => [
-//                    [
-//                        'links' => [
-//                            'Énergie' => 'solutions/energie',
-//                            'Aéronautique' => 'solutions/aero',
-//                            'Ferroviaire' => 'solutions/ferroviaire',
-//                            'Automobile' => 'solutions/auto',
-//                            'Génie civil' => 'solutions/civil',
-//                            'Industrie' => 'solutions/industrie',
-//                        ]
-//                    ],
-//                ],
-//            ],
-//
-//            'Services' => [
-//                'url' => 'services',
-//                'submenus' => [
-//                    [
-//                        'title' => null,
-//                        'links' => [
-//                            'Location' => 'services/location',
-//                            'Calibration' => 'services/calibration',
-//                            'Développement OEM' => 'services/developpement-oem',
-//                            'Custom Design' => 'services/custom-design',
-//                            'Formation' => 'services/formation',
-//                        ],
-//                    ],
-//                ],
-//            ],
-//            'Support' => ['url' => 'support'],
-//            'Société' => [
-//                'url' => 'societe',
-//                'submenus' => [
-//                    [
-//                        'links' => [
-//                            'Qui sommes nous ?' => 'societe/a-propos',
-//                            'Actualités' => 'societe/actualites',
-//                        ]
-//                    ]
-//                ],
-//            ],
-//            'Contact' => ['url' => 'contact'],
-//        ];
-
-
-        \Menu::make('primary', function ($menu) use ($nav_items) {
-
-            foreach ($nav_items as $nav_label => $nav_item) {
-
-                $parent = $menu->add($nav_label, $nav_item['url']);
-
-                // Handle items with submenus
-                if (isset($nav_item['submenus'])) {
-
-                    foreach ($nav_item['submenus'] as $submenu_data) {
-
-                        // Create an empty sub-element that will serve as a wrapper for the submenu(s)
-                        $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']);
-
-                        // Some submenus have a title element
-                        if (isset($submenu_data['title'])) {
-                            $wrapper->raw($submenu_data['title'])->attr(['class' => 'nav-submenu-title']);
-                        }
-
-                        foreach ($submenu_data['links'] as $label => $url) {
-                            $wrapper->add($label, $url);
-                        }
-                    }
-                }
-
-            }
-
-        });
-
-        // Also make a menu for the breadcrumbs - this one is simpler and doesn't have the submenu headings
-        \Menu::make('breadcrumbs', function ($menu) use ($nav_items) {
-
-            // Start with home link
-            $menu = $menu->add('Home', '');
-
-            foreach ($nav_items as $nav_label => $nav_item) {
-
-                $parent = $menu->add($nav_label, $nav_item['url']);
-
-                // Handle items with submenus
-                if (isset($nav_item['submenus'])) {
-
-                    foreach ($nav_item['submenus'] as $submenu_data) {
-                        foreach ($submenu_data['links'] as $label => $url) {
-                            $parent->add($label, $url);
-                        }
-                    }
-                }
-            }
-        });
-    }
 }
index a81c80921df7578b67a1f33f2cf3f4818b4de9af..e888e767ff46be26fcc2433a871ef4c6d9cc36da 100644 (file)
@@ -22,7 +22,6 @@ class HomeSolution extends SubForm
 
         $this->addField(['name' => 'page',
             'label' => 'Lien vers',
-            'type' => 'SelectFromModel',
-            'optionsmodel' => 'App\Models\Page']);
+            'type' => 'PageInternal']);
     }
 }
index 3626460a369d0d8e6e570eade5848b37203403bd..f76d2b94997d0ae82ef3c125f86aff95f20d306d 100644 (file)
@@ -1,8 +1,6 @@
 <?php
-
 namespace App\Templates;
 
-
 class Home extends Base
 {
 
@@ -44,9 +42,9 @@ class Home extends Base
             'multiple' => true]);
 
         $this->addField(['name' => 'solutions',
-            'type'=>'BunchOfFieldsMultiple',
-            'bunch'=>'App\SubForms\HomeSolution',
-            'label'=>'Solutions',
+            'type' => 'BunchOfFieldsMultiple',
+            'bunch' => 'App\SubForms\HomeSolution',
+            'label' => 'Solutions',
             'tab' => 'Solutions / Applications']);
 
         $this->addField(['name' => 'products_systems',