2019-10-01 22:20:23 +00:00
|
|
|
<template>
|
2019-10-25 08:14:34 +00:00
|
|
|
<div>
|
2020-10-21 01:11:45 +00:00
|
|
|
<div
|
2020-10-21 06:50:32 +00:00
|
|
|
:class="['row-wrapper', dragging ? 'drop-zone' : '']"
|
2020-10-21 01:11:45 +00:00
|
|
|
@dragover.prevent
|
|
|
|
|
@drop.prevent="dropEvent"
|
2020-10-21 06:50:32 +00:00
|
|
|
@dragover="dragging = true"
|
|
|
|
|
@drop="dragging = false"
|
|
|
|
|
@dragleave="dragging = false"
|
|
|
|
|
@dragend="dragging = false"
|
2020-10-21 01:11:45 +00:00
|
|
|
>
|
2019-10-25 08:14:34 +00:00
|
|
|
<div>
|
|
|
|
|
<button class="icon" @click="toggleShowChildren">
|
2020-10-11 04:52:18 +00:00
|
|
|
<i class="material-icons" v-show="!showChildren && !isFiltered">arrow_right</i>
|
|
|
|
|
<i class="material-icons" v-show="showChildren || isFiltered">arrow_drop_down</i>
|
2019-10-25 08:14:34 +00:00
|
|
|
<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>
|
2020-10-26 01:14:59 +00:00
|
|
|
<button
|
|
|
|
|
class="icon"
|
|
|
|
|
@click="$emit('add-folder', { folder, path: folderPath })"
|
|
|
|
|
v-close-popover
|
|
|
|
|
>
|
2020-10-21 01:11:45 +00:00
|
|
|
<i class="material-icons">create_new_folder</i>
|
|
|
|
|
<span>{{ $t("new_folder") }}</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2020-10-21 06:50:32 +00:00
|
|
|
<button
|
|
|
|
|
class="icon"
|
|
|
|
|
@click="$emit('edit-folder', { folder, folderIndex, collectionIndex })"
|
|
|
|
|
v-close-popover
|
|
|
|
|
>
|
2019-11-16 23:33:57 +00:00
|
|
|
<i class="material-icons">edit</i>
|
2020-02-25 02:06:23 +00:00
|
|
|
<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>
|
2020-08-17 10:37:36 +00:00
|
|
|
<deleteIcon class="material-icons" />
|
2020-02-25 02:06:23 +00:00
|
|
|
<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
|
|
|
|
2020-10-11 04:52:18 +00:00
|
|
|
<div v-show="showChildren || isFiltered">
|
2020-09-22 17:06:37 +00:00
|
|
|
<ul class="flex-col">
|
|
|
|
|
<li
|
|
|
|
|
v-for="(request, index) in folder.requests"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="flex ml-8 border-l border-brdColor"
|
|
|
|
|
>
|
2019-10-25 08:14:34 +00:00
|
|
|
<request
|
2019-12-15 13:50:31 +00:00
|
|
|
:request="request"
|
|
|
|
|
:collection-index="collectionIndex"
|
|
|
|
|
:folder-index="folderIndex"
|
2020-10-21 01:11:45 +00:00
|
|
|
:folder-name="folder.name"
|
2019-12-15 13:50:31 +00:00
|
|
|
:request-index="index"
|
2020-07-18 12:16:29 +00:00
|
|
|
:doc="doc"
|
2020-10-21 01:11:45 +00:00
|
|
|
@edit-request="$emit('edit-request', $event)"
|
2019-11-26 14:31:48 +00:00
|
|
|
/>
|
2019-10-25 08:14:34 +00:00
|
|
|
</li>
|
2020-10-21 01:11:45 +00:00
|
|
|
</ul>
|
|
|
|
|
<ul v-if="folder.folders && folder.folders.length" class="flex-col">
|
2020-10-21 06:50:32 +00:00
|
|
|
<li v-for="(subFolder, subFolderIndex) in folder.folders" :key="subFolder.name">
|
2020-10-21 01:11:45 +00:00
|
|
|
<folder
|
|
|
|
|
:folder="subFolder"
|
|
|
|
|
:folder-index="subFolderIndex"
|
|
|
|
|
:collection-index="collectionIndex"
|
|
|
|
|
:doc="doc"
|
2020-10-26 01:14:59 +00:00
|
|
|
:folder-path="`${folderPath}/${subFolderIndex}`"
|
2020-10-21 01:11:45 +00:00
|
|
|
@add-folder="$emit('add-folder', $event)"
|
|
|
|
|
@edit-folder="$emit('edit-folder', $event)"
|
|
|
|
|
@edit-request="$emit('edit-request', $event)"
|
|
|
|
|
/>
|
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>
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-06-21 03:54:45 +00:00
|
|
|
import { fb } from "~/helpers/fb"
|
2020-08-17 10:37:36 +00:00
|
|
|
import deleteIcon from "~/static/icons/delete-24px.svg?inline"
|
2020-06-07 17:56:13 +00:00
|
|
|
|
2019-11-02 05:32:21 +00:00
|
|
|
export default {
|
2020-08-17 10:37:36 +00:00
|
|
|
components: { deleteIcon },
|
2020-10-21 01:11:45 +00:00
|
|
|
name: "folder",
|
2019-11-02 05:32:21 +00:00
|
|
|
props: {
|
|
|
|
|
folder: Object,
|
2020-02-24 18:44:50 +00:00
|
|
|
folderIndex: Number,
|
2020-10-21 01:11:45 +00:00
|
|
|
collectionIndex: Number,
|
2020-10-26 01:14:59 +00:00
|
|
|
folderPath: String,
|
2020-07-18 12:16:29 +00:00
|
|
|
doc: Boolean,
|
2020-10-11 04:52:18 +00:00
|
|
|
isFiltered: Boolean,
|
2019-11-02 05:32:21 +00:00
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-02-24 18:44:50 +00:00
|
|
|
showChildren: false,
|
2020-10-21 01:11:45 +00:00
|
|
|
dragging: false,
|
2020-02-24 18:44:50 +00:00
|
|
|
}
|
2019-11-02 05:32:21 +00:00
|
|
|
},
|
|
|
|
|
methods: {
|
2020-06-07 17:56:13 +00:00
|
|
|
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
|
|
|
removeFolder() {
|
2020-08-17 12:59:14 +00:00
|
|
|
if (!confirm(this.$t("are_you_sure_remove_folder"))) return
|
2020-02-25 02:06:23 +00:00
|
|
|
this.$store.commit("postwoman/removeFolder", {
|
2020-10-21 01:11:45 +00:00
|
|
|
collectionIndex: this.$props.collectionIndex,
|
|
|
|
|
folderName: this.$props.folder.name,
|
2020-10-21 06:50:32 +00:00
|
|
|
folderIndex: this.$props.folderIndex,
|
2020-02-24 18:44:50 +00:00
|
|
|
})
|
2020-06-19 06:56:04 +00:00
|
|
|
this.syncCollections()
|
2020-08-17 12:59:14 +00:00
|
|
|
this.$toast.error(this.$t("deleted"), {
|
2020-08-16 11:56:33 +00:00
|
|
|
icon: "delete",
|
|
|
|
|
})
|
2019-10-01 22:20:23 +00:00
|
|
|
},
|
2020-10-21 06:50:32 +00:00
|
|
|
dropEvent({ dataTransfer }) {
|
|
|
|
|
this.dragging = !this.dragging
|
|
|
|
|
const oldCollectionIndex = dataTransfer.getData("oldCollectionIndex")
|
|
|
|
|
const oldFolderIndex = dataTransfer.getData("oldFolderIndex")
|
|
|
|
|
const oldFolderName = dataTransfer.getData("oldFolderName")
|
|
|
|
|
const requestIndex = dataTransfer.getData("requestIndex")
|
2020-10-21 01:11:45 +00:00
|
|
|
|
|
|
|
|
this.$store.commit("postwoman/moveRequest", {
|
2020-10-21 06:50:32 +00:00
|
|
|
oldCollectionIndex,
|
2020-10-21 01:11:45 +00:00
|
|
|
newCollectionIndex: this.$props.collectionIndex,
|
|
|
|
|
newFolderIndex: this.$props.folderIndex,
|
|
|
|
|
newFolderName: this.$props.folder.name,
|
2020-10-21 06:50:32 +00:00
|
|
|
oldFolderIndex,
|
|
|
|
|
oldFolderName,
|
|
|
|
|
requestIndex,
|
2020-10-21 01:11:45 +00:00
|
|
|
})
|
|
|
|
|
this.syncCollections()
|
2020-02-24 18:44:50 +00:00
|
|
|
},
|
2020-10-21 06:50:32 +00:00
|
|
|
},
|
2020-02-24 18:44:50 +00:00
|
|
|
}
|
2019-10-22 09:13:54 +00:00
|
|
|
</script>
|