mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
Fix auto-selection of selected columns
This commit is contained in:
parent
ca12f39c1a
commit
08d56cd19f
@ -320,9 +320,8 @@ class TableConfigForm(forms.ModelForm):
|
|||||||
)
|
)
|
||||||
columns = SimpleArrayField(
|
columns = SimpleArrayField(
|
||||||
base_field=forms.CharField(),
|
base_field=forms.CharField(),
|
||||||
required=False,
|
|
||||||
widget=forms.SelectMultiple(
|
widget=forms.SelectMultiple(
|
||||||
attrs={'size': 10, 'class': 'form-select'}
|
attrs={'size': 10, 'class': 'form-select select-all'}
|
||||||
),
|
),
|
||||||
label=_('Selected Columns')
|
label=_('Selected Columns')
|
||||||
)
|
)
|
||||||
|
BIN
netbox/project-static/dist/netbox.js
vendored
BIN
netbox/project-static/dist/netbox.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js.map
vendored
BIN
netbox/project-static/dist/netbox.js.map
vendored
Binary file not shown.
@ -1,6 +1,12 @@
|
|||||||
import { getElements, scrollTo } from '../util';
|
import { getElements, scrollTo } from '../util';
|
||||||
|
|
||||||
function handleFormSubmit(event: Event, form: HTMLFormElement): void {
|
function handleFormSubmit(event: Event, form: HTMLFormElement): void {
|
||||||
|
// Automatically select all options in any <select> with the "select-all" class. This is useful for
|
||||||
|
// multi-select fields that are used to add/remove choices.
|
||||||
|
for (const element of getElements<HTMLOptionElement>('select.select-all option')) {
|
||||||
|
element.selected = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Track the names of each invalid field.
|
// Track the names of each invalid field.
|
||||||
const invalids = new Set<string>();
|
const invalids = new Set<string>();
|
||||||
|
|
||||||
|
@ -1,16 +1,6 @@
|
|||||||
import { createToast } from './bs';
|
import { createToast } from './bs';
|
||||||
import { getElements, apiPatch, hasError, getSelectedOptions } from './util';
|
import { getElements, apiPatch, hasError, getSelectedOptions } from './util';
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark each option element in the selected columns element as 'selected' so they are submitted to
|
|
||||||
* the API.
|
|
||||||
*/
|
|
||||||
function saveTableConfig(): void {
|
|
||||||
for (const element of getElements<HTMLOptionElement>('select[name="columns"] option')) {
|
|
||||||
element.selected = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add columns to the table config select element.
|
* Add columns to the table config select element.
|
||||||
*/
|
*/
|
||||||
@ -124,9 +114,6 @@ function handleSubmit(event: Event): void {
|
|||||||
* Initialize table configuration elements.
|
* Initialize table configuration elements.
|
||||||
*/
|
*/
|
||||||
export function initTableConfig(): void {
|
export function initTableConfig(): void {
|
||||||
for (const element of getElements<HTMLButtonElement>('#save_tableconfig')) {
|
|
||||||
element.addEventListener('click', saveTableConfig);
|
|
||||||
}
|
|
||||||
for (const element of getElements<HTMLButtonElement>('#add_columns')) {
|
for (const element of getElements<HTMLButtonElement>('#add_columns')) {
|
||||||
element.addEventListener('click', addColumns);
|
element.addEventListener('click', addColumns);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ class TableConfigForm(forms.Form):
|
|||||||
choices=[],
|
choices=[],
|
||||||
required=False,
|
required=False,
|
||||||
widget=forms.SelectMultiple(
|
widget=forms.SelectMultiple(
|
||||||
attrs={'size': 10, 'class': 'form-select'}
|
attrs={'size': 10, 'class': 'form-select select-all'}
|
||||||
),
|
),
|
||||||
label=_('Selected Columns')
|
label=_('Selected Columns')
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user