From 462d17de17ecb73edcdbbc9381f9745c98a054db Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Sun, 1 Aug 2021 15:01:31 +0530 Subject: [PATCH] feat: auto increment headers and parameters list on input --- components/http/Headers.vue | 27 +++++++++++++++------------ components/http/Parameters.vue | 25 +++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/components/http/Headers.vue b/components/http/Headers.vue index d632406ef..ffed0e988 100644 --- a/components/http/Headers.vue +++ b/components/http/Headers.vue @@ -168,6 +168,7 @@ export default { data() { return { commonHeaders, + headers$: [], } }, subscriptions() { @@ -178,18 +179,20 @@ export default { ), } }, - // watch: { - // headers: { - // handler(newValue) { - // if ( - // newValue[newValue.length - 1]?.key !== "" || - // newValue[newValue.length - 1]?.value !== "" - // ) - // this.addRequestHeader() - // }, - // deep: true, - // }, - // }, + watch: { + headers$: { + handler(newValue) { + console.log("changed") + if ( + (newValue[newValue.length - 1]?.key !== "" || + newValue[newValue.length - 1]?.value !== "") && + newValue.length + ) + this.addHeader() + }, + deep: true, + }, + }, mounted() { if (!this.headers$?.length) { this.addHeader() diff --git a/components/http/Parameters.vue b/components/http/Parameters.vue index 96234896b..18e906c00 100644 --- a/components/http/Parameters.vue +++ b/components/http/Parameters.vue @@ -197,18 +197,19 @@ export default { ), } }, - // watch: { - // params$: { - // handler(newValue) { - // if ( - // newValue[newValue.length - 1]?.key !== "" || - // newValue[newValue.length - 1]?.value !== "" - // ) - // this.addParam() - // }, - // deep: true, - // }, - // }, + watch: { + params$: { + handler(newValue) { + if ( + (newValue[newValue.length - 1]?.key !== "" || + newValue[newValue.length - 1]?.value !== "") && + newValue.length + ) + this.addParam() + }, + deep: true, + }, + }, mounted() { if (!this.params$?.length) { this.addParam()