LinkedMaterialCard.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <article class="card linkedmaterialcard">
  3. <header
  4. @click.prevent="openModalCard"
  5. >
  6. <h1>{{ 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">
  11. </nav>
  12. <section class="images" v-switcher>
  13. <figure
  14. v-for="(img, index) in item.images"
  15. :key="img.url"
  16. class="lazy"
  17. v-lazy="index"
  18. >
  19. <img
  20. :data-src="img.style_linkedmaterialcard.url"
  21. :title="img.title"
  22. />
  23. <img
  24. class="blank"
  25. :src="blanksrc"
  26. @click.prevent="openModalCard"
  27. />
  28. </figure>
  29. </section>
  30. </article>
  31. </template>
  32. <script>
  33. import { mapState, mapActions } from 'vuex'
  34. import cardMixins from 'vuejs/components/cardMixins'
  35. import ModalCard from 'vuejs/components/Content/ModalCard'
  36. export default {
  37. name: "LinkedMaterialCard",
  38. props: ['item'],
  39. mixins: [cardMixins],
  40. // components: {
  41. // ModalCard
  42. // },
  43. data() {
  44. return {
  45. blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
  46. loadingItem: false
  47. }
  48. },
  49. computed: {
  50. ...mapState({
  51. isloggedin: state => state.User.isloggedin
  52. })
  53. },
  54. methods: {
  55. itemIsLoading(id) {
  56. return this.loadingItem
  57. },
  58. openModalCard (e) {
  59. console.log('openModalCard', this.isLoggedin)
  60. if (this.isloggedin) {
  61. this.$modal.show(
  62. ModalCard,
  63. {
  64. item: this.item,
  65. // not really an event
  66. // more a callback function passed as prop to the component
  67. addNoteId:(id) => {
  68. // no needs to refresh the entire item via searchresults
  69. // plus if we are in article, there is not searchresults
  70. // this.refreshItem({id: this.item.id})
  71. // instead create the note id directly
  72. this.item.note = {id: id}
  73. }
  74. },
  75. {
  76. name: `modal-${this.item.id}`,
  77. draggable: false,
  78. classes: "vm--modale-card",
  79. // this does not work
  80. // adaptative: true,
  81. // maxWidth: 850,
  82. // maxHeight: 610,
  83. width: '95%',
  84. height: '95%'
  85. }
  86. )
  87. } else {
  88. this.$modal.show(
  89. MemberWarning,
  90. {},
  91. {
  92. // name: `modal-${this.item.id}`,
  93. draggable: false,
  94. // classes: "vm--modale-card",
  95. // this does not work
  96. // adaptative: true,
  97. // maxWidth: 850,
  98. // maxHeight: 610,
  99. width: '400px',
  100. height: '250px'
  101. }
  102. )
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. </style>