From 8091e2884bbeb6f2235322b1376fe9bf537fc740 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 22 Aug 2021 11:52:28 +0200 Subject: [PATCH 1/4] Add auto save for route verb in block --- src/components/RouteBlock.vue | 16 +++++++++++++--- src/store/routeCollection.js | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/RouteBlock.vue b/src/components/RouteBlock.vue index d28a84e..caa663a 100644 --- a/src/components/RouteBlock.vue +++ b/src/components/RouteBlock.vue @@ -40,13 +40,11 @@ export default { }, created() { const a = this.$store.getters.routeData(this.idx); - this.routeVerb = a.routeVerb; this.routePath = a.routePath; this.routeBody = a.routeBody; }, data() { return { - routeVerb: '', routePath: '', routeBody: '', apiResponse: '', @@ -56,10 +54,22 @@ export default { routeDataStore() { return this.$store.getters.routeData(this.idx); }, + routeVerb: { + get() { + return this.$store.getters.routeData(this.idx).routeVerb; + }, + set(value) { + const data = { + idx: this.idx, + routeVerb: value, + }; + + this.$store.commit('UPDATE_ROUTE_VERB', data); + }, + }, }, watch: { routeDataStore(nVal) { - this.routeVerb = nVal.routeVerb; this.routePath = nVal.routePath; this.routeBody = nVal.routeBody; }, diff --git a/src/store/routeCollection.js b/src/store/routeCollection.js index d0e67a1..555f0d1 100644 --- a/src/store/routeCollection.js +++ b/src/store/routeCollection.js @@ -33,6 +33,11 @@ export default { DELETE_ROUTE(state, idx) { state.routeCollection.splice(idx, 1); }, + UPDATE_ROUTE_VERB(state, data) { + const elem = state.routeCollection[data.idx]; + elem.routeVerb = data.routeVerb; + Vue.set(state.routeCollection, data.idx, elem); + }, }, actions: { ADD_ROUTE({ commit }) { -- GitLab From b5fc913c3050cd819cbb0387984a6fffdb78c946 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 22 Aug 2021 12:01:14 +0200 Subject: [PATCH 2/4] Auto save route path --- src/components/RouteBlock.vue | 16 +++++++++++++--- src/store/routeCollection.js | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/RouteBlock.vue b/src/components/RouteBlock.vue index caa663a..f9151f3 100644 --- a/src/components/RouteBlock.vue +++ b/src/components/RouteBlock.vue @@ -40,12 +40,10 @@ export default { }, created() { const a = this.$store.getters.routeData(this.idx); - this.routePath = a.routePath; this.routeBody = a.routeBody; }, data() { return { - routePath: '', routeBody: '', apiResponse: '', }; @@ -67,10 +65,22 @@ export default { this.$store.commit('UPDATE_ROUTE_VERB', data); }, }, + routePath: { + get() { + return this.$store.getters.routeData(this.idx).routePath; + }, + set(value) { + const data = { + idx: this.idx, + routePath: value, + }; + + this.$store.commit('UPDATE_ROUTE_PATH', data); + }, + }, }, watch: { routeDataStore(nVal) { - this.routePath = nVal.routePath; this.routeBody = nVal.routeBody; }, }, diff --git a/src/store/routeCollection.js b/src/store/routeCollection.js index 555f0d1..63a3449 100644 --- a/src/store/routeCollection.js +++ b/src/store/routeCollection.js @@ -34,9 +34,19 @@ export default { state.routeCollection.splice(idx, 1); }, UPDATE_ROUTE_VERB(state, data) { - const elem = state.routeCollection[data.idx]; - elem.routeVerb = data.routeVerb; - Vue.set(state.routeCollection, data.idx, elem); + const payload = state.routeCollection[data.idx]; + payload.routeVerb = data.routeVerb; + Vue.set(state.routeCollection, data.idx, payload); + }, + UPDATE_ROUTE_PATH(state, data) { + const payload = state.routeCollection[data.idx]; + payload.routePath = data.routePath; + Vue.set(state.routeCollection, data.idx, payload); + }, + UPDATE_ROUTE_BODY(state, data) { + const payload = state.routeCollection[data.idx]; + payload.routeBody = data.routeBody; + Vue.set(state.routeCollection, data.idx, payload); }, }, actions: { -- GitLab From c08a29f689686b354ef4b3384fd27145f80ca66a Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 22 Aug 2021 12:05:23 +0200 Subject: [PATCH 3/4] Auto save body --- src/components/RouteBlock.vue | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/RouteBlock.vue b/src/components/RouteBlock.vue index f9151f3..950d6d3 100644 --- a/src/components/RouteBlock.vue +++ b/src/components/RouteBlock.vue @@ -38,13 +38,8 @@ export default { required: true, }, }, - created() { - const a = this.$store.getters.routeData(this.idx); - this.routeBody = a.routeBody; - }, data() { return { - routeBody: '', apiResponse: '', }; }, @@ -78,10 +73,18 @@ export default { this.$store.commit('UPDATE_ROUTE_PATH', data); }, }, - }, - watch: { - routeDataStore(nVal) { - this.routeBody = nVal.routeBody; + routeBody: { + get() { + return this.$store.getters.routeData(this.idx).routeBody; + }, + set(value) { + const data = { + idx: this.idx, + routeBody: value, + }; + + this.$store.commit('UPDATE_ROUTE_BODY', data); + }, }, }, methods: { -- GitLab From d8b47f34925e0b4960a0097df57541fab10ef892 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 22 Aug 2021 12:07:42 +0200 Subject: [PATCH 4/4] Delete save button (we have auto save now) --- src/components/RouteBlock.vue | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/components/RouteBlock.vue b/src/components/RouteBlock.vue index 950d6d3..30d4f40 100644 --- a/src/components/RouteBlock.vue +++ b/src/components/RouteBlock.vue @@ -14,7 +14,6 @@ - @@ -44,9 +43,6 @@ export default { }; }, computed: { - routeDataStore() { - return this.$store.getters.routeData(this.idx); - }, routeVerb: { get() { return this.$store.getters.routeData(this.idx).routeVerb; @@ -99,15 +95,6 @@ export default { this.apiResponse = JSON.stringify(res); }); }, - saveData() { - this.$store.dispatch('UPDATE_ROUTE', - { - idx: this.idx, - routeVerb: this.routeVerb, - routePath: this.routePath, - routeBody: this.routeBody, - }); - }, deleteRoute() { this.$store.dispatch('DELETE_ROUTE', this.idx); }, -- GitLab