api-client/components/collections/edit-request.vue

89 lines
2.1 KiB
Vue
Raw Normal View History

<template>
2019-10-25 08:14:34 +00:00
<modal v-if="show" @close="hideModal">
<div slot="header">
2020-12-11 10:29:03 +00:00
<div class="row-wrapper">
<h3 class="title">{{ $t("edit_request") }}</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">
<label for="selectLabel">{{ $t("label") }}</label>
<input
type="text"
id="selectLabel"
v-model="requestUpdateData.name"
@keyup.enter="saveRequest"
:placeholder="request.name"
/>
</div>
2019-10-25 08:14:34 +00:00
<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="saveRequest">
{{ $t("save") }}
2019-12-17 19:13:15 +00:00
</button>
</span>
</div>
2019-10-25 08:14:34 +00:00
</div>
</modal>
</template>
<script>
import { fb } from "~/helpers/fb"
2019-11-02 05:32:21 +00:00
export default {
props: {
show: Boolean,
collectionIndex: Number,
folderIndex: Number,
folderName: String,
2019-11-02 05:32:21 +00:00
request: Object,
2020-02-24 18:44:50 +00:00
requestIndex: Number,
2019-11-02 05:32:21 +00:00
},
data() {
return {
requestUpdateData: {
name: undefined,
2020-02-24 18:44:50 +00:00
},
}
2019-11-02 05:32:21 +00:00
},
methods: {
syncCollections() {
if (fb.currentUser !== null && fb.currentSettings[0]) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
2019-11-02 05:32:21 +00:00
saveRequest() {
const requestUpdated = {
...this.$props.request,
name: this.$data.requestUpdateData.name || this.$props.request.name,
2020-02-24 18:44:50 +00:00
}
this.$store.commit("postwoman/editRequest", {
requestCollectionIndex: this.$props.collectionIndex,
requestFolderName: this.$props.folderName,
requestFolderIndex: this.$props.folderIndex,
2019-11-02 05:32:21 +00:00
requestNew: requestUpdated,
requestIndex: this.$props.requestIndex,
2020-02-24 18:44:50 +00:00
})
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>