From d2f7f07cbf65a8f4b05f9d93736b0b7fb54844e4 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Thu, 17 Oct 2024 19:53:45 -0500 Subject: [PATCH] add `CollectionCreatorModal` that replaces `buildCollectionModal` - `buildCollectionModal.ts` still exists but just to create the rules collection modal, all other modals are replaced with a parent `CollectionCreatorModal` - also added a `collectionBuilderItemsStore` that is used to store the datasets fetched for the builder; only when the builder is opened: which is when we start reacting to any changes in the `historyId`, `history.update_time` and any filter on a history selection. --- .../Collections/CollectionCreatorModal.vue | 322 ++++++++++++++++++ .../Collections/ListCollectionCreator.vue | 23 +- .../ListDatasetCollectionElementView.vue | 15 +- .../Collections/PairCollectionCreator.vue | 243 +++++++++---- .../PairedListCollectionCreator.vue | 41 +-- .../Form/Elements/FormData/FormData.vue | 87 ++--- .../HistoryOperations/SelectionOperations.vue | 72 ++-- .../History/adapters/HistoryPanelProxy.js | 6 +- .../History/adapters/buildCollectionModal.ts | 49 +-- .../LibraryFolder/TopToolbar/FolderTopBar.vue | 26 ++ .../import-to-history/import-collection.js | 8 +- client/src/components/Upload/DefaultBox.vue | 31 +- client/src/components/Upload/RulesInput.vue | 2 +- client/src/components/Upload/builders.js | 27 -- .../src/composables/useHistoryItemsForType.ts | 90 ----- .../src/stores/collectionBuilderItemsStore.ts | 78 +++++ 16 files changed, 758 insertions(+), 362 deletions(-) create mode 100644 client/src/components/Collections/CollectionCreatorModal.vue delete mode 100644 client/src/components/Upload/builders.js delete mode 100644 client/src/composables/useHistoryItemsForType.ts create mode 100644 client/src/stores/collectionBuilderItemsStore.ts diff --git a/client/src/components/Collections/CollectionCreatorModal.vue b/client/src/components/Collections/CollectionCreatorModal.vue new file mode 100644 index 000000000000..96bdaad6245b --- /dev/null +++ b/client/src/components/Collections/CollectionCreatorModal.vue @@ -0,0 +1,322 @@ + + + + + diff --git a/client/src/components/Collections/ListCollectionCreator.vue b/client/src/components/Collections/ListCollectionCreator.vue index a9750da933f4..8d1e5be51705 100644 --- a/client/src/components/Collections/ListCollectionCreator.vue +++ b/client/src/components/Collections/ListCollectionCreator.vue @@ -19,9 +19,6 @@ import DatasetCollectionElementView from "@/components/Collections/ListDatasetCo interface Props { initialElements: HistoryItemSummary[]; - oncancel: () => void; - oncreate: () => void; - creationFn: (workingElements: HDASummary[], collectionName: string, hideSourceItems: boolean) => any; defaultHideSourceItems?: boolean; fromSelection?: boolean; extensions?: string[]; @@ -31,6 +28,7 @@ const props = defineProps(); const emit = defineEmits<{ (e: "clicked-create", workingElements: HDASummary[], collectionName: string, hideSourceItems: boolean): void; + (e: "on-cancel"): void; }>(); const state = ref("build"); @@ -152,7 +150,7 @@ function _isElementInvalid(element: HistoryItemSummary): string | null { element.extension && !datatypesMapper.value?.isSubTypeOfAny(element.extension, props.extensions!) ) { - return localize("has an invalid extension"); + return localize(`has an invalid extension: ${element.extension}`); } return null; } @@ -231,13 +229,6 @@ function clickedCreate(collectionName: string) { if (state.value !== "error") { emit("clicked-create", returnedElements, collectionName, hideSourceItems.value); - - return props - .creationFn(returnedElements, collectionName, hideSourceItems.value) - .done(props.oncreate) - .fail(() => { - state.value = "error"; - }); } } @@ -339,14 +330,14 @@ function renameElement(element: any, name: string) { {{ localize("No datasets were selected") }} {{ localize("At least one element is needed for the collection. You may need to") }} - + {{ localize("cancel") }} {{ localize("and reselect new elements.") }}
-
@@ -375,14 +366,14 @@ function renameElement(element: any, name: string) { {{ localize("At least one element is needed for the collection. You may need to") }} - + {{ localize("cancel") }} {{ localize("and reselect new elements.") }}
-
@@ -414,7 +405,7 @@ function renameElement(element: any, name: string) { (); @@ -21,7 +23,7 @@ const emit = defineEmits<{ (event: "element-is-discarded", element: any): void; }>(); -const elementName = ref(props.element.name); +const elementName = ref(props.element.name || "..."); watch(elementName, () => { emit("onRename", elementName.value); @@ -43,13 +45,16 @@ function clickDiscard() { {{ element.hid }}: - + + {{ elementName }} - ({{ element.extension }}) + ({{ element.extension }})
- Added to list + + Added to collection + Selected