Browse Source

added linked materials in modalCard

bach 1 month ago
parent
commit
37f199416f

+ 1 - 1
config/sync/autologout.settings.yml

@@ -2,7 +2,7 @@ timeout: 3600
 max_timeout: 172800
 padding: 360
 role_logout: true
-redirect_url: /node/1
+redirect_url: /
 no_dialog: true
 message: 'Your session is about to expire. Do you want to reset it?'
 inactivity_message: ''

+ 15 - 0
config/sync/image.style.linkedmaterial_card.yml

@@ -0,0 +1,15 @@
+uuid: 759fea88-864c-4370-ad7b-b50d2ad09d31
+langcode: en
+status: true
+dependencies: {  }
+name: linkedmaterial_card
+label: 'linkedmaterial-card (200x110)'
+effects:
+  34e936a0-1fee-4327-9553-b4f48bde14e6:
+    uuid: 34e936a0-1fee-4327-9553-b4f48bde14e6
+    id: image_scale_and_crop
+    weight: 1
+    data:
+      width: 200
+      height: 110
+      anchor: center-center

+ 1 - 1
config/sync/search_api.index.database.yml

@@ -157,7 +157,7 @@ field_settings:
     label: Title
     datasource_id: 'entity:node'
     property_path: title
-    type: 'solr_text_custom:ngramstring'
+    type: text
     boost: !!float 21
     dependencies:
       module:

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

@@ -198,6 +198,8 @@ type Image {
   alt: String
   style_minicard: ImageStyle
   style_minicard_url: String
+  style_linkedmaterialcard: ImageStyle
+  style_linkedmaterialcard_url: String
   style_cardmedium: ImageStyle
   style_cardmedium_url: String
   style_cardfull: ImageStyle

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

@@ -626,6 +626,22 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
           })
       ));
 
