materio-d9/web/themes/custom/materiotheme/vuejs/components/User/UserFlags.vue

77 lines
1.7 KiB
Vue
Raw Normal View History

<template lang="html">
<div id="user-flags">
2020-11-19 21:43:56 +01:00
<h2
class="mdi mdi-folder-outline"
2020-11-19 21:43:56 +01:00
>My folders</h2>
<ul>
2020-11-19 17:09:48 +01:00
<li v-if="flags" v-for="flag in flags" :key="flag.id">
<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>
</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
/>
</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
}),
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-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 = "";
})
}
}
}
</script>
<style lang="scss" scoped>
2020-11-19 21:43:56 +01:00
</style>