api-client/components/collections/folder.vue

119 lines
3 KiB
Vue
Raw Normal View History

2019-10-01 22:20:23 +00:00
<template>
2019-10-25 08:14:34 +00:00
<div>
<div class="flex-wrap">
<div>
<button class="icon" @click="toggleShowChildren">
<i class="material-icons" v-show="!showChildren">arrow_right</i>
<i class="material-icons" v-show="showChildren">arrow_drop_down</i>
<i class="material-icons">folder_open</i>
2019-11-12 04:52:50 +00:00
<span>{{ folder.name }}</span>
2019-10-25 08:14:34 +00:00
</button>
</div>
2019-11-16 23:33:57 +00:00
<v-popover>
2020-06-30 08:44:05 +00:00
<button class="tooltip-target icon" v-tooltip.left="$t('more')">
2019-11-13 01:27:09 +00:00
<i class="material-icons">more_vert</i>
</button>
<template slot="popover">
<div>
2019-11-18 12:32:44 +00:00
<button class="icon" @click="editFolder" v-close-popover>
2019-11-16 23:33:57 +00:00
<i class="material-icons">edit</i>
<span>{{ $t("edit") }}</span>
2019-11-13 01:27:09 +00:00
</button>
</div>
<div>
2019-11-18 12:32:44 +00:00
<button class="icon" @click="removeFolder" v-close-popover>
2019-11-16 23:33:57 +00:00
<i class="material-icons">delete</i>
<span>{{ $t("delete") }}</span>
2019-11-13 01:27:09 +00:00
</button>
</div>
</template>
</v-popover>
2019-10-25 08:14:34 +00:00
</div>
2019-10-01 22:20:23 +00:00
2019-10-25 08:14:34 +00:00
<div v-show="showChildren">
<ul>
<li v-for="(request, index) in folder.requests" :key="index">
<request
:request="request"
:collection-index="collectionIndex"
:folder-index="folderIndex"
:request-index="index"
:doc="doc"
@edit-request="
2019-11-12 04:52:50 +00:00
$emit('edit-request', {
request,
collectionIndex,
folderIndex,
2020-02-24 18:44:50 +00:00
requestIndex: index,
2019-11-12 04:52:50 +00:00
})
2019-11-26 14:31:48 +00:00
"
/>
2019-10-25 08:14:34 +00:00
</li>
<li v-if="folder.requests.length === 0">
<label>{{ $t("folder_empty") }}</label>
2019-10-25 08:14:34 +00:00
</li>
</ul>
2019-10-01 22:20:23 +00:00
</div>
2019-10-25 08:14:34 +00:00
</div>
2019-10-01 22:20:23 +00:00
</template>
2019-12-06 01:41:38 +00:00
<style scoped lang="scss">
2019-11-02 05:32:21 +00:00
ul {
display: flex;
flex-direction: column;
}
2019-10-01 22:20:23 +00:00
2019-11-02 05:32:21 +00:00
ul li {
display: flex;
margin-left: 32px;
border-left: 1px solid var(--brd-color);
}
2019-10-01 22:20:23 +00:00
</style>
<script>
import { fb } from "~/helpers/fb"
2019-11-02 05:32:21 +00:00
export default {
props: {
folder: Object,
collectionIndex: Number,
2020-02-24 18:44:50 +00:00
folderIndex: Number,
doc: Boolean,
2019-11-02 05:32:21 +00:00
},
components: {
request: () => import("./request"),
2019-11-02 05:32:21 +00:00
},
data() {
return {
2020-02-24 18:44:50 +00:00
showChildren: false,
}
2019-11-02 05:32:21 +00:00
},
methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
2019-11-02 05:32:21 +00:00
toggleShowChildren() {
2020-02-24 18:44:50 +00:00
this.showChildren = !this.showChildren
2019-10-01 22:20:23 +00:00
},
2019-11-02 05:32:21 +00:00
selectRequest(request) {
this.$store.commit("postwoman/selectRequest", { request })
2019-10-01 22:20:23 +00:00
},
2019-11-02 05:32:21 +00:00
removeFolder() {
if (!confirm("Are you sure you want to remove this folder?")) return
this.$store.commit("postwoman/removeFolder", {
2019-11-02 05:32:21 +00:00
collectionIndex: this.collectionIndex,
2020-02-24 18:44:50 +00:00
folderIndex: this.folderIndex,
})
2020-06-19 06:56:04 +00:00
this.syncCollections()
2019-10-01 22:20:23 +00:00
},
2019-11-02 05:32:21 +00:00
editFolder() {
this.$emit("edit-folder")
2020-02-24 18:44:50 +00:00
},
},
}
2019-10-22 09:13:54 +00:00
</script>