Add validation messages for final P1/11 lineNameInfo

This commit is contained in:
D. Berge
2025-06-26 23:48:35 +02:00
parent 12082b91a3
commit e6669026fa

View File

@@ -7,8 +7,32 @@
:is-valid="isValid" :is-valid="isValid"
:save="save" :save="save"
> >
</dougal-project-settings-file-matching-parameters> <template v-slot:paths v-if="validationErrors.includes('ERR_PATHS')">
<v-alert type="warning">
At least one path entry is required.<br/>
<ul>
<li>If you have final P1/11 files in multiple paths (e.g., each file in its own sequence directory), enter here the parent directory.</li>
<li>If files are across multiple paths without a common ancestor, you must add multiple entries here.</li>
</ul>
</v-alert>
</template>
<template v-slot:globs v-if="validationErrors.includes('ERR_GLOBS')">
<v-alert type="warning">
At least one glob expression is required.
</v-alert>
</template>
<template v-slot:line-info v-if="validationErrors.includes('ERR_LINEINFO')">
<v-alert type="warning">
At least the following fields are required:
<ul>
<li><code>line</code> (integer, the preplot line number)</li>
<li><code>sequence</code> (integer, the acquisition sequence number)</li>
</ul>
</v-alert>
</template>
</dougal-project-settings-file-matching-parameters>
</template> </template>
<style scoped> <style scoped>
@@ -117,18 +141,38 @@ export default {
globs: this.cwo?.globs, globs: this.cwo?.globs,
paths: this.cwo?.paths, paths: this.cwo?.paths,
pattern: this.cwo?.pattern, pattern: this.cwo?.pattern,
lineNameInfo: this.cwo?.lineNameInfo lineNameInfo: this.cwo?.lineNameInfo ?? {}
}; };
}, },
validationErrors () {
const errors = [];
if (!this.cwo?.paths.length || !this.cwo?.paths[0].length) {
// "Missing path: we need at least one directory where to search for matching files"
errors.push("ERR_PATHS");
}
if (!this.cwo?.globs.length) {
// "Missing globs: we need at least one glob to search for matching files"
errors.push("ERR_GLOBS");
}
if (this.cwo?.lineNameInfo) {
const pass = !this.cwo?.lineNameInfo?.fields || [ "line", "sequence" ].every( i =>
["offset", "length"].every( j => j in (this.cwo?.lineNameInfo?.fields?.[i] ?? {}) ));
if (!pass) {
// "Missing field info: We need at least 'line' and 'sequence' fields"
errors.push("ERR_LINEINFO")
}
}
return errors;
},
isValid () { isValid () {
return !!(this.cwo?.paths.length && this.cwo?.globs.length && ( return this.validationErrors.length == 0;
this.cwo?.pattern?.regex &&
["direction", "line", "sequence"].every( i => this.cwo?.pattern?.captures?.includes(i) )) || (
this.cwo?.lineNameInfo &&
this.cwo?.lineNameInfo?.fields &&
[ "line", "sequence", "incr" ].every( i =>
["offset", "length"].every( j => j in this.cwo?.lineNameInfo.fields[i] ))));
} }
}, },