Added edit and remove collection.

This commit is contained in:
Keith Holliday
2019-10-16 07:11:34 -06:00
parent 18a0c391f6
commit ed53b433b5
5 changed files with 88 additions and 6 deletions

View File

@@ -5,7 +5,8 @@
<ul>
<li>
<div class="flex-wrap">
<h3 class="title">Add New Collection</h3>
<h3 class="title" v-if='!newCollection.hasOwnProperty("collectionIndex")'>Add New Collection</h3>
<h3 class="title" v-if='newCollection.hasOwnProperty("collectionIndex")'>Edit Collection</h3>
<div>
<button class="icon" @click="hideModel">
<i class="material-icons">close</i>
@@ -18,12 +19,13 @@
<div slot="body">
<ul>
<li>
<input type="text" v-model="newCollection.name" placeholder="My New Collection" />
<input type="text" v-model="newCollection.name" placeholder="My New Collection" />
</li>
</ul>
</div>
<div slot="footer">
<button @click="addNewCollection">Add</button>
<button @click="addNewCollection" v-if='!newCollection.hasOwnProperty("collectionIndex")'>Add</button>
<button @click="saveCollection" v-if='newCollection.hasOwnProperty("collectionIndex")'>Save</button>
</div>
</modal>
</div>
@@ -35,6 +37,7 @@ import modal from "../../components/modal";
export default {
props: {
show: Boolean,
editingCollection: Object,
},
components: {
modal,
@@ -48,6 +51,12 @@ export default {
},
}
},
watch: {
show() {
if (!this.editingCollection.collectionIndex);
this.newCollection = Object.assign({}, this.editingCollection);
},
},
methods: {
addNewCollection() {
const newCollection = Object.assign({}, this.newCollection);
@@ -58,6 +67,15 @@ export default {
requests: [],
};
},
saveCollection() {
const savedCollection = Object.assign({}, this.newCollection);
this.$emit('saved-collection', savedCollection);
this.newCollection = {
name: '',
folders: [],
requests: [],
};
},
hideModel() {
this.$emit('hide-model');
},