From 205fb0d0c47d65d5e72ac0392fa40577b0e84101 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Thu, 27 Jun 2024 15:33:38 +0200 Subject: [PATCH] Use default addAssay/Study function #203#180#161 --- .../renderer/src/dialogs/NewAssayDialog.vue | 116 +----------------- packages/renderer/src/views/ArcTreeView.vue | 37 +----- 2 files changed, 2 insertions(+), 151 deletions(-) diff --git a/packages/renderer/src/dialogs/NewAssayDialog.vue b/packages/renderer/src/dialogs/NewAssayDialog.vue index e2e0957a..8a1521e8 100644 --- a/packages/renderer/src/dialogs/NewAssayDialog.vue +++ b/packages/renderer/src/dialogs/NewAssayDialog.vue @@ -8,39 +8,19 @@ import * as internal from 'stream'; export type NewAssayInformation = { assayIdentifier: string - studyIdentifier: string [] | null } const iProps : { valid: boolean, - temp_studyInput: string, assay_identifier: string - study_identifier: string [], - studies: string [], existingAssays: string [], - existingStudies: string [], } = reactive({ valid: true, - // Study multiple select with useChips requires "ENTER" to accept new values. This lead to confusion. Here we try to store any input given by the user. - // 👀 The logic is: If temp_studyInput !== '' && temp_studyInput passes validation then add temp_studyInput as identifer. - temp_studyInput: '', assay_identifier: '', - // This value contains the selected study identifiers, for which the new assay will be registered - study_identifier: [], - // This value contains the currently available select options - // (this can differ from existingStudies if new options are added) - studies: [], // This is used to disallow adding same assay again existingAssays: [], - // This value always contains only the existing study identifiers from ARC model - existingStudies: [], }); -// This binds to q-select quasar component -const studySelect = ref(null) - -let filterOptions = ref(iProps.studies) - defineEmits([ ...useDialogPluginComponent.emits ]); @@ -48,18 +28,14 @@ defineEmits([ const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent(); const onSubmit = async () => { - const newAssayInformation : NewAssayInformation = {assayIdentifier: iProps.assay_identifier, studyIdentifier: iProps.study_identifier} + const newAssayInformation : NewAssayInformation = {assayIdentifier: iProps.assay_identifier} onDialogOK(newAssayInformation); }; const init = async ()=>{ - let arcStudies = ArcControlService.props.arc.ISA.StudyIdentifiers.sort() let arcAssays = ArcControlService.props.arc.ISA.AssayIdentifiers - iProps.studies = [...arcStudies]; - iProps.existingStudies = [...arcStudies]; iProps.existingAssays = arcAssays iProps.assay_identifier = ''; - iProps.study_identifier = []; }; onMounted(init); @@ -73,73 +49,9 @@ function hasValidCharacters (identifier: string) { } } -function hasValidCharactersStudies (identifiers: string []) { - if (identifiers.length === 0) return true; - try { - for (const identifier of identifiers) { - checkValidCharacters(identifier) - } - return true; - } catch (err) { - return false; - } -} - function assayIsNew(newAssayIdentifer:string) { return iProps.existingAssays.includes(newAssayIdentifer) ? false : true } - -function filterStudyIdentifiers (val: string, update) { - update(() => { - if (val === '') { - filterOptions.value = iProps.studies - } - else { - const needle = val.toLowerCase() - filterOptions.value = iProps.studies.filter( - v => v.toLowerCase().indexOf(needle) > -1 - ) - } - }) -} - -function createNewStudyIdentifier (val, done) { - if (val.length > 0) { - if (!iProps.studies.includes(val)) { - iProps.studies.push(val) - } - done(val, 'toggle') - } -} - -function clearStudyIdentifier (val: {index: number, value: string}) { - let contains = !iProps.existingStudies.includes(val.value) - if (contains) { - let index = iProps.studies.indexOf(val.value); - // console.log("cleared non existing study at index: ", index); - iProps.studies.splice(index, 1) - } - return; -} - -function onBlurAddTemp_StudyInput() { - let v = iProps.temp_studyInput - if (v === '') return; - if (!hasValidCharacters(v)) return; - iProps.study_identifier.push(iProps.temp_studyInput); - // only add to studies if it did not exist beforehand - if (!iProps.studies.includes(v)) { - iProps.studies.push(iProps.temp_studyInput); - } -} - -function onChangeSetTemp_StudyInput(val: string) { - iProps.temp_studyInput = val; - if (!studySelect.value) return; - // quasar q-select method - studySelect.value.validate(val); -} -