Card.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <article class="card search-card">
  3. <header
  4. @click.prevent="openModalCard"
  5. >
  6. <h1 v-if="isloggedin">{{ item.title }}</h1>
  7. <h4>{{ item.short_description }}</h4>
  8. <span v-if="isloggedin" class="ref">{{ item.reference }}</span>
  9. </header>
  10. <nav class="tools" v-if="isloggedin">
  11. <section class="tool flags">
  12. <span class="btn mdi mdi-folder-outline"/>
  13. <div class="tool-content">
  14. <ul>
  15. <li v-if="flagcolls" v-for="coll in flagcolls" :key="coll.id">
  16. <span
  17. class="flag mdi"
  18. :class="[
  19. flagIsLoading(coll.id) ? 'mdi-loading mdi-spin' : flagIsActive(coll.id) ? 'mdi-close-circle isActive' : 'mdi-plus'
  20. ]"
  21. :collid="coll.id"
  22. @click.prevent="onFlagActionCard"
  23. >
  24. {{ coll.name }}
  25. </span>
  26. </li>
  27. </ul>
  28. </div>
  29. </section>
  30. <section class="tool samples" v-if="item.samples && item.samples.length">
  31. <span class="btn mdi mdi-beaker-outline"/>
  32. <div class="tool-content">
  33. <span class="label">{{ $t("materio.Samples") }}</span>
  34. <ul>
  35. <li
  36. v-for="sample in item.samples"
  37. :key="sample.showroom.id"
  38. >
  39. <span class="showroom">{{ sample.showroom.name }}</span>: {{ sample.location }}
  40. </li>
  41. </ul>
  42. </div>
  43. </section>
  44. <section class="tool print">
  45. <a :href="item.path+'/printable/print'" target="_blank">
  46. <span class="btn mdi mdi-printer"/>
  47. </a>
  48. </section>
  49. </nav>
  50. <section class="images" v-switcher>
  51. <figure
  52. v-for="(img, index) in item.images"
  53. :key="img.url"
  54. >
  55. <img
  56. class="lazy"
  57. v-lazy="index"
  58. :data-src="img.style_cardmedium_url"
  59. :title="img.title"
  60. />
  61. <img
  62. class="blank"
  63. :src="blanksrc"
  64. @click.prevent="openModalCard"
  65. />
  66. </figure>
  67. </section>
  68. <!-- <CoolLightBox
  69. v-if="isloggedin"
  70. :items="item.images"
  71. :index="lightbox_index"
  72. srcName="style_hd_url"
  73. :loop="true"
  74. @close="lightbox_index = null">
  75. </CoolLightBox> -->
  76. </article>
  77. </template>
  78. <script>
  79. import { mapState, mapActions } from 'vuex'
  80. import cardMixins from 'vuejs/components/cardMixins'
  81. import ModalCard from 'vuejs/components/Content/ModalCard'
  82. export default {
  83. name: "Card",
  84. props: ['item'],
  85. mixins: [cardMixins],
  86. components: {
  87. ModalCard
  88. },
  89. data() {
  90. return {
  91. blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
  92. loadingFlag: false
  93. // lightbox_index: null
  94. }
  95. },
  96. computed: {
  97. ...mapState({
  98. flagcolls: state => state.User.flagcolls,
  99. isloggedin: state => state.User.isloggedin
  100. })
  101. },
  102. methods: {
  103. ...mapActions({
  104. flagUnflag: 'User/flagUnflag'
  105. }),
  106. flagIsActive(collid) {
  107. // console.log("Card flagIsActive",
  108. // this.item.id,
  109. // this.flagcolls[collid].items,
  110. // this.flagcolls[collid].items.indexOf(this.item.id)
  111. // );
  112. // console.log(this.flagcolls[collid].items_uuids);
  113. // return this.flagcolls[collid].items_uuids.indexOf(this.item.uuid) !== -1;
  114. return this.flagcolls[collid].items.indexOf(this.item.id) !== -1;
  115. },
  116. flagIsLoading(collid) {
  117. // console.log(this.item.uuid);
  118. // console.log(this.flagcolls[collid].items_uuids);
  119. return collid === this.loadingFlag;
  120. },
  121. onFlagActionCard (e) {
  122. console.log("Card onFlagActionCard", e, this.item);
  123. if (!this.loadingFlag) {
  124. let collid = e.target.getAttribute('collid');
  125. let isActive = this.flagIsActive(collid);
  126. let action = isActive ? 'unflag' : 'flag';
  127. // console.log('collid', collid);
  128. // console.log("this.item", this.item);
  129. this.loadingFlag = collid;
  130. this.flagUnflag({ action: action, id: this.item.id, collid: collid})
  131. .then(data => {
  132. console.log("onFlagActionCard then", data);
  133. this.loadingFlag = false;
  134. })
  135. }
  136. },
  137. // onClickImg (e, index) {
  138. // this.lightbox_index = index
  139. // },
  140. openModalCard (e) {
  141. console.log('openModalCard', this.isLoggedin);
  142. if(this.isloggedin){
  143. this.$modal.show(
  144. ModalCard,
  145. { item: this.item },
  146. {
  147. name: `modal-${this.item.id}`,
  148. draggable: true,
  149. width: '850px',
  150. height: '610px'
  151. }
  152. )
  153. }
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. </style>