Skip to content

Commit

Permalink
Merge branch 'release_24.0' into release_24.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Oct 8, 2024
2 parents 81d0578 + de8e982 commit 87cddaf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ function focusOptionAtIndex(selected: "selected" | "unselected", index: number)
}
}
/** convert array of select options to a map of select labels to select values */
function optionsToLabelMap(options: SelectOption[]): Map<string, SelectValue> {
return new Map(options.map((o) => [o.label, o.value]));
}
function valuesToOptions(values: SelectValue[]): SelectOption[] {
function stringifyObject(value: SelectValue) {
return typeof value === "object" && value !== null ? JSON.stringify(value) : value;
}
const comparableValues = values.map(stringifyObject);
const valueSet = new Set(comparableValues);
const options: SelectOption[] = [];
props.options.forEach((option) => {
if (valueSet.has(stringifyObject(option.value))) {
options.push(option);
}
});
return options;
}
async function selectOption(event: MouseEvent, index: number): Promise<void> {
if (event.shiftKey || event.ctrlKey) {
handleHighlight(event, index, highlightUnselected);
Expand Down Expand Up @@ -168,10 +191,10 @@ async function deselectOption(event: MouseEvent, index: number) {
function selectAll() {
if (highlightUnselected.highlightedIndexes.length > 0) {
const highlightedValues = highlightUnselected.highlightedOptions.map((o) => o.value);
const selectedSet = new Set([...selected.value, ...highlightedValues]);
selected.value = Array.from(selectedSet);
selected.value = [...selected.value, ...highlightedValues];
unselectedOptionsFiltered.value.filter((o) => highlightedValues.includes(o.value));
const highlightedMap = optionsToLabelMap(highlightUnselected.highlightedOptions);
unselectedOptionsFiltered.value.filter((o) => highlightedMap.has(o.label));
} else if (searchValue.value === "") {
selected.value = props.options.map((o) => o.value);
Expand All @@ -188,13 +211,13 @@ function selectAll() {
function deselectAll() {
if (highlightSelected.highlightedIndexes.length > 0) {
const selectedSet = new Set(selected.value);
const highlightedValues = highlightSelected.highlightedOptions.map((o) => o.value);
const selectedMap = optionsToLabelMap(valuesToOptions(selected.value));
const highlightedMap = optionsToLabelMap(highlightSelected.highlightedOptions);
highlightedValues.forEach((v) => selectedSet.delete(v));
selected.value = Array.from(selectedSet);
highlightedMap.forEach((_value, label) => selectedMap.delete(label));
selected.value = Array.from(selectedMap.values());
selectedOptionsFiltered.value.filter((o) => highlightedValues.includes(o.value));
selectedOptionsFiltered.value.filter((o) => highlightedMap.has(o.label));
} else if (searchValue.value === "") {
selected.value = [];
selectedOptionsFiltered.value = [];
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Sharing/UserSharing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ defineExpose({
class="mb-4">
<BFormSelect v-model="selectedSharingOption">
<BFormSelectOption value="make_public"> Make datasets public </BFormSelectOption>
<BFormSelectOption value="make_accessible_and_shared">
<BFormSelectOption value="make_accessible_to_shared">
Make datasets private to me and users this {{ modelClass }} is shared with
</BFormSelectOption>
<BFormSelectOption value="no_changes"> Share {{ modelClass }} anyways </BFormSelectOption>
Expand Down

0 comments on commit 87cddaf

Please sign in to comment.