api-client/components/collections/folder.vue

91 lines
2.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>
<span>{{folder.name}}</span>
</button>
</div>
<div>
<button class="icon" @click="removeFolder" v-tooltip="'Delete folder'">
<i class="material-icons">delete</i>
</button>
<button class="icon" @click="editFolder" v-tooltip="'Edit folder'">
<i class="material-icons">edit</i>
</button>
</div>
</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
v-bind:request="request"
v-bind:collection-index="collectionIndex"
v-bind:folder-index="folderIndex"
v-bind:request-index="index"
v-on:edit-request="$emit('edit-request', { request, collectionIndex, folderIndex, requestIndex: index })"
></request>
</li>
<li v-if="folder.requests.length === 0">
<label>Folder is empty</label>
</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>
<style scoped>
2019-10-25 08:14:34 +00:00
ul {
display: flex;
flex-direction: column;
}
2019-10-01 22:20:23 +00:00
2019-10-25 08:14:34 +00:00
ul li {
display: flex;
padding-left: 16px;
border-left: 1px solid var(--brd-color);
}
2019-10-01 22:20:23 +00:00
</style>
<script>
2019-10-25 08:14:34 +00:00
import request from "./request";
2019-10-01 22:20:23 +00:00
2019-10-25 08:14:34 +00:00
export default {
2019-10-01 22:20:23 +00:00
props: {
2019-10-25 08:14:34 +00:00
folder: Object,
collectionIndex: Number,
folderIndex: Number
2019-10-01 22:20:23 +00:00
},
components: {
2019-10-25 08:14:34 +00:00
request
2019-10-01 22:20:23 +00:00
},
2019-10-25 08:14:34 +00:00
data() {
return {
showChildren: false
};
2019-10-01 22:20:23 +00:00
},
methods: {
2019-10-25 08:14:34 +00:00
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
});
},
editFolder() {
this.$emit("edit-folder");
}
2019-10-01 22:20:23 +00:00
}
2019-10-25 08:14:34 +00:00
};
2019-10-22 09:13:54 +00:00
</script>