]> _ Git - pmi.git/commitdiff
Done #2980 @0.5
authorStephen Cameron <stephen@cubedesigners.com>
Wed, 28 Aug 2019 12:06:29 +0000 (14:06 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Wed, 28 Aug 2019 12:06:29 +0000 (14:06 +0200)
app/Models/Product.php
resources/js/components/CartItem.vue
resources/views/pages/cart.blade.php
resources/views/partials/product-link.blade.php

index 9827f37a6d50c3bae4f5a9d82ddb8450fab3c65d..d73ebce5a7e8d6fde76c49fea578c7b140a9ee8f 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use Cubist\Backpack\app\Magic\Menu\Menu;
 use Cubist\Backpack\app\Magic\Models\CubistMagicPageModel;
 use Cubist\Util\Json;
 use Illuminate\Support\Facades\App;
@@ -305,6 +306,15 @@ class Product extends CubistMagicPageModel
     }
 
 
+    /**
+     * Custom accessor to return URL to product detail
+     * page by accessing $product->URL...
+     */
+    public function getURLAttribute()
+    {
+        return Menu::getNavigation()->getHrefById("product/{$this->id}");
+    }
+
     /**
      * Custom accessor to return fallback image
      * by accessing $product->image_fallback...
@@ -352,6 +362,7 @@ class Product extends CubistMagicPageModel
                 'category' => $product->type->name,
                 'quantity' => $cart_items[$product->id],
                 'image' => $product->image,
+                'URL' => $product->url,
             ];
         }
 
index ed3ec7c2cdd56381346bdb7d2607448859114b6f..9380099d184f0da0f55170d0ffee45d10e7171e5 100644 (file)
@@ -1,14 +1,15 @@
 <template>
     <div class="cart-item flex mb-1v">
-        <div class="border-gray-100 border-2 bg-center bg-contain bg-no-repeat flex-shrink-0"
-             :style="`background-image: url(${item.image}); width: 144px; height: 144px`">
-        </div>
+        <a class="block border-gray-100 border-2 bg-center bg-contain bg-no-repeat flex-shrink-0"
+           :href="item.URL"
+           :style="`background-image: url(${item.image}); width: 144px; height: 144px`">
+        </a>
         <div class="pl-6 leading-relaxed flex-grow">
-            <div class="font-bold">
+            <a :href="item.URL" class="block text-navy font-display">
                 {{ item.category }}
                 <br>
                 {{ item.name }}
-            </div>
+            </a>
             <div class="cart-quantity bg-grey-100 py-1 pl-3 my-2 flex items-center justify-between">
                 <span class="mr-2">Quantité</span>
                 <number-input :value="item.quantity" :min="1" inline center controls @change="updateQuantity"></number-input>
index 91cec1903f73d94f28e9fcd58b345d64a8e20b4c..b4b42ac467df1fce89fde37014af2adf58e85e6e 100644 (file)
@@ -5,24 +5,32 @@
     <content class="pb-3v">
         <text-block :title="$page->page_heading" />
 
-        {{-- Columns set to auto because cart will disappear when quote form is sent, leaving just the confirmation message. --}}
-        <grid cols="auto">
+        <div v-if="cartItemCount > 0">
 
-            {{-- Nested divs to allow grey backgrounds of columns to match the height of their content instead of total height --}}
-            <div v-if="cartItemCount > 0">
-                <cart :items='items' class="cart-page bg-grey-100 p-1v pb-0 overflow-hidden"></cart>
-            </div>
+            {{-- Columns set to auto because cart will disappear when quote form is sent, leaving just the confirmation message. --}}
+            <grid cols="auto">
 
-            <div>
-                <div class="bg-grey-100 p-1v">
-                    @form([
+                {{-- Nested divs to allow grey backgrounds of columns to match the height of their content instead of total height --}}
+                <div>
+                    <cart :items='items' class="cart-page bg-grey-100 p-1v pb-0 overflow-hidden"></cart>
+                </div>
+
+                <div>
+                    <div class="bg-grey-100 p-1v">
+                        @form([
                         'action' => '/ajax/request_quote',
                         'extra_fields' => '<input type="hidden" name="cart_data" :value="cartData">' // Populated by VueJS
-                    ])
+                        ])
+                    </div>
                 </div>
-            </div>
 
-        </grid>
+            </grid>
+
+        </div>
+
+        <div v-if="cartItemCount == 0" class="p-1v text-center bg-grey-100 text-lg">
+            {{ __("Vous n'avez encore rien sélectionné") }}
+        </div>
 
     </content>
 
index a9fbfd0a38a1f36fd00a8e79f62e52d9f1eb63c1..1a5692754f436cf40bade573573b14b3cdb58c1c 100644 (file)
@@ -1,9 +1,6 @@
-@php
-    $product_URL = $nav->getHrefById("product/{$product->id}");
-@endphp
 <div data-product-id="{{$id}}" class="product-grid-item bg-grey-200">
     {{-- Image holder --}}
-    <a href="{{ $product_URL }}">
+    <a href="{{ $product->URL }}">
         <div class="product-img-holder">
             <div class="product-img"
                  style="background-image: url({{ $product->getEntity()->image }})"></div>
 
     {{-- Product details --}}
     <div class="p-4">
-        <h3><a class="text-navy" href="{{ $product_URL }}">{{ $product->get('reference') }}</a>
+        <h3><a class="text-navy" href="{{ $product->URL }}">{{ $product->get('reference') }}</a>
         </h3>
         <div class="product-highlights text-sm">
             {{$product->get('name')}}
         </div>
         <p class="mt-4">
-            <a href="{{ $product_URL }}">
+            <a href="{{ $product->URL }}">
                 {{ __('Voir la fiche produit') }}
             </a>
         </p>