]> _ Git - pmi.git/commitdiff
wip #3520
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 30 Mar 2020 13:06:05 +0000 (15:06 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 30 Mar 2020 13:06:05 +0000 (15:06 +0200)
app/Http/Kernel.php
app/Http/Middleware/Menu.php [deleted file]
app/PageTemplates.php [deleted file]
app/Templates/Category.php
app/Templates/CategoryGroup.php
app/Templates/News.php
app/Templates/Solution.php
resources/styles/components/navigation.styl
resources/views/partials/nav.blade.php

index 82221796affa94ddbb39f3c2682496c84e402ae2..55cc452f3ae553b6046d512bccf0399ec4c414a5 100644 (file)
@@ -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 (file)
index 11338ac..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-
-namespace App\Http\Middleware;
-
-
-use Cubist\Backpack\app\Magic\Menu\Facade as CubistMenu;
-use Illuminate\Http\Request;
-use \Closure;
-
-class Menu
-{
-    public function handle(Request $request, Closure $next)
-    {
-        CubistMenu::registerMenuMaker('pmi', [$this, 'makePMIMenu']);
-        return $next($request);
-    }
-
-    public function makePMIMenu($menu, $item)
-    {
-        foreach ($item->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 (file)
index 18e96c0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-namespace App;
-
-trait PageTemplates
-{
-    /*
-    |--------------------------------------------------------------------------
-    | Page Templates for Backpack\PageManager
-    |--------------------------------------------------------------------------
-    |
-    | Each page template has its own method, that define what fields should show up using the Backpack\CRUD API.
-    | Use snake_case for naming and PageManager will make sure it looks pretty in the create/update form
-    | template dropdown.
-    |
-    | Any fields defined here will show up after the standard page fields:
-    | - select template
-    | - page name (only seen by admins)
-    | - page title
-    | - page slug
-    */
-
-
-}
index dd5ffa33c36477bbf640c1ab4ab2372c0defcc32..c8d697058916bb91d0265bc4766c45cbfb74a287 100644 (file)
@@ -16,6 +16,15 @@ class Category extends Base
     {
         parent::init();
 
+        $this->addField([
+            'name' => 'intro',
+            'type' => 'BunchOfFields',
+            'bunch' => 'App\SubForms\Intro',
+            'label' => 'Introduction',
+            'tab' => 'Introduction',
+            'translatable' => true,
+        ]);
+
         $this->addField(['name' => 'category',
             'type' => 'SelectFromModel',
             'optionsmodel' => ProductType::class,
index ff56872a74403766d0ac4f0c04281c6d1e0332fe..daa8e47357c93f97a63c2d2a9fc316a15bddb39d 100644 (file)
@@ -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);
-            }
-        }
-    }
-
 }
index edba0d8626e1b5b1651c8b406f6a451cf2030c8b..faace5618ffc739390a14f58509a3b1a4f376a44 100644 (file)
@@ -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');
index 5332eb5271c82c4d36e3efa53e6bd74953625475..4a483e6a220fb6235e9541babcbd2d0b90b24d5f 100644 (file)
@@ -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);
         }
 
index 84e1827a2d7501bb1965d54db29ef6b94eaaa0ac..13c2b4fc927e61b5007e412290cfb60a6d45f846 100644 (file)
@@ -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
     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)
index ce59a2a64d814899d26fb3a1355c8720b9b3118b..87b9f2d36604486b8f0f46382906bda94458d29c 100644 (file)
@@ -1,2 +1,2 @@
-{!! CubistMenu::get('#main','pmi')->asUl(['class' => 'nav-primary']) !!}
+{!! CubistMenu::get('#main')->asUl(['class' => 'nav-primary']) !!}