Fixed linter issues in savedFiltersSelect.ts

This commit is contained in:
Julio-Oliveira-Encora 2024-05-21 15:36:07 -03:00
parent 02e62b4248
commit d26c08cb4b
4 changed files with 9 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
import {isTruthy} from "./util"; import { isTruthy } from '../util';
/** /**
* Handle saved filter change event. * Handle saved filter change event.
@ -7,21 +7,22 @@ import {isTruthy} from "./util";
*/ */
function handleSavedFilterChange(event: Event): void { function handleSavedFilterChange(event: Event): void {
const savedFilter = event.currentTarget as HTMLSelectElement; const savedFilter = event.currentTarget as HTMLSelectElement;
let baseUrl = savedFilter.baseURI.split("?")[0]; let baseUrl = savedFilter.baseURI.split('?')[0];
let preFilter = "?"; const preFilter = '?';
const selectedOptions = Array.from(savedFilter.options) const selectedOptions = Array.from(savedFilter.options)
.filter(option => option.selected) .filter(option => option.selected)
.map(option => `filter_id=${option.value}`) .map(option => `filter_id=${option.value}`)
.join("&"); .join('&');
baseUrl += `${preFilter}${selectedOptions}`; baseUrl += `${preFilter}${selectedOptions}`;
document.location.href = baseUrl; document.location.href = baseUrl;
} }
export function initSavedFilterSelect(): void { export function initSavedFilterSelect(): void {
const savedFilterSelect = document.getElementById("id_filter_id"); const savedFilterSelect = document.getElementById('id_filter_id');
if (isTruthy(savedFilterSelect)) { if (isTruthy(savedFilterSelect)) {
savedFilterSelect.addEventListener("change", handleSavedFilterChange); savedFilterSelect.addEventListener('change', handleSavedFilterChange);
} }
} }

View File

@ -13,7 +13,7 @@ import { initSideNav } from './sidenav';
import { initDashboard } from './dashboard'; import { initDashboard } from './dashboard';
import { initRackElevation } from './racks'; import { initRackElevation } from './racks';
import { initHtmx } from './htmx'; import { initHtmx } from './htmx';
import {initSavedFilterSelect} from "./savedFiltersSelect"; import { initSavedFilterSelect } from "./forms/savedFiltersSelect";
function initDocument(): void { function initDocument(): void {
for (const init of [ for (const init of [