api-client/components/collections/editCollection.vue

82 lines
1.8 KiB
Vue
Raw Normal View History

<template>
2019-12-17 19:13:15 +00:00
<modal v-if="show" @close="hideModal">
2019-10-25 08:14:34 +00:00
<div slot="header">
<ul>
<li>
<div class="flex-wrap">
<h3 class="title">{{ $t("edit_collection") }}</h3>
2019-10-25 08:14:34 +00:00
<div>
2019-12-17 19:13:15 +00:00
<button class="icon" @click="hideModal">
2019-10-25 08:14:34 +00:00
<i class="material-icons">close</i>
</button>
</div>
2019-10-25 08:14:34 +00:00
</div>
</li>
</ul>
</div>
<div slot="body">
<ul>
<li>
2019-11-12 04:52:50 +00:00
<input
type="text"
v-model="name"
:placeholder="editingCollection.name"
2019-11-12 04:52:50 +00:00
@keyup.enter="saveCollection"
/>
2019-10-25 08:14:34 +00:00
</li>
</ul>
</div>
2019-10-25 08:14:34 +00:00
<div slot="footer">
2019-12-17 19:13:15 +00:00
<div class="flex-wrap">
<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="saveCollection">
{{ $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>
2019-11-02 05:32:21 +00:00
export default {
props: {
show: Boolean,
editingCollection: Object,
2020-02-24 18:44:50 +00:00
editingCollectionIndex: Number,
2019-11-02 05:32:21 +00:00
},
components: {
modal: () => import("../../components/modal"),
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
},
methods: {
saveCollection() {
if (!this.$data.name) {
this.$toast.info($t("invalid_collection_name"))
2020-02-24 18:44:50 +00:00
return
}
2019-11-02 05:32:21 +00:00
const collectionUpdated = {
...this.$props.editingCollection,
2020-02-24 18:44:50 +00:00
name: this.$data.name,
}
this.$store.commit("postwoman/editCollection", {
2019-11-02 05:32:21 +00:00
collection: collectionUpdated,
2020-02-24 18:44:50 +00:00
collectionIndex: this.$props.editingCollectionIndex,
})
this.$emit("hide-modal")
},
2019-12-17 19:13:15 +00:00
hideModal() {
this.$emit("hide-modal")
2020-02-24 18:44:50 +00:00
},
},
}
</script>