-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathPairedOrUnpairedListCollectionCreator.vue
More file actions
795 lines (723 loc) · 27 KB
/
PairedOrUnpairedListCollectionCreator.vue
File metadata and controls
795 lines (723 loc) · 27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
<script setup lang="ts">
import type { ColDef, GetRowIdParams, IRowDragItem, NewValueParams } from "ag-grid-community";
import { BAlert, BCol, BLink, BRow } from "bootstrap-vue";
import { getActivePinia } from "pinia";
import { computed, nextTick, ref } from "vue";
import type { components, CreateNewCollectionPayload, HDASummary, HistoryItemSummary } from "@/api";
import { splitIntoPairedAndUnpaired } from "@/components/Collections/pairing";
import { useConfirmDialog } from "@/composables/confirmDialog";
import { Toast } from "@/composables/toast";
import { useAgGrid } from "@/composables/useAgGrid";
import { usePairingDatasetTargetsStore } from "@/stores/collectionBuilderItemsStore";
import localize from "@/utils/localization";
import type { GenericPair } from "../Collections/common/buildCollectionModal";
import { stripExtension, useUpdateIdentifiersForRemoveExtensions } from "./common/stripExtension";
import {
type SupportedPairedOrPairedBuilderCollectionTypes,
useCollectionCreator,
} from "./common/useCollectionCreator";
import { usePairingSummary } from "./common/usePairingSummary";
import { type AutoPairingResult, autoPairWithCommonFilters, guessNameForPair } from "./pairing";
import AutoPairing from "./common/AutoPairing.vue";
import PairedOrUnpairedListCreatorHelp from "./PairedOrUnpairedListCreatorHelp.vue";
import CollectionCreator from "@/components/Collections/common/CollectionCreator.vue";
type CollectionElementIdentifier = components["schemas"]["CollectionElementIdentifier"];
type CollectionSourceType = components["schemas"]["CollectionSourceType"];
const NOT_VALID_ELEMENT_MSG: string = localize("is not a valid element for this collection");
const { confirm } = useConfirmDialog();
const pinia = getActivePinia();
const pairingTargetsStore = usePairingDatasetTargetsStore();
interface Props {
historyId: string;
initialElements: HistoryItemSummary[];
defaultHideSourceItems?: boolean;
suggestedName?: string;
fromSelection?: boolean;
extensions?: string[];
forwardFilter?: string;
reverseFilter?: string;
collectionType: SupportedPairedOrPairedBuilderCollectionTypes;
mode: "wizard" | "modal"; // in modal mode we need to show buttons and manage pairing components, wizard takes care these details
}
const props = defineProps<Props>();
const { gridApi, AgGridVue, onGridReady, theme } = useAgGrid(resize);
const { updateIdentifierIfUnchanged } = useUpdateIdentifiersForRemoveExtensions(props);
const showAutoPairing = ref<boolean>(false);
function resize() {
if (gridApi.value) {
gridApi.value.sizeColumnsToFit();
}
}
const emit = defineEmits<{
(e: "on-create", options: CreateNewCollectionPayload): void;
(e: "on-cancel"): void;
(e: "go-to-auto-pairing"): void;
(e: "name", value: string): void;
(e: "input-valid", value: boolean): void;
}>();
const currentForwardFilter = ref(props.forwardFilter);
const currentReverseFilter = ref(props.reverseFilter);
const activeElements = ref(props.initialElements);
const { currentSummary, summaryText, autoPair } = usePairingSummary<HistoryItemSummary>(props);
const {
removeExtensions,
hideSourceItems,
isElementInvalid,
onUpdateHideSourceItems,
collectionName,
onUpdateCollectionName,
onCollectionCreate,
showButtonsForModal,
showHid,
showElementExtension,
} = useCollectionCreator(props, emit);
pairingTargetsStore.setShowElementExtension(showElementExtension);
const style = computed(() => {
return { width: "100%", height: "500px" };
});
const flatLists = computed(() => props.collectionType.indexOf("paired") == -1);
const isNestedList = computed(() => {
return props.collectionType.startsWith("list:list");
});
const collectionTypeForAutoPairing = computed<"list:paired" | "list:paired_or_unpaired">(() => {
return props.collectionType == "list:paired_or_unpaired" ? "list:paired_or_unpaired" : "list:paired";
});
// Default Column Properties
const defaultColDef = ref<ColDef>({
editable: false,
sortable: false,
filter: false,
resizable: true,
});
type StatusType = "ok" | "duplicate" | "requires_pairing";
type UnpairedDataset = { unpaired: HistoryItemSummary };
interface RowT {
id: string;
datasets: GenericPair<HistoryItemSummary> | UnpairedDataset;
identifier: string;
outerIdentifier?: string;
status: StatusType;
}
const rowData = ref<RowT[]>([]);
const columnDefs = computed(() => {
let datasets: ColDef;
if (!flatLists.value) {
datasets = {
headerName: "Dataset(s)",
field: "datasets",
editable: false,
cellRenderer: "PairedDatasetCellComponent",
rowDrag: true,
};
} else {
datasets = {
headerName: "Dataset",
field: "datasets",
editable: false,
rowDrag: true,
valueFormatter: (p) => {
if (showHid) {
return `${p.value.unpaired.hid}: ${p.value.unpaired.name}`;
} else {
return p.value.unpaired.name;
}
},
};
}
const identifierColumns: ColDef[] = [];
if (!isNestedList.value) {
identifierColumns.push({
headerName: "List Identifier",
field: "identifier",
editable: true,
onCellValueChanged: onIdentifierChange,
});
} else {
identifierColumns.push({
headerName: "Outer List Identifier",
field: "outerIdentifier",
editable: true,
onCellValueChanged: onIdentifierChange,
});
identifierColumns.push({
headerName: "Inner List Identifier",
field: "identifier",
editable: true,
onCellValueChanged: onIdentifierChange,
});
}
const discard: ColDef = {
headerName: "Discard",
field: "discard",
editable: false,
cellRenderer: "CellDiscardComponent",
width: 65,
};
const status: ColDef = {
headerName: "Status",
field: "status",
editable: false,
cellRenderer: "CellStatusComponent",
width: 65,
};
return [datasets, ...identifierColumns, discard, status];
});
function onIdentifierChange(e: NewValueParams) {
nextTick(() => {
checkForDuplicates(true);
});
}
function checkForDuplicates(refresh: boolean) {
const isNested = isNestedList.value;
function identifierKey(item: RowT): string {
// duplicate checking for nested collections is trickier - need to check combination
// of keys is unique instead.
if (isNested) {
return `${item.outerIdentifier ?? ""}:${item.identifier}`;
} else {
return item.identifier;
}
}
const isDuplicate: Record<string, boolean> = {};
let anyDuplicated = false;
for (const item of rowData.value) {
const identifier = identifierKey(item);
if (identifier in isDuplicate) {
isDuplicate[identifier] = true;
anyDuplicated = true;
} else {
isDuplicate[identifier] = false;
}
}
for (const item of rowData.value) {
const identifier = identifierKey(item);
if (item.status == "ok" || item.status == "duplicate") {
item.status = isDuplicate[identifier] ? "duplicate" : "ok";
}
}
if (refresh) {
_refresh();
gridApi.value?.redrawRows();
}
return anyDuplicated;
}
function unpairedRow(item: HistoryItemSummary): RowT {
let name = item.name || "";
if (removeExtensions.value) {
name = stripExtension(name);
}
let status: StatusType = "ok";
if (props.collectionType.endsWith(":paired")) {
status = "requires_pairing";
}
return { identifier: name || "", datasets: { unpaired: item }, id: item.id, status: status };
}
function pairedRow(item: GenericPair<HistoryItemSummary>): RowT {
return { identifier: item.name, datasets: item, id: item.forward.id, status: "ok" };
}
function syncPairingToRowData(summary: AutoPairingResult<HistoryItemSummary>, rowDataValue: RowT[]) {
if (!flatLists.value) {
if (summary) {
for (const pair of summary.pairs) {
rowDataValue.push(pairedRow(pair));
}
for (const unpaired of summary.unpaired) {
rowDataValue.push(unpairedRow(unpaired));
}
} else {
for (const unpaired of activeElements.value) {
rowDataValue.push(unpairedRow(unpaired));
}
}
} else {
for (const unpaired of activeElements.value) {
rowDataValue.push(unpairedRow(unpaired));
}
}
}
function syncRowDataToRowPairing() {
rowData.value.splice(0);
const summary = currentSummary.value;
if (summary) {
syncPairingToRowData(summary, rowData.value);
}
}
function initialize() {
if (currentForwardFilter.value === undefined) {
const summary = autoPairWithCommonFilters(activeElements.value, true);
const { forwardFilter, reverseFilter } = summary;
if (forwardFilter !== undefined && reverseFilter !== undefined) {
currentSummary.value = summary;
currentForwardFilter.value = forwardFilter;
currentReverseFilter.value = reverseFilter;
} else {
autoPair(activeElements.value, "", "", removeExtensions.value);
}
} else {
autoPair(
activeElements.value,
currentForwardFilter.value,
currentReverseFilter.value || "",
removeExtensions.value,
);
}
syncRowDataToRowPairing();
checkForDuplicates(false);
}
initialize();
function getRowId(params: GetRowIdParams) {
return String(params.data.id);
}
function addUploadedFiles(files: HDASummary[]) {
// Any uploaded files are added to workingElements in _elementsSetUp
// The user will have to manually select the files to add them to the pair
// Check for validity of uploads
const addedFiles = [];
files.forEach((file) => {
const problem = isElementInvalid(file);
if (problem) {
const invalidMsg = `${file.hid}: ${file.name} ${problem} and ${NOT_VALID_ELEMENT_MSG}`;
Toast.error(invalidMsg, localize("Uploaded item invalid for pair"));
} else {
activeElements.value.push(file);
addedFiles.push(file);
}
});
if (currentForwardFilter.value === undefined) {
// Auto-pairing hasn't paired anything yet - just take all the files and try them...
initialize();
} else {
const summary = splitIntoPairedAndUnpaired(
files,
currentForwardFilter.value || "",
currentReverseFilter.value || "",
removeExtensions.value,
);
syncPairingToRowData(summary, rowData.value);
}
_refresh();
}
function updatePairNames() {
return (rowData.value || []).map((v) => {
if ("forward" in v.datasets) {
const previousRemoveExtensions = !removeExtensions.value;
const previousUnchangedIdentifier = guessNameForPair(
v.datasets.forward,
v.datasets.reverse,
currentForwardFilter.value || "",
currentReverseFilter.value || "",
previousRemoveExtensions,
);
if (v.identifier == previousUnchangedIdentifier) {
v.identifier = guessNameForPair(
v.datasets.forward,
v.datasets.reverse,
currentForwardFilter.value || "",
currentReverseFilter.value || "",
removeExtensions.value,
);
}
} else {
updateIdentifierIfUnchanged(v, removeExtensions.value);
}
});
}
function removeExtensionsToggle() {
removeExtensions.value = !removeExtensions.value;
updatePairNames();
_refresh();
gridApi.value?.redrawRows();
}
function flatListIdentifiers(): CollectionElementIdentifier[] {
const outerIdentifiers: Record<string, RowT[]> = {};
for (const row of rowData.value) {
const outerIdentifier = row.outerIdentifier || "";
if (!(outerIdentifier in outerIdentifiers)) {
outerIdentifiers[outerIdentifier] = [];
}
outerIdentifiers[outerIdentifier]?.push(row);
}
const listIdentifiers: CollectionElementIdentifier[] = [];
for (const outerIdentifier of Object.keys(outerIdentifiers)) {
const outerIdentifierElements = [];
for (const innerRowData of outerIdentifiers[outerIdentifier] ?? []) {
const unpaired = unpairedDataset(innerRowData);
const innerElement = {
name: innerRowData.identifier,
id: unpaired.id as string,
src: ("src" in unpaired ? unpaired.src : "hda") as CollectionSourceType,
};
outerIdentifierElements.push(innerElement);
}
listIdentifiers.push({
collection_type: "list",
src: "new_collection" as CollectionSourceType,
name: outerIdentifier,
element_identifiers: outerIdentifierElements,
});
}
return listIdentifiers;
}
function pairedListIdentifiers(): CollectionElementIdentifier[] {
let rows = rowData.value || [];
const strictPairs = props.collectionType.endsWith(":paired");
if (strictPairs) {
rows = rows.filter((value) => !("unpaired" in value.datasets));
}
return rows.map((v) => {
const isPaired = "forward" in v.datasets;
function toElementIdentifierObject(
collectionType: "paired" | "paired_or_unpaired",
identifiers: CollectionElementIdentifier[],
) {
return {
collection_type: collectionType,
src: "new_collection" as CollectionSourceType,
name: v.identifier as string,
element_identifiers: identifiers,
};
}
if (isPaired) {
const pair = v.datasets as GenericPair<HistoryItemSummary>;
const identifiers: CollectionElementIdentifier[] = [
{
name: "forward",
id: pair.forward.id as string,
src: ("src" in pair.forward ? pair.forward.src : "hda") as CollectionSourceType,
},
{
name: "reverse",
id: pair.reverse.id as string,
src: ("src" in pair.reverse ? pair.reverse.src : "hda") as CollectionSourceType,
},
];
return toElementIdentifierObject(
props.collectionType == "list:paired" ? "paired" : "paired_or_unpaired",
identifiers,
);
} else {
const unpaired = unpairedDataset(v);
const identifiers = [
{
name: "unpaired",
id: unpaired.id as string,
src: ("src" in unpaired ? unpaired.src : "hda") as CollectionSourceType,
},
];
return toElementIdentifierObject(strictPairs ? "paired" : "paired_or_unpaired", identifiers);
}
});
}
function unpairedDataset(row: RowT): HistoryItemSummary {
if ("unpaired" in row.datasets) {
return row.datasets.unpaired;
} else {
throw Error("Unknown data encountered, logic bug in Galaxy's client.");
}
}
async function attemptCreate() {
if (checkForDuplicates(true)) {
return;
}
let listIdentifiers: CollectionElementIdentifier[];
if (props.collectionType == "list:list") {
listIdentifiers = flatListIdentifiers();
} else {
listIdentifiers = pairedListIdentifiers();
}
let confirmed: boolean | null = false;
if (listIdentifiers.length == 0) {
confirmed = await confirm("Are you sure you want to create a list with no entries?", {
title: "Create an empty list",
okText: "Create",
});
if (!confirmed) {
return;
}
}
onCollectionCreate(props.collectionType, listIdentifiers);
}
defineExpose({ attemptCreate, redraw: resize });
function applyFilters(forwardFilter: string, reverseFilter: string) {
currentForwardFilter.value = forwardFilter;
currentReverseFilter.value = reverseFilter;
showAutoPairing.value = false;
initialize();
}
// two ways to pair, can drag and drop rows or more accessible can just click links in
// pairs. This type is used to indicate what type of pairing is occurring.
type PairBy = "click" | "drag_and_drop";
// do you drag forward to reverse or drag reverse to forward, I'm not sure what is more intuitive
// so leaving this configurable for now - not by the user but in the code. Same with clicking,
// do you click first than second or second than first. Here I think it makes a bit more sense
// to click forward to reverse.
type PairDirection = "from_1_to_2" | "from_2_to_1";
const pairDirections: Record<PairBy, PairDirection> = {
click: "from_1_to_2",
drag_and_drop: "from_1_to_2",
};
// when dragging - do you insert the pair at the drop target ("2") or at where the dragging
// starting from ("1") - this is independent of what is forward or reverse. Likewise if pairing
// by clicking, do you do that from the first click ("1") or the second click ("2")
const insertPairAtIndexType: Record<PairBy, "1" | "2"> = {
click: "2",
drag_and_drop: "2",
};
function onPair(firstId: string, secondId: string, pairBy: PairBy) {
// if pairBy is click -> firstId is the first thing clicked, secondId is the second
// if pairBy is drag_and_drop -> firstId is what is being dragged, secondId is what it is dragged to
let firstIndex = -1;
let secondIndex = -1;
let forward: HistoryItemSummary | null = null;
let reverse: HistoryItemSummary | null = null;
const pairDirection = pairDirections[pairBy];
rowData.value.forEach((row, index) => {
if (row.id == firstId && "unpaired" in row.datasets) {
firstIndex = index;
if (pairDirection == "from_1_to_2") {
forward = row.datasets.unpaired as HistoryItemSummary;
} else {
reverse = row.datasets.unpaired as HistoryItemSummary;
}
}
if (row.id == secondId && "unpaired" in row.datasets) {
secondIndex = index;
if (pairDirection == "from_1_to_2") {
reverse = row.datasets.unpaired as HistoryItemSummary;
} else {
forward = row.datasets.unpaired as HistoryItemSummary;
}
}
});
if (firstIndex !== -1 && secondIndex !== -1 && forward && reverse) {
const nameForPair = guessNameForPair(
forward,
reverse,
currentForwardFilter.value || "",
currentReverseFilter.value || "",
removeExtensions.value,
);
const pair = { forward, reverse, name: nameForPair };
const insertPairAt = insertPairAtIndexType[pairBy];
let targetIndex;
// try to splice the targets so the pair ends up at the correct spot
// based on insertPairAtIndexType (does it replace the first element
// or the second element).
if (insertPairAt == "1") {
if (firstIndex < secondIndex) {
targetIndex = firstIndex;
} else {
targetIndex = firstIndex - 1;
}
} else {
if (secondIndex < firstIndex) {
targetIndex = secondIndex;
} else {
targetIndex = secondIndex - 1;
}
}
// need to remove the latter item first to preserve indices
if (firstIndex < secondIndex) {
rowData.value.splice(secondIndex, 1);
rowData.value.splice(firstIndex, 1);
} else {
rowData.value.splice(firstIndex, 1);
rowData.value.splice(secondIndex, 1);
}
rowData.value.splice(targetIndex, 0, pairedRow(pair));
_refresh();
// reset pairing targets and such... even if coming from drag_and_drop reset this
// because we might have paired the current target with a drag and drop.
activeUnpairedTarget.value = null;
pairingTargetsStore.resetUnpairedTarget();
}
}
function _refresh() {
gridApi.value!.setRowData(rowData.value);
}
function onUnpair(pair: GenericPair<HistoryItemSummary>) {
const targetIndex = onRemove(pair, false) || 0;
rowData.value.splice(targetIndex, 0, unpairedRow(pair.forward), unpairedRow(pair.reverse));
_refresh();
}
type UnpairedValue = { unpaired: HistoryItemSummary };
const activeUnpairedTarget = ref<UnpairedValue | null>(null);
function onUnpairedClick(value: UnpairedValue) {
if (activeUnpairedTarget.value == null) {
activeUnpairedTarget.value = value;
pairingTargetsStore.setUnpairedTarget(value.unpaired.id);
} else {
const forwardId = activeUnpairedTarget.value.unpaired.id;
const reverseId = value.unpaired.id;
if (forwardId == reverseId) {
// cannot pair an element with itself, assuming user wants to make this no longer
// the active target
activeUnpairedTarget.value = null;
pairingTargetsStore.resetUnpairedTarget();
return;
} else {
onPair(forwardId, reverseId, "click");
}
}
}
function onRemove(item: GenericPair<HistoryItemSummary> | UnpairedValue, refresh = true) {
let rowId = null as string | null;
if ("forward" in item) {
rowId = item.forward.id;
} else {
rowId = item.unpaired.id;
}
let targetIndex = null;
rowData.value.forEach((row, index) => {
if (row.id == rowId) {
targetIndex = index;
}
});
if (targetIndex !== null) {
rowData.value.splice(targetIndex, 1);
}
if (refresh) {
_refresh();
}
return targetIndex;
}
const unpairedProblemDatasetCount = computed(() => {
if (!props.collectionType.endsWith(":paired")) {
return 0;
}
let count = 0;
rowData.value.forEach((v) => {
if ("unpaired" in v.datasets) {
count += 1;
}
});
return count;
});
function dismissUnmatchedDatasets() {
const toRemove: UnpairedDataset[] = [];
rowData.value.forEach((v) => {
if ("unpaired" in v.datasets) {
toRemove.push(v.datasets);
}
});
toRemove.forEach((v) => {
onRemove(v, false);
});
_refresh();
}
function onSwap(pair: GenericPair<HistoryItemSummary>) {
const newForward = pair.reverse;
pair.reverse = pair.forward;
pair.forward = newForward;
}
function goToAutoPairing() {
if (props.mode === "wizard") {
emit("go-to-auto-pairing");
} else {
showAutoPairing.value = true;
}
}
function rowDragText(params: IRowDragItem) {
return params.rowNode?.data.identifier;
}
const context = {
pinia,
onPair,
onUnpair,
onUnpairedClick,
onRemove,
onSwap,
};
</script>
<script lang="ts">
// eslint-disable-next-line import/first
import { components as VueComponents } from "./PairedOrUnpairedComponents";
// defineExpose should work for exposing PairedDatasetCellComponent to AG Grid
// but doesn't seem to and it has been reported as an issue with Vue 2.7.
export default {
components: VueComponents,
};
</script>
<template>
<div>
<div v-if="showAutoPairing">
<AutoPairing
:elements="initialElements"
:collection-type="collectionTypeForAutoPairing"
:remove-extensions="removeExtensions"
:forward-filter="currentForwardFilter"
:reverse-filter="currentReverseFilter"
:mode="mode"
:show-hid="showHid"
:extensions="extensions"
@on-apply="applyFilters"
@on-cancel="showAutoPairing = false" />
</div>
<CollectionCreator
v-else
:oncancel="() => emit('on-cancel')"
:history-id="props.historyId"
:hide-source-items="hideSourceItems"
render-extensions-toggle
:extensions-toggle="removeExtensions"
:extensions="extensions"
collection-type="collectionType"
:no-items="props.initialElements.length == 0 && !props.fromSelection"
:show-upload="!fromSelection"
:show-buttons="showButtonsForModal"
:collection-name="collectionName"
:mode="mode"
@on-update-collection-name="onUpdateCollectionName"
@add-uploaded-files="addUploadedFiles"
@onUpdateHideSourceItems="onUpdateHideSourceItems"
@clicked-create="attemptCreate"
@remove-extensions-toggle="removeExtensionsToggle">
<template v-slot:help-content>
<PairedOrUnpairedListCreatorHelp
:from-selection="props.fromSelection"
:collection-type="props.collectionType"
:mode="mode" />
</template>
<template v-slot:middle-content>
<div>
<BRow v-if="!flatLists">
<BCol>
<BAlert show variant="info" dismissible>
{{ summaryText }}
If this isn't correct,
<BLink style="font-weight: bold" @click="goToAutoPairing">configure auto-pairing</BLink
>.
</BAlert>
</BCol>
</BRow>
<BRow v-if="unpairedProblemDatasetCount > 0">
<BCol>
<BAlert show variant="warning" dismissible>
{{ unpairedProblemDatasetCount }} unmatched datasets, these should be either dismissed
or paired off.
<BLink
style="font-weight: bold"
data-description="dismiss unmatched datasets"
@click="dismissUnmatchedDatasets"
>Click here to discard all remaining unpaired datasets.</BLink
>
</BAlert>
</BCol>
</BRow>
<div :style="style" :class="theme">
<AgGridVue
:row-drag-managed="true"
:row-drag-text="rowDragText"
:get-row-id="getRowId"
:default-col-def="defaultColDef"
:column-defs="columnDefs"
:style="style"
:row-data="rowData"
:context="context"
@gridReady="onGridReady" />
</div>
</div>
</template>
</CollectionCreator>
</div>
</template>