api-client/components/collections/EditFolder.vue

86 lines
2 KiB
Vue
Raw Normal View History

<template>
<SmartModal v-if="show" @close="show = false">
2019-10-25 08:14:34 +00:00
<div slot="header">
2020-12-11 10:29:03 +00:00
<div class="row-wrapper">
<h3 class="title">{{ $t("edit_folder") }}</h3>
<div>
<button class="icon" @click="hideModal">
<i class="material-icons">close</i>
</button>
</div>
</div>
2019-10-25 08:14:34 +00:00
</div>
2020-12-11 16:54:34 +00:00
<div slot="body" class="flex flex-col">
2020-12-11 10:29:03 +00:00
<label for="selectLabel">{{ $t("label") }}</label>
<input
type="text"
id="selectLabel"
v-model="name"
:placeholder="folder.name"
@keyup.enter="editFolder"
/>
2019-10-25 08:14:34 +00:00
</div>
<div slot="footer">
2020-09-22 17:06:37 +00:00
<div class="row-wrapper">
2019-12-17 19:13:15 +00:00
<span></span>
<span>
<button class="icon" @click="hideModal">
{{ $t("cancel") }}
2019-10-25 08:14:34 +00:00
</button>
2019-12-17 19:13:15 +00:00
<button class="icon primary" @click="editFolder">
{{ $t("save") }}
2019-12-17 19:13:15 +00:00
</button>
</span>
</div>
2019-10-25 08:14:34 +00:00
</div>
</SmartModal>
</template>
<script>
import { fb } from "~/helpers/fb"
import { getSettingSubject } from "~/newstore/settings"
2019-11-02 05:32:21 +00:00
export default {
props: {
show: Boolean,
collectionIndex: Number,
folder: Object,
2020-02-24 18:44:50 +00:00
folderIndex: Number,
2019-11-02 05:32:21 +00:00
},
data() {
return {
2020-02-24 18:44:50 +00:00
name: undefined,
}
2019-11-02 05:32:21 +00:00
},
subscriptions() {
return {
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
}
},
2019-11-02 05:32:21 +00:00
methods: {
syncCollections() {
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
fb.writeCollections(
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
"collections"
)
}
},
2019-11-02 05:32:21 +00:00
editFolder() {
this.$store.commit("postwoman/editFolder", {
2019-11-02 05:32:21 +00:00
collectionIndex: this.$props.collectionIndex,
folder: { ...this.$props.folder, name: this.$data.name },
2020-02-24 18:44:50 +00:00
folderIndex: this.$props.folderIndex,
folderName: this.$props.folder.name,
2021-03-18 14:55:12 +00:00
flag: "rest",
2020-02-24 18:44:50 +00:00
})
this.hideModal()
2020-06-19 06:56:04 +00:00
this.syncCollections()
},
2019-11-02 05:32:21 +00:00
hideModal() {
this.$emit("hide-modal")
2020-02-24 18:44:50 +00:00
},
},
}
</script>