From: Vincent Vanwaelscappel Date: Mon, 30 Mar 2020 13:06:05 +0000 (+0200) Subject: wip #3520 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=44fb59cac1568599e5ec68b3c63b333430dfe9f5;p=pmi.git wip #3520 --- diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 8222179..55cc452 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -42,7 +42,6 @@ class Kernel extends HttpKernel \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \Cubist\Backpack\app\Middleware\EmailObfuscate::class, - \App\Http\Middleware\Menu::class, ], 'api' => [ diff --git a/app/Http/Middleware/Menu.php b/app/Http/Middleware/Menu.php deleted file mode 100644 index 11338ac..0000000 --- a/app/Http/Middleware/Menu.php +++ /dev/null @@ -1,48 +0,0 @@ -getChildren() as $child) { - if (!$child->isMenuDesktop()) { - continue; - } - $parent = $menu->add($child->getTitle(), $child->getHref()); - - // Handle items with submenus - if ($child->hasChildren()) { - // Create an empty sub-element that will serve as a wrapper for the submenu(s) - - if ($child->getType() == 'mega') { - foreach ($child->getChildren() as $submenu) { - $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']); - $wrapper->raw($submenu->getTitle())->attr(['class' => 'nav-submenu-title']); - foreach ($submenu->getChildren() as $subitem) { - $wrapper->add($subitem->getTitle(), $subitem->getHref()); - } - } - } else { - $wrapper = $parent->raw('')->attr(['class' => 'nav-submenu-wrapper']); - foreach ($child->getChildren() as $subitem) { - $wrapper->add($subitem->getTitle(), $subitem->getHref()); - } - } - } - } - } -} diff --git a/app/PageTemplates.php b/app/PageTemplates.php deleted file mode 100644 index 18e96c0..0000000 --- a/app/PageTemplates.php +++ /dev/null @@ -1,24 +0,0 @@ -addField([ + 'name' => 'intro', + 'type' => 'BunchOfFields', + 'bunch' => 'App\SubForms\Intro', + 'label' => 'Introduction', + 'tab' => 'Introduction', + 'translatable' => true, + ]); + $this->addField(['name' => 'category', 'type' => 'SelectFromModel', 'optionsmodel' => ProductType::class, diff --git a/app/Templates/CategoryGroup.php b/app/Templates/CategoryGroup.php index ff56872..daa8e47 100644 --- a/app/Templates/CategoryGroup.php +++ b/app/Templates/CategoryGroup.php @@ -28,57 +28,4 @@ class CategoryGroup extends FirstRedirection 'allows_multiple' => true, 'order' => true]); } - - public function setMenuChildren($menu) - { - $menu->setType('mega'); - - $productTypes = ProductType::whereVariant($menu->getVariant())->get(); - $products = Product::whereVariant($menu->getVariant())->get(); - - $categories = $menu->getPageData()->get('categories'); - if (null === $categories || !$categories) { - return; - } - foreach ($productTypes as $productType) { - if (!in_array($productType->id, $categories)) { - continue; - } - $category = new PageItem(); - $category->setVariant($menu->getVariant()); - $category->setLocale($menu->getLocale()); - $category->initFromEntity($productType); - $category->setTitle($productType->name); - $category->setHref($productType->getSlugOrTitleAttribute()); - $category->setId('product_type/' . $productType->id); - $category->setController(['controller' => 'ProductController', 'action' => 'productList', 'params' => ['id' => $productType->id]]); - $category->showInAllMenus(); - - $count = 0; - foreach ($products as $product) { - if ($product->product_type != $productType->id) { - continue; - } - if (!$product->online) { - continue; - } - $detail = new PageItem(); - $detail->setLocale($menu->getLocale()); - $detail->setVariant($menu->getVariant()); - $detail->initFromEntity($product); - $detail->setTitle($product->name); - $detail->setHref($product->getSlugOrTitleAttribute()); - $detail->setId('product/' . $product->id); - $detail->setController(['controller' => 'ProductController', 'action' => 'productDetails', 'params' => ['id' => $product->id]]); - $detail->hideInAllMenus(); - $category->addChild($detail); - $count++; - } - - if ($count) { - $menu->addChild($category); - } - } - } - } diff --git a/app/Templates/News.php b/app/Templates/News.php index edba0d8..faace56 100644 --- a/app/Templates/News.php +++ b/app/Templates/News.php @@ -21,6 +21,8 @@ class News extends Base $news = NewsModel::whereVariant()->get(); + $i = 0; + foreach ($news as $newsItem) { // Don't include offline items @@ -28,18 +30,30 @@ class News extends Base continue; } - // Todo: see if we should handle events differently? Should events have a different ID + URL and maybe a different controller action in case we need a different layout? + // exclude events + if ($newsItem->getPageData()->get('type') == 'event') { + continue; + } + $item = new PageItem(); $item->initFromEntity($newsItem); $item->setLocale($menu->getLocale()); $item->setVariant($menu->getVariant()); $item->setTitle($newsItem->title); - $item->setHref($newsItem->slug); // Todo: consider having a configurable / translatable prefix for news URLs + $item->setHref($newsItem->slug); $item->setId('news/' . $newsItem->id); $item->setController(['controller' => 'NewsController', 'action' => 'view', 'params' => ['id' => $newsItem->id]]); - $item->hideInAllMenus(); + + // Only show 10 latest news in the menus + if ($i <= 9) { + $item->showInAllMenus(); + } else { + $item->hideInAllMenus(); + } $menu->addChild($item); + + $i++; } Debugbar::stopMeasure('nav_news'); diff --git a/app/Templates/Solution.php b/app/Templates/Solution.php index 5332eb5..4a483e6 100644 --- a/app/Templates/Solution.php +++ b/app/Templates/Solution.php @@ -53,7 +53,7 @@ class Solution extends Base $item->setHref($application->getSlugOrTitleAttribute()); $item->setId('application/' . $application->id); $item->setController(['controller' => 'ApplicationController', 'action' => 'view', 'params' => ['id' => $application->id]]); - $item->hideInAllMenus(); + $item->showInAllMenus(); $menu->addChild($item); } diff --git a/resources/styles/components/navigation.styl b/resources/styles/components/navigation.styl index 84e1827..13c2b4f 100644 --- a/resources/styles/components/navigation.styl +++ b/resources/styles/components/navigation.styl @@ -25,7 +25,7 @@ &:hover > ul // First level submenus - display: flex // Set to flex so we can have 2 menus side-by-side in submenu + display: block // Set to flex so we can have 2 menus side-by-side in submenu animation: submenu-fade-in 0.3s // Top level links @@ -46,46 +46,37 @@ margin-top: 1rem // Extra margin to replace top: 100% (see IE11 notes above) padding: 1em 0 -// Submenu items -.nav-submenu-wrapper ul - @apply bg-white // For IE 11 - - li - &:hover, &.active - a - @apply text-primary - transform: translateX(0) - - &:before - transform: scaleX(1) - - // Submenu links - a - @apply text-navy flex items-center w-full py-2 - white-space: nowrap - padding-right: 1.5em // Give space to translate into - padding-left: @padding-right - transform: translateX(-2em) - - // Animated dash before link - &:before - content: '' - display: block - width: 1.5em - height: 2px - margin-right: 0.5em - background: currentColor - transform: scaleX(0) - transform-origin: right - - // Set transition for links - same for both elements - a, a:before - transition: transform 0.2s ease-out - -.nav-submenu-title - @apply bg-grey-100 text-lg text-navy px-6 py-5 -mt-4 mb-2 - min-width: 285px // Make sure both columns are a bit closer in width - + li + &:hover, &.active + a + @apply text-primary + transform: translateX(0) + + &:before + transform: scaleX(1) + + // Submenu links + a + @apply text-navy flex items-center w-full py-2 + white-space: nowrap + padding-right: 1.5em // Give space to translate into + padding-left: @padding-right + transform: translateX(-2em) + + // Animated dash before link + &:before + content: '' + display: block + width: 1.5em + height: 2px + margin-right: 0.5em + background: currentColor + transform: scaleX(0) + transform-origin: right + + // Set transition for links - same for both elements + a, a:before + transition: transform 0.2s ease-out #mobile-nav +below($breakpoint-menu) diff --git a/resources/views/partials/nav.blade.php b/resources/views/partials/nav.blade.php index ce59a2a..87b9f2d 100644 --- a/resources/views/partials/nav.blade.php +++ b/resources/views/partials/nav.blade.php @@ -1,2 +1,2 @@ -{!! CubistMenu::get('#main','pmi')->asUl(['class' => 'nav-primary']) !!} +{!! CubistMenu::get('#main')->asUl(['class' => 'nav-primary']) !!}