"use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true });
(() => {
const los = exports.los;
const workOrderPrints = exports.workOrderPrints;
const searchFilterFormElement = document.querySelector('#form--searchFilters');
los.initializeDatePickers(searchFilterFormElement);
const searchResultsContainerElement = document.querySelector('#container--searchResults');
const limit = Number.parseInt(document.querySelector('#searchFilter--limit').value, 10);
const offsetElement = document.querySelector('#searchFilter--offset');
function renderWorkOrders(responseJSON) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
if (responseJSON.workOrders.length === 0) {
searchResultsContainerElement.innerHTML = `
There are no work orders that meet the search criteria.
`;
return;
}
const resultsTbodyElement = document.createElement('tbody');
for (const workOrder of responseJSON.workOrders) {
let relatedHTML = '';
for (const lot of workOrder.workOrderLots) {
relatedHTML += `
${cityssm.escapeHTML(((_b = lot.lotName) !== null && _b !== void 0 ? _b : '') === ''
? '(No ' + los.escapedAliases.Lot + ' Name)'
: lot.lotName)}
`;
}
for (const occupancy of workOrder.workOrderLotOccupancies) {
for (const occupant of occupancy.lotOccupancyOccupants) {
relatedHTML += `
${cityssm.escapeHTML(((_e = occupant.occupantName) !== null && _e !== void 0 ? _e : '') === '' &&
((_f = occupant.occupantFamilyName) !== null && _f !== void 0 ? _f : '') === ''
? '(No Name)'
: occupant.occupantName + ' ' + occupant.occupantFamilyName)}
`;
}
}
resultsTbodyElement.insertAdjacentHTML('beforeend', '' +
('| ' +
'' +
(workOrder.workOrderNumber.trim() === ''
? '(No Number)'
: cityssm.escapeHTML((_g = workOrder.workOrderNumber) !== null && _g !== void 0 ? _g : '')) +
'' +
' | ') +
('' +
cityssm.escapeHTML((_h = workOrder.workOrderType) !== null && _h !== void 0 ? _h : '') +
' ' +
'' +
cityssm.escapeHTML((_j = workOrder.workOrderDescription) !== null && _j !== void 0 ? _j : '') +
'' +
' | ') +
('' +
(relatedHTML === ''
? ''
: '') +
' | ') +
('' +
'' +
('- ' +
'' +
' ' +
workOrder.workOrderOpenDateString +
'
') +
('- ' +
'' +
' ' +
(workOrder.workOrderCloseDate
? workOrder.workOrderCloseDateString
: '(No ' +
los.escapedAliases.WorkOrderCloseDate +
')') +
'
') +
' ' +
' | ') +
('' +
(workOrder.workOrderMilestoneCount === 0
? '-'
: workOrder.workOrderMilestoneCompletionCount.toString() +
' / ' +
workOrder.workOrderMilestoneCount.toString()) +
' | ') +
(workOrderPrints.length > 0
? '' +
'' +
'' +
'' +
' | '
: '') +
'
');
}
searchResultsContainerElement.innerHTML = `