Merge pull request #516 from liyasthomas/hotfix/validate-collections
Validations for edit and create collections activity
This commit is contained in:
@@ -56,6 +56,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addNewCollection() {
|
addNewCollection() {
|
||||||
|
if (!this.$data.name) {
|
||||||
|
this.$toast.info('Please provide a valid name for the collection')
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$store.commit("postwoman/addNewCollection", {
|
this.$store.commit("postwoman/addNewCollection", {
|
||||||
name: this.$data.name
|
name: this.$data.name
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
saveCollection() {
|
saveCollection() {
|
||||||
|
if (!this.$data.name) {
|
||||||
|
this.$toast.info('Please provide a valid name for the collection');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const collectionUpdated = {
|
const collectionUpdated = {
|
||||||
...this.$props.editingCollection,
|
...this.$props.editingCollection,
|
||||||
name: this.$data.name
|
name: this.$data.name
|
||||||
|
|||||||
@@ -132,6 +132,12 @@ export const mutations = {
|
|||||||
|
|
||||||
editCollection({ collections }, payload) {
|
editCollection({ collections }, payload) {
|
||||||
const { collection, collectionIndex } = payload;
|
const { collection, collectionIndex } = payload;
|
||||||
|
const { name } = collection
|
||||||
|
const duplicateCollection = collections.some(item => item.name === name)
|
||||||
|
if (duplicateCollection) {
|
||||||
|
this.$toast.info('Duplicate collection');
|
||||||
|
return;
|
||||||
|
}
|
||||||
collections[collectionIndex] = collection;
|
collections[collectionIndex] = collection;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user