mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:37:08 +00:00
Refactor <dougal-project-settings-raw-p111/>.
Use fixed width name decoding instead of regular expression.
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<dougal-project-settings-file-matching-parameters
|
||||
:value="value" title="Raw P1/11" subtitle="Raw P1/11 files location and parameters."
|
||||
title="Raw P1/11"
|
||||
subtitle="Raw P1/11 files location and parameters."
|
||||
v-bind="{rootPath}"
|
||||
v-bind.sync="bind"
|
||||
:is-valid="isValid"
|
||||
:save="save"
|
||||
>
|
||||
</dougal-project-settings-file-matching-parameters>
|
||||
|
||||
@@ -14,6 +19,8 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { deepCompare, deepMerge } from '@/lib/utils';
|
||||
import setIfDifferent from '@/lib/watcher-mixin';
|
||||
import DougalProjectSettingsFileMatchingParameters from '@/components/project-settings/file-matching-parameters';
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
|
||||
@@ -24,49 +31,106 @@ export default {
|
||||
DougalProjectSettingsFileMatchingParameters
|
||||
},
|
||||
|
||||
props: [ "value", "title", "subtitle" ],
|
||||
mixins: [
|
||||
setIfDifferent({
|
||||
globs: "globs_",
|
||||
paths: "paths_",
|
||||
pattern: "pattern_",
|
||||
lineNameInfo: "lineNameInfo_"
|
||||
})
|
||||
],
|
||||
|
||||
props: {
|
||||
title: String,
|
||||
subtitle: String,
|
||||
rootPath: String,
|
||||
paths: Array,
|
||||
globs: Array,
|
||||
lineNameInfo: Object,
|
||||
pattern: Object
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
tab: null,
|
||||
globs: [],
|
||||
paths: [],
|
||||
pattern: {
|
||||
flags: "i",
|
||||
regex: null,
|
||||
captures: []
|
||||
}
|
||||
paths_: [],
|
||||
globs_: [],
|
||||
pattern_: {},
|
||||
lineNameInfo_: {}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
||||
bind () {
|
||||
return {
|
||||
globs: this.globs_,
|
||||
paths: this.paths_,
|
||||
pattern: this.pattern_,
|
||||
lineNameInfo: this.lineNameInfo_
|
||||
};
|
||||
},
|
||||
|
||||
isValid () {
|
||||
return false;
|
||||
// return this.preplots && this.preplots.every( item => item.format != null );
|
||||
return !!(this.paths_.length && this.globs_.length && (
|
||||
this.pattern_?.regex &&
|
||||
["direction", "line", "sequence"].every( i => this.pattern_?.captures?.includes(i) )) || (
|
||||
this.lineNameInfo_ &&
|
||||
this.lineNameInfo_?.fields &&
|
||||
[ "line", "sequence", "incr" ].every( i =>
|
||||
["offset", "length"].every( j => j in this.lineNameInfo_.fields[i] ))));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
watch: {
|
||||
value (newValue) {
|
||||
this.reset();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
reset () {
|
||||
if (!this.value) {
|
||||
return;
|
||||
|
||||
this.paths_ = [...this.paths];
|
||||
|
||||
this.globs_ = [...this.globs];
|
||||
|
||||
this.lineNameInfo_ = deepMerge({
|
||||
example: "",
|
||||
fields: {
|
||||
line: {
|
||||
length: 4,
|
||||
type: "int"
|
||||
},
|
||||
sequence: {
|
||||
length: 3,
|
||||
type: "int"
|
||||
},
|
||||
incr: {
|
||||
length: 1,
|
||||
type: "bool"
|
||||
},
|
||||
attempt: {
|
||||
length: 1,
|
||||
type: "int"
|
||||
},
|
||||
file_no: {
|
||||
length: 3,
|
||||
type: "int"
|
||||
}
|
||||
this.globs = this.value.globs;
|
||||
this.paths = this.value.paths;
|
||||
this.pattern = this.value.pattern;
|
||||
}
|
||||
}, structuredClone(this.lineNameInfo ?? {}));
|
||||
|
||||
this.pattern_ = structuredClone(this.pattern ?? {});
|
||||
},
|
||||
|
||||
save () {
|
||||
this.$emit('input', this.data);
|
||||
this.$emit("merge", [ ["raw", "p111"], {
|
||||
paths: this.paths_,
|
||||
globs: this.globs_,
|
||||
pattern: this.pattern_,
|
||||
lineNameInfo: this.lineNameInfo_
|
||||
}]);
|
||||
this.$nextTick(this.reset);
|
||||
},
|
||||
|
||||
back () {
|
||||
|
||||
Reference in New Issue
Block a user