LinkedMaterialCard.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. const ModalCard = () => import(
  37. /* webpackChunkName: "module-base" */
  38. /* webpackMode: "lazy" */
  39. /* webpackPrefetch: true */
  40. /* webpackPreload: true */
  41. 'vuejs/components/Content/ModalCard')
  42. export default {
  43. name: "LinkedMaterialCard",
  44. props: ['item'],
  45. mixins: [cardMixins],
  46. // components: {
  47. // ModalCard
  48. // },
  49. data() {
  50. return {
  51. blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
  52. loadingItem: false
  53. }
  54. },
  55. computed: {
  56. ...mapState({
  57. isloggedin: state => state.User.isloggedin
  58. })
  59. },
  60. methods: {
  61. itemIsLoading(id) {
  62. return this.loadingItem
  63. },
  64. openModalCard (e) {
  65. console.log('openModalCard', this.isLoggedin)
  66. if (this.isloggedin) {
  67. this.$modal.show(
  68. ModalCard,
  69. {
  70. item: this.item,
  71. // not really an event
  72. // more a callback function passed as prop to the component
  73. addNoteId:(id) => {
  74. // no needs to refresh the entire item via searchresults
  75. // plus if we are in article, there is not searchresults
  76. // this.refreshItem({id: this.item.id})
  77. // instead create the note id directly
  78. this.item.note = {id: id}
  79. }
  80. },
  81. {
  82. name: `modal-${this.item.id}`,
  83. draggable: false,
  84. classes: "vm--modale-card",
  85. // this does not work
  86. // adaptative: true,
  87. // maxWidth: 850,
  88. // maxHeight: 610,
  89. width: '95%',
  90. height: '95%'
  91. }
  92. )
  93. } else {
  94. this.$modal.show(
  95. MemberWarning,
  96. {},
  97. {
  98. // name: `modal-${this.item.id}`,
  99. draggable: false,
  100. // classes: "vm--modale-card",
  101. // this does not work
  102. // adaptative: true,
  103. // maxWidth: 850,
  104. // maxHeight: 610,
  105. width: '400px',
  106. height: '250px'
  107. }
  108. )
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. </style>