Files
hoppscotch/components/collections/folder.vue
Liyas Thomas 1587a44cd7 Lint
2020-06-19 12:26:04 +05:30

117 lines
2.9 KiB
Vue

<template>
<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>
<span>{{ folder.name }}</span>
</button>
</div>
<v-popover>
<button class="tooltip-target icon" v-tooltip="$t('more')">
<i class="material-icons">more_vert</i>
</button>
<template slot="popover">
<div>
<button class="icon" @click="editFolder" v-close-popover>
<i class="material-icons">edit</i>
<span>{{ $t("edit") }}</span>
</button>
</div>
<div>
<button class="icon" @click="removeFolder" v-close-popover>
<i class="material-icons">delete</i>
<span>{{ $t("delete") }}</span>
</button>
</div>
</template>
</v-popover>
</div>
<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"
@edit-request="
$emit('edit-request', {
request,
collectionIndex,
folderIndex,
requestIndex: index,
})
"
/>
</li>
<li v-if="folder.requests.length === 0">
<label>{{ $t("folder_empty") }}</label>
</li>
</ul>
</div>
</div>
</template>
<style scoped lang="scss">
ul {
display: flex;
flex-direction: column;
}
ul li {
display: flex;
margin-left: 32px;
border-left: 1px solid var(--brd-color);
}
</style>
<script>
import { fb } from "../../functions/fb"
export default {
props: {
folder: Object,
collectionIndex: Number,
folderIndex: Number,
},
components: {
request: () => import("./request"),
},
data() {
return {
showChildren: false,
}
},
methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
toggleShowChildren() {
this.showChildren = !this.showChildren
},
selectRequest(request) {
this.$store.commit("postwoman/selectRequest", { request })
},
removeFolder() {
if (!confirm("Are you sure you want to remove this folder?")) return
this.$store.commit("postwoman/removeFolder", {
collectionIndex: this.collectionIndex,
folderIndex: this.folderIndex,
})
this.syncCollections()
},
editFolder() {
this.$emit("edit-folder")
},
},
}
</script>