mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
clicking a PkCheckbox updates state
This commit is contained in:
parent
c536944a10
commit
db142061ff
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,5 +1,21 @@
|
|||||||
import { getElement, getElements, findFirstAdjacent } from '../util';
|
import { getElements } from '../util';
|
||||||
|
import { StateManager } from 'src/state';
|
||||||
|
import { previousPkCheckState } from '../stores';
|
||||||
|
|
||||||
export function initSelectMultiple(): void {
|
type PreviousPkCheckState = { element: Nullable<HTMLInputElement> };
|
||||||
|
|
||||||
|
function updatePreviousPkCheckState(eventTargetElement: HTMLInputElement, state: StateManager<PreviousPkCheckState>): void {
|
||||||
|
console.log(state)
|
||||||
|
state.set('element', eventTargetElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function initSelectMultiple(): void {
|
||||||
|
const checkboxElements = getElements<HTMLInputElement>('input[type="checkbox"][name="pk"]');
|
||||||
|
for (const element of checkboxElements) {
|
||||||
|
element.addEventListener('click', (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
updatePreviousPkCheckState(event.target as HTMLInputElement, previousPkCheckState);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { createState } from '../state';
|
import { createState } from '../state';
|
||||||
|
|
||||||
export const previousPKCheckState = createState<{ hidden: boolean }>(
|
export const previousPkCheckState = createState<{ element: Nullable<HTMLInputElement> }>(
|
||||||
{ hidden: false },
|
{ element: null},
|
||||||
{ persist: false },
|
{ persist: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user