materio-d9/web/themes/custom/materiotheme/vuejs/components/Content/MiniCard.vue

81 lines
1.7 KiB
Vue
Raw Normal View History

<template>
<article class="card minicard">
<header>
<h1>{{ item.title }}</h1>
<span class="ref">{{ item.field_reference }}</span>
</header>
<nav class="tools">
<section class="tool flags">
2020-12-01 20:40:37 +01:00
<span
class="mdi unflag"
:class="[
itemIsLoading() ? 'mdi-loading mdi-spin' : 'mdi-folder-remove'
]"
@click.prevent="onUnFlagCard"
/>
</section>
</nav>
<section class="images" v-switcher>
<figure
v-for="(img, index) in item.images"
:key="img.url"
>
<img
class="lazy"
v-lazy="index"
:data-src="img.style_minicard.url"
:title="img.title"
/>
<img class="blank" :src="blanksrc">
</figure>
</section>
</article>
</template>
<script>
import { mapState, mapActions } from 'vuex'
import cardMixins from 'vuejs/components/cardMixins'
export default {
name: "MiniCard",
2020-12-01 20:40:37 +01:00
props: ['item', 'collid'],
mixins: [cardMixins],
data() {
return {
blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
2020-12-01 20:40:37 +01:00
loadingItem: false
}
},
computed: {
},
methods: {
2020-12-01 20:40:37 +01:00
...mapActions({
flagUnflag: 'User/flagUnflag'
}),
itemIsLoading(id) {
return this.loadingItem
},
onUnFlagCard (e) {
console.log("Card onFlagActionCard", e, this.item);
2020-12-01 20:40:37 +01:00
if (!this.loadingItem) {
this.loadingItem = true;
this.flagUnflag({
action: 'unflag',
id: this.item.id,
2020-12-01 20:40:37 +01:00
collid: this.collid
})
.then(data => {
console.log("onUnFlagCard then", data);
this.loadingItem = false;
})
}
}
}
}
</script>
<style lang="scss" scoped>
</style>