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
|
|
|
>
|
2021-09-03 10:39:00 +02:00
|
|
|
<h1 v-if="hasDBAccess">{{ item.title }}</h1>
|
2020-12-23 18:05:25 +01:00
|
|
|
<h4>{{ item.short_description }}</h4>
|
2021-09-03 10:39:00 +02:00
|
|
|
<span v-if="hasDBAccess" class="ref">{{ item.reference }}</span>
|
2019-06-10 18:30:48 +02:00
|
|
|
</header>
|
2021-09-03 10:39:00 +02:00
|
|
|
<nav class="tools" v-if="hasDBAccess">
|
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">
|
2021-09-16 13:04:37 +02:00
|
|
|
<span class="btn mdi mdi-map-marker-star-outline"/>
|
2021-01-25 17:39:44 +01:00
|
|
|
<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"
|
2021-07-12 12:50:40 +02:00
|
|
|
class="lazy"
|
|
|
|
v-lazy="index"
|
2019-06-11 18:04:46 +02:00
|
|
|
>
|
|
|
|
<img
|
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'
|
2021-06-08 21:20:59 +02:00
|
|
|
import MemberWarning from 'vuejs/components/Content/MemberWarning'
|
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: {
|
2021-06-08 21:20:59 +02:00
|
|
|
ModalCard,
|
|
|
|
MemberWarning
|
2020-12-01 23:02:35 +01:00
|
|
|
},
|
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,
|
2021-09-03 10:39:00 +02:00
|
|
|
isloggedin: state => state.User.isloggedin,
|
|
|
|
hasDBAccess: state => state.User.hasDBAccess
|
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
|
|
|
},
|
2021-08-04 13:50:00 +02:00
|
|
|
beforeMount () {
|
2021-09-21 11:05:29 +02:00
|
|
|
// console.log(this.item.id, this.samples)
|
2021-08-04 13:50:00 +02:00
|
|
|
},
|
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 => {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log("Card onCreateFlagColl then", data)
|
2021-03-08 22:04:50 +01:00
|
|
|
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 => {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log("onFlagActionCard then", data)
|
2021-03-08 22:04:50 +01:00
|
|
|
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)
|
|
|
|
// );
|
2021-03-31 18:42:05 +02: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) {
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log(this.item.uuid)
|
|
|
|
// console.log(this.flagcolls[collid].items_uuids)
|
2020-11-24 14:07:10 +01:00
|
|
|
return collid === this.loadingFlag;
|
|
|
|
},
|
|
|
|
onFlagActionCard (e) {
|
2021-03-31 18:42:05 +02: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';
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('collid', collid)
|
|
|
|
// console.log("this.item", this.item)
|
2020-11-24 14:07:10 +01:00
|
|
|
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 => {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log("onFlagActionCard then", data)
|
2020-12-01 20:40:37 +01:00
|
|
|
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) {
|
2021-09-03 10:39:00 +02:00
|
|
|
console.log('openModalCard', this.hasDBAccess)
|
|
|
|
if (this.hasDBAccess) {
|
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
|
|
|
}
|
|
|
|
)
|
2021-06-08 21:20:59 +02:00
|
|
|
} else {
|
|
|
|
this.$modal.show(
|
|
|
|
MemberWarning,
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
// name: `modal-${this.item.id}`,
|
|
|
|
draggable: false,
|
|
|
|
// classes: "vm--modale-card",
|
|
|
|
// this does not work
|
|
|
|
// adaptative: true,
|
|
|
|
// maxWidth: 850,
|
|
|
|
// maxHeight: 610,
|
|
|
|
width: '400px',
|
|
|
|
height: '250px'
|
|
|
|
}
|
|
|
|
)
|
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>
|