Skip to content

Commit bdb2cec

Browse files
disallow dragging collections to dataset-only inputs
This refers to `FormData` elements without the collection variant (only single or multiple dataset variants). Explained in #19866 (comment)
1 parent ce74cbe commit bdb2cec

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

client/src/components/Form/Elements/FormData/FormData.vue

+13-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ const keepOptionsUpdate = ref(0);
123123
*/
124124
const canBrowse = computed(() => variant.value && !!variant.value.find((v) => v.src === SOURCE.DATASET));
125125
126+
/**
127+
* A list of valid `src`s for the variant
128+
*/
129+
const validSrcs = computed(() => {
130+
return variant.value ? variant.value.map((v) => v.src) : [];
131+
});
132+
126133
/**
127134
* Provides the currently shown source type
128135
*/
@@ -562,7 +569,12 @@ function canAcceptSrc(element: HistoryOrCollectionItem) {
562569
}
563570
} else if (historyContentType === "dataset_collection") {
564571
if (props.type === "data") {
565-
// collection can always be mapped over a data input ... in theory.
572+
// if this input doesn't accept collections at all, return false
573+
if (!validSrcs.value.includes(SOURCE.COLLECTION)) {
574+
$emit("alert", "dataset collection is not a valid input for this dataset parameter.");
575+
return false;
576+
}
577+
// otherwise, collection can always be mapped over a data input ... in theory.
566578
// One day we should also validate the map over model
567579
return true;
568580
}

0 commit comments

Comments
 (0)