2020-11-26 22:45:46 +01:00
|
|
|
<template>
|
|
|
|
<section class="flag-collection">
|
2020-11-27 23:02:59 +01:00
|
|
|
<header>
|
|
|
|
<h3 class="mdi mdi-folder-outline">{{collection.name}}</h3>
|
|
|
|
<span
|
|
|
|
class="mdi mdi-close"
|
|
|
|
title="close"
|
|
|
|
@click.prevent="onCloseFlagColl"
|
|
|
|
/>
|
|
|
|
</header>
|
2020-11-26 22:45:46 +01:00
|
|
|
<ul v-if="loadedItems">
|
|
|
|
<li
|
|
|
|
v-for="item in loadedItems"
|
|
|
|
:key="item.id"
|
2020-11-27 23:02:59 +01:00
|
|
|
>
|
2020-12-01 20:40:37 +01:00
|
|
|
<MiniCard :item="item" :collid="collection.id"/>
|
2020-11-27 23:02:59 +01:00
|
|
|
</li>
|
2020-12-01 20:40:37 +01:00
|
|
|
<span v-if="loadedItems.length === 0">No items in your folder</span>
|
2020-11-26 22:45:46 +01:00
|
|
|
</ul>
|
2021-06-01 22:46:15 +02:00
|
|
|
<span v-else class="loading">{{ $t('default.Loading…') }}</span>
|
2020-11-26 22:45:46 +01:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
2020-11-27 23:02:59 +01:00
|
|
|
import MiniCard from 'vuejs/components/Content/MiniCard'
|
2020-11-26 22:45:46 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "FlagCollection",
|
|
|
|
props: ['collection'],
|
|
|
|
data: () => ({
|
|
|
|
loadedItems: false
|
|
|
|
}),
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
2020-11-27 23:02:59 +01:00
|
|
|
flagcolls: state => state.User.flagcolls,
|
2020-12-01 20:40:37 +01:00
|
|
|
flagcollsLoadedItems: state => state.User.flagcollsLoadedItems,
|
2020-11-27 23:02:59 +01:00
|
|
|
openedCollid: state => state.User.openedCollid
|
2020-11-26 22:45:46 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
// watch: {
|
|
|
|
// flagcolls (newv, oldv) {
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('watching flagcolls')
|
2020-11-26 22:45:46 +01:00
|
|
|
// if( typeof this.flagcolls[this.collection.id].loadedItems !== 'undefined' ) {
|
|
|
|
// this.loadedItems = this.flagcolls[this.collection.id].loadedItems
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
created() {
|
2020-12-01 20:40:37 +01:00
|
|
|
if (typeof this.flagcollsLoadedItems[this.openedCollid] !== 'undefined') {
|
2020-11-27 23:02:59 +01:00
|
|
|
// if loadedItems are alredy loaded,
|
|
|
|
// the mutation occurs before this subscription
|
|
|
|
// so we first check if they are already available
|
2020-12-01 20:40:37 +01:00
|
|
|
this.loadedItems = this.flagcollsLoadedItems[this.openedCollid]
|
2020-11-27 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2020-11-26 22:45:46 +01:00
|
|
|
this.unsubscribe = this.$store.subscribe((mutation, state) => {
|
|
|
|
if (mutation.type === 'User/setLoadedCollItems') {
|
2020-11-27 23:02:59 +01:00
|
|
|
console.log("mutation setLoadedCollItems collid", this.openedCollid)
|
|
|
|
// mutation is triggered before the component update
|
|
|
|
// so this.collection.id is not good
|
2020-12-01 20:40:37 +01:00
|
|
|
this.loadedItems = state.User.flagcollsLoadedItems[this.openedCollid]
|
2020-11-26 22:45:46 +01:00
|
|
|
}
|
2020-11-27 23:02:59 +01:00
|
|
|
})
|
|
|
|
|
2020-11-26 22:45:46 +01:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.unsubscribe()
|
|
|
|
},
|
|
|
|
// beforeMount () {
|
|
|
|
// if (typeof this.flagcolls[collection.id].loadedItems === 'undefined') {
|
|
|
|
// this.
|
|
|
|
// }
|
|
|
|
// },
|
2020-11-27 23:02:59 +01:00
|
|
|
methods: {
|
|
|
|
...mapActions({
|
|
|
|
closeFlagColl: 'User/closeFlagColl'
|
|
|
|
}),
|
|
|
|
onCloseFlagColl(e) {
|
|
|
|
this.closeFlagColl()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
MiniCard
|
|
|
|
}
|
2020-11-26 22:45:46 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|