Closes #19968: Use multiple selection lists for the assignment of object types when editing a permission (#19991)
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run

* Closes #19968: Use  multiple selection lists for the assignment of object types when editing a permission

* Remove errant logging statements

* Defer compilation of choices for object_types

* Fix test data
This commit is contained in:
Jeremy Stretch
2025-08-01 15:06:23 -04:00
committed by GitHub
parent d4b30a64ba
commit 35b9d80819
9 changed files with 172 additions and 28 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,20 @@
import { getElements } from '../util';
/**
* Move selected options from one select element to another.
*
* @param source Select Element
* @param target Select Element
*/
function moveOption(source: HTMLSelectElement, target: HTMLSelectElement): void {
for (const option of Array.from(source.options)) {
if (option.selected) {
target.appendChild(option.cloneNode(true));
option.remove();
}
}
}
/**
* Move selected options of a select element up in order.
*
@@ -39,23 +54,35 @@ function moveOptionDown(element: HTMLSelectElement): void {
}
/**
* Initialize move up/down buttons.
* Initialize select/move buttons.
*/
export function initMoveButtons(): void {
for (const button of getElements<HTMLButtonElement>('#move-option-up')) {
// Move selected option(s) between lists
for (const button of getElements<HTMLButtonElement>('.move-option')) {
const source = button.getAttribute('data-source');
const target = button.getAttribute('data-target');
if (target !== null) {
for (const select of getElements<HTMLSelectElement>(`#${target}`)) {
button.addEventListener('click', () => moveOptionUp(select));
}
const source_select = document.getElementById(`id_${source}`) as HTMLSelectElement;
const target_select = document.getElementById(`id_${target}`) as HTMLSelectElement;
if (source_select !== null && target_select !== null) {
button.addEventListener('click', () => moveOption(source_select, target_select));
}
}
for (const button of getElements<HTMLButtonElement>('#move-option-down')) {
// Move selected option(s) up in current list
for (const button of getElements<HTMLButtonElement>('.move-option-up')) {
const target = button.getAttribute('data-target');
if (target !== null) {
for (const select of getElements<HTMLSelectElement>(`#${target}`)) {
button.addEventListener('click', () => moveOptionDown(select));
}
const target_select = document.getElementById(`id_${target}`) as HTMLSelectElement;
if (target_select !== null) {
button.addEventListener('click', () => moveOptionUp(target_select));
}
}
// Move selected option(s) down in current list
for (const button of getElements<HTMLButtonElement>('.move-option-down')) {
const target = button.getAttribute('data-target');
const target_select = document.getElementById(`id_${target}`) as HTMLSelectElement;
if (target_select !== null) {
button.addEventListener('click', () => moveOptionDown(target_select));
}
}
}