+    $registry->addFieldResolver('Image', 'style_linkedmaterialcard',
+      $builder->produce('image_derivative')
+        ->map('entity', $builder->fromParent())
+        ->map('style', $builder->fromValue('linkedmaterial_card'))
+      );
+
+    $registry->addFieldResolver('Image', 'style_linkedmaterialcard_url',
+      $builder->compose(
+        $builder->produce('image_derivative')
+          ->map('entity', $builder->fromParent())
+          ->map('style', $builder->fromValue('linkedmaterial_card')),
+        $builder->callback(function($parent, $args){
+            return $parent['url'];
+          })
+      ));
+
     $registry->addFieldResolver('Image', 'style_cardmedium',
       $builder->produce('image_derivative')
         ->map('entity', $builder->fromParent())

+ 49 - 14
web/themes/custom/materiotheme/assets/dist/main.css

@@ -1839,7 +1839,43 @@ article.card {
     width: 423px;
     height: 295px; }
   article.card.minicard {
-    height: 100px; }
+    height: 100px;
+    width: 170px;
+    height: 100px;
+    margin: auto; }
+    article.card.minicard > header {
+      padding: 0.3em 0.3em 0.1em; }
+      article.card.minicard > header h1 {
+        margin: 0; }
+    article.card.minicard > nav.tools {
+      top: auto;
+      bottom: 0;
+      padding: 0 0.2em;
+      background: transparent; }
+      article.card.minicard > nav.tools .mdi.unflag {
+        cursor: pointer; }
+  article.card.linkedmaterialcard {
+    width: 200px;
+    height: 110px; }
+    article.card.linkedmaterialcard > header {
+      padding: 0.3em 0.3em 0.1em;
+      cursor: pointer; }
+      article.card.linkedmaterialcard > header h1 {
+        margin: 0;
+        font-size: 1em; }
+      article.card.linkedmaterialcard > header h4 {
+        margin: 0;
+        line-height: 1.1;
+        margin-bottom: -0.4em; }
+      article.card.linkedmaterialcard > header span.ref {
+        line-height: 0.5; }
+    article.card.linkedmaterialcard > nav.tools {
+      top: auto;
+      bottom: 0;
+      padding: 0 0.2em;
+      background: transparent; }
+      article.card.linkedmaterialcard > nav.tools .mdi.unflag {
+        cursor: pointer; }
   article.card header {
     position: absolute;
     bottom: 0;
@@ -1860,7 +1896,8 @@ article.card {
     article.card header h4 {
       font-size: 0.882em;
       font-weight: 300;
-      line-height: 1; }
+      line-height: 1.1;
+      margin-bottom: -0.2em; }
     article.card header span.ref {
       font-size: 0.693em;
       font-weight: 300;
@@ -1952,24 +1989,22 @@ article.card {
       flex-basis: 50%; }
     article.card.modal-card section.col-right > *:not(nav.tools) {
       position: relative;
-      padding: 0.5em;
+      padding: 0.5em 0.5em 0;
       box-sizing: border-box;
       width: 100%; }
-    article.card.modal-card section.col-right header {
+    article.card.modal-card section.col-right > header {
       bottom: auto; }
-    article.card.modal-card section.col-right section.samples ul {
-      display: flex;
-      flex-flow: row wrap;
-      font-size: 0.882em;
-      font-weight: 300; }
-      article.card.modal-card section.col-right section.samples ul li {
-        padding-right: 0.5em; }
-        article.card.modal-card section.col-right section.samples ul li span.showroom {
-          font-weight: 500; }
     article.card.modal-card section.col-right section.body p {
       font-size: 0.882em;
       font-weight: 300;
-      line-height: 1.35; }
+      line-height: 1.35;
+      margin: 0 0 0.5em; }
+    article.card.modal-card section.col-right section.linked-materials {
+      display: flex;
+      flex-flow: row;
+      justify-content: space-between; }
+      article.card.modal-card section.col-right section.linked-materials > article.linkedmaterialcard {
+        flex-basis: 0 0 50%; }
     article.card.modal-card section.col-right nav.tools {
       opacity: 1; }
       article.card.modal-card section.col-right nav.tools section.close span.btn.mdi-close {

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


+ 3 - 0
web/themes/custom/materiotheme/assets/styles/base/_variables.scss

@@ -13,5 +13,8 @@ $card_height: 295px;
 $minicard_width: 170px;
 $minicard_height: 100px;
 
+$linkedmaterialcard_width: 200px;
+$linkedmaterialcard_height: 110px;
+
 $modalcard_width: 850px;
 $modalcard_height: 610px;

+ 73 - 17
web/themes/custom/materiotheme/assets/styles/main.scss

@@ -947,6 +947,53 @@ article.card{
   }
   &.minicard{
     height:100px;
+    width:$minicard_width;
+    height:$minicard_height;
+    margin:auto;
+    >header{
+      padding: 0.3em 0.3em 0.1em;
+      h1{
+        margin:0;
+      }
+    }
+    >nav.tools{
+      top: auto;
+      bottom: 0;
+      padding:0 0.2em;
+      background:transparent;
+      .mdi.unflag{
+        cursor: pointer;
+      }
+    }
+  }
+  &.linkedmaterialcard{
+    width:$linkedmaterialcard_width;
+    height:$linkedmaterialcard_height;
+    >header{
+      padding: 0.3em 0.3em 0.1em;
+      cursor: pointer;
+      h1{
+        margin:0;
+        font-size: 1em;
+      }
+      h4{
+        margin:0;
+        line-height: 1.1;
+        margin-bottom: -0.4em;
+      }
+      span.ref{
+        line-height: 0.5;
+      }
+    }
+    >nav.tools{
+      top: auto;
+      bottom: 0;
+      padding:0 0.2em;
+      background:transparent;
+      .mdi.unflag{
+        cursor: pointer;
+      }
+    }
   }
   // &.card-small{
   //   width:100px; height:140px;
@@ -976,8 +1023,8 @@ article.card{
     h4{
       font-size: 0.882em;
       font-weight: 300;
-      line-height: 1;
-      // margin-bottom: 0.1em;
+      line-height: 1.1;
+      margin-bottom: -0.2em;
     }
     span.ref{
       font-size: 0.693em;
@@ -1101,34 +1148,43 @@ article.card{
     section.col-right{
       >*:not(nav.tools){
         position: relative;
-        padding: 0.5em;
+        padding: 0.5em 0.5em 0;
         box-sizing: border-box;
         width: 100%;
       }
-      header{
+      >header{
         bottom: auto;
       }
-      section.samples{
-        ul{
-          display: flex;
-          flex-flow: row wrap;
-          font-size: 0.882em;
-          font-weight: 300;
-          // line-height: 1.35;
-          li{
-            padding-right: 0.5em;
-            span.showroom{ font-weight: 500; }
-          }
-        }
-      }
+      // section.samples{
+      //   ul{
+      //     display: flex;
+      //     flex-flow: row wrap;
+      //     font-size: 0.882em;
+      //     font-weight: 300;
+      //     // line-height: 1.35;
+      //     li{
+      //       padding-right: 0.5em;
+      //       span.showroom{ font-weight: 500; }
+      //     }
+      //   }
+      // }
       section.body{
         p{
           font-size: 0.882em;
           font-weight: 300;
           line-height: 1.35;
+          margin:0 0 0.5em;
         }
 
       }
+      section.linked-materials{
+        display: flex;
+        flex-flow: row;
+        justify-content: space-between;
+        >article.linkedmaterialcard{
+          flex-basis: 0 0 50%;
+        }
+      }
       nav.tools{
         opacity: 1;
         section.close{

+ 37 - 3
web/themes/custom/materiotheme/vuejs/api/gql/materiaumodal.fragment.gql

@@ -1,9 +1,30 @@
 fragment MateriauFields on Materiau {
   title
-  short_description
-  body
+	short_description
   reference
-  samples{
+  attachments{
+    file{
+      filename
+      fid
+      filesize
+      url
+    }
+    description
+  }
+  distributor{
+    id
+    name
+    email
+    description
+  }
+  manufacturer{
+    id
+    name
+    email
+    description
+  }
+  body
+	samples{
     showroom{
       name
       id
@@ -17,4 +38,17 @@ fragment MateriauFields on Materiau {
       url
     }
   }
+  linked_materials{
+    id
+    short_description
+    title
+    reference
+    images{
+      url
+      alt
+      style_linkedmaterialcard{
+        url
+      }
+    }
+  }
 }

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

@@ -43,7 +43,7 @@
           class="blank"
           :src="blanksrc"
           @click.prevent="openModalCard"
-        >
+        />
       </figure>
     </section>
     <!-- <CoolLightBox

+ 82 - 0
web/themes/custom/materiotheme/vuejs/components/Content/LinkedMaterialCard.vue

@@ -0,0 +1,82 @@
+<template>
+  <article class="card linkedmaterialcard">
+    <header
+      @click.prevent="openModalCard"
+    >
+      <h1>{{ item.title }}</h1>
+      <h4>{{ item.short_description }}</h4>
+      <span v-if="isloggedin" class="ref">{{ item.reference }}</span>
+    </header>
+    <nav class="tools">
+
+    </nav>
+    <section class="images" v-switcher>
+      <figure
+        v-for="(img, index) in item.images"
+        :key="img.url"
+      >
+        <img
+          class="lazy"
+          v-lazy="index"
+          :data-src="img.style_linkedmaterialcard.url"
+          :title="img.title"
+        />
+        <img
+          class="blank"
+          :src="blanksrc"
+          @click.prevent="openModalCard"
+        />
+      </figure>
+    </section>
+  </article>
+</template>
+
+<script>
+import { mapState, mapActions } from 'vuex'
+import cardMixins from 'vuejs/components/cardMixins'
+import ModalCard from 'vuejs/components/Content/ModalCard'
+
+export default {
+  name: "LinkedMaterialCard",
+  props: ['item'],
+  mixins: [cardMixins],
+  // components: {
+  //   ModalCard
+  // },
+  data() {
+    return {
+      blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
+      loadingItem: false
+    }
+  },
+  computed: {
+    ...mapState({
+      isloggedin: state => state.User.isloggedin
+    })
+  },
+  methods: {
+    itemIsLoading(id) {
+      return this.loadingItem
+    },
+    openModalCard (e) {
+      console.log('openModalCard', this.isLoggedin);
+      if(this.isloggedin){
+        this.$modal.show(
+          ModalCard,
+          { item: this.item },
+          {
+            draggable: true,
+            width: '850px',
+            height: '610px'
+          }
+        )
+      }
+    }
+  }
+}
+
+</script>
+
+<style lang="scss" scoped>
+
+</style>

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

@@ -2,7 +2,7 @@
   <article class="card minicard">
     <header>
       <h1>{{ item.title }}</h1>
-      <span class="ref">{{ item.field_reference }}</span>
+      <span class="ref">{{ item.reference }}</span>
     </header>
     <nav class="tools">
       <section class="tool flags">

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

@@ -36,7 +36,7 @@
           </div>
         </section>
       </nav>
-      <section class="samples">
+      <!-- <section class="samples">
         <h3>{{ $t("materio.Samples") }}</h3>
         <ul>
           <li
@@ -46,8 +46,11 @@
             <span class="showroom">{{ sample.showroom.name }}</span>: {{ sample.location }}
           </li>
         </ul>
-      </section>
+      </section> -->
       <section class="body" v-html="material.body"/>
+      <section class="linked-materials">
+        <LinkedMaterialCard v-for="m in material.linked_materials" v-bind:key="m.id" :item="m"/>
+      </section>
     </section>
     <section class="col col-left images" v-switcher>
       <figure
@@ -79,6 +82,9 @@
 
 <script>
 import { mapState, mapActions } from 'vuex'
+
+import LinkedMaterialCard from 'vuejs/components/Content/LinkedMaterialCard'
+
 import cardMixins from 'vuejs/components/cardMixins'
 
 import { MGQ } from 'vuejs/api/graphql-axios'
@@ -90,6 +96,9 @@ export default {
   name: "ModalCard",
   props: ['item'],
   mixins: [cardMixins],
+  components: {
+    LinkedMaterialCard
+  },
   data() {
     return {
       material: null,
@@ -126,7 +135,7 @@ export default {
       MGQ.post('', { query: print(ast)
       })
         .then(({ data:{data:{materiau}}}) => {
-          console.log('loadMaterial', materiau )
+          console.log('loadMaterial material loaded', materiau )
           this.material = materiau
           this.loading = false
           // delay the lazyload to let the card the time to update dom