Skip to content

Commit

Permalink
Add "existing identifier" check to add study dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Nov 23, 2023
1 parent 8f386b0 commit 0fd3c79
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/renderer/src/dialogs/NewStudyDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const onSubmit = async () => {
};
const init = async ()=>{
let arcStudies = ArcControlService.props.arc.ISA.Studies.map((s: ArcStudy) => s.Identifier).sort();
let arcStudies = ArcControlService.props.arc.ISA.StudyIdentifiers.sort()
iProps.existingStudies = arcStudies
iProps.study_identifier = '';
};
Expand All @@ -51,6 +51,11 @@ function hasValidCharacters (identifier: string) {
}
}
function studyIsNew(newStudyIdentifer:string) {
return iProps.existingStudies.includes(newStudyIdentifer) ? false : true
}
</script>

<template>
Expand All @@ -66,11 +71,13 @@ function hasValidCharacters (identifier: string) {
<q-card-section>
<q-input
filled
style="margin-bottom: 1rem;"
v-model="iProps.study_identifier"
label="Add Study"
:rules="[
val => val !== '' || `Study identifier must not be empty`,
val => hasValidCharacters(val) || `Invalid Identifier for: '${iProps.study_identifier}': New identifier contains forbidden characters! Allowed characters are: letters, digits, underscore (_), dash (-) and whitespace ( ).`,
val => studyIsNew(val) || `Study identifier: '${val}' is already set for this ARC.`
]"
lazy-rules
/>
Expand Down

0 comments on commit 0fd3c79

Please sign in to comment.