Enhances employee hours view with dynamic weekly schedule rendering Updates toggle slider and theme switch components with improved interactions Adds more flexible notification and settings configurations for employees Improves user experience by streamlining UI controls and schedule display
36 lines
937 B
TypeScript
36 lines
937 B
TypeScript
/**
|
|
* Controls Module
|
|
*
|
|
* Handles generic UI controls functionality:
|
|
* - Toggle sliders (Ja/Nej switches)
|
|
*/
|
|
|
|
/**
|
|
* Controller for generic UI controls
|
|
*/
|
|
export class ControlsController {
|
|
constructor() {
|
|
this.initToggleSliders();
|
|
}
|
|
|
|
/**
|
|
* Initialize all toggle sliders on the page
|
|
* Toggle slider: Ja/Nej button switch with data-value attribute
|
|
* Clicking anywhere on the slider toggles the value
|
|
*/
|
|
private initToggleSliders(): void {
|
|
document.querySelectorAll('swp-toggle-slider').forEach(slider => {
|
|
slider.addEventListener('click', () => {
|
|
const el = slider as HTMLElement;
|
|
const newValue = el.dataset.value === 'yes' ? 'no' : 'yes';
|
|
el.dataset.value = newValue;
|
|
|
|
// Dispatch custom event for listeners
|
|
slider.dispatchEvent(new CustomEvent('toggle', {
|
|
bubbles: true,
|
|
detail: { value: newValue }
|
|
}));
|
|
});
|
|
});
|
|
}
|
|
}
|