2019-06-03 13:06:44 +02:00
|
|
|
<template>
|
2020-11-27 23:02:59 +01:00
|
|
|
<article class="card search-card">
|
2020-12-01 23:02:35 +01:00
|
|
|
<header
|
2021-01-19 16:56:53 +01:00
|
|
|
@click.prevent="openModalCard"
|
2020-12-01 23:02:35 +01:00
|
|
|
>
|
2020-12-25 11:33:39 +01:00
|
|
|
<h1 v-if="isloggedin">{{ item.title }}</h1>
|
2020-12-23 18:05:25 +01:00
|
|
|
<h4>{{ item.short_description }}</h4>
|
2020-12-25 11:33:39 +01:00
|
|
|
<span v-if="isloggedin" class="ref">{{ item.reference }}</span>
|
2019-06-10 18:30:48 +02:00
|
|
|
</header>
|
2020-12-25 11:33:39 +01:00
|
|
|
<nav class="tools" v-if="isloggedin">
|
2020-11-24 14:07:10 +01:00
|
|
|
<section class="tool flags">
|
|
|
|
<span class="btn mdi mdi-folder-outline"/>
|
|
|
|
<div class="tool-content">
|
|
|
|
<ul>
|
|
|
|
<li v-if="flagcolls" v-for="coll in flagcolls" :key="coll.id">
|
|
|
|
<span
|
|
|
|
class="flag mdi"
|
|
|
|
:class="[
|
2020-12-01 20:40:37 +01:00
|
|
|
flagIsLoading(coll.id) ? 'mdi-loading mdi-spin' : flagIsActive(coll.id) ? 'mdi-close-circle isActive' : 'mdi-plus'
|
2020-11-24 14:07:10 +01:00
|
|
|
]"
|
|
|
|
:collid="coll.id"
|
|
|
|
@click.prevent="onFlagActionCard"
|
|
|
|
>
|
2020-12-25 11:33:39 +01:00
|
|
|
{{ coll.name }}
|
2020-11-24 14:07:10 +01:00
|
|
|
</span>
|
|
|
|
</li>
|
2021-03-08 22:04:50 +01:00
|
|
|
<li v-if="collsLength<15" class="create-flag">
|
|
|
|
<input
|
|
|
|
placeholder="new folder"
|
|
|
|
v-model="new_folder_name"
|
|
|
|
@keyup.enter.prevent.stop="onCreateFlagColl"
|
|
|
|
/>
|
|
|
|
<span
|
|
|
|
class="add-btn mdi"
|
|
|
|
:class="addFlagBtnClassObj"
|
|
|
|
@click.prevent.stop="onCreateFlagColl"
|
|
|
|
/>
|
|
|
|
</li>
|
2020-11-24 14:07:10 +01:00
|
|
|
</ul>
|
2021-01-25 17:39:44 +01:00
|
|
|
</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>
|
2020-11-24 14:07:10 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
2021-03-10 11:54:08 +01:00
|
|
|
<section v-if="item.note" class="tool note">
|
|
|
|
<span class="btn mdi mdi-note"/>
|
|
|
|
</section>
|
2021-01-25 22:19:21 +01:00
|
|
|
<section class="tool print">
|
|
|
|
<a :href="item.path+'/printable/print'" target="_blank">
|
|
|
|
<span class="btn mdi mdi-printer"/>
|
|
|
|
</a>
|
|
|
|
</section>
|
2020-11-24 14:07:10 +01:00
|
|
|
</nav>
|
2019-06-11 18:04:46 +02:00
|
|
|
<section class="images" v-switcher>
|
|
|
|
<figure
|
|
|
|
v-for="(img, index) in item.images"
|
|
|
|
:key="img.url"
|
|
|
|
>
|
|
|
|
<img
|
|
|
|
class="lazy"
|
|
|
|
v-lazy="index"
|
2020-12-25 11:33:39 +01:00
|
|
|
:data-src="img.style_cardmedium_url"
|
2019-06-11 18:04:46 +02:00
|
|
|
:title="img.title"
|
|
|
|
/>
|
2020-12-01 23:02:35 +01:00
|
|
|
<img
|
|
|
|
class="blank"
|
|
|
|
:src="blanksrc"
|
2021-01-19 16:56:53 +01:00
|
|
|
@click.prevent="openModalCard"
|
2021-01-20 12:09:22 +01:00
|
|
|
/>
|
2019-06-11 18:04:46 +02:00
|
|
|
</figure>
|
2019-06-10 18:30:48 +02:00
|
|
|
</section>
|
2021-01-19 16:56:53 +01:00
|
|
|
<!-- <CoolLightBox
|
2020-12-25 11:33:39 +01:00
|
|
|
v-if="isloggedin"
|
2020-12-01 23:02:35 +01:00
|
|
|
:items="item.images"
|
|
|
|
:index="lightbox_index"
|
2020-12-25 11:33:39 +01:00
|
|
|
srcName="style_hd_url"
|
2020-12-07 23:11:31 +01:00
|
|
|
:loop="true"
|
2020-12-01 23:02:35 +01:00
|
|
|
@close="lightbox_index = null">
|
2021-01-19 16:56:53 +01:00
|
|
|
</CoolLightBox> -->
|
2019-06-17 16:50:16 +02:00
|
|
|
</article>
|
2019-06-03 13:06:44 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-11-24 14:07:10 +01:00
|
|
|
import { mapState, mapActions } from 'vuex'
|
2020-11-27 23:02:59 +01:00
|
|
|
import cardMixins from 'vuejs/components/cardMixins'
|
2020-12-01 23:02:35 +01:00
|
|
|
import ModalCard from 'vuejs/components/Content/ModalCard'
|
2019-06-03 13:06:44 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Card",
|
|
|
|
props: ['item'],
|
2020-11-27 23:02:59 +01:00
|
|
|
mixins: [cardMixins],
|
2020-12-01 23:02:35 +01:00
|
|
|
components: {
|
|
|
|
ModalCard
|
|
|
|
},
|
2019-06-11 18:04:46 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2020-11-24 14:07:10 +01:00
|
|
|
blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
|
2021-03-08 22:04:50 +01:00
|
|
|
loadingFlag: false,
|
|
|
|
new_folder_name: "",
|
|
|
|
is_creating_folder: false
|
2021-01-19 16:56:53 +01:00
|
|
|
// lightbox_index: null
|
2019-06-11 18:04:46 +02:00
|
|
|
}
|
|
|
|
},
|
2020-11-24 14:07:10 +01:00
|
|
|
computed: {
|
|
|
|
...mapState({
|
2020-12-25 11:33:39 +01:00
|
|
|
flagcolls: state => state.User.flagcolls,
|
|
|
|
isloggedin: state => state.User.isloggedin
|
2021-03-08 22:04:50 +01:00
|
|
|
}),
|
|
|
|
collsLength() {
|
|
|
|
return Object.keys(this.flagcolls).length
|
|
|
|
},
|
|
|
|
addFlagBtnClassObj() {
|
|
|
|
return {
|
|
|
|
'mdi-plus-circle-outline': !this.is_creating_folder,
|
|
|
|
'mdi-loading': this.is_creating_folder,
|
|
|
|
active: this.new_folder_name.length > 4 && !this.is_creating_folder,
|
|
|
|
loading: this.is_creating_folder
|
|
|
|
}
|
|
|
|
}
|
2020-11-24 14:07:10 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2021-03-10 14:54:58 +01:00
|
|
|
// refreshItem: 'Search/refreshItem',
|
2021-03-08 22:04:50 +01:00
|
|
|
createFlagColl: 'User/createFlagColl',
|
2020-12-01 20:40:37 +01:00
|
|
|
flagUnflag: 'User/flagUnflag'
|
2020-11-24 14:07:10 +01:00
|
|
|
}),
|
2021-03-08 22:04:50 +01:00
|
|
|
onCreateFlagColl () {
|
|
|
|
console.log("Card onCreateFlagColl", this.new_folder_name)
|
|
|
|
this.is_creating_folder = true;
|
|
|
|
this.createFlagColl(this.new_folder_name)
|
|
|
|
.then(data => {
|
|
|
|
console.log("Card onCreateFlagColl then", data);
|
|
|
|
this.new_folder_name = "";
|
|
|
|
this.is_creating_folder = false;
|
|
|
|
let collid = data.id
|
|
|
|
this.loadingFlag = collid;
|
|
|
|
this.flagUnflag({ action: 'flag', id: this.item.id, collid: collid})
|
|
|
|
.then(data => {
|
|
|
|
console.log("onFlagActionCard then", data);
|
|
|
|
this.loadingFlag = false;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
2020-11-24 14:07:10 +01:00
|
|
|
flagIsActive(collid) {
|
2020-12-23 18:05:25 +01:00
|
|
|
// console.log("Card flagIsActive",
|
|
|
|
// this.item.id,
|
|
|
|
// this.flagcolls[collid].items,
|
|
|
|
// this.flagcolls[collid].items.indexOf(this.item.id)
|
|
|
|
// );
|
2020-11-24 14:07:10 +01:00
|
|
|
// console.log(this.flagcolls[collid].items_uuids);
|
2020-12-23 18:05:25 +01:00
|
|
|
// return this.flagcolls[collid].items_uuids.indexOf(this.item.uuid) !== -1;
|
|
|
|
return this.flagcolls[collid].items.indexOf(this.item.id) !== -1;
|
2020-11-24 14:07:10 +01:00
|
|
|
},
|
|
|
|
flagIsLoading(collid) {
|
|
|
|
// console.log(this.item.uuid);
|
|
|
|
// console.log(this.flagcolls[collid].items_uuids);
|
|
|
|
return collid === this.loadingFlag;
|
|
|
|
},
|
|
|
|
onFlagActionCard (e) {
|
2020-12-23 18:05:25 +01:00
|
|
|
console.log("Card onFlagActionCard", e, this.item);
|
2020-11-24 14:07:10 +01:00
|
|
|
if (!this.loadingFlag) {
|
|
|
|
let collid = e.target.getAttribute('collid');
|
|
|
|
let isActive = this.flagIsActive(collid);
|
2020-12-01 20:40:37 +01:00
|
|
|
let action = isActive ? 'unflag' : 'flag';
|
2020-11-24 14:07:10 +01:00
|
|
|
// console.log('collid', collid);
|
|
|
|
// console.log("this.item", this.item);
|
|
|
|
this.loadingFlag = collid;
|
2020-12-23 18:05:25 +01:00
|
|
|
this.flagUnflag({ action: action, id: this.item.id, collid: collid})
|
2020-12-01 20:40:37 +01:00
|
|
|
.then(data => {
|
|
|
|
console.log("onFlagActionCard then", data);
|
|
|
|
this.loadingFlag = false;
|
|
|
|
})
|
2020-11-24 14:07:10 +01:00
|
|
|
}
|
2020-12-01 23:02:35 +01:00
|
|
|
},
|
2021-01-19 16:56:53 +01:00
|
|
|
// onClickImg (e, index) {
|
|
|
|
// this.lightbox_index = index
|
|
|
|
// },
|
2020-12-01 23:02:35 +01:00
|
|
|
openModalCard (e) {
|
2020-12-25 17:37:15 +01:00
|
|
|
console.log('openModalCard', this.isLoggedin);
|
|
|
|
if(this.isloggedin){
|
2020-12-25 11:33:39 +01:00
|
|
|
this.$modal.show(
|
|
|
|
ModalCard,
|
2021-03-10 14:54:58 +01:00
|
|
|
{
|
|
|
|
item: this.item,
|
|
|
|
// not really an event
|
|
|
|
// more a callback function passed as prop to the component
|
|
|
|
addNoteId:(id) => {
|
|
|
|
// no needs to refresh the entire item via searchresults
|
|
|
|
// plus if we are in article, there is not searchresults
|
|
|
|
// this.refreshItem({id: this.item.id})
|
|
|
|
// instead create the note id directly
|
|
|
|
this.item.note = {id: id}
|
|
|
|
}
|
|
|
|
},
|
2020-12-25 11:33:39 +01:00
|
|
|
{
|
2021-01-20 12:42:21 +01:00
|
|
|
name: `modal-${this.item.id}`,
|
2021-03-30 15:42:40 +02:00
|
|
|
draggable: false,
|
|
|
|
classes: "vm--modale-card",
|
|
|
|
// this does not work
|
|
|
|
// adaptative: true,
|
|
|
|
// maxWidth: 850,
|
|
|
|
// maxHeight: 610,
|
|
|
|
width: '95%',
|
|
|
|
height: '95%'
|
2020-12-25 11:33:39 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2020-11-24 14:07:10 +01:00
|
|
|
}
|
2019-06-11 18:04:46 +02:00
|
|
|
}
|
2019-06-03 13:06:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2019-06-10 18:30:48 +02:00
|
|
|
|
2019-06-03 13:06:44 +02:00
|
|
|
</style>
|