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: {
|
||||
addNewCollection() {
|
||||
if (!this.$data.name) {
|
||||
this.$toast.info('Please provide a valid name for the collection')
|
||||
return;
|
||||
}
|
||||
this.$store.commit("postwoman/addNewCollection", {
|
||||
name: this.$data.name
|
||||
});
|
||||
|
||||
@@ -59,6 +59,10 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
saveCollection() {
|
||||
if (!this.$data.name) {
|
||||
this.$toast.info('Please provide a valid name for the collection');
|
||||
return;
|
||||
}
|
||||
const collectionUpdated = {
|
||||
...this.$props.editingCollection,
|
||||
name: this.$data.name
|
||||
|
||||
@@ -132,6 +132,12 @@ export const mutations = {
|
||||
|
||||
editCollection({ collections }, 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;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user