Merge pull request #516 from liyasthomas/hotfix/validate-collections

Validations for edit and create collections activity
This commit is contained in:
James George
2020-01-23 15:10:47 +05:30
committed by GitHub
3 changed files with 14 additions and 0 deletions

View File

@@ -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
});

View File

@@ -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

View File

@@ -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;
},