Add validation messages for raw P1/11 lineNameInfo

This commit is contained in:
D. Berge
2025-06-26 23:47:38 +02:00
parent 7db9155899
commit 12082b91a3

View File

@@ -7,6 +7,31 @@
:is-valid="isValid"
:save="save"
>
<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>
@@ -121,14 +146,34 @@ export default {
};
},
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 () {
return !!(this.cwo?.paths.length && this.cwo?.globs.length && (
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] ))));
return this.validationErrors.length == 0;
}
},