added linked materials in modalCard

This commit is contained in:
Bachir Soussi Chiadmi 2021-01-20 12:09:22 +01:00
parent a3dd424289
commit 37f199416f
14 changed files with 382 additions and 46 deletions

View File

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

View File

@ -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

View File

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

View File

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

View File

@ -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', $registry->addFieldResolver('Image', 'style_cardmedium',
$builder->produce('image_derivative') $builder->produce('image_derivative')
->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())

View File

@ -1839,7 +1839,43 @@ article.card {
width: 423px; width: 423px;
height: 295px; } height: 295px; }
article.card.minicard { 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 { article.card header {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
@ -1860,7 +1896,8 @@ article.card {
article.card header h4 { article.card header h4 {
font-size: 0.882em; font-size: 0.882em;
font-weight: 300; font-weight: 300;
line-height: 1; } line-height: 1.1;
margin-bottom: -0.2em; }
article.card header span.ref { article.card header span.ref {
font-size: 0.693em; font-size: 0.693em;
font-weight: 300; font-weight: 300;
@ -1952,24 +1989,22 @@ article.card {
flex-basis: 50%; } flex-basis: 50%; }
article.card.modal-card section.col-right > *:not(nav.tools) { article.card.modal-card section.col-right > *:not(nav.tools) {
position: relative; position: relative;
padding: 0.5em; padding: 0.5em 0.5em 0;
box-sizing: border-box; box-sizing: border-box;
width: 100%; } width: 100%; }
article.card.modal-card section.col-right header { article.card.modal-card section.col-right > header {
bottom: auto; } 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 { article.card.modal-card section.col-right section.body p {
font-size: 0.882em; font-size: 0.882em;
font-weight: 300; 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 { article.card.modal-card section.col-right nav.tools {
opacity: 1; } opacity: 1; }
article.card.modal-card section.col-right nav.tools section.close span.btn.mdi-close { article.card.modal-card section.col-right nav.tools section.close span.btn.mdi-close {

File diff suppressed because one or more lines are too long

View File

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

View File

@ -947,6 +947,53 @@ article.card{
} }
&.minicard{ &.minicard{
height:100px; 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{ // &.card-small{
// width:100px; height:140px; // width:100px; height:140px;
@ -976,8 +1023,8 @@ article.card{
h4{ h4{
font-size: 0.882em; font-size: 0.882em;
font-weight: 300; font-weight: 300;
line-height: 1; line-height: 1.1;
// margin-bottom: 0.1em; margin-bottom: -0.2em;
} }
span.ref{ span.ref{
font-size: 0.693em; font-size: 0.693em;
@ -1101,34 +1148,43 @@ article.card{
section.col-right{ section.col-right{
>*:not(nav.tools){ >*:not(nav.tools){
position: relative; position: relative;
padding: 0.5em; padding: 0.5em 0.5em 0;
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
} }
header{ >header{
bottom: auto; bottom: auto;
} }
section.samples{ // section.samples{
ul{ // ul{
display: flex; // display: flex;
flex-flow: row wrap; // flex-flow: row wrap;
font-size: 0.882em; // font-size: 0.882em;
font-weight: 300; // font-weight: 300;
// line-height: 1.35; // // line-height: 1.35;
li{ // li{
padding-right: 0.5em; // padding-right: 0.5em;
span.showroom{ font-weight: 500; } // span.showroom{ font-weight: 500; }
} // }
} // }
} // }
section.body{ section.body{
p{ p{
font-size: 0.882em; font-size: 0.882em;
font-weight: 300; font-weight: 300;
line-height: 1.35; 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{ nav.tools{
opacity: 1; opacity: 1;
section.close{ section.close{

View File

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

View File

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

View File

@ -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>

View File

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

View File

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