"use strict"; // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair /* eslint-disable unicorn/prefer-module */ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const los = exports.los; const searchFilterFormElement = document.querySelector('#form--searchFilters'); const searchResultsContainerElement = document.querySelector('#container--searchResults'); const limit = Number.parseInt(document.querySelector('#searchFilter--limit').value, 10); const offsetElement = document.querySelector('#searchFilter--offset'); function renderLots(rawResponseJSON) { var _a, _b, _c, _d, _e, _f, _g; const responseJSON = rawResponseJSON; if (responseJSON.lots.length === 0) { // eslint-disable-next-line no-unsanitized/property searchResultsContainerElement.innerHTML = `

There are no ${los.escapedAliases.lots} that meet the search criteria.

`; return; } const resultsTbodyElement = document.createElement('tbody'); for (const lot of responseJSON.lots) { // eslint-disable-next-line no-unsanitized/method resultsTbodyElement.insertAdjacentHTML('beforeend', ` ${cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '')} ${lot.mapName ? cityssm.escapeHTML(lot.mapName) : '(No Name)'} ${cityssm.escapeHTML((_b = lot.lotType) !== null && _b !== void 0 ? _b : '')} ${lot.lotStatusId ? cityssm.escapeHTML((_c = lot.lotStatus) !== null && _c !== void 0 ? _c : '') : '(No Status)'}
${((_d = lot.lotOccupancyCount) !== null && _d !== void 0 ? _d : 0) > 0 ? 'Currently Occupied' : ''} `); } // eslint-disable-next-line no-unsanitized/property searchResultsContainerElement.innerHTML = `
${los.escapedAliases.Lot} ${los.escapedAliases.Map} ${los.escapedAliases.Lot} Type Status
`; // eslint-disable-next-line no-unsanitized/method searchResultsContainerElement.insertAdjacentHTML('beforeend', los.getSearchResultsPagerHTML(limit, responseJSON.offset, responseJSON.count)); (_e = searchResultsContainerElement .querySelector('table')) === null || _e === void 0 ? void 0 : _e.append(resultsTbodyElement); (_f = searchResultsContainerElement .querySelector("button[data-page='previous']")) === null || _f === void 0 ? void 0 : _f.addEventListener('click', previousAndGetLots); (_g = searchResultsContainerElement .querySelector("button[data-page='next']")) === null || _g === void 0 ? void 0 : _g.addEventListener('click', nextAndGetLots); } function getLots() { // eslint-disable-next-line no-unsanitized/property searchResultsContainerElement.innerHTML = los.getLoadingParagraphHTML(`Loading ${los.escapedAliases.Lots}...`); cityssm.postJSON(`${los.urlPrefix}/lots/doSearchLots`, searchFilterFormElement, renderLots); } function resetOffsetAndGetLots() { offsetElement.value = '0'; getLots(); } function previousAndGetLots() { offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString(); getLots(); } function nextAndGetLots() { offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString(); getLots(); } const filterElements = searchFilterFormElement.querySelectorAll('input, select'); for (const filterElement of filterElements) { filterElement.addEventListener('change', resetOffsetAndGetLots); } searchFilterFormElement.addEventListener('submit', (formEvent) => { formEvent.preventDefault(); }); getLots(); })();