From cc65b6584015591b1df2d8b4e9a1351d50a95fe7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sat, 18 Sep 2021 23:01:37 +0200 Subject: [PATCH 1/8] Implement id instead of index to manage routes --- src/components/RouteBlock.vue | 30 ++++++++-------- src/components/RouteBlockCollection.vue | 4 +-- src/store/routeCollection.js | 48 +++++++++++++++---------- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/components/RouteBlock.vue b/src/components/RouteBlock.vue index 6c94823..4e966d5 100644 --- a/src/components/RouteBlock.vue +++ b/src/components/RouteBlock.vue @@ -28,7 +28,7 @@ class="request-response"> - + @@ -39,7 +39,7 @@ import axios from 'axios'; export default { name: 'RouteBlock', props: { - idx: { + id: { type: Number, required: true, }, @@ -57,11 +57,11 @@ export default { }), routeVerb: { get() { - return this.$store.getters.routeData(this.idx).routeVerb; + return this.$store.getters.routeData(this.id).routeVerb; }, set(value) { const data = { - idx: this.idx, + id: this.id, routeVerb: value, }; @@ -70,11 +70,11 @@ export default { }, routePath: { get() { - return this.$store.getters.routeData(this.idx).routePath; + return this.$store.getters.routeData(this.id).routePath; }, set(value) { const data = { - idx: this.idx, + id: this.id, routePath: value, }; @@ -83,11 +83,11 @@ export default { }, routeBody: { get() { - return this.$store.getters.routeData(this.idx).routeBody; + return this.$store.getters.routeData(this.id).routeBody; }, set(value) { const data = { - idx: this.idx, + id: this.id, routeBody: value, }; @@ -97,14 +97,14 @@ export default { apiResponse: { get() { const key = this.$store.getters.displayOnlyKey; - if (key && this.$store.getters.routeData(this.idx).apiResponse[key]) { - return this.$store.getters.routeData(this.idx).apiResponse[key]; + if (key && this.$store.getters.routeData(this.id).apiResponse[key]) { + return this.$store.getters.routeData(this.id).apiResponse[key]; } - return this.$store.getters.routeData(this.idx).apiResponse; + return this.$store.getters.routeData(this.id).apiResponse; }, set(value) { const data = { - idx: this.idx, + id: this.id, apiResponse: value, }; @@ -112,7 +112,7 @@ export default { }, }, apiResponseStatus() { - return this.$store.getters.routeDataStatus(this.idx); + return this.$store.getters.routeDataStatus(this.id); }, apiResponseAsText() { if (this.apiResponse === '') { return null; } @@ -150,10 +150,10 @@ export default { }); }, cleanResponse() { - this.$store.dispatch('CLEAN_RESPONSE', this.idx); + this.$store.dispatch('CLEAN_RESPONSE', this.id); }, deleteRoute() { - this.$store.dispatch('DELETE_ROUTE', this.idx); + this.$store.dispatch('DELETE_ROUTE', this.id); }, }, }; diff --git a/src/components/RouteBlockCollection.vue b/src/components/RouteBlockCollection.vue index 8c682e1..26ea246 100644 --- a/src/components/RouteBlockCollection.vue +++ b/src/components/RouteBlockCollection.vue @@ -1,7 +1,7 @@