diff --git a/client/src/components/Collections/ListCollectionCreator.vue b/client/src/components/Collections/ListCollectionCreator.vue index 730819ccc588..841a206a3635 100644 --- a/client/src/components/Collections/ListCollectionCreator.vue +++ b/client/src/components/Collections/ListCollectionCreator.vue @@ -9,6 +9,7 @@ import { computed, ref, watch } from "vue"; import draggable from "vuedraggable"; import type { HDASummary, HistoryItemSummary } from "@/api"; +import { useConfirmDialog } from "@/composables/confirmDialog"; import { Toast } from "@/composables/toast"; import STATES from "@/mvc/dataset/states"; import { useDatatypesMapperStore } from "@/stores/datatypesMapperStore"; @@ -228,14 +229,24 @@ function clickSelectAll() { return element.id; }); } +const { confirm } = useConfirmDialog(); -function clickedCreate(collectionName: string) { +async function clickedCreate(collectionName: string) { checkForDuplicates(); const returnedElements = props.fromSelection ? workingElements.value : inListElements.value; atLeastOneElement.value = returnedElements.length > 0; - if (state.value !== "error" && atLeastOneElement.value) { + let confirmed = false; + if (!atLeastOneElement.value) { + confirmed = await confirm("Are you sure you want to create a list with no datasets?", { + title: "Create an empty list", + okTitle: "Create", + okVariant: "primary", + }); + } + + if (state.value !== "error" && (atLeastOneElement.value || confirmed)) { emit("clicked-create", returnedElements, collectionName, hideSourceItems.value); } } diff --git a/client/src/components/Collections/PairedListCollectionCreator.vue b/client/src/components/Collections/PairedListCollectionCreator.vue index b2b13d1fd36c..ba46d2139934 100644 --- a/client/src/components/Collections/PairedListCollectionCreator.vue +++ b/client/src/components/Collections/PairedListCollectionCreator.vue @@ -13,6 +13,7 @@ import { computed, ref, watch } from "vue"; import draggable from "vuedraggable"; import type { HDASummary, HistoryItemSummary } from "@/api"; +import { useConfirmDialog } from "@/composables/confirmDialog"; import { Toast } from "@/composables/toast"; import STATES from "@/mvc/dataset/states"; import { useDatatypesMapperStore } from "@/stores/datatypesMapperStore"; @@ -724,10 +725,22 @@ function addUploadedFiles(files: HDASummary[]) { }); } +const { confirm } = useConfirmDialog(); + async function clickedCreate(collectionName: string) { checkForDuplicates(); atLeastOnePair.value = generatedPairs.value.length > 0; - if (state.value == "build" && atLeastOnePair.value) { + + let confirmed = false; + if (!atLeastOnePair.value) { + confirmed = await confirm("Are you sure you want to create a list with no pairs?", { + title: "Create an empty list of pairs", + okTitle: "Create", + okVariant: "primary", + }); + } + + if (state.value == "build" && (atLeastOnePair.value || confirmed)) { emit("clicked-create", generatedPairs.value, collectionName, hideSourceItems.value); } } @@ -806,7 +819,7 @@ function _naiveStartingAndEndingLCS(s1: string, s2: string) {
- {{ localize("At least one pair is needed for the paired list.") }} + {{ localize("At least one pair is needed for the list of pairs.") }} {{ localize("Cancel") }}