api-client/components/collections/addCollection.vue

95 lines
2.8 KiB
Vue
Raw Normal View History

2019-10-01 22:20:23 +00:00
<template>
<div>
<modal v-if="show" @close="hideModel">
<div slot="header">
<ul>
<li>
<div class="flex-wrap">
2019-10-16 13:11:34 +00:00
<h3 class="title" v-if='!newCollection.hasOwnProperty("collectionIndex")'>Add New Collection</h3>
<h3 class="title" v-if='newCollection.hasOwnProperty("collectionIndex")'>Edit Collection</h3>
2019-10-01 22:20:23 +00:00
<div>
<button class="icon" @click="hideModel">
<i class="material-icons">close</i>
</button>
</div>
</div>
</li>
</ul>
</div>
<div slot="body">
<ul>
<li>
2019-10-22 15:57:48 +00:00
<input type="text" v-model="newCollection.name" placeholder="My New Collection" />
2019-10-01 22:20:23 +00:00
</li>
</ul>
</div>
<div slot="footer">
2019-10-22 12:02:26 +00:00
<ul>
<li>
<button class="icon" @click="addNewCollection" v-if='!newCollection.hasOwnProperty("collectionIndex")'>
<i class="material-icons">add</i>
<span>Create</span>
</button>
<button class="icon" @click="saveCollection" v-if='newCollection.hasOwnProperty("collectionIndex")'>
<i class="material-icons">save</i>
<span>Save</span>
</button>
</li>
</ul>
2019-10-01 22:20:23 +00:00
</div>
</modal>
</div>
</template>
<script>
import modal from "../../components/modal";
export default {
props: {
show: Boolean,
2019-10-16 13:11:34 +00:00
editingCollection: Object,
2019-10-01 22:20:23 +00:00
},
components: {
modal,
},
data() {
return {
newCollection: {
name: '',
folders: [],
requests: [],
},
}
},
2019-10-16 13:11:34 +00:00
watch: {
show() {
2019-10-22 04:50:09 +00:00
if (!this.editingCollection.collectionIndex) return;
2019-10-16 13:11:34 +00:00
this.newCollection = Object.assign({}, this.editingCollection);
},
},
2019-10-01 22:20:23 +00:00
methods: {
addNewCollection() {
const newCollection = Object.assign({}, this.newCollection);
this.$emit('new-collection', newCollection);
this.newCollection = {
name: '',
folders: [],
requests: [],
};
},
2019-10-16 13:11:34 +00:00
saveCollection() {
const savedCollection = Object.assign({}, this.newCollection);
this.$emit('saved-collection', savedCollection);
this.newCollection = {
name: '',
folders: [],
requests: [],
};
},
2019-10-01 22:20:23 +00:00
hideModel() {
this.$emit('hide-model');
},
},
};
2019-10-22 12:02:26 +00:00
</script>