2020-11-18 13:22:30 +01:00
|
|
|
<template lang="html">
|
|
|
|
<div id="user-flags">
|
2020-11-19 21:43:56 +01:00
|
|
|
<h2
|
2020-11-18 13:22:30 +01:00
|
|
|
class="mdi mdi-folder-outline"
|
2020-11-19 21:43:56 +01:00
|
|
|
>My folders</h2>
|
2020-11-18 13:22:30 +01:00
|
|
|
<ul>
|
2020-11-26 22:45:46 +01:00
|
|
|
<li v-if="flagcolls" v-for="coll in flagcolls" :key="coll.id">
|
|
|
|
<h5
|
|
|
|
:flagcollid="coll.id"
|
|
|
|
@click.prevent="onOpenFlagColl"
|
|
|
|
>{{ coll.name }} ({{ coll.items.length }})</h5>
|
2020-11-19 21:43:56 +01:00
|
|
|
<div class="actions">
|
|
|
|
<span
|
2020-11-20 10:39:19 +01:00
|
|
|
class="delete-btn mdi"
|
|
|
|
:class="flagDeletingClassObj"
|
2020-11-24 14:07:10 +01:00
|
|
|
:flagcollid="coll.id"
|
|
|
|
@click.prevent="onDeleteFlagColl"
|
2020-11-19 21:43:56 +01:00
|
|
|
/>
|
|
|
|
</div>
|
2020-11-18 13:22:30 +01:00
|
|
|
</li>
|
2020-11-20 10:39:19 +01:00
|
|
|
<li class="create-flag">
|
2020-11-19 17:09:48 +01:00
|
|
|
<input
|
|
|
|
placeholder="new folder"
|
|
|
|
v-model="new_folder_name"
|
|
|
|
/>
|
|
|
|
<span
|
2020-11-20 10:39:19 +01:00
|
|
|
class="add-btn mdi"
|
|
|
|
:class="addFlagBtnClassObj"
|
2020-11-24 14:07:10 +01:00
|
|
|
@click.prevent="onCreateFlagColl"
|
2020-11-19 17:09:48 +01:00
|
|
|
/>
|
2020-11-18 13:22:30 +01:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "userFlags",
|
|
|
|
data: () => ({
|
2020-11-19 21:43:56 +01:00
|
|
|
new_folder_name: "",
|
2020-11-20 10:39:19 +01:00
|
|
|
is_creating_folder: false,
|
|
|
|
is_deleting_folder: false
|
2020-11-18 13:22:30 +01:00
|
|
|
}),
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
2020-11-24 14:07:10 +01:00
|
|
|
flagcolls: state => state.User.flagcolls
|
2020-11-20 10:39:19 +01:00
|
|
|
}),
|
|
|
|
addFlagBtnClassObj() {
|
|
|
|
return {
|
|
|
|
'mdi-plus-circle-outline': !this.is_creating_folder,
|
|
|
|
'mdi-loading': this.is_creating_folder,
|
|
|
|
active: this.new_folder_name.length > 4 && !this.is_creating_folder,
|
|
|
|
loading: this.is_creating_folder
|
|
|
|
}
|
|
|
|
},
|
|
|
|
flagDeletingClassObj() {
|
|
|
|
return {
|
|
|
|
'mdi-trash-can-outline': !this.is_deleting_folder,
|
|
|
|
'mdi-loading': this.is_deleting_folder,
|
|
|
|
'loading': this.is_deleting_folder
|
|
|
|
}
|
|
|
|
}
|
2020-11-18 13:22:30 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2020-11-24 14:07:10 +01:00
|
|
|
createFlagColl: 'User/createFlagColl',
|
2020-11-26 22:45:46 +01:00
|
|
|
deleteFlagColl: 'User/deleteFlagColl',
|
|
|
|
openFlagColl: 'User/openFlagColl'
|
2020-11-18 13:22:30 +01:00
|
|
|
}),
|
2020-11-24 14:07:10 +01:00
|
|
|
onCreateFlagColl () {
|
|
|
|
console.log("UserFlags onCreateFlagColl", this.new_folder_name)
|
2020-11-20 10:39:19 +01:00
|
|
|
this.is_creating_folder = true;
|
2020-11-24 14:07:10 +01:00
|
|
|
this.createFlagColl(this.new_folder_name)
|
2020-11-19 19:02:04 +01:00
|
|
|
.then(data => {
|
2020-11-24 14:07:10 +01:00
|
|
|
console.log("onCreateFlagColl then", data);
|
2020-11-19 19:02:04 +01:00
|
|
|
this.new_folder_name = "";
|
2020-11-20 10:39:19 +01:00
|
|
|
this.is_creating_folder = false;
|
2020-11-19 19:02:04 +01:00
|
|
|
})
|
|
|
|
},
|
2020-11-24 14:07:10 +01:00
|
|
|
onDeleteFlagColl (e) {
|
2020-11-26 22:45:46 +01:00
|
|
|
const flagcollid = e.target.getAttribute('flagcollid');
|
2020-11-24 14:07:10 +01:00
|
|
|
console.log("UserFlags onDeleteFlagColl", flagcollid);
|
|
|
|
this.is_deleting_folder = flagcollid;
|
|
|
|
this.deleteFlagColl(flagcollid)
|
2020-11-20 10:39:19 +01:00
|
|
|
.then(() => {
|
2020-11-24 14:07:10 +01:00
|
|
|
// console.log("onDeleteFlagColl then", data);
|
2020-11-20 10:39:19 +01:00
|
|
|
this.is_deleting_folder = false;
|
2020-11-19 19:02:04 +01:00
|
|
|
})
|
2020-11-26 22:45:46 +01:00
|
|
|
},
|
|
|
|
onOpenFlagColl (e) {
|
|
|
|
const flagcollid = e.target.getAttribute('flagcollid');
|
|
|
|
console.log("UserFlags onDeleteFlagColl", flagcollid);
|
|
|
|
this.openFlagColl(flagcollid)
|
|
|
|
.then(() => {
|
|
|
|
// console.log("onDeleteFlagColl then", data);
|
|
|
|
})
|
2020-11-18 13:22:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-11-19 21:43:56 +01:00
|
|
|
|
2020-11-18 13:22:30 +01:00
|
|
|
</style>
|