-
Add New Collection
+
Add New Collection
+
Edit Collection
@@ -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');
},
diff --git a/components/collections/collection.vue b/components/collections/collection.vue
index a86cc16a5..3cec68711 100644
--- a/components/collections/collection.vue
+++ b/components/collections/collection.vue
@@ -12,13 +12,15 @@
+
e
+
x
+
@@ -94,6 +96,18 @@ export default {
});
this.showModal = false;
},
+ editCollection() {
+ this.$emit('edit-collection', {
+ collectionIndex: this.collectionIndex,
+ collection: this.collection,
+ });
+ },
+ removeCollection() {
+ if (!confirm("Are you sure you want to remove this collection?")) return;
+ this.$store.commit('postwoman/removeCollection', {
+ collectionIndex: this.collectionIndex,
+ });
+ },
}
};
\ No newline at end of file
diff --git a/components/collections/folder.vue b/components/collections/folder.vue
index e4215d82b..36d88ea56 100644
--- a/components/collections/folder.vue
+++ b/components/collections/folder.vue
@@ -4,6 +4,7 @@
arrow_right
arrow_drop_down
{{folder.name}}
+
x
@@ -30,6 +31,14 @@
display: flex;
align-items: center;
}
+
+ .add-button {
+ padding: 0;
+ width: 20px;
+ margin: 0;
+ height: 20px;
+ border-radius: 50%;
+ }
\ No newline at end of file
diff --git a/components/collections/index.vue b/components/collections/index.vue
index 74aa9464b..fbf59c7c0 100644
--- a/components/collections/index.vue
+++ b/components/collections/index.vue
@@ -3,7 +3,10 @@
+ v-on:hide-model='toggleModal'
+ v-bind:editing-collection="selectedCollection"
+ v-on:saved-collection="savedCollection"
+ >
@@ -52,6 +59,7 @@
data() {
return {
showAddModel: false,
+ selectedCollection: {},
}
},
computed: {
@@ -67,6 +75,16 @@
this.$store.commit('postwoman/addCollection', newCollection);
this.showAddModel = false;
},
+ editCollection(payload) {
+ const { collection, collectionIndex } = payload;
+ this.selectedCollection = Object.assign({ collectionIndex }, collection);
+ this.showAddModel = true;
+ },
+ savedCollection(savedCollection) {
+ this.$store.commit('postwoman/saveCollection', { savedCollection });
+ this.showAddModel = false;
+ this.selectedCollection = {};
+ },
},
}
diff --git a/store/postwoman.js b/store/postwoman.js
index e084faab0..c8e91cb1f 100644
--- a/store/postwoman.js
+++ b/store/postwoman.js
@@ -80,11 +80,27 @@ export const mutations = {
state.collections.push(newCollection);
},
+ removeCollection (state, payload) {
+ const { collectionIndex } = payload;
+ state.collections.splice(collectionIndex, 1)
+ },
+
+ saveCollection (state, payload) {
+ const { savedCollection } = payload;
+ state.collections[savedCollection.collectionIndex] = savedCollection;
+ },
+
addFolder (state, payload) {
const { collectionIndex, folder } = payload;
state.collections[collectionIndex].folders.push(folder);
},
+ removeFolder (state, payload) {
+ const { collectionIndex, folderIndex } = payload;
+ console.log(collectionIndex)
+ state.collections[collectionIndex].folders.splice(folderIndex, 1)
+ },
+
addRequest (state, payload) {
const { collectionIndex, folderIndex, request } = payload;
state.collections[collectionIndex].folders[folderIndex].push(request);