MiniCard.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <article class="card minicard">
  3. <header>
  4. <h1>{{ item.title }}</h1>
  5. <span class="ref">{{ item.reference }}</span>
  6. </header>
  7. <nav class="tools">
  8. <section class="tool flags">
  9. <span
  10. class="mdi unflag"
  11. :class="[
  12. itemIsLoading() ? 'mdi-loading mdi-spin' : 'mdi-folder-remove'
  13. ]"
  14. @click.prevent="onUnFlagCard"
  15. />
  16. </section>
  17. </nav>
  18. <section class="images" v-switcher>
  19. <figure
  20. v-for="(img, index) in item.images"
  21. :key="img.url"
  22. >
  23. <img
  24. class="lazy"
  25. v-lazy="index"
  26. :data-src="img.style_minicard.url"
  27. :title="img.title"
  28. />
  29. <img class="blank" :src="blanksrc">
  30. </figure>
  31. </section>
  32. </article>
  33. </template>
  34. <script>
  35. import { mapState, mapActions } from 'vuex'
  36. import cardMixins from 'vuejs/components/cardMixins'
  37. export default {
  38. name: "MiniCard",
  39. props: ['item', 'collid'],
  40. mixins: [cardMixins],
  41. data() {
  42. return {
  43. blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
  44. loadingItem: false
  45. }
  46. },
  47. computed: {
  48. },
  49. methods: {
  50. ...mapActions({
  51. flagUnflag: 'User/flagUnflag'
  52. }),
  53. itemIsLoading(id) {
  54. return this.loadingItem
  55. },
  56. onUnFlagCard (e) {
  57. console.log("Card onFlagActionCard", e, this.item);
  58. if (!this.loadingItem) {
  59. this.loadingItem = true;
  60. this.flagUnflag({
  61. action: 'unflag',
  62. id: this.item.id,
  63. collid: this.collid
  64. })
  65. .then(data => {
  66. console.log("onUnFlagCard then", data);
  67. this.loadingItem = false;
  68. })
  69. }
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. </style>