From d1c041995d53d7709cbcfdeaf4803b2cb700e390 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Mon, 13 Nov 2023 21:08:06 +0100 Subject: [PATCH] Refactor --- .../components/project-settings/name-id.vue | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/www/client/source/src/components/project-settings/name-id.vue b/lib/www/client/source/src/components/project-settings/name-id.vue index 62c91f1..d60f27c 100644 --- a/lib/www/client/source/src/components/project-settings/name-id.vue +++ b/lib/www/client/source/src/components/project-settings/name-id.vue @@ -8,14 +8,14 @@ label="ID" hint="Short survey ID" persistent-hint - v-model="id" + v-model="id_" > @@ -44,31 +44,41 @@ export default { name: "DougalProjectSettingsNameId", - props: [ "value" ], + props: { + id: String, + name: String + }, data () { return { - id: "", - name: "" + id_: "", + name_: "" } }, watch: { - value (newValue) { - this.reset(); + id () { + if (this.id != this.id_) { + this.id_ = this.id; + } + }, + + name () { + if (this.name != this.name_) { + this.name_ = this.name; + } } }, methods: { reset () { - for (const key of Object.keys(this.$data)) { - this[key] = this.value[key]; - } + this.id_ = this.id; + this.name_ = this.name; }, save () { - this.$emit('input', {...this.$data}); + this.$emit('input', {id: this.id_, name: this.name_}); }, back () {