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-19 17:09:48 +01:00
|
|
|
<li v-if="flags" v-for="flag in flags" :key="flag.id">
|
2020-11-18 13:22:30 +01:00
|
|
|
<h5>{{ flag.name }}</h5>
|
2020-11-19 21:43:56 +01:00
|
|
|
<div class="actions">
|
|
|
|
<span
|
|
|
|
class="mdi mdi-trash-can-outline"
|
|
|
|
:flagid="flag.id"
|
|
|
|
@click.prevent="onDeleteFlag"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-11-18 13:22:30 +01:00
|
|
|
</li>
|
|
|
|
<li ref="create-flag">
|
2020-11-19 17:09:48 +01:00
|
|
|
<input
|
|
|
|
placeholder="new folder"
|
|
|
|
v-model="new_folder_name"
|
|
|
|
/>
|
|
|
|
<span
|
2020-11-19 21:43:56 +01:00
|
|
|
|
2020-11-19 17:09:48 +01:00
|
|
|
class="mdi mdi-plus-box"
|
2020-11-19 21:43:56 +01:00
|
|
|
v-if="new_folder_name && !is_creating_folder"
|
2020-11-19 19:02:04 +01:00
|
|
|
@click.prevent="onCreateFlag"
|
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: "",
|
|
|
|
is_creating_folder: false
|
2020-11-18 13:22:30 +01:00
|
|
|
}),
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
flags: state => state.User.flags
|
|
|
|
})
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2020-11-19 19:02:04 +01:00
|
|
|
createFlag: 'User/createFlag',
|
|
|
|
deleteFlag: 'User/deleteFlag'
|
2020-11-18 13:22:30 +01:00
|
|
|
}),
|
2020-11-19 17:09:48 +01:00
|
|
|
onCreateFlag () {
|
|
|
|
console.log("UserFlags onCreateFlag", this.new_folder_name)
|
2020-11-19 19:02:04 +01:00
|
|
|
this.createFlag(this.new_folder_name)
|
|
|
|
.then(data => {
|
|
|
|
console.log("onCreateFlag then", data);
|
|
|
|
this.new_folder_name = "";
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onDeleteFlag (e) {
|
|
|
|
let flagid = e.target.getAttribute('flagid');
|
|
|
|
console.log("UserFlags onDeleteFlag", flagid);
|
|
|
|
this.deleteFlag(flagid)
|
|
|
|
.then(data => {
|
|
|
|
console.log("onDeleteFlag then", data);
|
|
|
|
this.new_folder_name = "";
|
|
|
|
})
|
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>
|