From 2853a4bbef8e3ded138d7dcb4be8d074a08a6907 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 21 Jan 2020 16:37:04 +0530 Subject: [PATCH 1/5] fix: validation for duplicate collections --- store/postwoman.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/store/postwoman.js b/store/postwoman.js index bf5881268..895464977 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -111,6 +111,10 @@ export const mutations = { }, addNewCollection({ collections }, collection) { + const duplicateCollection = collections.some(item => item.name === collection.name) + if (duplicateCollection) { + alert('Duplicate collection'); + } collections.push({ name: "", folders: [], From a34acfd0c53b79227ddc5f9edfdd003278ba7108 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 21 Jan 2020 16:38:09 +0530 Subject: [PATCH 2/5] fix: return for duplicate collection --- store/postwoman.js | 1 + 1 file changed, 1 insertion(+) diff --git a/store/postwoman.js b/store/postwoman.js index 895464977..dabaf781b 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -114,6 +114,7 @@ export const mutations = { const duplicateCollection = collections.some(item => item.name === collection.name) if (duplicateCollection) { alert('Duplicate collection'); + return; } collections.push({ name: "", From fcdf93c5e55683f8f02edd450c7e76a2fa9c88ec Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 21 Jan 2020 16:38:34 +0530 Subject: [PATCH 3/5] fix: prefer destructuring approach --- store/postwoman.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/store/postwoman.js b/store/postwoman.js index dabaf781b..df7399d31 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -111,7 +111,8 @@ export const mutations = { }, addNewCollection({ collections }, collection) { - const duplicateCollection = collections.some(item => item.name === collection.name) + const { name } = collection + const duplicateCollection = collections.some(item => item.name === name) if (duplicateCollection) { alert('Duplicate collection'); return; From e16019dcbf0c939305fecd79a32cb37f6ea80741 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 21 Jan 2020 19:45:52 +0530 Subject: [PATCH 4/5] chore: make use of toast --- store/postwoman.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/store/postwoman.js b/store/postwoman.js index df7399d31..d07d70957 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -114,8 +114,7 @@ export const mutations = { const { name } = collection const duplicateCollection = collections.some(item => item.name === name) if (duplicateCollection) { - alert('Duplicate collection'); - return; + this.$toast.info('Duplicate collection'); } collections.push({ name: "", From bb973ee449cf2f44bb95e558b2e2e69a23d042f2 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 21 Jan 2020 19:46:33 +0530 Subject: [PATCH 5/5] fix: prevent creation of duplicate collection --- store/postwoman.js | 1 + 1 file changed, 1 insertion(+) diff --git a/store/postwoman.js b/store/postwoman.js index d07d70957..61712fb65 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -115,6 +115,7 @@ export const mutations = { const duplicateCollection = collections.some(item => item.name === name) if (duplicateCollection) { this.$toast.info('Duplicate collection'); + return; } collections.push({ name: "",