From: Vincent Vanwaelscappel Date: Thu, 4 Jul 2019 18:26:58 +0000 (+0200) Subject: wip #2843 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c261fa34ccb5c268359a04c45417d18392bad576;p=pmi.git wip #2843 @2 --- diff --git a/app/Models/Page.php b/app/Models/Page.php index d8fb4b3..8b7effd 100644 --- a/app/Models/Page.php +++ b/app/Models/Page.php @@ -1,207 +1,9 @@ '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); - } - } - } - } - }); - } } diff --git a/app/SubForms/HomeSolution.php b/app/SubForms/HomeSolution.php index a81c809..e888e76 100644 --- a/app/SubForms/HomeSolution.php +++ b/app/SubForms/HomeSolution.php @@ -22,7 +22,6 @@ class HomeSolution extends SubForm $this->addField(['name' => 'page', 'label' => 'Lien vers', - 'type' => 'SelectFromModel', - 'optionsmodel' => 'App\Models\Page']); + 'type' => 'PageInternal']); } } diff --git a/app/Templates/Home.php b/app/Templates/Home.php index 3626460..f76d2b9 100644 --- a/app/Templates/Home.php +++ b/app/Templates/Home.php @@ -1,8 +1,6 @@ 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',