Browse Source

added samples to search result card

bach 3 years ago
parent
commit
1ca9937fd4

+ 1 - 0
web/modules/custom/materio_graphql/graphql/materio_extension.base.graphqls

@@ -70,6 +70,7 @@ type SearchResult {
   images: [Image]
   visuels: [Image]
   reference: String
+  samples: [Sample]
 }
 
 type Product {

+ 6 - 0
web/modules/custom/materio_graphql/src/Plugin/GraphQL/SchemaExtension/MaterioSchemaExtension.php

@@ -342,6 +342,12 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
         ->map('path', $builder->fromValue('field_reference.value'))
       );
 
+    $registry->addFieldResolver('SearchResult', 'samples',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:node'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_samples'))
+      );
   }
 
   //  ___                  _

File diff suppressed because it is too large
+ 0 - 0
web/themes/custom/materiotheme/assets/dist/main.js


+ 7 - 0
web/themes/custom/materiotheme/vuejs/api/gql/searchresults.fragment.gql

@@ -16,5 +16,12 @@ fragment SearchResultFields on SearchResult {
     alt
     style_cardmedium_url
     style_hd_url
+  }
+	samples{
+    showroom{
+      name
+      id
+    }
+    location
   }
 }

+ 14 - 0
web/themes/custom/materiotheme/vuejs/components/Content/Card.vue

@@ -27,6 +27,20 @@
           </ul>
         </div>
       </section>
+      <section class="tool samples" v-if="item.samples && item.samples.length">
+        <span class="btn mdi mdi-beaker-outline"/>
+        <div class="tool-content">
+          <span class="label">{{ $t("materio.Samples") }}</span>
+          <ul>
+            <li
+              v-for="sample in item.samples"
+              :key="sample.showroom.id"
+            >
+              <span class="showroom">{{ sample.showroom.name }}</span>: {{ sample.location }}
+            </li>
+          </ul>
+        </div>
+      </section>
     </nav>
     <section class="images" v-switcher>
       <figure

+ 1 - 1
web/themes/custom/materiotheme/vuejs/components/Content/ModalCard.vue

@@ -36,7 +36,7 @@
             </ul>
           </div>
         </section>
-        <section class="tool samples">
+        <section class="tool samples" v-if="item.samples && item.samples.length">
           <span class="btn mdi mdi-beaker-outline"/>
           <div class="tool-content">
             <span class="label">{{ $t("materio.Samples") }}</span>

Some files were not shown because too many files changed in this diff