Refactor <dougal-project-settings-name-id/>

This commit is contained in:
D. Berge
2023-11-13 21:08:06 +01:00
parent 399e86be87
commit d1c041995d

View File

@@ -8,14 +8,14 @@
label="ID"
hint="Short survey ID"
persistent-hint
v-model="id"
v-model="id_"
>
</v-text-field>
<v-text-field
label="Name"
hint="Survey name"
persistent-hint
v-model="name"
v-model="name_"
>
</v-text-field>
</v-form>
@@ -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 () {