deepsource-autofix-76c6eb20
Dan Gowans 2024-06-27 13:48:12 -04:00
parent 604e122907
commit 9f94906112
17 changed files with 887 additions and 885 deletions

View File

@ -380,7 +380,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
los.populateAliases(modalElement); los.populateAliases(modalElement);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
var _a; var _a, _b;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
lotSelectModalElement = modalElement; lotSelectModalElement = modalElement;
lotSelectCloseModalFunction = closeModalFunction; lotSelectCloseModalFunction = closeModalFunction;
@ -428,7 +428,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const optionElement = document.createElement('option'); const optionElement = document.createElement('option');
optionElement.value = map.mapId.toString(); optionElement.value = map.mapId.toString();
optionElement.textContent = optionElement.textContent =
((_a = map.mapName) !== null && _a !== void 0 ? _a : '') === '' ? '(No Name)' : map.mapName; ((_a = map.mapName) !== null && _a !== void 0 ? _a : '') === '' ? '(No Name)' : (_b = map.mapName) !== null && _b !== void 0 ? _b : '';
mapElement.append(optionElement); mapElement.append(optionElement);
} }
; ;
@ -449,7 +449,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
else { else {
window.open(los.urlPrefix + '/lots/' + lotId); window.open(`${los.urlPrefix}/lots/${lotId}`);
} }
}); });
(_e = document (_e = document
@ -1586,7 +1586,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
.querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(tableRowElement); .querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(tableRowElement);
} }
; ;
lotOccupancyTransactionsContainerElement.querySelector('#lotOccupancyTransactions--grandTotal').textContent = '$' + transactionGrandTotal.toFixed(2); lotOccupancyTransactionsContainerElement.querySelector('#lotOccupancyTransactions--grandTotal').textContent = `\$${transactionGrandTotal.toFixed(2)}`;
const feeGrandTotal = getFeeGrandTotal(); const feeGrandTotal = getFeeGrandTotal();
if (feeGrandTotal.toFixed(2) !== transactionGrandTotal.toFixed(2)) { if (feeGrandTotal.toFixed(2) !== transactionGrandTotal.toFixed(2)) {
lotOccupancyTransactionsContainerElement.insertAdjacentHTML('afterbegin', `<div class="message is-warning"> lotOccupancyTransactionsContainerElement.insertAdjacentHTML('afterbegin', `<div class="message is-warning">
@ -1596,7 +1596,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
<div class="level-item">Outstanding Balance</div> <div class="level-item">Outstanding Balance</div>
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item">$${cityssm.escapeHTML((feeGrandTotal - transactionGrandTotal).toFixed(2))}</div> <div class="level-item">
$${cityssm.escapeHTML((feeGrandTotal - transactionGrandTotal).toFixed(2))}
</div>
</div> </div>
</div> </div>
</div></div>`); </div></div>`);

View File

@ -380,7 +380,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
los.populateAliases(modalElement); los.populateAliases(modalElement);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
var _a; var _a, _b;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
lotSelectModalElement = modalElement; lotSelectModalElement = modalElement;
lotSelectCloseModalFunction = closeModalFunction; lotSelectCloseModalFunction = closeModalFunction;
@ -428,7 +428,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const optionElement = document.createElement('option'); const optionElement = document.createElement('option');
optionElement.value = map.mapId.toString(); optionElement.value = map.mapId.toString();
optionElement.textContent = optionElement.textContent =
((_a = map.mapName) !== null && _a !== void 0 ? _a : '') === '' ? '(No Name)' : map.mapName; ((_a = map.mapName) !== null && _a !== void 0 ? _a : '') === '' ? '(No Name)' : (_b = map.mapName) !== null && _b !== void 0 ? _b : '';
mapElement.append(optionElement); mapElement.append(optionElement);
} }
; ;
@ -449,7 +449,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
else { else {
window.open(los.urlPrefix + '/lots/' + lotId); window.open(`${los.urlPrefix}/lots/${lotId}`);
} }
}); });
(_e = document (_e = document

View File

@ -661,7 +661,7 @@ declare const exports: Record<string, unknown>
const optionElement = document.createElement('option') const optionElement = document.createElement('option')
optionElement.value = map.mapId!.toString() optionElement.value = map.mapId!.toString()
optionElement.textContent = optionElement.textContent =
(map.mapName ?? '') === '' ? '(No Name)' : map.mapName! (map.mapName ?? '') === '' ? '(No Name)' : map.mapName ?? ''
mapElement.append(optionElement) mapElement.append(optionElement)
} }
@ -688,7 +688,7 @@ declare const exports: Record<string, unknown>
contextualColorName: 'info' contextualColorName: 'info'
}) })
} else { } else {
window.open(los.urlPrefix + '/lots/' + lotId) window.open(`${los.urlPrefix}/lots/${lotId}`)
} }
}) })

View File

