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

81 lines
1.7 KiB
Vue

<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">
<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.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",
props: ['item', 'collid'],
mixins: [cardMixins],
data() {
return {
blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
loadingItem: false
}
},
computed: {
},
methods: {
...mapActions({
flagUnflag: 'User/flagUnflag'
}),
itemIsLoading(id) {
return this.loadingItem
},
onUnFlagCard (e) {
console.log("Card onFlagActionCard", e);
if (!this.loadingItem) {
this.loadingItem = true;
this.flagUnflag({
action: 'unflag',
uuid: this.item.uuid,
collid: this.collid
})
.then(data => {
console.log("onUnFlagCard then", data);
this.loadingItem = false;
})
}
}
}
}
</script>
<style lang="scss" scoped>
</style>