From 0dc62f68801562d841109e029cbe88c6c38a5ecf Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 5 Sep 2023 19:37:49 -0400 Subject: [PATCH 1/7] refactor(PatientBrowser): remove unused code --- src/components/PatientBrowser.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/PatientBrowser.vue b/src/components/PatientBrowser.vue index 0a2873a5a..43dccb0e6 100644 --- a/src/components/PatientBrowser.vue +++ b/src/components/PatientBrowser.vue @@ -1,11 +1,9 @@ diff --git a/src/utils/index.ts b/src/utils/index.ts index 92344e6ca..18f5fbb5d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -273,3 +273,7 @@ export function zodEnumFromObjKeys( const [firstKey, ...otherKeys] = Object.keys(obj) as K[]; return z.enum([firstKey, ...otherKeys]); } + +export function nonNullable(value: T): value is NonNullable { + return value !== null && value !== undefined; +} From eccf549d99455f90ce85d53e784ce4d3d845423b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 6 Sep 2023 12:04:50 -0400 Subject: [PATCH 4/7] fix(useMultiSelection): unselect when all selected just unselects one closes #407 --- src/components/ImageDataBrowser.vue | 4 +++- src/components/MeasurementsToolList.vue | 4 +++- src/components/PatientBrowser.vue | 4 +++- src/components/PatientStudyVolumeBrowser.vue | 4 +++- src/composables/useMultiSelection.ts | 24 +++++++++----------- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/components/ImageDataBrowser.vue b/src/components/ImageDataBrowser.vue index 195b8afd6..d09c372ec 100644 --- a/src/components/ImageDataBrowser.vue +++ b/src/components/ImageDataBrowser.vue @@ -123,7 +123,7 @@ export default defineComponent({ // --- selection --- // - const { selected, selectedAll, selectedSome } = + const { selected, selectedAll, selectedSome, toggleSelectAll } = useMultiSelection(nonDICOMImages); function removeSelection() { @@ -137,6 +137,7 @@ export default defineComponent({ selected, selectedAll, selectedSome, + toggleSelectAll, removeSelection, images, thumbnails, @@ -161,6 +162,7 @@ export default defineComponent({ :indeterminate="selectedSome && !selectedAll" label="Select All" v-model="selectedAll" + @click.stop="toggleSelectAll" density="compact" hide-details /> diff --git a/src/components/MeasurementsToolList.vue b/src/components/MeasurementsToolList.vue index a4a8c87b6..acb7721fd 100644 --- a/src/components/MeasurementsToolList.vue +++ b/src/components/MeasurementsToolList.vue @@ -70,7 +70,8 @@ const tools = computed(() => { const toolIds = computed(() => tools.value.map((tool) => tool.id)); -const { selected, selectedAll, selectedSome } = useMultiSelection(toolIds); +const { selected, selectedAll, selectedSome, toggleSelectAll } = + useMultiSelection(toolIds); const forEachSelectedTool = ( callback: (tool: (typeof tools.value)[number]) => void @@ -104,6 +105,7 @@ function toggleGlobalHidden() { :indeterminate="selectedSome && !selectedAll" label="Select All" v-model="selectedAll" + @click.stop="toggleSelectAll" density="compact" hide-details /> diff --git a/src/components/PatientBrowser.vue b/src/components/PatientBrowser.vue index 43dccb0e6..ea8427c19 100644 --- a/src/components/PatientBrowser.vue +++ b/src/components/PatientBrowser.vue @@ -58,7 +58,7 @@ export default defineComponent({ // --- selection --- // - const { selected, selectedAll, selectedSome } = + const { selected, selectedAll, selectedSome, toggleSelectAll } = useMultiSelection(studyKeys); const removeSelectedStudies = () => { @@ -77,6 +77,7 @@ export default defineComponent({ selected, selectedAll, selectedSome, + toggleSelectAll, primarySelection, removeSelectedStudies, studies, @@ -104,6 +105,7 @@ export default defineComponent({ :indeterminate="selectedSome && !selectedAll" label="Select All Studies" v-model="selectedAll" + @click.stop="toggleSelectAll" density="compact" hide-details /> diff --git a/src/components/PatientStudyVolumeBrowser.vue b/src/components/PatientStudyVolumeBrowser.vue index 953d04840..2b2316b18 100644 --- a/src/components/PatientStudyVolumeBrowser.vue +++ b/src/components/PatientStudyVolumeBrowser.vue @@ -163,7 +163,7 @@ export default defineComponent({ // --- selection --- // - const { selected, selectedAll, selectedSome } = + const { selected, selectedAll, selectedSome, toggleSelectAll } = useMultiSelection(volumeKeys); const removeSelectedDICOMVolumes = () => { @@ -178,6 +178,7 @@ export default defineComponent({ selected, selectedAll, selectedSome, + toggleSelectAll, thumbnailCache, volumes, removeSelectedDICOMVolumes, @@ -195,6 +196,7 @@ export default defineComponent({ :indeterminate="selectedSome && !selectedAll" label="Select All" v-model="selectedAll" + @click.stop="toggleSelectAll" density="compact" hide-details /> diff --git a/src/composables/useMultiSelection.ts b/src/composables/useMultiSelection.ts index 646115c09..6e600234c 100644 --- a/src/composables/useMultiSelection.ts +++ b/src/composables/useMultiSelection.ts @@ -1,23 +1,21 @@ -import { computed, Ref, ref, watch, UnwrapRef } from 'vue'; +import { computed, Ref, ref, UnwrapRef } from 'vue'; export function useMultiSelection(allItems: Ref) { const selected = ref([]); - const selectedAll = ref(false); const selectedSome = computed(() => selected.value.length > 0); - - watch(selected, () => { - selectedAll.value = + const selectedAll = computed( + () => selected.value.length > 0 && - selected.value.length === allItems.value.length; - }); + selected.value.length === allItems.value.length + ); - watch(selectedAll, (yn) => { - if (yn) { - selected.value = allItems.value as UnwrapRef; - } else { + const toggleSelectAll = () => { + if (selectedAll.value) { selected.value = []; + } else { + selected.value = allItems.value as UnwrapRef; } - }); + }; - return { selected, selectedAll, selectedSome }; + return { selected, selectedAll, selectedSome, toggleSelectAll }; } From 7158a8e0ef1fffd27b4b4ed427bbc7d40b9b3c3e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 6 Sep 2023 16:38:53 -0400 Subject: [PATCH 5/7] fix(MeasurementsToolList): global show/hide button based on tool state --- src/components/AnnotationsModule.vue | 2 +- src/components/MeasurementsToolList.vue | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/components/AnnotationsModule.vue b/src/components/AnnotationsModule.vue index a31a3f956..b185e6acb 100644 --- a/src/components/AnnotationsModule.vue +++ b/src/components/AnnotationsModule.vue @@ -10,7 +10,7 @@ import MeasurementRulerDetails from './MeasurementRulerDetails.vue'; const tools = [ { - store: useRulerStore() as unknown as AnnotationToolStore, + store: useRulerStore(), icon: 'mdi-ruler', details: MeasurementRulerDetails, }, diff --git a/src/components/MeasurementsToolList.vue b/src/components/MeasurementsToolList.vue index acb7721fd..b65197e81 100644 --- a/src/components/MeasurementsToolList.vue +++ b/src/components/MeasurementsToolList.vue @@ -1,5 +1,5 @@ @@ -117,10 +123,10 @@ function toggleGlobalHidden() { :disabled="!selectedSome" @click.stop="toggleGlobalHidden" > - mdi-eye-off + mdi-eye-off mdi-eye {{ - globalHidden ? 'Show' : 'Hide' + allHidden ? 'Show' : 'Hide' }} Date: Tue, 12 Sep 2023 09:18:07 -0400 Subject: [PATCH 6/7] fix(useMultiSelection): remove deleted item from selected Co-authored-by: Forrest Li --- src/composables/useMultiSelection.ts | 14 +++++++++++--- src/utils/index.ts | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/composables/useMultiSelection.ts b/src/composables/useMultiSelection.ts index 6e600234c..1d63ca9c1 100644 --- a/src/composables/useMultiSelection.ts +++ b/src/composables/useMultiSelection.ts @@ -1,7 +1,15 @@ -import { computed, Ref, ref, UnwrapRef } from 'vue'; +import { computed, ref, Ref, watch } from 'vue'; export function useMultiSelection(allItems: Ref) { - const selected = ref([]); + const selected = ref([]) as Ref; + + // remove deleted item + watch(allItems, () => { + selected.value = selected.value.filter((item) => + allItems.value.includes(item) + ); + }); + const selectedSome = computed(() => selected.value.length > 0); const selectedAll = computed( () => @@ -13,7 +21,7 @@ export function useMultiSelection(allItems: Ref) { if (selectedAll.value) { selected.value = []; } else { - selected.value = allItems.value as UnwrapRef; + selected.value = allItems.value; } }; diff --git a/src/utils/index.ts b/src/utils/index.ts index 18f5fbb5d..ad8b326db 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -275,5 +275,5 @@ export function zodEnumFromObjKeys( } export function nonNullable(value: T): value is NonNullable { - return value !== null && value !== undefined; + return value != null; } From 673e542d7db4a6b4dc791d7c317c11c07f0f7fe4 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 12 Sep 2023 10:06:10 -0400 Subject: [PATCH 7/7] fix(MeasurementToolDetails): avoid line wrapping of Axis: Sagittal --- src/components/MeasurementRulerDetails.vue | 4 ++-- src/components/MeasurementToolDetails.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MeasurementRulerDetails.vue b/src/components/MeasurementRulerDetails.vue index 9d7212104..829c5dbd3 100644 --- a/src/components/MeasurementRulerDetails.vue +++ b/src/components/MeasurementRulerDetails.vue @@ -11,8 +11,8 @@ const toolStore = useRulerStore();