@ -514,7 +514,7 @@ function renderLotOccupancyTransactions() {
.querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(tableRowElement); .querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(tableRowElement);
} }
; ;
lotOccupancyTransactionsContainerElement.querySelector('#lotOccupancyTransactions--grandTotal').textContent = '$' + transactionGrandTotal.toFixed(2); lotOccupancyTransactionsContainerElement.querySelector('#lotOccupancyTransactions--grandTotal').textContent = `\$${transactionGrandTotal.toFixed(2)}`;
const feeGrandTotal = getFeeGrandTotal(); const feeGrandTotal = getFeeGrandTotal();
if (feeGrandTotal.toFixed(2) !== transactionGrandTotal.toFixed(2)) { if (feeGrandTotal.toFixed(2) !== transactionGrandTotal.toFixed(2)) {
lotOccupancyTransactionsContainerElement.insertAdjacentHTML('afterbegin', `<div class="message is-warning"> lotOccupancyTransactionsContainerElement.insertAdjacentHTML('afterbegin', `<div class="message is-warning">
@ -524,7 +524,9 @@ function renderLotOccupancyTransactions() {
<div class="level-item">Outstanding Balance</div> <div class="level-item">Outstanding Balance</div>
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item">$${cityssm.escapeHTML((feeGrandTotal - transactionGrandTotal).toFixed(2))}</div> <div class="level-item">
$${cityssm.escapeHTML((feeGrandTotal - transactionGrandTotal).toFixed(2))}
</div>
</div> </div>
</div> </div>
</div></div>`); </div></div>`);

View File

@ -784,7 +784,7 @@ function renderLotOccupancyTransactions(): void {
lotOccupancyTransactionsContainerElement.querySelector( lotOccupancyTransactionsContainerElement.querySelector(
'#lotOccupancyTransactions--grandTotal' '#lotOccupancyTransactions--grandTotal'
) as HTMLElement ) as HTMLElement
).textContent = '$' + transactionGrandTotal.toFixed(2) ).textContent = `\$${transactionGrandTotal.toFixed(2)}`
const feeGrandTotal = getFeeGrandTotal() const feeGrandTotal = getFeeGrandTotal()
@ -798,7 +798,9 @@ function renderLotOccupancyTransactions(): void {
<div class="level-item">Outstanding Balance</div> <div class="level-item">Outstanding Balance</div>
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item">$${cityssm.escapeHTML((feeGrandTotal - transactionGrandTotal).toFixed(2))}</div> <div class="level-item">
$${cityssm.escapeHTML((feeGrandTotal - transactionGrandTotal).toFixed(2))}
</div>
</div> </div>
</div> </div>
</div></div>` </div></div>`

View File

@ -65,7 +65,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
function getLots() { function getLots() {
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = los.getLoadingParagraphHTML(`Loading ${los.escapedAliases.Lots}...`); searchResultsContainerElement.innerHTML = los.getLoadingParagraphHTML(`Loading ${los.escapedAliases.Lots}...`);
cityssm.postJSON(los.urlPrefix + '/lots/doSearchLots', searchFilterFormElement, renderLots); cityssm.postJSON(`${los.urlPrefix}/lots/doSearchLots`, searchFilterFormElement, renderLots);
} }
function resetOffsetAndGetLots() { function resetOffsetAndGetLots() {
offsetElement.value = '0'; offsetElement.value = '0';

View File

@ -121,7 +121,7 @@ declare const exports: Record<string, unknown>
) )
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/lots/doSearchLots', `${los.urlPrefix}/lots/doSearchLots`,
searchFilterFormElement, searchFilterFormElement,
renderLots renderLots
) )

View File

@ -153,7 +153,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
*/ */
if (!isCreate) { if (!isCreate) {
"use strict"; "use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
var _a, _b; var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let workOrderLots = exports.workOrderLots; let workOrderLots = exports.workOrderLots;
@ -163,7 +164,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
function deleteLotOccupancy(clickEvent) { function deleteLotOccupancy(clickEvent) {
const lotOccupancyId = clickEvent.currentTarget.closest('.container--lotOccupancy').dataset.lotOccupancyId; const lotOccupancyId = clickEvent.currentTarget.closest('.container--lotOccupancy').dataset.lotOccupancyId;
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderLotOccupancy', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderLotOccupancy`, {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -193,7 +194,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function addLot(lotId, callbackFunction) { function addLot(lotId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderLot', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderLot`, {
workOrderId, workOrderId,
lotId lotId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -216,7 +217,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function addLotOccupancy(lotOccupancyId, callbackFunction) { function addLotOccupancy(lotOccupancyId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderLotOccupancy', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderLotOccupancy`, {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -228,7 +229,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Adding ' + los.escapedAliases.Occupancy, title: `Error Adding ${los.escapedAliases.Occupancy}`,
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '', message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
contextualColorName: 'danger' contextualColorName: 'danger'
}); });
@ -239,19 +240,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function addLotFromLotOccupancy(clickEvent) { function addLotFromLotOccupancy(clickEvent) {
const lotId = clickEvent.currentTarget.dataset.lotId; var _a;
const lotId = (_a = clickEvent.currentTarget.dataset.lotId) !== null && _a !== void 0 ? _a : '';
addLot(lotId); addLot(lotId);
} }
function renderRelatedOccupancies() { function renderRelatedOccupancies() {
var _a, _b, _c, _d; var _a, _b, _c, _d, _e, _f;
const occupanciesContainerElement = document.querySelector('#container--lotOccupancies'); const occupanciesContainerElement = document.querySelector('#container--lotOccupancies');
document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString(); document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString();
if (workOrderLotOccupancies.length === 0) { if (workOrderLotOccupancies.length === 0) {
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<div class="message is-info"> occupanciesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p> <p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p>
</div>`; </div>`;
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -275,44 +279,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
workOrderLots.some((lot) => { workOrderLots.some((lot) => {
return lotOccupancy.lotId === lot.lotId; return lotOccupancy.lotId === lot.lotId;
}); });
rowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td class="is-width-1 has-text-centered">' + rowElement.innerHTML = `<td class="is-width-1 has-text-centered">
(isActive ${isActive
? '<i class="fas fa-play" title="Current ' + ? `<i class="fas fa-play" title="Current ${los.escapedAliases.Occupancy}"></i>`
los.escapedAliases.Occupancy + : `<i class="fas fa-stop" title="Previous ${los.escapedAliases.Occupancy}"></i>`}
'"></i>' </td><td>
: '<i class="fas fa-stop" title="Previous ' + <a class="has-text-weight-bold" href="${los.getLotOccupancyURL(lotOccupancy.lotOccupancyId)}">
los.escapedAliases.Occupancy + ${cityssm.escapeHTML((_a = lotOccupancy.occupancyType) !== null && _a !== void 0 ? _a : '')}
'"></i>') + </a><br />
'</td>' + <span class="is-size-7">#${lotOccupancy.lotOccupancyId}</span>
('<td>' + </td>`;
'<a class="has-text-weight-bold" href="' +
los.getLotOccupancyURL(lotOccupancy.lotOccupancyId) +
'">' +
cityssm.escapeHTML((_a = lotOccupancy.occupancyType) !== null && _a !== void 0 ? _a : '') +
'</a><br />' +
`<span class="is-size-7">#${lotOccupancy.lotOccupancyId}</span>` +
'</td>');
if (lotOccupancy.lotId) { if (lotOccupancy.lotId) {
rowElement.insertAdjacentHTML('beforeend', '<td>' + // eslint-disable-next-line no-unsanitized/method
cityssm.escapeHTML((_b = lotOccupancy.lotName) !== null && _b !== void 0 ? _b : '') + rowElement.insertAdjacentHTML('beforeend', `<td>
(hasLotRecord ${cityssm.escapeHTML((_b = lotOccupancy.lotName) !== null && _b !== void 0 ? _b : '')}
? '' ${hasLotRecord
: ' <button class="button is-small is-light is-success button--addLot"' + ? ''
' data-lot-id="' + : ` <button class="button is-small is-light is-success button--addLot"
lotOccupancy.lotId.toString() + data-lot-id="${lotOccupancy.lotId.toString()}"
'"' + data-tooltip="Add ${los.escapedAliases.Lot}"
' data-tooltip="Add ' + aria-label="Add ${los.escapedAliases.Lot}" type="button">
los.escapedAliases.Lot + <i class="fas fa-plus" aria-hidden="true"></i>
'"' + </button>`}
' aria-label="Add ' + </td>`);
los.escapedAliases.Lot +
'" type="button">' +
'<i class="fas fa-plus" aria-hidden="true"></i>' +
'</button>') +
'</td>');
} }
else { else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`); rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`);
} }
let occupantsHTML = ''; let occupantsHTML = '';
@ -328,41 +321,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
${cityssm.escapeHTML(occupant.occupantFamilyName)} ${cityssm.escapeHTML(occupant.occupantFamilyName)}
</li>`; </li>`;
} }
rowElement.insertAdjacentHTML('beforeend', '<td>' + // eslint-disable-next-line no-unsanitized/method
lotOccupancy.occupancyStartDateString + rowElement.insertAdjacentHTML('beforeend', `<td>
'</td>' + ${lotOccupancy.occupancyStartDateString}
('<td>' + </td><td>
(lotOccupancy.occupancyEndDate ${lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString ? lotOccupancy.occupancyEndDateString
: '<span class="has-text-grey">(No End Date)</span>') + : '<span class="has-text-grey">(No End Date)</span>'}
'</td>') + </td><td>
('<td>' + ${lotOccupancy.lotOccupancyOccupants.length === 0
(lotOccupancy.lotOccupancyOccupants.length === 0 ? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>`
? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>` : `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`}
: `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`) + </td><td>
'</td>') + <button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">
('<td>' + <i class="fas fa-trash" aria-hidden="true"></i>
'<button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">' + </button>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </td>`);
'</button>' +
'</td>'));
(_d = rowElement (_d = rowElement
.querySelector('.button--addLot')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', addLotFromLotOccupancy); .querySelector('.button--addLot')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', addLotFromLotOccupancy);
rowElement (_e = rowElement
.querySelector('.button--deleteLotOccupancy') .querySelector('.button--deleteLotOccupancy')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', deleteLotOccupancy);
.addEventListener('click', deleteLotOccupancy); (_f = occupanciesContainerElement.querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(rowElement);
occupanciesContainerElement.querySelector('tbody').append(rowElement);
} }
} }
function openEditLotStatus(clickEvent) { function openEditLotStatus(clickEvent) {
const lotId = Number.parseInt(clickEvent.currentTarget.closest('.container--lot').dataset.lotId, 10); var _a;
const lotId = Number.parseInt((_a = clickEvent.currentTarget.closest('.container--lot').dataset.lotId) !== null && _a !== void 0 ? _a : '', 10);
const lot = workOrderLots.find((possibleLot) => { const lot = workOrderLots.find((possibleLot) => {
return possibleLot.lotId === lotId; return possibleLot.lotId === lotId;
}); });
let editCloseModalFunction; let editCloseModalFunction;
function doUpdateLotStatus(submitEvent) { function doUpdateLotStatus(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doUpdateLotStatus', submitEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${los.urlPrefix}/workOrders/doUpdateLotStatus`, submitEvent.currentTarget, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
@ -381,9 +372,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('lot-editLotStatus', { cityssm.openHtmlModal('lot-editLotStatus', {
onshow(modalElement) { onshow(modalElement) {
var _a, _b, _c;
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector('#lotStatusEdit--lotId').value = lotId.toString(); modalElement.querySelector('#lotStatusEdit--lotId').value = lotId.toString();
modalElement.querySelector('#lotStatusEdit--lotName').value = lot.lotName; modalElement.querySelector('#lotStatusEdit--lotName').value = (_a = lot.lotName) !== null && _a !== void 0 ? _a : '';
const lotStatusElement = modalElement.querySelector('#lotStatusEdit--lotStatusId'); const lotStatusElement = modalElement.querySelector('#lotStatusEdit--lotStatusId');
let lotStatusFound = false; let lotStatusFound = false;
for (const lotStatus of exports.lotStatuses) { for (const lotStatus of exports.lotStatuses) {
@ -398,22 +390,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (!lotStatusFound && lot.lotStatusId) { if (!lotStatusFound && lot.lotStatusId) {
const optionElement = document.createElement('option'); const optionElement = document.createElement('option');
optionElement.value = lot.lotStatusId.toString(); optionElement.value = lot.lotStatusId.toString();
optionElement.textContent = lot.lotStatus; optionElement.textContent = (_b = lot.lotStatus) !== null && _b !== void 0 ? _b : '';
lotStatusElement.append(optionElement); lotStatusElement.append(optionElement);
} }
if (lot.lotStatusId) { if (lot.lotStatusId) {
lotStatusElement.value = lot.lotStatusId.toString(); lotStatusElement.value = lot.lotStatusId.toString();
} }
modalElement // eslint-disable-next-line no-unsanitized/method
.querySelector('form') (_c = modalElement
.insertAdjacentHTML('beforeend', `<input name="workOrderId" type="hidden" value="${workOrderId}" />`); .querySelector('form')) === null || _c === void 0 ? void 0 : _c.insertAdjacentHTML('beforeend', `<input name="workOrderId" type="hidden" value="${workOrderId}" />`);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
var _a;
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement (_a = modalElement
.querySelector('form') .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateLotStatus);
.addEventListener('submit', doUpdateLotStatus);
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -423,7 +415,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
function deleteLot(clickEvent) { function deleteLot(clickEvent) {
const lotId = clickEvent.currentTarget.closest('.container--lot').dataset.lotId; const lotId = clickEvent.currentTarget.closest('.container--lot').dataset.lotId;
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderLot', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderLot`, {
workOrderId, workOrderId,
lotId lotId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -453,59 +445,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function renderRelatedLots() { function renderRelatedLots() {
var _a, _b, _c, _d; var _a, _b, _c, _d, _e, _f, _g;
const lotsContainerElement = document.querySelector('#container--lots'); const lotsContainerElement = document.querySelector('#container--lots');
document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent = workOrderLots.length.toString(); document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent = workOrderLots.length.toString();
if (workOrderLots.length === 0) { if (workOrderLots.length === 0) {
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<div class="message is-info"> lotsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p> <p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
</div>`; </div>`;
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th>${los.escapedAliases.Lot}</th> <th>${los.escapedAliases.Lot}</th>
<th>${los.escapedAliases.Map}</th> <th>${los.escapedAliases.Map}</th>
<th>${los.escapedAliases.Lot} Type</th> <th>${los.escapedAliases.Lot} Type</th>
<th>Status</th> <th>Status</th>
<th class="has-width-1"></th> <th class="has-width-1"></th>
</tr></thead> </tr></thead>
<tbody></tbody> <tbody></tbody>
</table>`; </table>`;
for (const lot of workOrderLots) { for (const lot of workOrderLots) {
const rowElement = document.createElement('tr'); const rowElement = document.createElement('tr');
rowElement.className = 'container--lot'; rowElement.className = 'container--lot';
rowElement.dataset.lotId = lot.lotId.toString(); rowElement.dataset.lotId = lot.lotId.toString();
rowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td>' + rowElement.innerHTML = `<td>
'<a class="has-text-weight-bold" href="' + <a class="has-text-weight-bold" href="${los.getLotURL(lot.lotId)}">
los.getLotURL(lot.lotId) + ${cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '')}
'">' + </a>
cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '') + </td><td>
'</a>' + ${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}
'</td>' + </td><td>
`<td>${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}</td>` + ${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}
`<td>${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}</td>` + </td><td>
('<td>' + ${lot.lotStatusId
(lot.lotStatusId ? cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '')
? cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '') : '<span class="has-text-grey">(No Status)</span>'}
: '<span class="has-text-grey">(No Status)</span>') + </td><td class="is-nowrap">
'</td>') +
`<td class="is-nowrap">
<button class="button is-small is-light is-info button--editLotStatus" data-tooltip="Update Status" type="button"> <button class="button is-small is-light is-info button--editLotStatus" data-tooltip="Update Status" type="button">
<i class="fas fa-pencil-alt" aria-hidden="true"></i> <i class="fas fa-pencil-alt" aria-hidden="true"></i>
</button> </button>
<button class="button is-small is-light is-danger button--deleteLot" data-tooltip="Delete Relationship" type="button"> <button class="button is-small is-light is-danger button--deleteLot" data-tooltip="Delete Relationship" type="button">
<i class="fas fa-trash" aria-hidden="true"></i> <i class="fas fa-trash" aria-hidden="true"></i>
</button> </button>
</td>`; </td>`;
rowElement (_e = rowElement
.querySelector('.button--editLotStatus') .querySelector('.button--editLotStatus')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', openEditLotStatus);
.addEventListener('click', openEditLotStatus); (_f = rowElement
rowElement .querySelector('.button--deleteLot')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', deleteLot);
.querySelector('.button--deleteLot') (_g = lotsContainerElement.querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(rowElement);
.addEventListener('click', deleteLot);
lotsContainerElement.querySelector('tbody').append(rowElement);
} }
} }
function renderRelatedLotsAndOccupancies() { function renderRelatedLotsAndOccupancies() {
@ -514,8 +504,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
renderRelatedLotsAndOccupancies(); renderRelatedLotsAndOccupancies();
function doAddLotOccupancy(clickEvent) { function doAddLotOccupancy(clickEvent) {
var _a;
const rowElement = clickEvent.currentTarget.closest('tr'); const rowElement = clickEvent.currentTarget.closest('tr');
const lotOccupancyId = rowElement.dataset.lotOccupancyId; const lotOccupancyId = (_a = rowElement.dataset.lotOccupancyId) !== null && _a !== void 0 ? _a : '';
addLotOccupancy(lotOccupancyId, (success) => { addLotOccupancy(lotOccupancyId, (success) => {
if (success) { if (success) {
rowElement.remove(); rowElement.remove();
@ -530,10 +521,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...'); los.getLoadingParagraphHTML('Searching...');
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doSearchLotOccupancies', searchFormElement, (rawResponseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doSearchLotOccupancies`, searchFormElement, (rawResponseJSON) => {
var _a, _b; var _a, _b, _c, _d;
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.lotOccupancies.length === 0) { if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML = `<div class="message is-info"> searchResultsContainerElement.innerHTML = `<div class="message is-info">
@ -541,6 +533,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</div>`; </div>`;
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -571,32 +564,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
'</td>'); '</td>');
} }
else { else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`); rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`);
} }
rowElement.insertAdjacentHTML('beforeend', `<td>${lotOccupancy.occupancyStartDateString}</td>` + // eslint-disable-next-line no-unsanitized/method
('<td>' + rowElement.insertAdjacentHTML('beforeend', `<td>
(lotOccupancy.occupancyEndDate ${lotOccupancy.occupancyStartDateString}
? lotOccupancy.occupancyEndDateString </td><td>
: '<span class="has-text-grey">(No End Date)</span>') + ${lotOccupancy.occupancyEndDate
'</td>') + ? lotOccupancy.occupancyEndDateString
('<td>' + : '<span class="has-text-grey">(No End Date)</span>'}
(lotOccupancy.lotOccupancyOccupants.length === 0 </td><td>
? `<span class="has-text-grey">(No ${cityssm.escapeHTML(los.escapedAliases.Occupants)})</span>` ${lotOccupancy.lotOccupancyOccupants.length === 0
: cityssm.escapeHTML(lotOccupancy.lotOccupancyOccupants[0].occupantName + ? `<span class="has-text-grey">
' ' + (No ${cityssm.escapeHTML(los.escapedAliases.Occupants)})
lotOccupancy.lotOccupancyOccupants[0] </span>`
.occupantFamilyName) + : cityssm.escapeHTML(`${lotOccupancy.lotOccupancyOccupants[0].occupantName}
(lotOccupancy.lotOccupancyOccupants.length > 1 ${lotOccupancy.lotOccupancyOccupants[0]
? ' plus ' + .occupantFamilyName}`) +
(lotOccupancy.lotOccupancyOccupants.length - 1).toString() (lotOccupancy.lotOccupancyOccupants.length > 1
: '')) + ? ` plus
'</td>')); ${(lotOccupancy.lotOccupancyOccupants.length - 1).toString()}`
rowElement : '')}</td>`);
.querySelector('.button--addLotOccupancy') (_c = rowElement
.addEventListener('click', doAddLotOccupancy); .querySelector('.button--addLotOccupancy')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', doAddLotOccupancy);
searchResultsContainerElement (_d = searchResultsContainerElement
.querySelector('tbody') .querySelector('tbody')) === null || _d === void 0 ? void 0 : _d.append(rowElement);
.append(rowElement);
} }
}); });
} }
@ -624,8 +617,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
}); });
function doAddLot(clickEvent) { function doAddLot(clickEvent) {
var _a;
const rowElement = clickEvent.currentTarget.closest('tr'); const rowElement = clickEvent.currentTarget.closest('tr');
const lotId = rowElement.dataset.lotId; const lotId = (_a = rowElement.dataset.lotId) !== null && _a !== void 0 ? _a : '';
addLot(lotId, (success) => { addLot(lotId, (success) => {
if (success) { if (success) {
rowElement.remove(); rowElement.remove();
@ -639,18 +633,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...'); los.getLoadingParagraphHTML('Searching...');
cityssm.postJSON(los.urlPrefix + '/lots/doSearchLots', searchFormElement, (rawResponseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lots/doSearchLots`, searchFormElement, (rawResponseJSON) => {
var _a, _b, _c, _d; var _a, _b, _c, _d, _e, _f;
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.lots.length === 0) { if (responseJSON.lots.length === 0) {
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no records that meet the search criteria.</p>
'<p class="message-body">There are no records that meet the search criteria.</p>' + </div>`;
'</div>';
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -665,26 +660,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
const rowElement = document.createElement('tr'); const rowElement = document.createElement('tr');
rowElement.className = 'container--lot'; rowElement.className = 'container--lot';
rowElement.dataset.lotId = lot.lotId.toString(); rowElement.dataset.lotId = lot.lotId.toString();
rowElement.innerHTML = rowElement.innerHTML = `<td class="has-text-centered">
'<td class="has-text-centered">' + <button class="button is-small is-success button--addLot" data-tooltip="Add" type="button" aria-label="Add">
'<button class="button is-small is-success button--addLot" data-tooltip="Add" type="button" aria-label="Add">' + <i class="fas fa-plus" aria-hidden="true"></i>
'<i class="fas fa-plus" aria-hidden="true"></i>' + </button>
'</button>' + </td><td class="has-text-weight-bold">
'</td>' + ${cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '')}
('<td class="has-text-weight-bold">' + </td><td>
cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '') + ${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}
'</td>') + </td><td>
'<td>' + ${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}
cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '') + </td><td>
'</td>' + ${cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '')}
('<td>' + cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '') + '</td>') + </td>`;
('<td>' + cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '') + '</td>'); (_e = rowElement
rowElement .querySelector('.button--addLot')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', doAddLot);
.querySelector('.button--addLot') (_f = searchResultsContainerElement
.addEventListener('click', doAddLot); .querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(rowElement);
searchResultsContainerElement
.querySelector('tbody')
.append(rowElement);
} }
}); });
} }
@ -704,13 +696,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
doSearch(); doSearch();
}, },
onshown(modalElement) { onshown(modalElement) {
var _a;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
const lotNameElement = modalElement.querySelector('#lotSearch--lotName'); const lotNameElement = modalElement.querySelector('#lotSearch--lotName');
lotNameElement.addEventListener('change', doSearch); lotNameElement.addEventListener('change', doSearch);
lotNameElement.focus(); lotNameElement.focus();
modalElement (_a = modalElement
.querySelector('#lotSearch--lotStatusId') .querySelector('#lotSearch--lotStatusId')) === null || _a === void 0 ? void 0 : _a.addEventListener('change', doSearch);
.addEventListener('change', doSearch);
searchFormElement.addEventListener('submit', doSearch); searchFormElement.addEventListener('submit', doSearch);
}, },
onremoved() { onremoved() {
@ -725,14 +717,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
* Comments * Comments
*/ */
"use strict"; "use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
var _a; var _a;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let workOrderComments = exports.workOrderComments; let workOrderComments = exports.workOrderComments;
delete exports.workOrderComments; delete exports.workOrderComments;
function openEditWorkOrderComment(clickEvent) { function openEditWorkOrderComment(clickEvent) {
const workOrderCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.workOrderCommentId, 10); const workOrderCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.workOrderCommentId) !== null && _b !== void 0 ? _b : '', 10);
const workOrderComment = workOrderComments.find((currentComment) => { const workOrderComment = workOrderComments.find((currentComment) => {
return currentComment.workOrderCommentId === workOrderCommentId; return currentComment.workOrderCommentId === workOrderCommentId;
}); });
@ -740,8 +733,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
let editCloseModalFunction; let editCloseModalFunction;
function editComment(submitEvent) { function editComment(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doUpdateWorkOrderComment', editFormElement, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/workOrders/doUpdateWorkOrderComment`, editFormElement, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments; workOrderComments = responseJSON.workOrderComments;
editCloseModalFunction(); editCloseModalFunction();
@ -758,19 +752,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('workOrder-editComment', { cityssm.openHtmlModal('workOrder-editComment', {
onshow(modalElement) { onshow(modalElement) {
var _a, _b, _c, _d;
; ;
modalElement.querySelector('#workOrderCommentEdit--workOrderId').value = workOrderId; modalElement.querySelector('#workOrderCommentEdit--workOrderId').value = workOrderId;
modalElement.querySelector('#workOrderCommentEdit--workOrderCommentId').value = workOrderCommentId.toString(); modalElement.querySelector('#workOrderCommentEdit--workOrderCommentId').value = workOrderCommentId.toString();
modalElement.querySelector('#workOrderCommentEdit--workOrderComment').value = workOrderComment.workOrderComment; modalElement.querySelector('#workOrderCommentEdit--workOrderComment').value = (_a = workOrderComment.workOrderComment) !== null && _a !== void 0 ? _a : '';
const workOrderCommentDateStringElement = modalElement.querySelector('#workOrderCommentEdit--workOrderCommentDateString'); const workOrderCommentDateStringElement = modalElement.querySelector('#workOrderCommentEdit--workOrderCommentDateString');
workOrderCommentDateStringElement.value = workOrderCommentDateStringElement.value =
workOrderComment.workOrderCommentDateString; (_b = workOrderComment.workOrderCommentDateString) !== null && _b !== void 0 ? _b : '';
const currentDateString = cityssm.dateToString(new Date()); const currentDateString = cityssm.dateToString(new Date());
workOrderCommentDateStringElement.max = workOrderCommentDateStringElement.max =
workOrderComment.workOrderCommentDateString <= currentDateString workOrderComment.workOrderCommentDateString <= currentDateString
? currentDateString ? currentDateString
: workOrderComment.workOrderCommentDateString; : (_c = workOrderComment.workOrderCommentDateString) !== null && _c !== void 0 ? _c : '';
modalElement.querySelector('#workOrderCommentEdit--workOrderCommentTimeString').value = workOrderComment.workOrderCommentTimeString; modalElement.querySelector('#workOrderCommentEdit--workOrderCommentTimeString').value = (_d = workOrderComment.workOrderCommentTimeString) !== null && _d !== void 0 ? _d : '';
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -786,14 +781,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function deleteWorkOrderComment(clickEvent) { function deleteWorkOrderComment(clickEvent) {
const workOrderCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.workOrderCommentId, 10); const workOrderCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.workOrderCommentId) !== null && _b !== void 0 ? _b : '', 10);
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderComment', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderComment`, {
workOrderId, workOrderId,
workOrderCommentId workOrderCommentId
}, (responseJSON) => { }, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments; workOrderComments = responseJSON.workOrderComments;
renderWorkOrderComments(); renderWorkOrderComments();
@ -818,7 +814,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function renderWorkOrderComments() { function renderWorkOrderComments() {
var _a, _b; var _a, _b, _c, _d, _e, _f;
const containerElement = document.querySelector('#container--workOrderComments'); const containerElement = document.querySelector('#container--workOrderComments');
if (workOrderComments.length === 0) { if (workOrderComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info"> containerElement.innerHTML = `<div class="message is-info">
@ -836,38 +832,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
for (const workOrderComment of workOrderComments) { for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr'); const tableRowElement = document.createElement('tr');
tableRowElement.dataset.workOrderCommentId = tableRowElement.dataset.workOrderCommentId =
workOrderComment.workOrderCommentId.toString(); (_a = workOrderComment.workOrderCommentId) === null || _a === void 0 ? void 0 : _a.toString();
tableRowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td>' + tableRowElement.innerHTML = `<td>
cityssm.escapeHTML((_a = workOrderComment.recordCreate_userName) !== null && _a !== void 0 ? _a : '') + ${cityssm.escapeHTML((_b = workOrderComment.recordCreate_userName) !== null && _b !== void 0 ? _b : '')}
'</td>' + </td><td>
'<td>' + ${workOrderComment.workOrderCommentDateString}
workOrderComment.workOrderCommentDateString + ${workOrderComment.workOrderCommentTime === 0
(workOrderComment.workOrderCommentTime === 0 ? ''
? '' : ' ' + workOrderComment.workOrderCommentTimePeriodString}
: ' ' + workOrderComment.workOrderCommentTimePeriodString) + </td><td>
'</td>' + ${cityssm.escapeHTML((_c = workOrderComment.workOrderComment) !== null && _c !== void 0 ? _c : '')}
'<td>' + </td><td class="is-hidden-print">
cityssm.escapeHTML((_b = workOrderComment.workOrderComment) !== null && _b !== void 0 ? _b : '') + <div class="buttons are-small is-justify-content-end">
'</td>' + <button class="button is-primary button--edit" type="button">
('<td class="is-hidden-print">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
'<div class="buttons are-small is-justify-content-end">' + <span>Edit</span>
('<button class="button is-primary button--edit" type="button">' + </button>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + <button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">
' <span>Edit</span>' + <i class="fas fa-trash" aria-hidden="true"></i>
'</button>') + </button>
('<button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">' + </div>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </td>`;
'</button>') + (_d = tableRowElement
'</div>' + .querySelector('.button--edit')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', openEditWorkOrderComment);
'</td>'); (_e = tableRowElement
tableRowElement .querySelector('.button--delete')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', deleteWorkOrderComment);
.querySelector('.button--edit') (_f = tableElement.querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(tableRowElement);
.addEventListener('click', openEditWorkOrderComment);
tableRowElement
.querySelector('.button--delete')
.addEventListener('click', deleteWorkOrderComment);
tableElement.querySelector('tbody').append(tableRowElement);
} }
containerElement.innerHTML = ''; containerElement.innerHTML = '';
containerElement.append(tableElement); containerElement.append(tableElement);
@ -876,7 +867,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
let addCommentCloseModalFunction; let addCommentCloseModalFunction;
function doAddComment(formEvent) { function doAddComment(formEvent) {
formEvent.preventDefault(); formEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderComment', formEvent.currentTarget, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderComment`, formEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments; workOrderComments = responseJSON.workOrderComments;
renderWorkOrderComments(); renderWorkOrderComments();
@ -886,11 +878,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('workOrder-addComment', { cityssm.openHtmlModal('workOrder-addComment', {
onshow(modalElement) { onshow(modalElement) {
var _a;
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector('#workOrderCommentAdd--workOrderId').value = workOrderId; modalElement.querySelector('#workOrderCommentAdd--workOrderId').value = workOrderId;
modalElement (_a = modalElement
.querySelector('form') .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doAddComment);
.addEventListener('submit', doAddComment);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -1136,66 +1128,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
panelBlockElement.dataset.workOrderMilestoneId = panelBlockElement.dataset.workOrderMilestoneId =
(_a = milestone.workOrderMilestoneId) === null || _a === void 0 ? void 0 : _a.toString(); (_a = milestone.workOrderMilestoneId) === null || _a === void 0 ? void 0 : _a.toString();
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = panelBlockElement.innerHTML = `<div class="columns is-mobile">
'<div class="columns is-mobile">' + <div class="column is-narrow">
('<div class="column is-narrow">' + ${milestone.workOrderMilestoneCompletionDate
(milestone.workOrderMilestoneCompletionDate ? `<span class="button is-static"
? '<span class="button is-static" data-tooltip="Completed ' + data-tooltip="Completed ${milestone.workOrderMilestoneCompletionDateString}"
milestone.workOrderMilestoneCompletionDateString + aria-label="Completed ${milestone.workOrderMilestoneCompletionDateString}">
'" aria-label="Completed ' + <span class="icon is-small"><i class="fas fa-check" aria-hidden="true"></i></span>
milestone.workOrderMilestoneCompletionDateString + </span>`
'">' + : `<button class="button button--completeMilestone" data-tooltip="Incomplete" type="button" aria-label="Incomplete">
'<span class="icon is-small"><i class="fas fa-check" aria-hidden="true"></i></span>' + <span class="icon is-small"><i class="far fa-square" aria-hidden="true"></i></span>
'</span>' </button>`}
: '<button class="button button--completeMilestone" data-tooltip="Incomplete" type="button" aria-label="Incomplete">' + </div><div class="column">
'<span class="icon is-small"><i class="far fa-square" aria-hidden="true"></i></span>' + ${milestone.workOrderMilestoneTypeId
'</button>') + ? `<strong>${cityssm.escapeHTML((_b = milestone.workOrderMilestoneType) !== null && _b !== void 0 ? _b : '')}</strong><br />`
'</div>') + : ''}
('<div class="column">' + ${milestone.workOrderMilestoneDate === 0
(milestone.workOrderMilestoneTypeId ? '<span class="has-text-grey">(No Set Date)</span>'
? '<strong>' + : milestone.workOrderMilestoneDateString}
cityssm.escapeHTML((_b = milestone.workOrderMilestoneType) !== null && _b !== void 0 ? _b : '') + ${milestone.workOrderMilestoneTime
'</strong><br />' ? ` ${milestone.workOrderMilestoneTimePeriodString}`
: '') + : ''}<br />
(milestone.workOrderMilestoneDate === 0 <span class="is-size-7">
? '<span class="has-text-grey">(No Set Date)</span>' ${cityssm.escapeHTML((_c = milestone.workOrderMilestoneDescription) !== null && _c !== void 0 ? _c : '')}
: milestone.workOrderMilestoneDateString) + </span>
(milestone.workOrderMilestoneTime </div><div class="column is-narrow">
? ' ' + milestone.workOrderMilestoneTimePeriodString <div class="dropdown is-right">
: '') + <div class="dropdown-trigger">
'<br />' + <button class="button is-small" data-tooltip="Options" type="button" aria-label="Options">
'<span class="is-size-7">' + <i class="fas fa-ellipsis-v" aria-hidden="true"></i>
cityssm.escapeHTML((_c = milestone.workOrderMilestoneDescription) !== null && _c !== void 0 ? _c : '') + </button>
'</span>' + </div>
'</div>') + <div class="dropdown-menu">
('<div class="column is-narrow">' + <div class="dropdown-content">
'<div class="dropdown is-right">' + ${milestone.workOrderMilestoneCompletionDate
('<div class="dropdown-trigger">' + ? `<a class="dropdown-item button--reopenMilestone" href="#">
'<button class="button is-small" data-tooltip="Options" type="button" aria-label="Options">' + <span class="icon is-small"><i class="fas fa-times" aria-hidden="true"></i></span>
'<i class="fas fa-ellipsis-v" aria-hidden="true"></i>' + <span>Reopen Milestone</span>
'</button>' + </a>`
'</div>') + : `<a class="dropdown-item button--editMilestone" href="#">
('<div class="dropdown-menu">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
'<div class="dropdown-content">' + <span>Edit Milestone</span>
(milestone.workOrderMilestoneCompletionDate </a>`}
? '<a class="dropdown-item button--reopenMilestone" href="#">' + <hr class="dropdown-divider" />
'<span class="icon is-small"><i class="fas fa-times" aria-hidden="true"></i></span>' + <a class="dropdown-item button--deleteMilestone" href="#">
' <span>Reopen Milestone</span>' + <span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>
'</a>' <span>Delete Milestone</span>
: '<a class="dropdown-item button--editMilestone" href="#">' + </a>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + </div>
' <span>Edit Milestone</span>' + </div>
'</a>') + </div>
'<hr class="dropdown-divider" />' + </div></div>`;
'<a class="dropdown-item button--deleteMilestone" href="#">' +
'<span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>' +
' <span>Delete Milestone</span>' +
'</a>' +
'</div>' +
'</div>') +
'</div>' +
'</div>') +
'</div>';
(_d = panelBlockElement (_d = panelBlockElement
.querySelector('.button--reopenMilestone')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', reopenMilestone); .querySelector('.button--reopenMilestone')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', reopenMilestone);
(_e = panelBlockElement (_e = panelBlockElement

View File

@ -385,66 +385,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
panelBlockElement.dataset.workOrderMilestoneId = panelBlockElement.dataset.workOrderMilestoneId =
(_a = milestone.workOrderMilestoneId) === null || _a === void 0 ? void 0 : _a.toString(); (_a = milestone.workOrderMilestoneId) === null || _a === void 0 ? void 0 : _a.toString();
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = panelBlockElement.innerHTML = `<div class="columns is-mobile">
'<div class="columns is-mobile">' + <div class="column is-narrow">
('<div class="column is-narrow">' + ${milestone.workOrderMilestoneCompletionDate
(milestone.workOrderMilestoneCompletionDate ? `<span class="button is-static"
? '<span class="button is-static" data-tooltip="Completed ' + data-tooltip="Completed ${milestone.workOrderMilestoneCompletionDateString}"
milestone.workOrderMilestoneCompletionDateString + aria-label="Completed ${milestone.workOrderMilestoneCompletionDateString}">
'" aria-label="Completed ' + <span class="icon is-small"><i class="fas fa-check" aria-hidden="true"></i></span>
milestone.workOrderMilestoneCompletionDateString + </span>`
'">' + : `<button class="button button--completeMilestone" data-tooltip="Incomplete" type="button" aria-label="Incomplete">
'<span class="icon is-small"><i class="fas fa-check" aria-hidden="true"></i></span>' + <span class="icon is-small"><i class="far fa-square" aria-hidden="true"></i></span>
'</span>' </button>`}
: '<button class="button button--completeMilestone" data-tooltip="Incomplete" type="button" aria-label="Incomplete">' + </div><div class="column">
'<span class="icon is-small"><i class="far fa-square" aria-hidden="true"></i></span>' + ${milestone.workOrderMilestoneTypeId
'</button>') + ? `<strong>${cityssm.escapeHTML((_b = milestone.workOrderMilestoneType) !== null && _b !== void 0 ? _b : '')}</strong><br />`
'</div>') + : ''}
('<div class="column">' + ${milestone.workOrderMilestoneDate === 0
(milestone.workOrderMilestoneTypeId ? '<span class="has-text-grey">(No Set Date)</span>'
? '<strong>' + : milestone.workOrderMilestoneDateString}
cityssm.escapeHTML((_b = milestone.workOrderMilestoneType) !== null && _b !== void 0 ? _b : '') + ${milestone.workOrderMilestoneTime
'</strong><br />' ? ` ${milestone.workOrderMilestoneTimePeriodString}`
: '') + : ''}<br />
(milestone.workOrderMilestoneDate === 0 <span class="is-size-7">
? '<span class="has-text-grey">(No Set Date)</span>' ${cityssm.escapeHTML((_c = milestone.workOrderMilestoneDescription) !== null && _c !== void 0 ? _c : '')}
: milestone.workOrderMilestoneDateString) + </span>
(milestone.workOrderMilestoneTime </div><div class="column is-narrow">
? ' ' + milestone.workOrderMilestoneTimePeriodString <div class="dropdown is-right">
: '') + <div class="dropdown-trigger">
'<br />' + <button class="button is-small" data-tooltip="Options" type="button" aria-label="Options">
'<span class="is-size-7">' + <i class="fas fa-ellipsis-v" aria-hidden="true"></i>
cityssm.escapeHTML((_c = milestone.workOrderMilestoneDescription) !== null && _c !== void 0 ? _c : '') + </button>
'</span>' + </div>
'</div>') + <div class="dropdown-menu">
('<div class="column is-narrow">' + <div class="dropdown-content">
'<div class="dropdown is-right">' + ${milestone.workOrderMilestoneCompletionDate
('<div class="dropdown-trigger">' + ? `<a class="dropdown-item button--reopenMilestone" href="#">
'<button class="button is-small" data-tooltip="Options" type="button" aria-label="Options">' + <span class="icon is-small"><i class="fas fa-times" aria-hidden="true"></i></span>
'<i class="fas fa-ellipsis-v" aria-hidden="true"></i>' + <span>Reopen Milestone</span>
'</button>' + </a>`
'</div>') + : `<a class="dropdown-item button--editMilestone" href="#">
('<div class="dropdown-menu">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
'<div class="dropdown-content">' + <span>Edit Milestone</span>
(milestone.workOrderMilestoneCompletionDate </a>`}
? '<a class="dropdown-item button--reopenMilestone" href="#">' + <hr class="dropdown-divider" />
'<span class="icon is-small"><i class="fas fa-times" aria-hidden="true"></i></span>' + <a class="dropdown-item button--deleteMilestone" href="#">
' <span>Reopen Milestone</span>' + <span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>
'</a>' <span>Delete Milestone</span>
: '<a class="dropdown-item button--editMilestone" href="#">' + </a>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + </div>
' <span>Edit Milestone</span>' + </div>
'</a>') + </div>
'<hr class="dropdown-divider" />' + </div></div>`;
'<a class="dropdown-item button--deleteMilestone" href="#">' +
'<span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>' +
' <span>Delete Milestone</span>' +
'</a>' +
'</div>' +
'</div>') +
'</div>' +
'</div>') +
'</div>';
(_d = panelBlockElement (_d = panelBlockElement
.querySelector('.button--reopenMilestone')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', reopenMilestone); .querySelector('.button--reopenMilestone')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', reopenMilestone);
(_e = panelBlockElement (_e = panelBlockElement

View File

@ -598,66 +598,67 @@ declare const exports: Record<string, unknown>
milestone.workOrderMilestoneId?.toString() milestone.workOrderMilestoneId?.toString()
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = panelBlockElement.innerHTML = `<div class="columns is-mobile">
'<div class="columns is-mobile">' + <div class="column is-narrow">
('<div class="column is-narrow">' + ${
(milestone.workOrderMilestoneCompletionDate milestone.workOrderMilestoneCompletionDate
? '<span class="button is-static" data-tooltip="Completed ' + ? `<span class="button is-static"
milestone.workOrderMilestoneCompletionDateString + data-tooltip="Completed ${milestone.workOrderMilestoneCompletionDateString}"
'" aria-label="Completed ' + aria-label="Completed ${milestone.workOrderMilestoneCompletionDateString}">
milestone.workOrderMilestoneCompletionDateString + <span class="icon is-small"><i class="fas fa-check" aria-hidden="true"></i></span>
'">' + </span>`
'<span class="icon is-small"><i class="fas fa-check" aria-hidden="true"></i></span>' + : `<button class="button button--completeMilestone" data-tooltip="Incomplete" type="button" aria-label="Incomplete">
'</span>' <span class="icon is-small"><i class="far fa-square" aria-hidden="true"></i></span>
: '<button class="button button--completeMilestone" data-tooltip="Incomplete" type="button" aria-label="Incomplete">' + </button>`
'<span class="icon is-small"><i class="far fa-square" aria-hidden="true"></i></span>' + }
'</button>') + </div><div class="column">
'</div>') + ${
('<div class="column">' + milestone.workOrderMilestoneTypeId
(milestone.workOrderMilestoneTypeId ? `<strong>${cityssm.escapeHTML(milestone.workOrderMilestoneType ?? '')}</strong><br />`
? '<strong>' + : ''
cityssm.escapeHTML(milestone.workOrderMilestoneType ?? '') + }
'</strong><br />' ${
: '') + milestone.workOrderMilestoneDate === 0
(milestone.workOrderMilestoneDate === 0 ? '<span class="has-text-grey">(No Set Date)</span>'
? '<span class="has-text-grey">(No Set Date)</span>' : milestone.workOrderMilestoneDateString
: milestone.workOrderMilestoneDateString) + }
(milestone.workOrderMilestoneTime ${
? ' ' + milestone.workOrderMilestoneTimePeriodString milestone.workOrderMilestoneTime
: '') + ? ` ${milestone.workOrderMilestoneTimePeriodString}`
'<br />' + : ''
'<span class="is-size-7">' + }<br />
cityssm.escapeHTML(milestone.workOrderMilestoneDescription ?? '') + <span class="is-size-7">
'</span>' + ${cityssm.escapeHTML(milestone.workOrderMilestoneDescription ?? '')}
'</div>') + </span>
('<div class="column is-narrow">' + </div><div class="column is-narrow">
'<div class="dropdown is-right">' + <div class="dropdown is-right">
('<div class="dropdown-trigger">' + <div class="dropdown-trigger">
'<button class="button is-small" data-tooltip="Options" type="button" aria-label="Options">' + <button class="button is-small" data-tooltip="Options" type="button" aria-label="Options">
'<i class="fas fa-ellipsis-v" aria-hidden="true"></i>' + <i class="fas fa-ellipsis-v" aria-hidden="true"></i>
'</button>' + </button>
'</div>') + </div>
('<div class="dropdown-menu">' + <div class="dropdown-menu">
'<div class="dropdown-content">' + <div class="dropdown-content">
(milestone.workOrderMilestoneCompletionDate ${
? '<a class="dropdown-item button--reopenMilestone" href="#">' + milestone.workOrderMilestoneCompletionDate
'<span class="icon is-small"><i class="fas fa-times" aria-hidden="true"></i></span>' + ? `<a class="dropdown-item button--reopenMilestone" href="#">
' <span>Reopen Milestone</span>' + <span class="icon is-small"><i class="fas fa-times" aria-hidden="true"></i></span>
'</a>' <span>Reopen Milestone</span>
: '<a class="dropdown-item button--editMilestone" href="#">' + </a>`
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + : `<a class="dropdown-item button--editMilestone" href="#">
' <span>Edit Milestone</span>' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
'</a>') + <span>Edit Milestone</span>
'<hr class="dropdown-divider" />' + </a>`
'<a class="dropdown-item button--deleteMilestone" href="#">' + }
'<span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>' + <hr class="dropdown-divider" />
' <span>Delete Milestone</span>' + <a class="dropdown-item button--deleteMilestone" href="#">
'</a>' + <span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>
'</div>' + <span>Delete Milestone</span>
'</div>') + </a>
'</div>' + </div>
'</div>') + </div>
'</div>' </div>
</div></div>`
panelBlockElement panelBlockElement
.querySelector('.button--reopenMilestone') .querySelector('.button--reopenMilestone')

View File

@ -1,12 +1,13 @@
"use strict"; "use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
var _a; var _a;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let workOrderComments = exports.workOrderComments; let workOrderComments = exports.workOrderComments;
delete exports.workOrderComments; delete exports.workOrderComments;
function openEditWorkOrderComment(clickEvent) { function openEditWorkOrderComment(clickEvent) {
const workOrderCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.workOrderCommentId, 10); const workOrderCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.workOrderCommentId) !== null && _b !== void 0 ? _b : '', 10);
const workOrderComment = workOrderComments.find((currentComment) => { const workOrderComment = workOrderComments.find((currentComment) => {
return currentComment.workOrderCommentId === workOrderCommentId; return currentComment.workOrderCommentId === workOrderCommentId;
}); });
@ -14,8 +15,9 @@ function openEditWorkOrderComment(clickEvent) {
let editCloseModalFunction; let editCloseModalFunction;
function editComment(submitEvent) { function editComment(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doUpdateWorkOrderComment', editFormElement, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/workOrders/doUpdateWorkOrderComment`, editFormElement, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments; workOrderComments = responseJSON.workOrderComments;
editCloseModalFunction(); editCloseModalFunction();
@ -32,19 +34,20 @@ function openEditWorkOrderComment(clickEvent) {
} }
cityssm.openHtmlModal('workOrder-editComment', { cityssm.openHtmlModal('workOrder-editComment', {
onshow(modalElement) { onshow(modalElement) {
var _a, _b, _c, _d;
; ;
modalElement.querySelector('#workOrderCommentEdit--workOrderId').value = workOrderId; modalElement.querySelector('#workOrderCommentEdit--workOrderId').value = workOrderId;
modalElement.querySelector('#workOrderCommentEdit--workOrderCommentId').value = workOrderCommentId.toString(); modalElement.querySelector('#workOrderCommentEdit--workOrderCommentId').value = workOrderCommentId.toString();
modalElement.querySelector('#workOrderCommentEdit--workOrderComment').value = workOrderComment.workOrderComment; modalElement.querySelector('#workOrderCommentEdit--workOrderComment').value = (_a = workOrderComment.workOrderComment) !== null && _a !== void 0 ? _a : '';
const workOrderCommentDateStringElement = modalElement.querySelector('#workOrderCommentEdit--workOrderCommentDateString'); const workOrderCommentDateStringElement = modalElement.querySelector('#workOrderCommentEdit--workOrderCommentDateString');
workOrderCommentDateStringElement.value = workOrderCommentDateStringElement.value =
workOrderComment.workOrderCommentDateString; (_b = workOrderComment.workOrderCommentDateString) !== null && _b !== void 0 ? _b : '';
const currentDateString = cityssm.dateToString(new Date()); const currentDateString = cityssm.dateToString(new Date());
workOrderCommentDateStringElement.max = workOrderCommentDateStringElement.max =
workOrderComment.workOrderCommentDateString <= currentDateString workOrderComment.workOrderCommentDateString <= currentDateString
? currentDateString ? currentDateString
: workOrderComment.workOrderCommentDateString; : (_c = workOrderComment.workOrderCommentDateString) !== null && _c !== void 0 ? _c : '';
modalElement.querySelector('#workOrderCommentEdit--workOrderCommentTimeString').value = workOrderComment.workOrderCommentTimeString; modalElement.querySelector('#workOrderCommentEdit--workOrderCommentTimeString').value = (_d = workOrderComment.workOrderCommentTimeString) !== null && _d !== void 0 ? _d : '';
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -60,14 +63,15 @@ function openEditWorkOrderComment(clickEvent) {
}); });
} }
function deleteWorkOrderComment(clickEvent) { function deleteWorkOrderComment(clickEvent) {
const workOrderCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.workOrderCommentId, 10); const workOrderCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.workOrderCommentId) !== null && _b !== void 0 ? _b : '', 10);
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderComment', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderComment`, {
workOrderId, workOrderId,
workOrderCommentId workOrderCommentId
}, (responseJSON) => { }, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments; workOrderComments = responseJSON.workOrderComments;
renderWorkOrderComments(); renderWorkOrderComments();
@ -92,7 +96,7 @@ function deleteWorkOrderComment(clickEvent) {
}); });
} }
function renderWorkOrderComments() { function renderWorkOrderComments() {
var _a, _b; var _a, _b, _c, _d, _e, _f;
const containerElement = document.querySelector('#container--workOrderComments'); const containerElement = document.querySelector('#container--workOrderComments');
if (workOrderComments.length === 0) { if (workOrderComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info"> containerElement.innerHTML = `<div class="message is-info">
@ -110,38 +114,33 @@ function renderWorkOrderComments() {
for (const workOrderComment of workOrderComments) { for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr'); const tableRowElement = document.createElement('tr');
tableRowElement.dataset.workOrderCommentId = tableRowElement.dataset.workOrderCommentId =
workOrderComment.workOrderCommentId.toString(); (_a = workOrderComment.workOrderCommentId) === null || _a === void 0 ? void 0 : _a.toString();
tableRowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td>' + tableRowElement.innerHTML = `<td>
cityssm.escapeHTML((_a = workOrderComment.recordCreate_userName) !== null && _a !== void 0 ? _a : '') + ${cityssm.escapeHTML((_b = workOrderComment.recordCreate_userName) !== null && _b !== void 0 ? _b : '')}
'</td>' + </td><td>
'<td>' + ${workOrderComment.workOrderCommentDateString}
workOrderComment.workOrderCommentDateString + ${workOrderComment.workOrderCommentTime === 0
(workOrderComment.workOrderCommentTime === 0 ? ''
? '' : ' ' + workOrderComment.workOrderCommentTimePeriodString}
: ' ' + workOrderComment.workOrderCommentTimePeriodString) + </td><td>
'</td>' + ${cityssm.escapeHTML((_c = workOrderComment.workOrderComment) !== null && _c !== void 0 ? _c : '')}
'<td>' + </td><td class="is-hidden-print">
cityssm.escapeHTML((_b = workOrderComment.workOrderComment) !== null && _b !== void 0 ? _b : '') + <div class="buttons are-small is-justify-content-end">
'</td>' + <button class="button is-primary button--edit" type="button">
('<td class="is-hidden-print">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
'<div class="buttons are-small is-justify-content-end">' + <span>Edit</span>
('<button class="button is-primary button--edit" type="button">' + </button>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + <button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">
' <span>Edit</span>' + <i class="fas fa-trash" aria-hidden="true"></i>
'</button>') + </button>
('<button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">' + </div>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </td>`;
'</button>') + (_d = tableRowElement
'</div>' + .querySelector('.button--edit')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', openEditWorkOrderComment);
'</td>'); (_e = tableRowElement
tableRowElement .querySelector('.button--delete')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', deleteWorkOrderComment);
.querySelector('.button--edit') (_f = tableElement.querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(tableRowElement);
.addEventListener('click', openEditWorkOrderComment);
tableRowElement
.querySelector('.button--delete')
.addEventListener('click', deleteWorkOrderComment);
tableElement.querySelector('tbody').append(tableRowElement);
} }
containerElement.innerHTML = ''; containerElement.innerHTML = '';
containerElement.append(tableElement); containerElement.append(tableElement);
@ -150,7 +149,8 @@ function openAddCommentModal() {
let addCommentCloseModalFunction; let addCommentCloseModalFunction;
function doAddComment(formEvent) { function doAddComment(formEvent) {
formEvent.preventDefault(); formEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderComment', formEvent.currentTarget, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderComment`, formEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments; workOrderComments = responseJSON.workOrderComments;
renderWorkOrderComments(); renderWorkOrderComments();
@ -160,11 +160,11 @@ function openAddCommentModal() {
} }
cityssm.openHtmlModal('workOrder-addComment', { cityssm.openHtmlModal('workOrder-addComment', {
onshow(modalElement) { onshow(modalElement) {
var _a;
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector('#workOrderCommentAdd--workOrderId').value = workOrderId; modalElement.querySelector('#workOrderCommentAdd--workOrderId').value = workOrderId;
modalElement (_a = modalElement
.querySelector('form') .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doAddComment);
.addEventListener('submit', doAddComment);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();

View File

@ -1,33 +1,35 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types' import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { BulmaJS } from '@cityssm/bulma-js/types' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type * as globalTypes from '../../types/globalTypes' import type { LOS } from '../../types/globalTypes.js'
import type * as recordTypes from '../../types/recordTypes' import type * as recordTypes from '../../types/recordTypes.js'
declare const cityssm: cityssmGlobal declare const cityssm: cityssmGlobal
declare const bulmaJS: BulmaJS declare const bulmaJS: BulmaJS
declare const los: globalTypes.LOS declare const exports: Record<string, unknown>
declare const los: LOS
declare const workOrderId: string declare const workOrderId: string
declare const isCreate: boolean declare const isCreate: boolean
let workOrderComments: recordTypes.WorkOrderComment[] = let workOrderComments =
exports.workOrderComments exports.workOrderComments as recordTypes.WorkOrderComment[]
delete exports.workOrderComments delete exports.workOrderComments
function openEditWorkOrderComment(clickEvent: Event): void { function openEditWorkOrderComment(clickEvent: Event): void {
const workOrderCommentId = Number.parseInt( const workOrderCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset (clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.workOrderCommentId!, .workOrderCommentId ?? '',
10 10
) )
const workOrderComment = workOrderComments.find((currentComment) => { const workOrderComment = workOrderComments.find((currentComment) => {
return currentComment.workOrderCommentId === workOrderCommentId return currentComment.workOrderCommentId === workOrderCommentId
})! }) as recordTypes.WorkOrderComment
let editFormElement: HTMLFormElement let editFormElement: HTMLFormElement
let editCloseModalFunction: () => void let editCloseModalFunction: () => void
@ -36,15 +38,17 @@ function openEditWorkOrderComment(clickEvent: Event): void {
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doUpdateWorkOrderComment', `${los.urlPrefix}/workOrders/doUpdateWorkOrderComment`,
editFormElement, editFormElement,
(responseJSON: { (rawResponseJSON) => {
success: boolean const responseJSON = rawResponseJSON as {
errorMessage?: string success: boolean
workOrderComments?: recordTypes.WorkOrderComment[] errorMessage?: string
}) => { workOrderComments: recordTypes.WorkOrderComment[]
}
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments! workOrderComments = responseJSON.workOrderComments
editCloseModalFunction() editCloseModalFunction()
renderWorkOrderComments() renderWorkOrderComments()
} else { } else {
@ -74,26 +78,26 @@ function openEditWorkOrderComment(clickEvent: Event): void {
modalElement.querySelector( modalElement.querySelector(
'#workOrderCommentEdit--workOrderComment' '#workOrderCommentEdit--workOrderComment'
) as HTMLInputElement ) as HTMLInputElement
).value = workOrderComment.workOrderComment! ).value = workOrderComment.workOrderComment ?? ''
const workOrderCommentDateStringElement = modalElement.querySelector( const workOrderCommentDateStringElement = modalElement.querySelector(
'#workOrderCommentEdit--workOrderCommentDateString' '#workOrderCommentEdit--workOrderCommentDateString'
) as HTMLInputElement ) as HTMLInputElement
workOrderCommentDateStringElement.value = workOrderCommentDateStringElement.value =
workOrderComment.workOrderCommentDateString! workOrderComment.workOrderCommentDateString ?? ''
const currentDateString = cityssm.dateToString(new Date()) const currentDateString = cityssm.dateToString(new Date())
workOrderCommentDateStringElement.max = workOrderCommentDateStringElement.max =
workOrderComment.workOrderCommentDateString! <= currentDateString workOrderComment.workOrderCommentDateString! <= currentDateString
? currentDateString ? currentDateString
: workOrderComment.workOrderCommentDateString! : workOrderComment.workOrderCommentDateString ?? ''
;( ;(
modalElement.querySelector( modalElement.querySelector(
'#workOrderCommentEdit--workOrderCommentTimeString' '#workOrderCommentEdit--workOrderCommentTimeString'
) as HTMLInputElement ) as HTMLInputElement
).value = workOrderComment.workOrderCommentTimeString! ).value = workOrderComment.workOrderCommentTimeString ?? ''
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
@ -105,7 +109,7 @@ function openEditWorkOrderComment(clickEvent: Event): void {
) as HTMLTextAreaElement ) as HTMLTextAreaElement
).focus() ).focus()
editFormElement = modalElement.querySelector('form')! editFormElement = modalElement.querySelector('form') as HTMLFormElement
editFormElement.addEventListener('submit', editComment) editFormElement.addEventListener('submit', editComment)
editCloseModalFunction = closeModalFunction editCloseModalFunction = closeModalFunction
@ -118,23 +122,25 @@ function openEditWorkOrderComment(clickEvent: Event): void {
function deleteWorkOrderComment(clickEvent: Event): void { function deleteWorkOrderComment(clickEvent: Event): void {
const workOrderCommentId = Number.parseInt( const workOrderCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset (clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.workOrderCommentId!, .workOrderCommentId ?? '',
10 10
) )
function doDelete(): void { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doDeleteWorkOrderComment', `${los.urlPrefix}/workOrders/doDeleteWorkOrderComment`,
{ {
workOrderId, workOrderId,
workOrderCommentId workOrderCommentId
}, },
(responseJSON: { (rawResponseJSON) => {
success: boolean const responseJSON = rawResponseJSON as {
errorMessage?: string success: boolean
workOrderComments: recordTypes.WorkOrderComment[] errorMessage?: string
}) => { workOrderComments: recordTypes.WorkOrderComment[]
}
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments workOrderComments = responseJSON.workOrderComments
renderWorkOrderComments() renderWorkOrderComments()
@ -182,43 +188,43 @@ function renderWorkOrderComments(): void {
for (const workOrderComment of workOrderComments) { for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr') const tableRowElement = document.createElement('tr')
tableRowElement.dataset.workOrderCommentId = tableRowElement.dataset.workOrderCommentId =
workOrderComment.workOrderCommentId!.toString() workOrderComment.workOrderCommentId?.toString()
tableRowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td>' + tableRowElement.innerHTML = `<td>
cityssm.escapeHTML(workOrderComment.recordCreate_userName ?? '') + ${cityssm.escapeHTML(workOrderComment.recordCreate_userName ?? '')}
'</td>' + </td><td>
'<td>' + ${workOrderComment.workOrderCommentDateString}
workOrderComment.workOrderCommentDateString + ${
(workOrderComment.workOrderCommentTime === 0 workOrderComment.workOrderCommentTime === 0
? '' ? ''
: ' ' + workOrderComment.workOrderCommentTimePeriodString!) + : ' ' + workOrderComment.workOrderCommentTimePeriodString
'</td>' + }
'<td>' + </td><td>
cityssm.escapeHTML(workOrderComment.workOrderComment ?? '') + ${cityssm.escapeHTML(workOrderComment.workOrderComment ?? '')}
'</td>' + </td><td class="is-hidden-print">
('<td class="is-hidden-print">' + <div class="buttons are-small is-justify-content-end">
'<div class="buttons are-small is-justify-content-end">' + <button class="button is-primary button--edit" type="button">
('<button class="button is-primary button--edit" type="button">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + <span>Edit</span>
' <span>Edit</span>' + </button>
'</button>') + <button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">
('<button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">' + <i class="fas fa-trash" aria-hidden="true"></i>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </button>
'</button>') + </div>
'</div>' + </td>`
'</td>')
tableRowElement tableRowElement
.querySelector('.button--edit')! .querySelector('.button--edit')
.addEventListener('click', openEditWorkOrderComment) ?.addEventListener('click', openEditWorkOrderComment)
tableRowElement tableRowElement
.querySelector('.button--delete')! .querySelector('.button--delete')
.addEventListener('click', deleteWorkOrderComment) ?.addEventListener('click', deleteWorkOrderComment)
tableElement.querySelector('tbody')!.append(tableRowElement) tableElement.querySelector('tbody')?.append(tableRowElement)
} }
containerElement.innerHTML = '' containerElement.innerHTML = ''
@ -232,14 +238,16 @@ function openAddCommentModal(): void {
formEvent.preventDefault() formEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doAddWorkOrderComment', `${los.urlPrefix}/workOrders/doAddWorkOrderComment`,
formEvent.currentTarget, formEvent.currentTarget,
(responseJSON: { (rawResponseJSON) => {
success: boolean const responseJSON = rawResponseJSON as {
workOrderComments?: recordTypes.WorkOrderComment[] success: boolean
}) => { workOrderComments: recordTypes.WorkOrderComment[]
}
if (responseJSON.success) { if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments! workOrderComments = responseJSON.workOrderComments
renderWorkOrderComments() renderWorkOrderComments()
addCommentCloseModalFunction() addCommentCloseModalFunction()
} }
@ -255,9 +263,10 @@ function openAddCommentModal(): void {
'#workOrderCommentAdd--workOrderId' '#workOrderCommentAdd--workOrderId'
) as HTMLInputElement ) as HTMLInputElement
).value = workOrderId ).value = workOrderId
modalElement modalElement
.querySelector('form')! .querySelector('form')
.addEventListener('submit', doAddComment) ?.addEventListener('submit', doAddComment)
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()

View File

@ -1,5 +1,6 @@
"use strict"; "use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
var _a, _b; var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let workOrderLots = exports.workOrderLots; let workOrderLots = exports.workOrderLots;
@ -9,7 +10,7 @@ delete exports.workOrderLotOccupancies;
function deleteLotOccupancy(clickEvent) { function deleteLotOccupancy(clickEvent) {
const lotOccupancyId = clickEvent.currentTarget.closest('.container--lotOccupancy').dataset.lotOccupancyId; const lotOccupancyId = clickEvent.currentTarget.closest('.container--lotOccupancy').dataset.lotOccupancyId;
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderLotOccupancy', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderLotOccupancy`, {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -39,7 +40,7 @@ function deleteLotOccupancy(clickEvent) {
}); });
} }
function addLot(lotId, callbackFunction) { function addLot(lotId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderLot', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderLot`, {
workOrderId, workOrderId,
lotId lotId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -62,7 +63,7 @@ function addLot(lotId, callbackFunction) {
}); });
} }
function addLotOccupancy(lotOccupancyId, callbackFunction) { function addLotOccupancy(lotOccupancyId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderLotOccupancy', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderLotOccupancy`, {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -74,7 +75,7 @@ function addLotOccupancy(lotOccupancyId, callbackFunction) {
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Adding ' + los.escapedAliases.Occupancy, title: `Error Adding ${los.escapedAliases.Occupancy}`,
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '', message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
contextualColorName: 'danger' contextualColorName: 'danger'
}); });
@ -85,19 +86,22 @@ function addLotOccupancy(lotOccupancyId, callbackFunction) {
}); });
} }
function addLotFromLotOccupancy(clickEvent) { function addLotFromLotOccupancy(clickEvent) {
const lotId = clickEvent.currentTarget.dataset.lotId; var _a;
const lotId = (_a = clickEvent.currentTarget.dataset.lotId) !== null && _a !== void 0 ? _a : '';
addLot(lotId); addLot(lotId);
} }
function renderRelatedOccupancies() { function renderRelatedOccupancies() {
var _a, _b, _c, _d; var _a, _b, _c, _d, _e, _f;
const occupanciesContainerElement = document.querySelector('#container--lotOccupancies'); const occupanciesContainerElement = document.querySelector('#container--lotOccupancies');
document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString(); document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString();
if (workOrderLotOccupancies.length === 0) { if (workOrderLotOccupancies.length === 0) {
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<div class="message is-info"> occupanciesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p> <p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p>
</div>`; </div>`;
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -121,44 +125,33 @@ function renderRelatedOccupancies() {
workOrderLots.some((lot) => { workOrderLots.some((lot) => {
return lotOccupancy.lotId === lot.lotId; return lotOccupancy.lotId === lot.lotId;
}); });
rowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td class="is-width-1 has-text-centered">' + rowElement.innerHTML = `<td class="is-width-1 has-text-centered">
(isActive ${isActive
? '<i class="fas fa-play" title="Current ' + ? `<i class="fas fa-play" title="Current ${los.escapedAliases.Occupancy}"></i>`
los.escapedAliases.Occupancy + : `<i class="fas fa-stop" title="Previous ${los.escapedAliases.Occupancy}"></i>`}
'"></i>' </td><td>
: '<i class="fas fa-stop" title="Previous ' + <a class="has-text-weight-bold" href="${los.getLotOccupancyURL(lotOccupancy.lotOccupancyId)}">
los.escapedAliases.Occupancy + ${cityssm.escapeHTML((_a = lotOccupancy.occupancyType) !== null && _a !== void 0 ? _a : '')}
'"></i>') + </a><br />
'</td>' + <span class="is-size-7">#${lotOccupancy.lotOccupancyId}</span>
('<td>' + </td>`;
'<a class="has-text-weight-bold" href="' +
los.getLotOccupancyURL(lotOccupancy.lotOccupancyId) +
'">' +
cityssm.escapeHTML((_a = lotOccupancy.occupancyType) !== null && _a !== void 0 ? _a : '') +
'</a><br />' +
`<span class="is-size-7">#${lotOccupancy.lotOccupancyId}</span>` +
'</td>');
if (lotOccupancy.lotId) { if (lotOccupancy.lotId) {
rowElement.insertAdjacentHTML('beforeend', '<td>' + // eslint-disable-next-line no-unsanitized/method
cityssm.escapeHTML((_b = lotOccupancy.lotName) !== null && _b !== void 0 ? _b : '') + rowElement.insertAdjacentHTML('beforeend', `<td>
(hasLotRecord ${cityssm.escapeHTML((_b = lotOccupancy.lotName) !== null && _b !== void 0 ? _b : '')}
? '' ${hasLotRecord
: ' <button class="button is-small is-light is-success button--addLot"' + ? ''
' data-lot-id="' + : ` <button class="button is-small is-light is-success button--addLot"
lotOccupancy.lotId.toString() + data-lot-id="${lotOccupancy.lotId.toString()}"
'"' + data-tooltip="Add ${los.escapedAliases.Lot}"
' data-tooltip="Add ' + aria-label="Add ${los.escapedAliases.Lot}" type="button">
los.escapedAliases.Lot + <i class="fas fa-plus" aria-hidden="true"></i>
'"' + </button>`}
' aria-label="Add ' + </td>`);
los.escapedAliases.Lot +
'" type="button">' +
'<i class="fas fa-plus" aria-hidden="true"></i>' +
'</button>') +
'</td>');
} }
else { else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`); rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`);
} }
let occupantsHTML = ''; let occupantsHTML = '';
@ -174,41 +167,39 @@ function renderRelatedOccupancies() {
${cityssm.escapeHTML(occupant.occupantFamilyName)} ${cityssm.escapeHTML(occupant.occupantFamilyName)}
</li>`; </li>`;
} }
rowElement.insertAdjacentHTML('beforeend', '<td>' + // eslint-disable-next-line no-unsanitized/method
lotOccupancy.occupancyStartDateString + rowElement.insertAdjacentHTML('beforeend', `<td>
'</td>' + ${lotOccupancy.occupancyStartDateString}
('<td>' + </td><td>
(lotOccupancy.occupancyEndDate ${lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString ? lotOccupancy.occupancyEndDateString
: '<span class="has-text-grey">(No End Date)</span>') + : '<span class="has-text-grey">(No End Date)</span>'}
'</td>') + </td><td>
('<td>' + ${lotOccupancy.lotOccupancyOccupants.length === 0
(lotOccupancy.lotOccupancyOccupants.length === 0 ? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>`
? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>` : `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`}
: `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`) + </td><td>
'</td>') + <button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">
('<td>' + <i class="fas fa-trash" aria-hidden="true"></i>
'<button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">' + </button>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </td>`);
'</button>' +
'</td>'));
(_d = rowElement (_d = rowElement
.querySelector('.button--addLot')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', addLotFromLotOccupancy); .querySelector('.button--addLot')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', addLotFromLotOccupancy);
rowElement (_e = rowElement
.querySelector('.button--deleteLotOccupancy') .querySelector('.button--deleteLotOccupancy')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', deleteLotOccupancy);
.addEventListener('click', deleteLotOccupancy); (_f = occupanciesContainerElement.querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(rowElement);
occupanciesContainerElement.querySelector('tbody').append(rowElement);
} }
} }
function openEditLotStatus(clickEvent) { function openEditLotStatus(clickEvent) {
const lotId = Number.parseInt(clickEvent.currentTarget.closest('.container--lot').dataset.lotId, 10); var _a;
const lotId = Number.parseInt((_a = clickEvent.currentTarget.closest('.container--lot').dataset.lotId) !== null && _a !== void 0 ? _a : '', 10);
const lot = workOrderLots.find((possibleLot) => { const lot = workOrderLots.find((possibleLot) => {
return possibleLot.lotId === lotId; return possibleLot.lotId === lotId;
}); });
let editCloseModalFunction; let editCloseModalFunction;
function doUpdateLotStatus(submitEvent) { function doUpdateLotStatus(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doUpdateLotStatus', submitEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${los.urlPrefix}/workOrders/doUpdateLotStatus`, submitEvent.currentTarget, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
@ -227,9 +218,10 @@ function openEditLotStatus(clickEvent) {
} }
cityssm.openHtmlModal('lot-editLotStatus', { cityssm.openHtmlModal('lot-editLotStatus', {
onshow(modalElement) { onshow(modalElement) {
var _a, _b, _c;
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector('#lotStatusEdit--lotId').value = lotId.toString(); modalElement.querySelector('#lotStatusEdit--lotId').value = lotId.toString();
modalElement.querySelector('#lotStatusEdit--lotName').value = lot.lotName; modalElement.querySelector('#lotStatusEdit--lotName').value = (_a = lot.lotName) !== null && _a !== void 0 ? _a : '';
const lotStatusElement = modalElement.querySelector('#lotStatusEdit--lotStatusId'); const lotStatusElement = modalElement.querySelector('#lotStatusEdit--lotStatusId');
let lotStatusFound = false; let lotStatusFound = false;
for (const lotStatus of exports.lotStatuses) { for (const lotStatus of exports.lotStatuses) {
@ -244,22 +236,22 @@ function openEditLotStatus(clickEvent) {
if (!lotStatusFound && lot.lotStatusId) { if (!lotStatusFound && lot.lotStatusId) {
const optionElement = document.createElement('option'); const optionElement = document.createElement('option');
optionElement.value = lot.lotStatusId.toString(); optionElement.value = lot.lotStatusId.toString();
optionElement.textContent = lot.lotStatus; optionElement.textContent = (_b = lot.lotStatus) !== null && _b !== void 0 ? _b : '';
lotStatusElement.append(optionElement); lotStatusElement.append(optionElement);
} }
if (lot.lotStatusId) { if (lot.lotStatusId) {
lotStatusElement.value = lot.lotStatusId.toString(); lotStatusElement.value = lot.lotStatusId.toString();
} }
modalElement // eslint-disable-next-line no-unsanitized/method
.querySelector('form') (_c = modalElement
.insertAdjacentHTML('beforeend', `<input name="workOrderId" type="hidden" value="${workOrderId}" />`); .querySelector('form')) === null || _c === void 0 ? void 0 : _c.insertAdjacentHTML('beforeend', `<input name="workOrderId" type="hidden" value="${workOrderId}" />`);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
var _a;
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement (_a = modalElement
.querySelector('form') .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateLotStatus);
.addEventListener('submit', doUpdateLotStatus);
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -269,7 +261,7 @@ function openEditLotStatus(clickEvent) {
function deleteLot(clickEvent) { function deleteLot(clickEvent) {
const lotId = clickEvent.currentTarget.closest('.container--lot').dataset.lotId; const lotId = clickEvent.currentTarget.closest('.container--lot').dataset.lotId;
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderLot', { cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderLot`, {
workOrderId, workOrderId,
lotId lotId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
@ -299,59 +291,57 @@ function deleteLot(clickEvent) {
}); });
} }
function renderRelatedLots() { function renderRelatedLots() {
var _a, _b, _c, _d; var _a, _b, _c, _d, _e, _f, _g;
const lotsContainerElement = document.querySelector('#container--lots'); const lotsContainerElement = document.querySelector('#container--lots');
document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent = workOrderLots.length.toString(); document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent = workOrderLots.length.toString();
if (workOrderLots.length === 0) { if (workOrderLots.length === 0) {
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<div class="message is-info"> lotsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p> <p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
</div>`; </div>`;
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th>${los.escapedAliases.Lot}</th> <th>${los.escapedAliases.Lot}</th>
<th>${los.escapedAliases.Map}</th> <th>${los.escapedAliases.Map}</th>
<th>${los.escapedAliases.Lot} Type</th> <th>${los.escapedAliases.Lot} Type</th>
<th>Status</th> <th>Status</th>
<th class="has-width-1"></th> <th class="has-width-1"></th>
</tr></thead> </tr></thead>
<tbody></tbody> <tbody></tbody>
</table>`; </table>`;
for (const lot of workOrderLots) { for (const lot of workOrderLots) {
const rowElement = document.createElement('tr'); const rowElement = document.createElement('tr');
rowElement.className = 'container--lot'; rowElement.className = 'container--lot';
rowElement.dataset.lotId = lot.lotId.toString(); rowElement.dataset.lotId = lot.lotId.toString();
rowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td>' + rowElement.innerHTML = `<td>
'<a class="has-text-weight-bold" href="' + <a class="has-text-weight-bold" href="${los.getLotURL(lot.lotId)}">
los.getLotURL(lot.lotId) + ${cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '')}
'">' + </a>
cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '') + </td><td>
'</a>' + ${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}
'</td>' + </td><td>
`<td>${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}</td>` + ${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}
`<td>${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}</td>` + </td><td>
('<td>' + ${lot.lotStatusId
(lot.lotStatusId ? cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '')
? cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '') : '<span class="has-text-grey">(No Status)</span>'}
: '<span class="has-text-grey">(No Status)</span>') + </td><td class="is-nowrap">
'</td>') +
`<td class="is-nowrap">
<button class="button is-small is-light is-info button--editLotStatus" data-tooltip="Update Status" type="button"> <button class="button is-small is-light is-info button--editLotStatus" data-tooltip="Update Status" type="button">
<i class="fas fa-pencil-alt" aria-hidden="true"></i> <i class="fas fa-pencil-alt" aria-hidden="true"></i>
</button> </button>
<button class="button is-small is-light is-danger button--deleteLot" data-tooltip="Delete Relationship" type="button"> <button class="button is-small is-light is-danger button--deleteLot" data-tooltip="Delete Relationship" type="button">
<i class="fas fa-trash" aria-hidden="true"></i> <i class="fas fa-trash" aria-hidden="true"></i>
</button> </button>
</td>`; </td>`;
rowElement (_e = rowElement
.querySelector('.button--editLotStatus') .querySelector('.button--editLotStatus')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', openEditLotStatus);
.addEventListener('click', openEditLotStatus); (_f = rowElement
rowElement .querySelector('.button--deleteLot')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', deleteLot);
.querySelector('.button--deleteLot') (_g = lotsContainerElement.querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(rowElement);
.addEventListener('click', deleteLot);
lotsContainerElement.querySelector('tbody').append(rowElement);
} }
} }
function renderRelatedLotsAndOccupancies() { function renderRelatedLotsAndOccupancies() {
@ -360,8 +350,9 @@ function renderRelatedLotsAndOccupancies() {
} }
renderRelatedLotsAndOccupancies(); renderRelatedLotsAndOccupancies();
function doAddLotOccupancy(clickEvent) { function doAddLotOccupancy(clickEvent) {
var _a;
const rowElement = clickEvent.currentTarget.closest('tr'); const rowElement = clickEvent.currentTarget.closest('tr');
const lotOccupancyId = rowElement.dataset.lotOccupancyId; const lotOccupancyId = (_a = rowElement.dataset.lotOccupancyId) !== null && _a !== void 0 ? _a : '';
addLotOccupancy(lotOccupancyId, (success) => { addLotOccupancy(lotOccupancyId, (success) => {
if (success) { if (success) {
rowElement.remove(); rowElement.remove();
@ -376,10 +367,11 @@ function doAddLotOccupancy(clickEvent) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...'); los.getLoadingParagraphHTML('Searching...');
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doSearchLotOccupancies', searchFormElement, (rawResponseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doSearchLotOccupancies`, searchFormElement, (rawResponseJSON) => {
var _a, _b; var _a, _b, _c, _d;
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.lotOccupancies.length === 0) { if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML = `<div class="message is-info"> searchResultsContainerElement.innerHTML = `<div class="message is-info">
@ -387,6 +379,7 @@ function doAddLotOccupancy(clickEvent) {
</div>`; </div>`;
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -417,32 +410,32 @@ function doAddLotOccupancy(clickEvent) {
'</td>'); '</td>');
} }
else { else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`); rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`);
} }
rowElement.insertAdjacentHTML('beforeend', `<td>${lotOccupancy.occupancyStartDateString}</td>` + // eslint-disable-next-line no-unsanitized/method
('<td>' + rowElement.insertAdjacentHTML('beforeend', `<td>
(lotOccupancy.occupancyEndDate ${lotOccupancy.occupancyStartDateString}
? lotOccupancy.occupancyEndDateString </td><td>
: '<span class="has-text-grey">(No End Date)</span>') + ${lotOccupancy.occupancyEndDate
'</td>') + ? lotOccupancy.occupancyEndDateString
('<td>' + : '<span class="has-text-grey">(No End Date)</span>'}
(lotOccupancy.lotOccupancyOccupants.length === 0 </td><td>
? `<span class="has-text-grey">(No ${cityssm.escapeHTML(los.escapedAliases.Occupants)})</span>` ${lotOccupancy.lotOccupancyOccupants.length === 0
: cityssm.escapeHTML(lotOccupancy.lotOccupancyOccupants[0].occupantName + ? `<span class="has-text-grey">
' ' + (No ${cityssm.escapeHTML(los.escapedAliases.Occupants)})
lotOccupancy.lotOccupancyOccupants[0] </span>`
.occupantFamilyName) + : cityssm.escapeHTML(`${lotOccupancy.lotOccupancyOccupants[0].occupantName}
(lotOccupancy.lotOccupancyOccupants.length > 1 ${lotOccupancy.lotOccupancyOccupants[0]
? ' plus ' + .occupantFamilyName}`) +
(lotOccupancy.lotOccupancyOccupants.length - 1).toString() (lotOccupancy.lotOccupancyOccupants.length > 1
: '')) + ? ` plus
'</td>')); ${(lotOccupancy.lotOccupancyOccupants.length - 1).toString()}`
rowElement : '')}</td>`);
.querySelector('.button--addLotOccupancy') (_c = rowElement
.addEventListener('click', doAddLotOccupancy); .querySelector('.button--addLotOccupancy')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', doAddLotOccupancy);
searchResultsContainerElement (_d = searchResultsContainerElement
.querySelector('tbody') .querySelector('tbody')) === null || _d === void 0 ? void 0 : _d.append(rowElement);
.append(rowElement);
} }
}); });
} }
@ -470,8 +463,9 @@ function doAddLotOccupancy(clickEvent) {
}); });
}); });
function doAddLot(clickEvent) { function doAddLot(clickEvent) {
var _a;
const rowElement = clickEvent.currentTarget.closest('tr'); const rowElement = clickEvent.currentTarget.closest('tr');
const lotId = rowElement.dataset.lotId; const lotId = (_a = rowElement.dataset.lotId) !== null && _a !== void 0 ? _a : '';
addLot(lotId, (success) => { addLot(lotId, (success) => {
if (success) { if (success) {
rowElement.remove(); rowElement.remove();
@ -485,18 +479,19 @@ function doAddLot(clickEvent) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...'); los.getLoadingParagraphHTML('Searching...');
cityssm.postJSON(los.urlPrefix + '/lots/doSearchLots', searchFormElement, (rawResponseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lots/doSearchLots`, searchFormElement, (rawResponseJSON) => {
var _a, _b, _c, _d; var _a, _b, _c, _d, _e, _f;
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.lots.length === 0) { if (responseJSON.lots.length === 0) {
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no records that meet the search criteria.</p>
'<p class="message-body">There are no records that meet the search criteria.</p>' + </div>`;
'</div>';
return; return;
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -511,26 +506,23 @@ function doAddLot(clickEvent) {
const rowElement = document.createElement('tr'); const rowElement = document.createElement('tr');
rowElement.className = 'container--lot'; rowElement.className = 'container--lot';
rowElement.dataset.lotId = lot.lotId.toString(); rowElement.dataset.lotId = lot.lotId.toString();
rowElement.innerHTML = rowElement.innerHTML = `<td class="has-text-centered">
'<td class="has-text-centered">' + <button class="button is-small is-success button--addLot" data-tooltip="Add" type="button" aria-label="Add">
'<button class="button is-small is-success button--addLot" data-tooltip="Add" type="button" aria-label="Add">' + <i class="fas fa-plus" aria-hidden="true"></i>
'<i class="fas fa-plus" aria-hidden="true"></i>' + </button>
'</button>' + </td><td class="has-text-weight-bold">
'</td>' + ${cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '')}
('<td class="has-text-weight-bold">' + </td><td>
cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '') + ${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}
'</td>') + </td><td>
'<td>' + ${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}
cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '') + </td><td>
'</td>' + ${cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '')}
('<td>' + cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '') + '</td>') + </td>`;
('<td>' + cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '') + '</td>'); (_e = rowElement
rowElement .querySelector('.button--addLot')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', doAddLot);
.querySelector('.button--addLot') (_f = searchResultsContainerElement
.addEventListener('click', doAddLot); .querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(rowElement);
searchResultsContainerElement
.querySelector('tbody')
.append(rowElement);
} }
}); });
} }
@ -550,13 +542,13 @@ function doAddLot(clickEvent) {
doSearch(); doSearch();
}, },
onshown(modalElement) { onshown(modalElement) {
var _a;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
const lotNameElement = modalElement.querySelector('#lotSearch--lotName'); const lotNameElement = modalElement.querySelector('#lotSearch--lotName');
lotNameElement.addEventListener('change', doSearch); lotNameElement.addEventListener('change', doSearch);
lotNameElement.focus(); lotNameElement.focus();
modalElement (_a = modalElement
.querySelector('#lotSearch--lotStatusId') .querySelector('#lotSearch--lotStatusId')) === null || _a === void 0 ? void 0 : _a.addEventListener('change', doSearch);
.addEventListener('change', doSearch);
searchFormElement.addEventListener('submit', doSearch); searchFormElement.addEventListener('submit', doSearch);
}, },
onremoved() { onremoved() {

View File

@ -1,23 +1,25 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types' import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { BulmaJS } from '@cityssm/bulma-js/types' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type * as globalTypes from '../../types/globalTypes' import type { LOS } from '../../types/globalTypes.js'
import type * as recordTypes from '../../types/recordTypes' import type * as recordTypes from '../../types/recordTypes.js'
declare const cityssm: cityssmGlobal declare const cityssm: cityssmGlobal
declare const bulmaJS: BulmaJS declare const bulmaJS: BulmaJS
declare const los: globalTypes.LOS declare const exports: Record<string, unknown>
declare const los: LOS
declare const workOrderId: string declare const workOrderId: string
let workOrderLots: recordTypes.Lot[] = exports.workOrderLots let workOrderLots = exports.workOrderLots as recordTypes.Lot[]
delete exports.workOrderLots delete exports.workOrderLots
let workOrderLotOccupancies: recordTypes.LotOccupancy[] = let workOrderLotOccupancies =
exports.workOrderLotOccupancies exports.workOrderLotOccupancies as recordTypes.LotOccupancy[]
delete exports.workOrderLotOccupancies delete exports.workOrderLotOccupancies
function deleteLotOccupancy(clickEvent: Event): void { function deleteLotOccupancy(clickEvent: Event): void {
@ -29,7 +31,7 @@ function deleteLotOccupancy(clickEvent: Event): void {
function doDelete(): void { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doDeleteWorkOrderLotOccupancy', `${los.urlPrefix}/workOrders/doDeleteWorkOrderLotOccupancy`,
{ {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
@ -38,11 +40,11 @@ function deleteLotOccupancy(clickEvent: Event): void {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
workOrderLotOccupancies?: recordTypes.LotOccupancy[] workOrderLotOccupancies: recordTypes.LotOccupancy[]
} }
if (responseJSON.success) { if (responseJSON.success) {
workOrderLotOccupancies = responseJSON.workOrderLotOccupancies! workOrderLotOccupancies = responseJSON.workOrderLotOccupancies
renderRelatedLotsAndOccupancies() renderRelatedLotsAndOccupancies()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
@ -71,7 +73,7 @@ function addLot(
callbackFunction?: (success: boolean) => void callbackFunction?: (success: boolean) => void
): void { ): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doAddWorkOrderLot', `${los.urlPrefix}/workOrders/doAddWorkOrderLot`,
{ {
workOrderId, workOrderId,
lotId lotId
@ -80,11 +82,11 @@ function addLot(
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
workOrderLots?: recordTypes.Lot[] workOrderLots: recordTypes.Lot[]
} }
if (responseJSON.success) { if (responseJSON.success) {
workOrderLots = responseJSON.workOrderLots! workOrderLots = responseJSON.workOrderLots
renderRelatedLotsAndOccupancies() renderRelatedLotsAndOccupancies()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
@ -106,7 +108,7 @@ function addLotOccupancy(
callbackFunction?: (success?: boolean) => void callbackFunction?: (success?: boolean) => void
): void { ): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doAddWorkOrderLotOccupancy', `${los.urlPrefix}/workOrders/doAddWorkOrderLotOccupancy`,
{ {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
@ -115,15 +117,15 @@ function addLotOccupancy(
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
workOrderLotOccupancies?: recordTypes.LotOccupancy[] workOrderLotOccupancies: recordTypes.LotOccupancy[]
} }
if (responseJSON.success) { if (responseJSON.success) {
workOrderLotOccupancies = responseJSON.workOrderLotOccupancies! workOrderLotOccupancies = responseJSON.workOrderLotOccupancies
renderRelatedLotsAndOccupancies() renderRelatedLotsAndOccupancies()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Adding ' + los.escapedAliases.Occupancy, title: `Error Adding ${los.escapedAliases.Occupancy}`,
message: responseJSON.errorMessage ?? '', message: responseJSON.errorMessage ?? '',
contextualColorName: 'danger' contextualColorName: 'danger'
}) })
@ -137,7 +139,7 @@ function addLotOccupancy(
} }
function addLotFromLotOccupancy(clickEvent: Event): void { function addLotFromLotOccupancy(clickEvent: Event): void {
const lotId = (clickEvent.currentTarget as HTMLElement).dataset.lotId! const lotId = (clickEvent.currentTarget as HTMLElement).dataset.lotId ?? ''
addLot(lotId) addLot(lotId)
} }
@ -153,6 +155,7 @@ function renderRelatedOccupancies(): void {
).textContent = workOrderLotOccupancies.length.toString() ).textContent = workOrderLotOccupancies.length.toString()
if (workOrderLotOccupancies.length === 0) { if (workOrderLotOccupancies.length === 0) {
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<div class="message is-info"> occupanciesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p> <p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p>
</div>` </div>`
@ -160,6 +163,7 @@ function renderRelatedOccupancies(): void {
return return
} }
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -178,7 +182,7 @@ function renderRelatedOccupancies(): void {
for (const lotOccupancy of workOrderLotOccupancies) { for (const lotOccupancy of workOrderLotOccupancies) {
const rowElement = document.createElement('tr') const rowElement = document.createElement('tr')
rowElement.className = 'container--lotOccupancy' rowElement.className = 'container--lotOccupancy'
rowElement.dataset.lotOccupancyId = lotOccupancy.lotOccupancyId!.toString() rowElement.dataset.lotOccupancyId = lotOccupancy.lotOccupancyId.toString()
const isActive = !( const isActive = !(
lotOccupancy.occupancyEndDate && lotOccupancy.occupancyEndDate &&
@ -191,47 +195,40 @@ function renderRelatedOccupancies(): void {
return lotOccupancy.lotId === lot.lotId return lotOccupancy.lotId === lot.lotId
}) })
rowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td class="is-width-1 has-text-centered">' + rowElement.innerHTML = `<td class="is-width-1 has-text-centered">
(isActive ${
? '<i class="fas fa-play" title="Current ' + isActive
los.escapedAliases.Occupancy + ? `<i class="fas fa-play" title="Current ${los.escapedAliases.Occupancy}"></i>`
'"></i>' : `<i class="fas fa-stop" title="Previous ${los.escapedAliases.Occupancy}"></i>`
: '<i class="fas fa-stop" title="Previous ' + }
los.escapedAliases.Occupancy + </td><td>
'"></i>') + <a class="has-text-weight-bold" href="${los.getLotOccupancyURL(lotOccupancy.lotOccupancyId)}">
'</td>' + ${cityssm.escapeHTML(lotOccupancy.occupancyType ?? '')}
('<td>' + </a><br />
'<a class="has-text-weight-bold" href="' + <span class="is-size-7">#${lotOccupancy.lotOccupancyId}</span>
los.getLotOccupancyURL(lotOccupancy.lotOccupancyId) + </td>`
'">' +
cityssm.escapeHTML(lotOccupancy.occupancyType ?? '') +
'</a><br />' +
`<span class="is-size-7">#${lotOccupancy.lotOccupancyId!}</span>` +
'</td>')
if (lotOccupancy.lotId) { if (lotOccupancy.lotId) {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML( rowElement.insertAdjacentHTML(
'beforeend', 'beforeend',
'<td>' + `<td>
cityssm.escapeHTML(lotOccupancy.lotName ?? '') + ${cityssm.escapeHTML(lotOccupancy.lotName ?? '')}
(hasLotRecord ${
? '' hasLotRecord
: ' <button class="button is-small is-light is-success button--addLot"' + ? ''
' data-lot-id="' + : ` <button class="button is-small is-light is-success button--addLot"
lotOccupancy.lotId.toString() + data-lot-id="${lotOccupancy.lotId.toString()}"
'"' + data-tooltip="Add ${los.escapedAliases.Lot}"
' data-tooltip="Add ' + aria-label="Add ${los.escapedAliases.Lot}" type="button">
los.escapedAliases.Lot + <i class="fas fa-plus" aria-hidden="true"></i>
'"' + </button>`
' aria-label="Add ' + }
los.escapedAliases.Lot + </td>`
'" type="button">' +
'<i class="fas fa-plus" aria-hidden="true"></i>' +
'</button>') +
'</td>'
) )
} else { } else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML( rowElement.insertAdjacentHTML(
'beforeend', 'beforeend',
`<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>` `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`
@ -255,26 +252,28 @@ function renderRelatedOccupancies(): void {
</li>` </li>`
} }
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML( rowElement.insertAdjacentHTML(
'beforeend', 'beforeend',
'<td>' + `<td>
lotOccupancy.occupancyStartDateString! + ${lotOccupancy.occupancyStartDateString}
'</td>' + </td><td>
('<td>' + ${
(lotOccupancy.occupancyEndDate lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString! ? lotOccupancy.occupancyEndDateString
: '<span class="has-text-grey">(No End Date)</span>') + : '<span class="has-text-grey">(No End Date)</span>'
'</td>') + }
('<td>' + </td><td>
(lotOccupancy.lotOccupancyOccupants!.length === 0 ${
? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>` lotOccupancy.lotOccupancyOccupants!.length === 0
: `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`) + ? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>`
'</td>') + : `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`
('<td>' + }
'<button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">' + </td><td>
'<i class="fas fa-trash" aria-hidden="true"></i>' + <button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">
'</button>' + <i class="fas fa-trash" aria-hidden="true"></i>
'</td>') </button>
</td>`
) )
rowElement rowElement
@ -282,10 +281,10 @@ function renderRelatedOccupancies(): void {
?.addEventListener('click', addLotFromLotOccupancy) ?.addEventListener('click', addLotFromLotOccupancy)
rowElement rowElement
.querySelector('.button--deleteLotOccupancy')! .querySelector('.button--deleteLotOccupancy')
.addEventListener('click', deleteLotOccupancy) ?.addEventListener('click', deleteLotOccupancy)
occupanciesContainerElement.querySelector('tbody')!.append(rowElement) occupanciesContainerElement.querySelector('tbody')?.append(rowElement)
} }
} }
@ -295,13 +294,13 @@ function openEditLotStatus(clickEvent: Event): void {
(clickEvent.currentTarget as HTMLElement).closest( (clickEvent.currentTarget as HTMLElement).closest(
'.container--lot' '.container--lot'
) as HTMLElement ) as HTMLElement
).dataset.lotId!, ).dataset.lotId ?? '',
10 10
) )
const lot = workOrderLots.find((possibleLot) => { const lot = workOrderLots.find((possibleLot) => {
return possibleLot.lotId === lotId return possibleLot.lotId === lotId
})! }) as recordTypes.Lot
let editCloseModalFunction: () => void let editCloseModalFunction: () => void
@ -309,17 +308,17 @@ function openEditLotStatus(clickEvent: Event): void {
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doUpdateLotStatus', `${los.urlPrefix}/workOrders/doUpdateLotStatus`,
submitEvent.currentTarget, submitEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
workOrderLots?: recordTypes.Lot[] workOrderLots: recordTypes.Lot[]
} }
if (responseJSON.success) { if (responseJSON.success) {
workOrderLots = responseJSON.workOrderLots! workOrderLots = responseJSON.workOrderLots
renderRelatedLotsAndOccupancies() renderRelatedLotsAndOccupancies()
editCloseModalFunction() editCloseModalFunction()
} else { } else {
@ -343,7 +342,7 @@ function openEditLotStatus(clickEvent: Event): void {
modalElement.querySelector( modalElement.querySelector(
'#lotStatusEdit--lotName' '#lotStatusEdit--lotName'
) as HTMLInputElement ) as HTMLInputElement
).value = lot.lotName! ).value = lot.lotName ?? ''
const lotStatusElement = modalElement.querySelector( const lotStatusElement = modalElement.querySelector(
'#lotStatusEdit--lotStatusId' '#lotStatusEdit--lotStatusId'
@ -366,7 +365,7 @@ function openEditLotStatus(clickEvent: Event): void {
if (!lotStatusFound && lot.lotStatusId) { if (!lotStatusFound && lot.lotStatusId) {
const optionElement = document.createElement('option') const optionElement = document.createElement('option')
optionElement.value = lot.lotStatusId.toString() optionElement.value = lot.lotStatusId.toString()
optionElement.textContent = lot.lotStatus! optionElement.textContent = lot.lotStatus ?? ''
lotStatusElement.append(optionElement) lotStatusElement.append(optionElement)
} }
@ -374,9 +373,10 @@ function openEditLotStatus(clickEvent: Event): void {
lotStatusElement.value = lot.lotStatusId.toString() lotStatusElement.value = lot.lotStatusId.toString()
} }
// eslint-disable-next-line no-unsanitized/method
modalElement modalElement
.querySelector('form')! .querySelector('form')
.insertAdjacentHTML( ?.insertAdjacentHTML(
'beforeend', 'beforeend',
`<input name="workOrderId" type="hidden" value="${workOrderId}" />` `<input name="workOrderId" type="hidden" value="${workOrderId}" />`
) )
@ -387,8 +387,8 @@ function openEditLotStatus(clickEvent: Event): void {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
modalElement modalElement
.querySelector('form')! .querySelector('form')
.addEventListener('submit', doUpdateLotStatus) ?.addEventListener('submit', doUpdateLotStatus)
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
@ -405,7 +405,7 @@ function deleteLot(clickEvent: Event): void {
function doDelete(): void { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/workOrders/doDeleteWorkOrderLot', `${los.urlPrefix}/workOrders/doDeleteWorkOrderLot`,
{ {
workOrderId, workOrderId,
lotId lotId
@ -414,11 +414,11 @@ function deleteLot(clickEvent: Event): void {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
workOrderLots?: recordTypes.Lot[] workOrderLots: recordTypes.Lot[]
} }
if (responseJSON.success) { if (responseJSON.success) {
workOrderLots = responseJSON.workOrderLots! workOrderLots = responseJSON.workOrderLots
renderRelatedLotsAndOccupancies() renderRelatedLotsAndOccupancies()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
@ -454,23 +454,25 @@ function renderRelatedLots(): void {
).textContent = workOrderLots.length.toString() ).textContent = workOrderLots.length.toString()
if (workOrderLots.length === 0) { if (workOrderLots.length === 0) {
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<div class="message is-info"> lotsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p> <p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
</div>` </div>`
return return
} }
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th>${los.escapedAliases.Lot}</th> <th>${los.escapedAliases.Lot}</th>
<th>${los.escapedAliases.Map}</th> <th>${los.escapedAliases.Map}</th>
<th>${los.escapedAliases.Lot} Type</th> <th>${los.escapedAliases.Lot} Type</th>
<th>Status</th> <th>Status</th>
<th class="has-width-1"></th> <th class="has-width-1"></th>
</tr></thead> </tr></thead>
<tbody></tbody> <tbody></tbody>
</table>` </table>`
for (const lot of workOrderLots) { for (const lot of workOrderLots) {
const rowElement = document.createElement('tr') const rowElement = document.createElement('tr')
@ -478,39 +480,39 @@ function renderRelatedLots(): void {
rowElement.dataset.lotId = lot.lotId.toString() rowElement.dataset.lotId = lot.lotId.toString()
rowElement.innerHTML = // eslint-disable-next-line no-unsanitized/property
'<td>' + rowElement.innerHTML = `<td>
'<a class="has-text-weight-bold" href="' + <a class="has-text-weight-bold" href="${los.getLotURL(lot.lotId)}">
los.getLotURL(lot.lotId) + ${cityssm.escapeHTML(lot.lotName ?? '')}
'">' + </a>
cityssm.escapeHTML(lot.lotName ?? '') + </td><td>
'</a>' + ${cityssm.escapeHTML(lot.mapName ?? '')}
'</td>' + </td><td>
`<td>${cityssm.escapeHTML(lot.mapName ?? '')}</td>` + ${cityssm.escapeHTML(lot.lotType ?? '')}
`<td>${cityssm.escapeHTML(lot.lotType ?? '')}</td>` + </td><td>
('<td>' + ${
(lot.lotStatusId lot.lotStatusId
? cityssm.escapeHTML(lot.lotStatus ?? '') ? cityssm.escapeHTML(lot.lotStatus ?? '')
: '<span class="has-text-grey">(No Status)</span>') + : '<span class="has-text-grey">(No Status)</span>'
'</td>') + }
`<td class="is-nowrap"> </td><td class="is-nowrap">
<button class="button is-small is-light is-info button--editLotStatus" data-tooltip="Update Status" type="button"> <button class="button is-small is-light is-info button--editLotStatus" data-tooltip="Update Status" type="button">
<i class="fas fa-pencil-alt" aria-hidden="true"></i> <i class="fas fa-pencil-alt" aria-hidden="true"></i>
</button> </button>
<button class="button is-small is-light is-danger button--deleteLot" data-tooltip="Delete Relationship" type="button"> <button class="button is-small is-light is-danger button--deleteLot" data-tooltip="Delete Relationship" type="button">
<i class="fas fa-trash" aria-hidden="true"></i> <i class="fas fa-trash" aria-hidden="true"></i>
</button> </button>
</td>` </td>`
rowElement rowElement
.querySelector('.button--editLotStatus')! .querySelector('.button--editLotStatus')
.addEventListener('click', openEditLotStatus) ?.addEventListener('click', openEditLotStatus)
rowElement rowElement
.querySelector('.button--deleteLot')! .querySelector('.button--deleteLot')
.addEventListener('click', deleteLot) ?.addEventListener('click', deleteLot)
lotsContainerElement.querySelector('tbody')!.append(rowElement) lotsContainerElement.querySelector('tbody')?.append(rowElement)
} }
} }
@ -522,9 +524,11 @@ function renderRelatedLotsAndOccupancies(): void {
renderRelatedLotsAndOccupancies() renderRelatedLotsAndOccupancies()
function doAddLotOccupancy(clickEvent: Event): void { function doAddLotOccupancy(clickEvent: Event): void {
const rowElement = (clickEvent.currentTarget as HTMLElement).closest('tr')! const rowElement = (clickEvent.currentTarget as HTMLElement).closest(
'tr'
) as HTMLTableRowElement
const lotOccupancyId = rowElement.dataset.lotOccupancyId! const lotOccupancyId = rowElement.dataset.lotOccupancyId ?? ''
addLotOccupancy(lotOccupancyId, (success) => { addLotOccupancy(lotOccupancyId, (success) => {
if (success) { if (success) {
@ -544,11 +548,12 @@ document
event.preventDefault() event.preventDefault()
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...') los.getLoadingParagraphHTML('Searching...')
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doSearchLotOccupancies', `${los.urlPrefix}/lotOccupancies/doSearchLotOccupancies`,
searchFormElement, searchFormElement,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
@ -563,6 +568,7 @@ document
return return
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -579,7 +585,7 @@ document
const rowElement = document.createElement('tr') const rowElement = document.createElement('tr')
rowElement.className = 'container--lotOccupancy' rowElement.className = 'container--lotOccupancy'
rowElement.dataset.lotOccupancyId = rowElement.dataset.lotOccupancyId =
lotOccupancy.lotOccupancyId!.toString() lotOccupancy.lotOccupancyId.toString()
rowElement.innerHTML = `<td class="has-text-centered"> rowElement.innerHTML = `<td class="has-text-centered">
<button class="button is-small is-success button--addLotOccupancy" data-tooltip="Add" type="button" aria-label="Add"> <button class="button is-small is-success button--addLotOccupancy" data-tooltip="Add" type="button" aria-label="Add">
@ -598,45 +604,55 @@ document
'</td>' '</td>'
) )
} else { } else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML( rowElement.insertAdjacentHTML(
'beforeend', 'beforeend',
`<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>` `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`
) )
} }
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML( rowElement.insertAdjacentHTML(
'beforeend', 'beforeend',
`<td>${lotOccupancy.occupancyStartDateString!}</td>` + `<td>
('<td>' + ${lotOccupancy.occupancyStartDateString}
(lotOccupancy.occupancyEndDate </td><td>
? lotOccupancy.occupancyEndDateString! ${
: '<span class="has-text-grey">(No End Date)</span>') + lotOccupancy.occupancyEndDate
'</td>') + ? lotOccupancy.occupancyEndDateString
('<td>' + : '<span class="has-text-grey">(No End Date)</span>'
(lotOccupancy.lotOccupancyOccupants!.length === 0 }
? `<span class="has-text-grey">(No ${cityssm.escapeHTML( </td><td>
los.escapedAliases.Occupants ${
)})</span>` lotOccupancy.lotOccupancyOccupants!.length === 0
: cityssm.escapeHTML( ? `<span class="has-text-grey">
lotOccupancy.lotOccupancyOccupants![0].occupantName! + (No ${cityssm.escapeHTML(
' ' + los.escapedAliases.Occupants
lotOccupancy.lotOccupancyOccupants![0] )})
.occupantFamilyName! </span>`
) + : cityssm.escapeHTML(
(lotOccupancy.lotOccupancyOccupants!.length > 1 `${lotOccupancy.lotOccupancyOccupants![0].occupantName}
? ' plus ' + ${
(lotOccupancy.lotOccupancyOccupants!.length - 1).toString() lotOccupancy.lotOccupancyOccupants![0]
: '')) + .occupantFamilyName
'</td>') }`
) +
(lotOccupancy.lotOccupancyOccupants!.length > 1
? ` plus
${(
lotOccupancy.lotOccupancyOccupants!.length - 1
).toString()}`
: '')
}</td>`
) )
rowElement rowElement
.querySelector('.button--addLotOccupancy')! .querySelector('.button--addLotOccupancy')
.addEventListener('click', doAddLotOccupancy) ?.addEventListener('click', doAddLotOccupancy)
searchResultsContainerElement searchResultsContainerElement
.querySelector('tbody')! .querySelector('tbody')
.append(rowElement) ?.append(rowElement)
} }
} }
) )
@ -646,7 +662,9 @@ document
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement) los.populateAliases(modalElement)
searchFormElement = modalElement.querySelector('form')! searchFormElement = modalElement.querySelector(
'form'
) as HTMLFormElement
searchResultsContainerElement = modalElement.querySelector( searchResultsContainerElement = modalElement.querySelector(
'#resultsContainer--lotOccupancyAdd' '#resultsContainer--lotOccupancyAdd'
@ -697,9 +715,11 @@ document
}) })
function doAddLot(clickEvent: Event): void { function doAddLot(clickEvent: Event): void {
const rowElement = (clickEvent.currentTarget as HTMLElement).closest('tr')! const rowElement = (clickEvent.currentTarget as HTMLElement).closest(
'tr'
) as HTMLTableRowElement
const lotId = rowElement.dataset.lotId! const lotId = rowElement.dataset.lotId ?? ''
addLot(lotId, (success) => { addLot(lotId, (success) => {
if (success) { if (success) {
@ -717,24 +737,25 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
event.preventDefault() event.preventDefault()
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...') los.getLoadingParagraphHTML('Searching...')
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/lots/doSearchLots', `${los.urlPrefix}/lots/doSearchLots`,
searchFormElement, searchFormElement,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { lots: recordTypes.Lot[] } const responseJSON = rawResponseJSON as { lots: recordTypes.Lot[] }
if (responseJSON.lots.length === 0) { if (responseJSON.lots.length === 0) {
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no records that meet the search criteria.</p>
'<p class="message-body">There are no records that meet the search criteria.</p>' + </div>`
'</div>'
return return
} }
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th class="has-width-1"></th> <th class="has-width-1"></th>
@ -751,28 +772,27 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
rowElement.className = 'container--lot' rowElement.className = 'container--lot'
rowElement.dataset.lotId = lot.lotId.toString() rowElement.dataset.lotId = lot.lotId.toString()
rowElement.innerHTML = rowElement.innerHTML = `<td class="has-text-centered">
'<td class="has-text-centered">' + <button class="button is-small is-success button--addLot" data-tooltip="Add" type="button" aria-label="Add">
'<button class="button is-small is-success button--addLot" data-tooltip="Add" type="button" aria-label="Add">' + <i class="fas fa-plus" aria-hidden="true"></i>
'<i class="fas fa-plus" aria-hidden="true"></i>' + </button>
'</button>' + </td><td class="has-text-weight-bold">
'</td>' + ${cityssm.escapeHTML(lot.lotName ?? '')}
('<td class="has-text-weight-bold">' + </td><td>
cityssm.escapeHTML(lot.lotName ?? '') + ${cityssm.escapeHTML(lot.mapName ?? '')}
'</td>') + </td><td>
'<td>' + ${cityssm.escapeHTML(lot.lotType ?? '')}
cityssm.escapeHTML(lot.mapName ?? '') + </td><td>
'</td>' + ${cityssm.escapeHTML(lot.lotStatus ?? '')}
('<td>' + cityssm.escapeHTML(lot.lotType ?? '') + '</td>') + </td>`
('<td>' + cityssm.escapeHTML(lot.lotStatus ?? '') + '</td>')
rowElement rowElement
.querySelector('.button--addLot')! .querySelector('.button--addLot')
.addEventListener('click', doAddLot) ?.addEventListener('click', doAddLot)
searchResultsContainerElement searchResultsContainerElement
.querySelector('tbody')! .querySelector('tbody')
.append(rowElement) ?.append(rowElement)
} }
} }
) )
@ -782,7 +802,7 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement) los.populateAliases(modalElement)
searchFormElement = modalElement.querySelector('form')! searchFormElement = modalElement.querySelector('form') as HTMLFormElement
searchResultsContainerElement = modalElement.querySelector( searchResultsContainerElement = modalElement.querySelector(
'#resultsContainer--lotAdd' '#resultsContainer--lotAdd'
@ -817,8 +837,8 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
lotNameElement.focus() lotNameElement.focus()
modalElement modalElement
.querySelector('#lotSearch--lotStatusId')! .querySelector('#lotSearch--lotStatusId')
.addEventListener('change', doSearch) ?.addEventListener('change', doSearch)
searchFormElement.addEventListener('submit', doSearch) searchFormElement.addEventListener('submit', doSearch)
}, },

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=exports.los,t=document.querySelector("#form--searchFilters"),s=document.querySelector("#container--searchResults"),a=Number.parseInt(document.querySelector("#searchFilter--limit").value,10),n=document.querySelector("#searchFilter--offset");function r(t){var n,r,o,l,d,u,p;const h=t;if(0===h.lots.length)return void(s.innerHTML=`<div class="message is-info">\n <p class="message-body">There are no ${e.escapedAliases.lots} that meet the search criteria.</p>\n </div>`);const m=document.createElement("tbody");for(const t of h.lots)m.insertAdjacentHTML("beforeend",`<tr>\n <td>\n <a class="has-text-weight-bold" href="${e.getLotURL(t.lotId)}">\n ${cityssm.escapeHTML(null!==(n=t.lotName)&&void 0!==n?n:"")}\n </a>\n </td><td>\n <a href="${e.getMapURL(t.mapId)}">\n ${t.mapName?cityssm.escapeHTML(t.mapName):'<span class="has-text-grey">(No Name)</span>'}\n </a>\n </td><td>\n ${cityssm.escapeHTML(null!==(r=t.lotType)&&void 0!==r?r:"")}\n </td><td>\n ${t.lotStatusId?cityssm.escapeHTML(null!==(o=t.lotStatus)&&void 0!==o?o:""):'<span class="has-text-grey">(No Status)</span>'}<br />\n ${(null!==(l=t.lotOccupancyCount)&&void 0!==l?l:0)>0?'<span class="is-size-7">Currently Occupied</span>':""}\n </td>\n </tr>`);s.innerHTML=`<table class="table is-fullwidth is-striped is-hoverable has-sticky-header">\n <thead><tr>\n <th>${e.escapedAliases.Lot}</th>\n <th>${e.escapedAliases.Map}</th>\n <th>${e.escapedAliases.Lot} Type</th>\n <th>Status</th>\n </tr></thead>\n <table>`,s.insertAdjacentHTML("beforeend",e.getSearchResultsPagerHTML(a,h.offset,h.count)),null===(d=s.querySelector("table"))||void 0===d||d.append(m),null===(u=s.querySelector("button[data-page='previous']"))||void 0===u||u.addEventListener("click",c),null===(p=s.querySelector("button[data-page='next']"))||void 0===p||p.addEventListener("click",i)}function o(){s.innerHTML=e.getLoadingParagraphHTML(`Loading ${e.escapedAliases.Lots}...`),cityssm.postJSON(e.urlPrefix+"/lots/doSearchLots",t,r)}function l(){n.value="0",o()}function c(){n.value=Math.max(Number.parseInt(n.value,10)-a,0).toString(),o()}function i(){n.value=(Number.parseInt(n.value,10)+a).toString(),o()}const d=t.querySelectorAll("input, select");for(const e of d)e.addEventListener("change",l);t.addEventListener("submit",e=>{e.preventDefault()}),o()})(); "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=exports.los,t=document.querySelector("#form--searchFilters"),s=document.querySelector("#container--searchResults"),a=Number.parseInt(document.querySelector("#searchFilter--limit").value,10),n=document.querySelector("#searchFilter--offset");function r(t){var n,r,o,l,d,u,p;const h=t;if(0===h.lots.length)return void(s.innerHTML=`<div class="message is-info">\n <p class="message-body">There are no ${e.escapedAliases.lots} that meet the search criteria.</p>\n </div>`);const m=document.createElement("tbody");for(const t of h.lots)m.insertAdjacentHTML("beforeend",`<tr>\n <td>\n <a class="has-text-weight-bold" href="${e.getLotURL(t.lotId)}">\n ${cityssm.escapeHTML(null!==(n=t.lotName)&&void 0!==n?n:"")}\n </a>\n </td><td>\n <a href="${e.getMapURL(t.mapId)}">\n ${t.mapName?cityssm.escapeHTML(t.mapName):'<span class="has-text-grey">(No Name)</span>'}\n </a>\n </td><td>\n ${cityssm.escapeHTML(null!==(r=t.lotType)&&void 0!==r?r:"")}\n </td><td>\n ${t.lotStatusId?cityssm.escapeHTML(null!==(o=t.lotStatus)&&void 0!==o?o:""):'<span class="has-text-grey">(No Status)</span>'}<br />\n ${(null!==(l=t.lotOccupancyCount)&&void 0!==l?l:0)>0?'<span class="is-size-7">Currently Occupied</span>':""}\n </td>\n </tr>`);s.innerHTML=`<table class="table is-fullwidth is-striped is-hoverable has-sticky-header">\n <thead><tr>\n <th>${e.escapedAliases.Lot}</th>\n <th>${e.escapedAliases.Map}</th>\n <th>${e.escapedAliases.Lot} Type</th>\n <th>Status</th>\n </tr></thead>\n <table>`,s.insertAdjacentHTML("beforeend",e.getSearchResultsPagerHTML(a,h.offset,h.count)),null===(d=s.querySelector("table"))||void 0===d||d.append(m),null===(u=s.querySelector("button[data-page='previous']"))||void 0===u||u.addEventListener("click",c),null===(p=s.querySelector("button[data-page='next']"))||void 0===p||p.addEventListener("click",i)}function o(){s.innerHTML=e.getLoadingParagraphHTML(`Loading ${e.escapedAliases.Lots}...`),cityssm.postJSON(`${e.urlPrefix}/lots/doSearchLots`,t,r)}function l(){n.value="0",o()}function c(){n.value=Math.max(Number.parseInt(n.value,10)-a,0).toString(),o()}function i(){n.value=(Number.parseInt(n.value,10)+a).toString(),o()}const d=t.querySelectorAll("input, select");for(const e of d)e.addEventListener("change",l);t.addEventListener("submit",e=>{e.preventDefault()}),o()})();

File diff suppressed because one or more lines are too long