mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:57:08 +00:00
Refactor configuration GUI.
Another refactoring. What we're doing now is eliminating the need to save individually on each section. Configuration changes are done directly on the local configuration and then the local configuration is saved, downloaded or discarded in one go.
This commit is contained in:
@@ -8,19 +8,20 @@
|
||||
label="Pattern"
|
||||
hint="Regular expression text"
|
||||
persistent-hint
|
||||
v-model="regex_"
|
||||
v-model="cwo.pattern.regex"
|
||||
>
|
||||
</v-text-field>
|
||||
<v-text-field
|
||||
label="Flags"
|
||||
hint="Regular expression modifier flags"
|
||||
persistent-hint
|
||||
v-model="flags_"
|
||||
v-model="cwo.pattern.flags"
|
||||
>
|
||||
</v-text-field>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<!--
|
||||
<v-btn
|
||||
color="primary"
|
||||
@click="save"
|
||||
@@ -30,6 +31,7 @@
|
||||
color="warning"
|
||||
@click="reset"
|
||||
>Reset</v-btn>
|
||||
-->
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="secondary"
|
||||
@@ -40,25 +42,51 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { deepCompare, deepMerge } from '@/lib/utils';
|
||||
import setIfDifferent from '@/lib/watcher-mixin';
|
||||
import { deepSet } from '@/lib/utils';
|
||||
|
||||
export default {
|
||||
name: "DougalProjectSettingsRawNTBP",
|
||||
|
||||
mixins: [
|
||||
setIfDifferent({
|
||||
regex: "regex_",
|
||||
flags: "flags_"
|
||||
})
|
||||
],
|
||||
|
||||
props: [ "regex", "flags" ],
|
||||
props: {
|
||||
value: Object
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
regex_: "NTBP",
|
||||
flags_: "i"
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
// Current working object.
|
||||
// A shortcut so we don't have to specify the full path
|
||||
// on every input control. It also makes it easier to
|
||||
// change that path if necessary. Finally, it ensures that
|
||||
// the properties being modified are always available.
|
||||
cwo: {
|
||||
|
||||
get () {
|
||||
if (this.value) {
|
||||
if (!this.value?.raw?.ntbp.pattern) {
|
||||
deepSet(this.value, [ "raw", "ntbp", "pattern" ], {
|
||||
flags: "i",
|
||||
regex: "NTBP"
|
||||
});
|
||||
}
|
||||
return this.value.raw.ntbp;
|
||||
} else {
|
||||
return {
|
||||
flags: "i",
|
||||
regex: "NTBP"
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
set (v) {
|
||||
if (this.value) {
|
||||
deepSet(this.value, [ "raw", "ntbp", "pattern" ], v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
@@ -68,16 +96,9 @@ export default {
|
||||
methods: {
|
||||
|
||||
reset () {
|
||||
this.regex_ = this.regex;
|
||||
this.flags_ = this.flags;
|
||||
},
|
||||
|
||||
save () {
|
||||
this.$emit('merge', [ ["raw", "ntbp"], {
|
||||
regex: this.regex_,
|
||||
flags: this.flags_
|
||||
}]);
|
||||
this.$nextTick(this.reset);
|
||||
},
|
||||
|
||||
back () {
|
||||
|
||||
Reference in New Issue
Block a user