mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
clicking a PkCheckbox updates state
This commit is contained in:
@ -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';
|
||||
|
||||
export const previousPKCheckState = createState<{ hidden: boolean }>(
|
||||
{ hidden: false },
|
||||
{ persist: false },
|
||||
export const previousPkCheckState = createState<{ element: Nullable<HTMLInputElement> }>(
|
||||
{ element: null},
|
||||
{ persist: false }
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user