mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-14 07:42:18 -06:00
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
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:
8
netbox/project-static/dist/netbox.js
vendored
8
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
6
netbox/project-static/dist/netbox.js.map
vendored
6
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user