Skip to content

Commit 514c169

Browse files
authored
Merge pull request #20442 from ahmedhamidawan/list_collection_creator_style_fixes
[25.0] Fix inconsistent styling in List Collection Builder selector
2 parents 8e27eca + 464e1f4 commit 514c169

File tree

7 files changed

+129
-22
lines changed

7 files changed

+129
-22
lines changed

client/src/components/Collections/ListCollectionCreator.vue

Lines changed: 99 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
22
import "ui/hoverhighlight";
33
4-
import { faSquare } from "@fortawesome/free-regular-svg-icons";
5-
import { faMinus, faSortAlphaDown, faTimes, faUndo } from "@fortawesome/free-solid-svg-icons";
4+
import { faEdit, faSquare } from "@fortawesome/free-regular-svg-icons";
5+
import { faGripLines, faMinus, faSortAlphaDown, faTimes, faUndo } from "@fortawesome/free-solid-svg-icons";
66
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
77
import { BAlert } from "bootstrap-vue";
88
import { computed, ref, watch } from "vue";
@@ -18,6 +18,7 @@ import { type Mode, useCollectionCreator } from "./common/useCollectionCreator";
1818
1919
import GButton from "../BaseComponents/GButton.vue";
2020
import GButtonGroup from "../BaseComponents/GButtonGroup.vue";
21+
import GModal from "../BaseComponents/GModal.vue";
2122
import FormSelectMany from "../Form/Elements/FormSelectMany/FormSelectMany.vue";
2223
import HelpText from "../Help/HelpText.vue";
2324
import CollectionCreator from "@/components/Collections/common/CollectionCreator.vue";
@@ -343,12 +344,39 @@ function addUploadedFiles(files: HDASummary[]) {
343344
});
344345
}
345346
347+
/** If we are creating a collection from a history (not a pre-selection of elements),
348+
* once we have some selected elements, we provide an option to rename them in a modal.
349+
*/
350+
const canRenameElements = computed(() => {
351+
return !props.fromSelection && inListElements.value.length > 0;
352+
});
353+
/** A toggle for the modal that allows renaming elements in the selected list */
354+
const renamingElements = ref(false);
346355
/** find the element in the workingElements array and update its name */
347356
function renameElement(element: any, name: string) {
357+
// We do this whole process of removing and readding because inListElements
358+
// might be reacting to changes in workingElements, and we want to
359+
// prevent that from causing issues with producing duplicate elements in either list:
360+
361+
// first check at what index of inlistElements the element is
362+
const index = inListElements.value.findIndex((e) => e.id === element.id);
363+
if (index < 0) {
364+
return;
365+
}
366+
367+
// remove from inListElements
368+
inListElements.value = inListElements.value.filter((e) => e.id !== element.id);
369+
370+
// then find the element in workingElements, and rename it
348371
element = workingElements.value.find((e) => e.id === element.id);
349372
if (element) {
350373
element.name = name;
351374
}
375+
376+
// now add again to inListElements at same index
377+
if (index >= 0) {
378+
inListElements.value.splice(index, 0, element);
379+
}
352380
}
353381
354382
function selectionAsHdaSummary(value: any): HDASummary {
@@ -413,11 +441,13 @@ function selectionAsHdaSummary(value: any): HDASummary {
413441
:show-buttons="showButtonsForModal"
414442
:collection-name="collectionName"
415443
:mode="mode"
444+
:can-rename-elements="canRenameElements"
416445
@on-update-collection-name="onUpdateCollectionName"
417446
@add-uploaded-files="addUploadedFiles"
418447
@on-update-datatype-toggle="changeDatatypeFilter"
419448
@onUpdateHideSourceItems="onUpdateHideSourceItems"
420449
@remove-extensions-toggle="removeExtensionsToggle"
450+
@clicked-rename="renamingElements = true"
421451
@clicked-create="attemptCreate">
422452
<template v-slot:help-content>
423453
<p>
@@ -443,7 +473,7 @@ function selectionAsHdaSummary(value: any): HDASummary {
443473
<li v-if="!fromSelection">
444474
The filter textbox can be used to rapidly find the datasets of interest by name.
445475
</li>
446-
<li>
476+
<li v-if="fromSelection">
447477
{{ localize("Change the identifier of elements in the list by clicking on") }}
448478
<i data-target=".collection-element .name">
449479
{{ localize("the existing name") }}
@@ -520,6 +550,24 @@ function selectionAsHdaSummary(value: any): HDASummary {
520550
</i>
521551
{{ localize(".") }}
522552
</p>
553+
554+
<p v-if="!fromSelection">
555+
<strong>
556+
{{ localize("Optional:") }}
557+
</strong>
558+
{{
559+
localize(
560+
[
561+
"Once you have made your selection, if you wish to rename identifiers for elements in the list",
562+
" or change/set the order in which they exist in the final list, you can click on ",
563+
].join("")
564+
)
565+
}}
566+
<i data-target=".rename-elements">
567+
{{ localize("Rename/Reorder list elements") }}
568+
</i>
569+
{{ localize(". This opens a modal where you can perform these actions.") }}
570+
</p>
523571
</template>
524572

525573
<template v-slot:middle-content>
@@ -646,6 +694,7 @@ function selectionAsHdaSummary(value: any): HDASummary {
646694
<draggable
647695
v-model="workingElements"
648696
class="collection-elements scroll-container flex-row drop-zone"
697+
style="max-height: 400px"
649698
chosen-class="bg-secondary">
650699
<DatasetCollectionElementView
651700
v-for="element in workingElements"
@@ -669,14 +718,49 @@ function selectionAsHdaSummary(value: any): HDASummary {
669718
:options="workingElements.map((e) => ({ label: e.name || '', value: e }))">
670719
<template v-slot:label-area="{ value }">
671720
<DatasetCollectionElementView
672-
class="w-100"
721+
text-only
722+
not-editable
673723
:element="selectionAsHdaSummary(value)"
674-
:hide-extension="!showElementExtension"
675-
@onRename="(name) => renameElement(value, name)" />
724+
:hide-extension="!showElementExtension" />
676725
</template>
677726
</FormSelectMany>
678727
</template>
679728
</CollectionCreator>
729+
730+
<GModal
731+
class="rename-elements-modal"
732+
:show.sync="renamingElements"
733+
fixed-height
734+
size="small"
735+
title="Rename and Reorder List Elements">
736+
<div>
737+
<FontAwesomeIcon :icon="faEdit" fixed-width />
738+
{{ localize("Here, you can change the identifiers of the elements in the list.") }}
739+
{{
740+
localize(
741+
"The final list will then have these identifiers, and this does not modify the original datasets."
742+
)
743+
}}
744+
</div>
745+
<div>
746+
<FontAwesomeIcon :icon="faGripLines" fixed-width />
747+
{{ localize("Also, you can click and drag to reorder the elements in the list.") }}
748+
</div>
749+
<hr class="w-100 my-2" />
750+
<draggable
751+
v-model="inListElements"
752+
class="collection-elements scroll-container flex-row"
753+
chosen-class="bg-secondary"
754+
@wheel.stop>
755+
<DatasetCollectionElementView
756+
v-for="value in inListElements"
757+
:key="value.id"
758+
class="w-100"
759+
:element="selectionAsHdaSummary(value)"
760+
:hide-extension="!showElementExtension"
761+
@onRename="(name) => renameElement(value, name)" />
762+
</draggable>
763+
</GModal>
680764
</div>
681765
</div>
682766
</template>
@@ -686,6 +770,15 @@ function selectionAsHdaSummary(value: any): HDASummary {
686770
@import "theme/blue.scss";
687771
688772
.list-collection-creator {
773+
.rename-elements-modal {
774+
.collection-element {
775+
cursor: grab;
776+
&:focus {
777+
cursor: grabbing;
778+
}
779+
}
780+
}
781+
689782
.footer {
690783
margin-top: 8px;
691784
}
@@ -709,7 +802,6 @@ function selectionAsHdaSummary(value: any): HDASummary {
709802
}
710803
711804
.collection-elements {
712-
max-height: 400px;
713805
border: 0px solid lightgrey;
714806
overflow-y: auto;
715807
overflow-x: hidden;
@@ -732,11 +824,6 @@ function selectionAsHdaSummary(value: any): HDASummary {
732824
border-color: black;
733825
}
734826
}
735-
&:not(.with-actions) {
736-
&:hover {
737-
border: none;
738-
}
739-
}
740827
741828
&:last-of-type {
742829
margin-bottom: 2px;

client/src/components/Collections/ListDatasetCollectionElementView.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ interface Props {
1414
hasActions?: boolean;
1515
notEditable?: boolean;
1616
hideExtension?: boolean;
17-
showHid?: boolean;
17+
hideHid?: boolean;
18+
textOnly?: boolean;
1819
}
1920
2021
const props = defineProps<Props>();
@@ -45,15 +46,16 @@ watch(
4546

4647
<template>
4748
<div
48-
class="collection-element d-flex justify-content-between"
49+
class="d-flex justify-content-between"
4950
:data-hid="element.hid"
50-
:class="{ 'with-actions': hasActions }"
51+
:class="{ 'collection-element': !textOnly, 'with-actions': hasActions }"
5152
role="button"
53+
data-description="list dataset collection element"
5254
tabindex="0"
5355
@keyup.enter="emit('element-is-selected', element)"
5456
@click="emit('element-is-selected', element)">
5557
<span class="d-flex flex-gapx-1">
56-
<span v-if="element.hid ?? true">{{ element.hid }}:</span>
58+
<span v-if="!hideHid && (element.hid ?? true)">{{ element.hid }}:</span>
5759
<strong>
5860
<ClickToEdit v-if="!notEditable" v-model="elementName" :title="localize('Click to rename')" />
5961
<span v-else>{{ elementName }}</span>

client/src/components/Collections/common/CollectionCreator.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ interface Props {
3636
showButtons?: boolean;
3737
collectionName: string;
3838
mode: "wizard" | "modal";
39+
canRenameElements?: boolean;
3940
}
4041
4142
const props = withDefaults(defineProps<Props>(), {
@@ -46,12 +47,14 @@ const props = withDefaults(defineProps<Props>(), {
4647
collectionType: undefined,
4748
showButtons: true,
4849
mode: "modal",
50+
canRenameElements: false,
4951
});
5052
5153
const emit = defineEmits<{
5254
(e: "on-update-collection-name", name: string): void;
5355
(e: "remove-extensions-toggle"): void;
5456
(e: "clicked-create", value: string): void;
57+
(e: "clicked-rename"): void;
5558
(e: "onUpdateHideSourceItems", value: boolean): void;
5659
(e: "on-update-datatype-toggle", value: "all" | "datatype" | "ext"): void;
5760
(e: "add-uploaded-files", value: HDASummary[]): void;
@@ -196,9 +199,11 @@ watch(
196199
<CollectionCreatorFooterButtons
197200
v-if="showButtons"
198201
:short-what-is-being-created="shortWhatIsBeingCreated"
202+
:can-rename-elements="props.canRenameElements"
199203
:valid-input="validInput"
200204
@clicked-cancel="cancelCreate"
201-
@clicked-create="emit('clicked-create', collectionName)" />
205+
@clicked-create="emit('clicked-create', collectionName)"
206+
@clicked-rename="emit('clicked-rename')" />
202207
</div>
203208
</div>
204209
</BTab>

client/src/components/Collections/common/CollectionCreatorFooterButtons.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import GButton from "@/components/BaseComponents/GButton.vue";
66
interface Props {
77
validInput: boolean;
88
shortWhatIsBeingCreated: string;
9+
canRenameElements?: boolean;
910
}
1011
1112
defineProps<Props>();
1213
1314
const emit = defineEmits<{
1415
(e: "clicked-create"): void;
16+
(e: "clicked-rename"): void;
1517
(e: "clicked-cancel"): void;
1618
}>();
1719
</script>
@@ -22,8 +24,18 @@ const emit = defineEmits<{
2224
{{ localize("Cancel") }}
2325
</GButton>
2426

25-
<GButton class="create-collection" color="blue" :disabled="!validInput" @click="emit('clicked-create')">
26-
{{ localize("Create " + shortWhatIsBeingCreated) }}
27-
</GButton>
27+
<span>
28+
<GButton
29+
v-if="canRenameElements"
30+
class="rename-elements"
31+
size="small"
32+
:disabled="!validInput"
33+
@click="emit('clicked-rename')">
34+
{{ localize("Rename/Reorder " + shortWhatIsBeingCreated) + " elements" }}
35+
</GButton>
36+
<GButton class="create-collection" color="blue" :disabled="!validInput" @click="emit('clicked-create')">
37+
{{ localize("Create " + shortWhatIsBeingCreated) }}
38+
</GButton>
39+
</span>
2840
</div>
2941
</template>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ const selectedCount = computed(() => {
472472
}
473473
474474
.toggle-button {
475+
display: block;
475476
padding-left: 0;
476477
padding-right: 0;
477478
}

client/src/components/Form/utilities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export function validateInputs(index, values, allowEmptyValueOnRequiredInput = f
154154
} else if (batchN !== n) {
155155
return [
156156
inputId,
157-
`Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>${n}</b> selection(s) while a previous field contains <b>${batchN}</b>.`,
157+
`Please make sure that you select the same number of inputs for all batch mode fields. This field contains ${n} selection(s) while a previous field contains ${batchN}.`,
158158
];
159159
}
160160
}

client/src/utils/navigation/navigation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ workflow_run:
729729
_: '[data-label="${label}"] .tabs'
730730
create: '${_} .create-collection'
731731
select_all: "${_} [data-description='select many select all']"
732-
element_by_hid: "${_} .collection-element[data-hid='${hid}']"
732+
element_by_hid: "${_} [data-description='list dataset collection element'][data-hid='${hid}']"
733733
<<: *upload_mixin
734734

735735
form_element:

0 commit comments

Comments
 (0)