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);
},
onshown(modalElement, closeModalFunction) {
var _a;
var _a, _b;
bulmaJS.toggleHtmlClipped();
lotSelectModalElement = modalElement;
lotSelectCloseModalFunction = closeModalFunction;
@ -428,7 +428,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const optionElement = document.createElement('option');
optionElement.value = map.mapId.toString();
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);
}
;
@ -449,7 +449,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
}
else {
window.open(los.urlPrefix + '/lots/' + lotId);
window.open(`${los.urlPrefix}/lots/${lotId}`);
}
});
(_e = document
@ -1586,7 +1586,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
.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();
if (feeGrandTotal.toFixed(2) !== transactionGrandTotal.toFixed(2)) {
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>
<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>`);

View File

@ -380,7 +380,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
los.populateAliases(modalElement);
},
onshown(modalElement, closeModalFunction) {
var _a;
var _a, _b;
bulmaJS.toggleHtmlClipped();
lotSelectModalElement = modalElement;
lotSelectCloseModalFunction = closeModalFunction;
@ -428,7 +428,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const optionElement = document.createElement('option');
optionElement.value = map.mapId.toString();
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);
}
;
@ -449,7 +449,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
}
else {
window.open(los.urlPrefix + '/lots/' + lotId);
window.open(`${los.urlPrefix}/lots/${lotId}`);
}
});
(_e = document

View File

@ -661,7 +661,7 @@ declare const exports: Record<string, unknown>
const optionElement = document.createElement('option')
optionElement.value = map.mapId!.toString()
optionElement.textContent =
(map.mapName ?? '') === '' ? '(No Name)' : map.mapName!
(map.mapName ?? '') === '' ? '(No Name)' : map.mapName ?? ''
mapElement.append(optionElement)
}
@ -688,7 +688,7 @@ declare const exports: Record<string, unknown>
contextualColorName: 'info'
})
} 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);
}
;
lotOccupancyTransactionsContainerElement.querySelector('#lotOccupancyTransactions--grandTotal').textContent = '$' + transactionGrandTotal.toFixed(2);
lotOccupancyTransactionsContainerElement.querySelector('#lotOccupancyTransactions--grandTotal').textContent = `\$${transactionGrandTotal.toFixed(2)}`;
const feeGrandTotal = getFeeGrandTotal();
if (feeGrandTotal.toFixed(2) !== transactionGrandTotal.toFixed(2)) {
lotOccupancyTransactionsContainerElement.insertAdjacentHTML('afterbegin', `<div class="message is-warning">
@ -524,7 +524,9 @@ function renderLotOccupancyTransactions() {
<div class="level-item">Outstanding Balance</div>
</div>
<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>`);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,13 @@
"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;
Object.defineProperty(exports, "__esModule", { value: true });
let workOrderComments = exports.workOrderComments;
delete exports.workOrderComments;
function openEditWorkOrderComment(clickEvent) {
const workOrderCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset
.workOrderCommentId, 10);
var _a, _b;
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) => {
return currentComment.workOrderCommentId === workOrderCommentId;
});
@ -14,8 +15,9 @@ function openEditWorkOrderComment(clickEvent) {
let editCloseModalFunction;
function editComment(submitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doUpdateWorkOrderComment', editFormElement, (responseJSON) => {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doUpdateWorkOrderComment`, editFormElement, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments;
editCloseModalFunction();
@ -32,19 +34,20 @@ function openEditWorkOrderComment(clickEvent) {
}
cityssm.openHtmlModal('workOrder-editComment', {
onshow(modalElement) {
var _a, _b, _c, _d;
;
modalElement.querySelector('#workOrderCommentEdit--workOrderId').value = workOrderId;
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');
workOrderCommentDateStringElement.value =
workOrderComment.workOrderCommentDateString;
(_b = workOrderComment.workOrderCommentDateString) !== null && _b !== void 0 ? _b : '';
const currentDateString = cityssm.dateToString(new Date());
workOrderCommentDateStringElement.max =
workOrderComment.workOrderCommentDateString <= currentDateString
? currentDateString
: workOrderComment.workOrderCommentDateString;
modalElement.querySelector('#workOrderCommentEdit--workOrderCommentTimeString').value = workOrderComment.workOrderCommentTimeString;
: (_c = workOrderComment.workOrderCommentDateString) !== null && _c !== void 0 ? _c : '';
modalElement.querySelector('#workOrderCommentEdit--workOrderCommentTimeString').value = (_d = workOrderComment.workOrderCommentTimeString) !== null && _d !== void 0 ? _d : '';
},
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped();
@ -60,14 +63,15 @@ function openEditWorkOrderComment(clickEvent) {
});
}
function deleteWorkOrderComment(clickEvent) {
const workOrderCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset
.workOrderCommentId, 10);
var _a, _b;
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() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderComment', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderComment`, {
workOrderId,
workOrderCommentId
}, (responseJSON) => {
}, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments;
renderWorkOrderComments();
@ -92,7 +96,7 @@ function deleteWorkOrderComment(clickEvent) {
});
}
function renderWorkOrderComments() {
var _a, _b;
var _a, _b, _c, _d, _e, _f;
const containerElement = document.querySelector('#container--workOrderComments');
if (workOrderComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info">
@ -110,38 +114,33 @@ function renderWorkOrderComments() {
for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr');
tableRowElement.dataset.workOrderCommentId =
workOrderComment.workOrderCommentId.toString();
tableRowElement.innerHTML =
'<td>' +
cityssm.escapeHTML((_a = workOrderComment.recordCreate_userName) !== null && _a !== void 0 ? _a : '') +
'</td>' +
'<td>' +
workOrderComment.workOrderCommentDateString +
(workOrderComment.workOrderCommentTime === 0
(_a = workOrderComment.workOrderCommentId) === null || _a === void 0 ? void 0 : _a.toString();
// eslint-disable-next-line no-unsanitized/property
tableRowElement.innerHTML = `<td>
${cityssm.escapeHTML((_b = workOrderComment.recordCreate_userName) !== null && _b !== void 0 ? _b : '')}
</td><td>
${workOrderComment.workOrderCommentDateString}
${workOrderComment.workOrderCommentTime === 0
? ''
: ' ' + workOrderComment.workOrderCommentTimePeriodString) +
'</td>' +
'<td>' +
cityssm.escapeHTML((_b = workOrderComment.workOrderComment) !== null && _b !== void 0 ? _b : '') +
'</td>' +
('<td class="is-hidden-print">' +
'<div class="buttons are-small is-justify-content-end">' +
('<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>Edit</span>' +
'</button>') +
('<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>' +
'</button>') +
'</div>' +
'</td>');
tableRowElement
.querySelector('.button--edit')
.addEventListener('click', openEditWorkOrderComment);
tableRowElement
.querySelector('.button--delete')
.addEventListener('click', deleteWorkOrderComment);
tableElement.querySelector('tbody').append(tableRowElement);
: ' ' + workOrderComment.workOrderCommentTimePeriodString}
</td><td>
${cityssm.escapeHTML((_c = workOrderComment.workOrderComment) !== null && _c !== void 0 ? _c : '')}
</td><td class="is-hidden-print">
<div class="buttons are-small is-justify-content-end">
<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>Edit</span>
</button>
<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>
</button>
</div>
</td>`;
(_d = tableRowElement
.querySelector('.button--edit')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', openEditWorkOrderComment);
(_e = tableRowElement
.querySelector('.button--delete')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', deleteWorkOrderComment);
(_f = tableElement.querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(tableRowElement);
}
containerElement.innerHTML = '';
containerElement.append(tableElement);
@ -150,7 +149,8 @@ function openAddCommentModal() {
let addCommentCloseModalFunction;
function doAddComment(formEvent) {
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) {
workOrderComments = responseJSON.workOrderComments;
renderWorkOrderComments();
@ -160,11 +160,11 @@ function openAddCommentModal() {
}
cityssm.openHtmlModal('workOrder-addComment', {
onshow(modalElement) {
var _a;
los.populateAliases(modalElement);
modalElement.querySelector('#workOrderCommentAdd--workOrderId').value = workOrderId;
modalElement
.querySelector('form')
.addEventListener('submit', doAddComment);
(_a = modalElement
.querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doAddComment);
},
onshown(modalElement, closeModalFunction) {
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'
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type * as globalTypes from '../../types/globalTypes'
import type * as recordTypes from '../../types/recordTypes'
import type { LOS } from '../../types/globalTypes.js'
import type * as recordTypes from '../../types/recordTypes.js'
declare const cityssm: cityssmGlobal
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 isCreate: boolean
let workOrderComments: recordTypes.WorkOrderComment[] =
exports.workOrderComments
let workOrderComments =
exports.workOrderComments as recordTypes.WorkOrderComment[]
delete exports.workOrderComments
function openEditWorkOrderComment(clickEvent: Event): void {
const workOrderCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset
.workOrderCommentId!,
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.workOrderCommentId ?? '',
10
)
const workOrderComment = workOrderComments.find((currentComment) => {
return currentComment.workOrderCommentId === workOrderCommentId
})!
}) as recordTypes.WorkOrderComment
let editFormElement: HTMLFormElement
let editCloseModalFunction: () => void
@ -36,15 +38,17 @@ function openEditWorkOrderComment(clickEvent: Event): void {
submitEvent.preventDefault()
cityssm.postJSON(
los.urlPrefix + '/workOrders/doUpdateWorkOrderComment',
`${los.urlPrefix}/workOrders/doUpdateWorkOrderComment`,
editFormElement,
(responseJSON: {
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
workOrderComments?: recordTypes.WorkOrderComment[]
}) => {
workOrderComments: recordTypes.WorkOrderComment[]
}
if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments!
workOrderComments = responseJSON.workOrderComments
editCloseModalFunction()
renderWorkOrderComments()
} else {
@ -74,26 +78,26 @@ function openEditWorkOrderComment(clickEvent: Event): void {
modalElement.querySelector(
'#workOrderCommentEdit--workOrderComment'
) as HTMLInputElement
).value = workOrderComment.workOrderComment!
).value = workOrderComment.workOrderComment ?? ''
const workOrderCommentDateStringElement = modalElement.querySelector(
'#workOrderCommentEdit--workOrderCommentDateString'
) as HTMLInputElement
workOrderCommentDateStringElement.value =
workOrderComment.workOrderCommentDateString!
workOrderComment.workOrderCommentDateString ?? ''
const currentDateString = cityssm.dateToString(new Date())
workOrderCommentDateStringElement.max =
workOrderComment.workOrderCommentDateString! <= currentDateString
? currentDateString
: workOrderComment.workOrderCommentDateString!
: workOrderComment.workOrderCommentDateString ?? ''
;(
modalElement.querySelector(
'#workOrderCommentEdit--workOrderCommentTimeString'
) as HTMLInputElement
).value = workOrderComment.workOrderCommentTimeString!
).value = workOrderComment.workOrderCommentTimeString ?? ''
},
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped()
@ -105,7 +109,7 @@ function openEditWorkOrderComment(clickEvent: Event): void {
) as HTMLTextAreaElement
).focus()
editFormElement = modalElement.querySelector('form')!
editFormElement = modalElement.querySelector('form') as HTMLFormElement
editFormElement.addEventListener('submit', editComment)
editCloseModalFunction = closeModalFunction
@ -118,23 +122,25 @@ function openEditWorkOrderComment(clickEvent: Event): void {
function deleteWorkOrderComment(clickEvent: Event): void {
const workOrderCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset
.workOrderCommentId!,
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.workOrderCommentId ?? '',
10
)
function doDelete(): void {
cityssm.postJSON(
los.urlPrefix + '/workOrders/doDeleteWorkOrderComment',
`${los.urlPrefix}/workOrders/doDeleteWorkOrderComment`,
{
workOrderId,
workOrderCommentId
},
(responseJSON: {
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
workOrderComments: recordTypes.WorkOrderComment[]
}) => {
}
if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments
renderWorkOrderComments()
@ -182,43 +188,43 @@ function renderWorkOrderComments(): void {
for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr')
tableRowElement.dataset.workOrderCommentId =
workOrderComment.workOrderCommentId!.toString()
workOrderComment.workOrderCommentId?.toString()
tableRowElement.innerHTML =
'<td>' +
cityssm.escapeHTML(workOrderComment.recordCreate_userName ?? '') +
'</td>' +
'<td>' +
workOrderComment.workOrderCommentDateString +
(workOrderComment.workOrderCommentTime === 0
// eslint-disable-next-line no-unsanitized/property
tableRowElement.innerHTML = `<td>
${cityssm.escapeHTML(workOrderComment.recordCreate_userName ?? '')}
</td><td>
${workOrderComment.workOrderCommentDateString}
${
workOrderComment.workOrderCommentTime === 0
? ''
: ' ' + workOrderComment.workOrderCommentTimePeriodString!) +
'</td>' +
'<td>' +
cityssm.escapeHTML(workOrderComment.workOrderComment ?? '') +
'</td>' +
('<td class="is-hidden-print">' +
'<div class="buttons are-small is-justify-content-end">' +
('<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>Edit</span>' +
'</button>') +
('<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>' +
'</button>') +
'</div>' +
'</td>')
: ' ' + workOrderComment.workOrderCommentTimePeriodString
}
</td><td>
${cityssm.escapeHTML(workOrderComment.workOrderComment ?? '')}
</td><td class="is-hidden-print">
<div class="buttons are-small is-justify-content-end">
<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>Edit</span>
</button>
<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>
</button>
</div>
</td>`
tableRowElement
.querySelector('.button--edit')!
.addEventListener('click', openEditWorkOrderComment)
.querySelector('.button--edit')
?.addEventListener('click', openEditWorkOrderComment)
tableRowElement
.querySelector('.button--delete')!
.addEventListener('click', deleteWorkOrderComment)
.querySelector('.button--delete')
?.addEventListener('click', deleteWorkOrderComment)
tableElement.querySelector('tbody')!.append(tableRowElement)
tableElement.querySelector('tbody')?.append(tableRowElement)
}
containerElement.innerHTML = ''
@ -232,14 +238,16 @@ function openAddCommentModal(): void {
formEvent.preventDefault()
cityssm.postJSON(
los.urlPrefix + '/workOrders/doAddWorkOrderComment',
`${los.urlPrefix}/workOrders/doAddWorkOrderComment`,
formEvent.currentTarget,
(responseJSON: {
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
workOrderComments?: recordTypes.WorkOrderComment[]
}) => {
workOrderComments: recordTypes.WorkOrderComment[]
}
if (responseJSON.success) {
workOrderComments = responseJSON.workOrderComments!
workOrderComments = responseJSON.workOrderComments
renderWorkOrderComments()
addCommentCloseModalFunction()
}
@ -255,9 +263,10 @@ function openAddCommentModal(): void {
'#workOrderCommentAdd--workOrderId'
) as HTMLInputElement
).value = workOrderId
modalElement
.querySelector('form')!
.addEventListener('submit', doAddComment)
.querySelector('form')
?.addEventListener('submit', doAddComment)
},
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped()

View File

@ -1,5 +1,6 @@
"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;
Object.defineProperty(exports, "__esModule", { value: true });
let workOrderLots = exports.workOrderLots;
@ -9,7 +10,7 @@ delete exports.workOrderLotOccupancies;
function deleteLotOccupancy(clickEvent) {
const lotOccupancyId = clickEvent.currentTarget.closest('.container--lotOccupancy').dataset.lotOccupancyId;
function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderLotOccupancy', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderLotOccupancy`, {
workOrderId,
lotOccupancyId
}, (rawResponseJSON) => {
@ -39,7 +40,7 @@ function deleteLotOccupancy(clickEvent) {
});
}
function addLot(lotId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderLot', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderLot`, {
workOrderId,
lotId
}, (rawResponseJSON) => {
@ -62,7 +63,7 @@ function addLot(lotId, callbackFunction) {
});
}
function addLotOccupancy(lotOccupancyId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + '/workOrders/doAddWorkOrderLotOccupancy', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doAddWorkOrderLotOccupancy`, {
workOrderId,
lotOccupancyId
}, (rawResponseJSON) => {
@ -74,7 +75,7 @@ function addLotOccupancy(lotOccupancyId, callbackFunction) {
}
else {
bulmaJS.alert({
title: 'Error Adding ' + los.escapedAliases.Occupancy,
title: `Error Adding ${los.escapedAliases.Occupancy}`,
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
contextualColorName: 'danger'
});
@ -85,19 +86,22 @@ function addLotOccupancy(lotOccupancyId, callbackFunction) {
});
}
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);
}
function renderRelatedOccupancies() {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f;
const occupanciesContainerElement = document.querySelector('#container--lotOccupancies');
document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString();
if (workOrderLotOccupancies.length === 0) {
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p>
</div>`;
return;
}
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
@ -121,44 +125,33 @@ function renderRelatedOccupancies() {
workOrderLots.some((lot) => {
return lotOccupancy.lotId === lot.lotId;
});
rowElement.innerHTML =
'<td class="is-width-1 has-text-centered">' +
(isActive
? '<i class="fas fa-play" title="Current ' +
los.escapedAliases.Occupancy +
'"></i>'
: '<i class="fas fa-stop" title="Previous ' +
los.escapedAliases.Occupancy +
'"></i>') +
'</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>');
// eslint-disable-next-line no-unsanitized/property
rowElement.innerHTML = `<td class="is-width-1 has-text-centered">
${isActive
? `<i class="fas fa-play" title="Current ${los.escapedAliases.Occupancy}"></i>`
: `<i class="fas fa-stop" title="Previous ${los.escapedAliases.Occupancy}"></i>`}
</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) {
rowElement.insertAdjacentHTML('beforeend', '<td>' +
cityssm.escapeHTML((_b = lotOccupancy.lotName) !== null && _b !== void 0 ? _b : '') +
(hasLotRecord
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td>
${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="' +
lotOccupancy.lotId.toString() +
'"' +
' data-tooltip="Add ' +
los.escapedAliases.Lot +
'"' +
' aria-label="Add ' +
los.escapedAliases.Lot +
'" type="button">' +
'<i class="fas fa-plus" aria-hidden="true"></i>' +
'</button>') +
'</td>');
: ` <button class="button is-small is-light is-success button--addLot"
data-lot-id="${lotOccupancy.lotId.toString()}"
data-tooltip="Add ${los.escapedAliases.Lot}"
aria-label="Add ${los.escapedAliases.Lot}" type="button">
<i class="fas fa-plus" aria-hidden="true"></i>
</button>`}
</td>`);
}
else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`);
}
let occupantsHTML = '';
@ -174,41 +167,39 @@ function renderRelatedOccupancies() {
${cityssm.escapeHTML(occupant.occupantFamilyName)}
</li>`;
}
rowElement.insertAdjacentHTML('beforeend', '<td>' +
lotOccupancy.occupancyStartDateString +
'</td>' +
('<td>' +
(lotOccupancy.occupancyEndDate
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td>
${lotOccupancy.occupancyStartDateString}
</td><td>
${lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString
: '<span class="has-text-grey">(No End Date)</span>') +
'</td>') +
('<td>' +
(lotOccupancy.lotOccupancyOccupants.length === 0
: '<span class="has-text-grey">(No End Date)</span>'}
</td><td>
${lotOccupancy.lotOccupancyOccupants.length === 0
? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>`
: `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`) +
'</td>') +
('<td>' +
'<button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">' +
'<i class="fas fa-trash" aria-hidden="true"></i>' +
'</button>' +
'</td>'));
: `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`}
</td><td>
<button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">
<i class="fas fa-trash" aria-hidden="true"></i>
</button>
</td>`);
(_d = rowElement
.querySelector('.button--addLot')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', addLotFromLotOccupancy);
rowElement
.querySelector('.button--deleteLotOccupancy')
.addEventListener('click', deleteLotOccupancy);
occupanciesContainerElement.querySelector('tbody').append(rowElement);
(_e = rowElement
.querySelector('.button--deleteLotOccupancy')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', deleteLotOccupancy);
(_f = occupanciesContainerElement.querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(rowElement);
}
}
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) => {
return possibleLot.lotId === lotId;
});
let editCloseModalFunction;
function doUpdateLotStatus(submitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/workOrders/doUpdateLotStatus', submitEvent.currentTarget, (rawResponseJSON) => {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doUpdateLotStatus`, submitEvent.currentTarget, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
@ -227,9 +218,10 @@ function openEditLotStatus(clickEvent) {
}
cityssm.openHtmlModal('lot-editLotStatus', {
onshow(modalElement) {
var _a, _b, _c;
los.populateAliases(modalElement);
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');
let lotStatusFound = false;
for (const lotStatus of exports.lotStatuses) {
@ -244,22 +236,22 @@ function openEditLotStatus(clickEvent) {
if (!lotStatusFound && lot.lotStatusId) {
const optionElement = document.createElement('option');
optionElement.value = lot.lotStatusId.toString();
optionElement.textContent = lot.lotStatus;
optionElement.textContent = (_b = lot.lotStatus) !== null && _b !== void 0 ? _b : '';
lotStatusElement.append(optionElement);
}
if (lot.lotStatusId) {
lotStatusElement.value = lot.lotStatusId.toString();
}
modalElement
.querySelector('form')
.insertAdjacentHTML('beforeend', `<input name="workOrderId" type="hidden" value="${workOrderId}" />`);
// eslint-disable-next-line no-unsanitized/method
(_c = modalElement
.querySelector('form')) === null || _c === void 0 ? void 0 : _c.insertAdjacentHTML('beforeend', `<input name="workOrderId" type="hidden" value="${workOrderId}" />`);
},
onshown(modalElement, closeModalFunction) {
var _a;
editCloseModalFunction = closeModalFunction;
bulmaJS.toggleHtmlClipped();
modalElement
.querySelector('form')
.addEventListener('submit', doUpdateLotStatus);
(_a = modalElement
.querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateLotStatus);
},
onremoved() {
bulmaJS.toggleHtmlClipped();
@ -269,7 +261,7 @@ function openEditLotStatus(clickEvent) {
function deleteLot(clickEvent) {
const lotId = clickEvent.currentTarget.closest('.container--lot').dataset.lotId;
function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderLot', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderLot`, {
workOrderId,
lotId
}, (rawResponseJSON) => {
@ -299,15 +291,17 @@ function deleteLot(clickEvent) {
});
}
function renderRelatedLots() {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f, _g;
const lotsContainerElement = document.querySelector('#container--lots');
document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent = workOrderLots.length.toString();
if (workOrderLots.length === 0) {
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
</div>`;
return;
}
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th>${los.escapedAliases.Lot}</th>
@ -322,22 +316,20 @@ function renderRelatedLots() {
const rowElement = document.createElement('tr');
rowElement.className = 'container--lot';
rowElement.dataset.lotId = lot.lotId.toString();
rowElement.innerHTML =
'<td>' +
'<a class="has-text-weight-bold" href="' +
los.getLotURL(lot.lotId) +
'">' +
cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '') +
'</a>' +
'</td>' +
`<td>${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}</td>` +
`<td>${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}</td>` +
('<td>' +
(lot.lotStatusId
// eslint-disable-next-line no-unsanitized/property
rowElement.innerHTML = `<td>
<a class="has-text-weight-bold" href="${los.getLotURL(lot.lotId)}">
${cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '')}
</a>
</td><td>
${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}
</td><td>
${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}
</td><td>
${lot.lotStatusId
? cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '')
: '<span class="has-text-grey">(No Status)</span>') +
'</td>') +
`<td class="is-nowrap">
: '<span class="has-text-grey">(No Status)</span>'}
</td><td class="is-nowrap">
<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>
</button>
@ -345,13 +337,11 @@ function renderRelatedLots() {
<i class="fas fa-trash" aria-hidden="true"></i>
</button>
</td>`;
rowElement
.querySelector('.button--editLotStatus')
.addEventListener('click', openEditLotStatus);
rowElement
.querySelector('.button--deleteLot')
.addEventListener('click', deleteLot);
lotsContainerElement.querySelector('tbody').append(rowElement);
(_e = rowElement
.querySelector('.button--editLotStatus')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', openEditLotStatus);
(_f = rowElement
.querySelector('.button--deleteLot')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', deleteLot);
(_g = lotsContainerElement.querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(rowElement);
}
}
function renderRelatedLotsAndOccupancies() {
@ -360,8 +350,9 @@ function renderRelatedLotsAndOccupancies() {
}
renderRelatedLotsAndOccupancies();
function doAddLotOccupancy(clickEvent) {
var _a;
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) => {
if (success) {
rowElement.remove();
@ -376,10 +367,11 @@ function doAddLotOccupancy(clickEvent) {
if (event) {
event.preventDefault();
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...');
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doSearchLotOccupancies', searchFormElement, (rawResponseJSON) => {
var _a, _b;
cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doSearchLotOccupancies`, searchFormElement, (rawResponseJSON) => {
var _a, _b, _c, _d;
const responseJSON = rawResponseJSON;
if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML = `<div class="message is-info">
@ -387,6 +379,7 @@ function doAddLotOccupancy(clickEvent) {
</div>`;
return;
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
@ -417,32 +410,32 @@ function doAddLotOccupancy(clickEvent) {
'</td>');
}
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>${lotOccupancy.occupancyStartDateString}</td>` +
('<td>' +
(lotOccupancy.occupancyEndDate
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML('beforeend', `<td>
${lotOccupancy.occupancyStartDateString}
</td><td>
${lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString
: '<span class="has-text-grey">(No End Date)</span>') +
'</td>') +
('<td>' +
(lotOccupancy.lotOccupancyOccupants.length === 0
? `<span class="has-text-grey">(No ${cityssm.escapeHTML(los.escapedAliases.Occupants)})</span>`
: cityssm.escapeHTML(lotOccupancy.lotOccupancyOccupants[0].occupantName +
' ' +
lotOccupancy.lotOccupancyOccupants[0]
.occupantFamilyName) +
: '<span class="has-text-grey">(No End Date)</span>'}
</td><td>
${lotOccupancy.lotOccupancyOccupants.length === 0
? `<span class="has-text-grey">
(No ${cityssm.escapeHTML(los.escapedAliases.Occupants)})
</span>`
: cityssm.escapeHTML(`${lotOccupancy.lotOccupancyOccupants[0].occupantName}
${lotOccupancy.lotOccupancyOccupants[0]
.occupantFamilyName}`) +
(lotOccupancy.lotOccupancyOccupants.length > 1
? ' plus ' +
(lotOccupancy.lotOccupancyOccupants.length - 1).toString()
: '')) +
'</td>'));
rowElement
.querySelector('.button--addLotOccupancy')
.addEventListener('click', doAddLotOccupancy);
searchResultsContainerElement
.querySelector('tbody')
.append(rowElement);
? ` plus
${(lotOccupancy.lotOccupancyOccupants.length - 1).toString()}`
: '')}</td>`);
(_c = rowElement
.querySelector('.button--addLotOccupancy')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', doAddLotOccupancy);
(_d = searchResultsContainerElement
.querySelector('tbody')) === null || _d === void 0 ? void 0 : _d.append(rowElement);
}
});
}
@ -470,8 +463,9 @@ function doAddLotOccupancy(clickEvent) {
});
});
function doAddLot(clickEvent) {
var _a;
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) => {
if (success) {
rowElement.remove();
@ -485,18 +479,19 @@ function doAddLot(clickEvent) {
if (event) {
event.preventDefault();
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...');
cityssm.postJSON(los.urlPrefix + '/lots/doSearchLots', searchFormElement, (rawResponseJSON) => {
var _a, _b, _c, _d;
cityssm.postJSON(`${los.urlPrefix}/lots/doSearchLots`, searchFormElement, (rawResponseJSON) => {
var _a, _b, _c, _d, _e, _f;
const responseJSON = rawResponseJSON;
if (responseJSON.lots.length === 0) {
searchResultsContainerElement.innerHTML =
'<div class="message is-info">' +
'<p class="message-body">There are no records that meet the search criteria.</p>' +
'</div>';
searchResultsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no records that meet the search criteria.</p>
</div>`;
return;
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
@ -511,26 +506,23 @@ function doAddLot(clickEvent) {
const rowElement = document.createElement('tr');
rowElement.className = 'container--lot';
rowElement.dataset.lotId = lot.lotId.toString();
rowElement.innerHTML =
'<td class="has-text-centered">' +
'<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>' +
'</button>' +
'</td>' +
('<td class="has-text-weight-bold">' +
cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '') +
'</td>') +
'<td>' +
cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '') +
'</td>' +
('<td>' + cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '') + '</td>') +
('<td>' + cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '') + '</td>');
rowElement
.querySelector('.button--addLot')
.addEventListener('click', doAddLot);
searchResultsContainerElement
.querySelector('tbody')
.append(rowElement);
rowElement.innerHTML = `<td class="has-text-centered">
<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>
</button>
</td><td class="has-text-weight-bold">
${cityssm.escapeHTML((_a = lot.lotName) !== null && _a !== void 0 ? _a : '')}
</td><td>
${cityssm.escapeHTML((_b = lot.mapName) !== null && _b !== void 0 ? _b : '')}
</td><td>
${cityssm.escapeHTML((_c = lot.lotType) !== null && _c !== void 0 ? _c : '')}
</td><td>
${cityssm.escapeHTML((_d = lot.lotStatus) !== null && _d !== void 0 ? _d : '')}
</td>`;
(_e = rowElement
.querySelector('.button--addLot')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', doAddLot);
(_f = searchResultsContainerElement
.querySelector('tbody')) === null || _f === void 0 ? void 0 : _f.append(rowElement);
}
});
}
@ -550,13 +542,13 @@ function doAddLot(clickEvent) {
doSearch();
},
onshown(modalElement) {
var _a;
bulmaJS.toggleHtmlClipped();
const lotNameElement = modalElement.querySelector('#lotSearch--lotName');
lotNameElement.addEventListener('change', doSearch);
lotNameElement.focus();
modalElement
.querySelector('#lotSearch--lotStatusId')
.addEventListener('change', doSearch);
(_a = modalElement
.querySelector('#lotSearch--lotStatusId')) === null || _a === void 0 ? void 0 : _a.addEventListener('change', doSearch);
searchFormElement.addEventListener('submit', doSearch);
},
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'
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type * as globalTypes from '../../types/globalTypes'
import type * as recordTypes from '../../types/recordTypes'
import type { LOS } from '../../types/globalTypes.js'
import type * as recordTypes from '../../types/recordTypes.js'
declare const cityssm: cityssmGlobal
declare const bulmaJS: BulmaJS
declare const los: globalTypes.LOS
declare const exports: Record<string, unknown>
declare const los: LOS
declare const workOrderId: string
let workOrderLots: recordTypes.Lot[] = exports.workOrderLots
let workOrderLots = exports.workOrderLots as recordTypes.Lot[]
delete exports.workOrderLots
let workOrderLotOccupancies: recordTypes.LotOccupancy[] =
exports.workOrderLotOccupancies
let workOrderLotOccupancies =
exports.workOrderLotOccupancies as recordTypes.LotOccupancy[]
delete exports.workOrderLotOccupancies
function deleteLotOccupancy(clickEvent: Event): void {
@ -29,7 +31,7 @@ function deleteLotOccupancy(clickEvent: Event): void {
function doDelete(): void {
cityssm.postJSON(
los.urlPrefix + '/workOrders/doDeleteWorkOrderLotOccupancy',
`${los.urlPrefix}/workOrders/doDeleteWorkOrderLotOccupancy`,
{
workOrderId,
lotOccupancyId
@ -38,11 +40,11 @@ function deleteLotOccupancy(clickEvent: Event): void {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
workOrderLotOccupancies?: recordTypes.LotOccupancy[]
workOrderLotOccupancies: recordTypes.LotOccupancy[]
}
if (responseJSON.success) {
workOrderLotOccupancies = responseJSON.workOrderLotOccupancies!
workOrderLotOccupancies = responseJSON.workOrderLotOccupancies
renderRelatedLotsAndOccupancies()
} else {
bulmaJS.alert({
@ -71,7 +73,7 @@ function addLot(
callbackFunction?: (success: boolean) => void
): void {
cityssm.postJSON(
los.urlPrefix + '/workOrders/doAddWorkOrderLot',
`${los.urlPrefix}/workOrders/doAddWorkOrderLot`,
{
workOrderId,
lotId
@ -80,11 +82,11 @@ function addLot(
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
workOrderLots?: recordTypes.Lot[]
workOrderLots: recordTypes.Lot[]
}
if (responseJSON.success) {
workOrderLots = responseJSON.workOrderLots!
workOrderLots = responseJSON.workOrderLots
renderRelatedLotsAndOccupancies()
} else {
bulmaJS.alert({
@ -106,7 +108,7 @@ function addLotOccupancy(
callbackFunction?: (success?: boolean) => void
): void {
cityssm.postJSON(
los.urlPrefix + '/workOrders/doAddWorkOrderLotOccupancy',
`${los.urlPrefix}/workOrders/doAddWorkOrderLotOccupancy`,
{
workOrderId,
lotOccupancyId
@ -115,15 +117,15 @@ function addLotOccupancy(
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
workOrderLotOccupancies?: recordTypes.LotOccupancy[]
workOrderLotOccupancies: recordTypes.LotOccupancy[]
}
if (responseJSON.success) {
workOrderLotOccupancies = responseJSON.workOrderLotOccupancies!
workOrderLotOccupancies = responseJSON.workOrderLotOccupancies
renderRelatedLotsAndOccupancies()
} else {
bulmaJS.alert({
title: 'Error Adding ' + los.escapedAliases.Occupancy,
title: `Error Adding ${los.escapedAliases.Occupancy}`,
message: responseJSON.errorMessage ?? '',
contextualColorName: 'danger'
})
@ -137,7 +139,7 @@ function addLotOccupancy(
}
function addLotFromLotOccupancy(clickEvent: Event): void {
const lotId = (clickEvent.currentTarget as HTMLElement).dataset.lotId!
const lotId = (clickEvent.currentTarget as HTMLElement).dataset.lotId ?? ''
addLot(lotId)
}
@ -153,6 +155,7 @@ function renderRelatedOccupancies(): void {
).textContent = workOrderLotOccupancies.length.toString()
if (workOrderLotOccupancies.length === 0) {
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.occupancies} associated with this work order.</p>
</div>`
@ -160,6 +163,7 @@ function renderRelatedOccupancies(): void {
return
}
// eslint-disable-next-line no-unsanitized/property
occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
@ -178,7 +182,7 @@ function renderRelatedOccupancies(): void {
for (const lotOccupancy of workOrderLotOccupancies) {
const rowElement = document.createElement('tr')
rowElement.className = 'container--lotOccupancy'
rowElement.dataset.lotOccupancyId = lotOccupancy.lotOccupancyId!.toString()
rowElement.dataset.lotOccupancyId = lotOccupancy.lotOccupancyId.toString()
const isActive = !(
lotOccupancy.occupancyEndDate &&
@ -191,47 +195,40 @@ function renderRelatedOccupancies(): void {
return lotOccupancy.lotId === lot.lotId
})
rowElement.innerHTML =
'<td class="is-width-1 has-text-centered">' +
(isActive
? '<i class="fas fa-play" title="Current ' +
los.escapedAliases.Occupancy +
'"></i>'
: '<i class="fas fa-stop" title="Previous ' +
los.escapedAliases.Occupancy +
'"></i>') +
'</td>' +
('<td>' +
'<a class="has-text-weight-bold" href="' +
los.getLotOccupancyURL(lotOccupancy.lotOccupancyId) +
'">' +
cityssm.escapeHTML(lotOccupancy.occupancyType ?? '') +
'</a><br />' +
`<span class="is-size-7">#${lotOccupancy.lotOccupancyId!}</span>` +
'</td>')
// eslint-disable-next-line no-unsanitized/property
rowElement.innerHTML = `<td class="is-width-1 has-text-centered">
${
isActive
? `<i class="fas fa-play" title="Current ${los.escapedAliases.Occupancy}"></i>`
: `<i class="fas fa-stop" title="Previous ${los.escapedAliases.Occupancy}"></i>`
}
</td><td>
<a class="has-text-weight-bold" href="${los.getLotOccupancyURL(lotOccupancy.lotOccupancyId)}">
${cityssm.escapeHTML(lotOccupancy.occupancyType ?? '')}
</a><br />
<span class="is-size-7">#${lotOccupancy.lotOccupancyId}</span>
</td>`
if (lotOccupancy.lotId) {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML(
'beforeend',
'<td>' +
cityssm.escapeHTML(lotOccupancy.lotName ?? '') +
(hasLotRecord
`<td>
${cityssm.escapeHTML(lotOccupancy.lotName ?? '')}
${
hasLotRecord
? ''
: ' <button class="button is-small is-light is-success button--addLot"' +
' data-lot-id="' +
lotOccupancy.lotId.toString() +
'"' +
' data-tooltip="Add ' +
los.escapedAliases.Lot +
'"' +
' aria-label="Add ' +
los.escapedAliases.Lot +
'" type="button">' +
'<i class="fas fa-plus" aria-hidden="true"></i>' +
'</button>') +
'</td>'
: ` <button class="button is-small is-light is-success button--addLot"
data-lot-id="${lotOccupancy.lotId.toString()}"
data-tooltip="Add ${los.escapedAliases.Lot}"
aria-label="Add ${los.escapedAliases.Lot}" type="button">
<i class="fas fa-plus" aria-hidden="true"></i>
</button>`
}
</td>`
)
} else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML(
'beforeend',
`<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`
@ -255,26 +252,28 @@ function renderRelatedOccupancies(): void {
</li>`
}
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML(
'beforeend',
'<td>' +
lotOccupancy.occupancyStartDateString! +
'</td>' +
('<td>' +
(lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString!
: '<span class="has-text-grey">(No End Date)</span>') +
'</td>') +
('<td>' +
(lotOccupancy.lotOccupancyOccupants!.length === 0
`<td>
${lotOccupancy.occupancyStartDateString}
</td><td>
${
lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString
: '<span class="has-text-grey">(No End Date)</span>'
}
</td><td>
${
lotOccupancy.lotOccupancyOccupants!.length === 0
? `<span class="has-text-grey">(No ${los.escapedAliases.Occupants})</span>`
: `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`) +
'</td>') +
('<td>' +
'<button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">' +
'<i class="fas fa-trash" aria-hidden="true"></i>' +
'</button>' +
'</td>')
: `<ul class="fa-ul ml-5">${occupantsHTML}</ul>`
}
</td><td>
<button class="button is-small is-light is-danger button--deleteLotOccupancy" data-tooltip="Delete Relationship" type="button">
<i class="fas fa-trash" aria-hidden="true"></i>
</button>
</td>`
)
rowElement
@ -282,10 +281,10 @@ function renderRelatedOccupancies(): void {
?.addEventListener('click', addLotFromLotOccupancy)
rowElement
.querySelector('.button--deleteLotOccupancy')!
.addEventListener('click', deleteLotOccupancy)
.querySelector('.button--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(
'.container--lot'
) as HTMLElement
).dataset.lotId!,
).dataset.lotId ?? '',
10
)
const lot = workOrderLots.find((possibleLot) => {
return possibleLot.lotId === lotId
})!
}) as recordTypes.Lot
let editCloseModalFunction: () => void
@ -309,17 +308,17 @@ function openEditLotStatus(clickEvent: Event): void {
submitEvent.preventDefault()
cityssm.postJSON(
los.urlPrefix + '/workOrders/doUpdateLotStatus',
`${los.urlPrefix}/workOrders/doUpdateLotStatus`,
submitEvent.currentTarget,
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
workOrderLots?: recordTypes.Lot[]
workOrderLots: recordTypes.Lot[]
}
if (responseJSON.success) {
workOrderLots = responseJSON.workOrderLots!
workOrderLots = responseJSON.workOrderLots
renderRelatedLotsAndOccupancies()
editCloseModalFunction()
} else {
@ -343,7 +342,7 @@ function openEditLotStatus(clickEvent: Event): void {
modalElement.querySelector(
'#lotStatusEdit--lotName'
) as HTMLInputElement
).value = lot.lotName!
).value = lot.lotName ?? ''
const lotStatusElement = modalElement.querySelector(
'#lotStatusEdit--lotStatusId'
@ -366,7 +365,7 @@ function openEditLotStatus(clickEvent: Event): void {
if (!lotStatusFound && lot.lotStatusId) {
const optionElement = document.createElement('option')
optionElement.value = lot.lotStatusId.toString()
optionElement.textContent = lot.lotStatus!
optionElement.textContent = lot.lotStatus ?? ''
lotStatusElement.append(optionElement)
}
@ -374,9 +373,10 @@ function openEditLotStatus(clickEvent: Event): void {
lotStatusElement.value = lot.lotStatusId.toString()
}
// eslint-disable-next-line no-unsanitized/method
modalElement
.querySelector('form')!
.insertAdjacentHTML(
.querySelector('form')
?.insertAdjacentHTML(
'beforeend',
`<input name="workOrderId" type="hidden" value="${workOrderId}" />`
)
@ -387,8 +387,8 @@ function openEditLotStatus(clickEvent: Event): void {
bulmaJS.toggleHtmlClipped()
modalElement
.querySelector('form')!
.addEventListener('submit', doUpdateLotStatus)
.querySelector('form')
?.addEventListener('submit', doUpdateLotStatus)
},
onremoved() {
bulmaJS.toggleHtmlClipped()
@ -405,7 +405,7 @@ function deleteLot(clickEvent: Event): void {
function doDelete(): void {
cityssm.postJSON(
los.urlPrefix + '/workOrders/doDeleteWorkOrderLot',
`${los.urlPrefix}/workOrders/doDeleteWorkOrderLot`,
{
workOrderId,
lotId
@ -414,11 +414,11 @@ function deleteLot(clickEvent: Event): void {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
workOrderLots?: recordTypes.Lot[]
workOrderLots: recordTypes.Lot[]
}
if (responseJSON.success) {
workOrderLots = responseJSON.workOrderLots!
workOrderLots = responseJSON.workOrderLots
renderRelatedLotsAndOccupancies()
} else {
bulmaJS.alert({
@ -454,6 +454,7 @@ function renderRelatedLots(): void {
).textContent = workOrderLots.length.toString()
if (workOrderLots.length === 0) {
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
</div>`
@ -461,6 +462,7 @@ function renderRelatedLots(): void {
return
}
// eslint-disable-next-line no-unsanitized/property
lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th>${los.escapedAliases.Lot}</th>
@ -478,22 +480,22 @@ function renderRelatedLots(): void {
rowElement.dataset.lotId = lot.lotId.toString()
rowElement.innerHTML =
'<td>' +
'<a class="has-text-weight-bold" href="' +
los.getLotURL(lot.lotId) +
'">' +
cityssm.escapeHTML(lot.lotName ?? '') +
'</a>' +
'</td>' +
`<td>${cityssm.escapeHTML(lot.mapName ?? '')}</td>` +
`<td>${cityssm.escapeHTML(lot.lotType ?? '')}</td>` +
('<td>' +
(lot.lotStatusId
// eslint-disable-next-line no-unsanitized/property
rowElement.innerHTML = `<td>
<a class="has-text-weight-bold" href="${los.getLotURL(lot.lotId)}">
${cityssm.escapeHTML(lot.lotName ?? '')}
</a>
</td><td>
${cityssm.escapeHTML(lot.mapName ?? '')}
</td><td>
${cityssm.escapeHTML(lot.lotType ?? '')}
</td><td>
${
lot.lotStatusId
? cityssm.escapeHTML(lot.lotStatus ?? '')
: '<span class="has-text-grey">(No Status)</span>') +
'</td>') +
`<td class="is-nowrap">
: '<span class="has-text-grey">(No Status)</span>'
}
</td><td class="is-nowrap">
<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>
</button>
@ -503,14 +505,14 @@ function renderRelatedLots(): void {
</td>`
rowElement
.querySelector('.button--editLotStatus')!
.addEventListener('click', openEditLotStatus)
.querySelector('.button--editLotStatus')
?.addEventListener('click', openEditLotStatus)
rowElement
.querySelector('.button--deleteLot')!
.addEventListener('click', deleteLot)
.querySelector('.button--deleteLot')
?.addEventListener('click', deleteLot)
lotsContainerElement.querySelector('tbody')!.append(rowElement)
lotsContainerElement.querySelector('tbody')?.append(rowElement)
}
}
@ -522,9 +524,11 @@ function renderRelatedLotsAndOccupancies(): void {
renderRelatedLotsAndOccupancies()
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) => {
if (success) {
@ -544,11 +548,12 @@ document
event.preventDefault()
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...')
cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doSearchLotOccupancies',
`${los.urlPrefix}/lotOccupancies/doSearchLotOccupancies`,
searchFormElement,
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
@ -563,6 +568,7 @@ document
return
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
@ -579,7 +585,7 @@ document
const rowElement = document.createElement('tr')
rowElement.className = 'container--lotOccupancy'
rowElement.dataset.lotOccupancyId =
lotOccupancy.lotOccupancyId!.toString()
lotOccupancy.lotOccupancyId.toString()
rowElement.innerHTML = `<td class="has-text-centered">
<button class="button is-small is-success button--addLotOccupancy" data-tooltip="Add" type="button" aria-label="Add">
@ -598,45 +604,55 @@ document
'</td>'
)
} else {
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML(
'beforeend',
`<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`
)
}
// eslint-disable-next-line no-unsanitized/method
rowElement.insertAdjacentHTML(
'beforeend',
`<td>${lotOccupancy.occupancyStartDateString!}</td>` +
('<td>' +
(lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString!
: '<span class="has-text-grey">(No End Date)</span>') +
'</td>') +
('<td>' +
(lotOccupancy.lotOccupancyOccupants!.length === 0
? `<span class="has-text-grey">(No ${cityssm.escapeHTML(
`<td>
${lotOccupancy.occupancyStartDateString}
</td><td>
${
lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString
: '<span class="has-text-grey">(No End Date)</span>'
}
</td><td>
${
lotOccupancy.lotOccupancyOccupants!.length === 0
? `<span class="has-text-grey">
(No ${cityssm.escapeHTML(
los.escapedAliases.Occupants
)})</span>`
)})
</span>`
: cityssm.escapeHTML(
lotOccupancy.lotOccupancyOccupants![0].occupantName! +
' ' +
`${lotOccupancy.lotOccupancyOccupants![0].occupantName}
${
lotOccupancy.lotOccupancyOccupants![0]
.occupantFamilyName!
.occupantFamilyName
}`
) +
(lotOccupancy.lotOccupancyOccupants!.length > 1
? ' plus ' +
(lotOccupancy.lotOccupancyOccupants!.length - 1).toString()
: '')) +
'</td>')
? ` plus
${(
lotOccupancy.lotOccupancyOccupants!.length - 1
).toString()}`
: '')
}</td>`
)
rowElement
.querySelector('.button--addLotOccupancy')!
.addEventListener('click', doAddLotOccupancy)
.querySelector('.button--addLotOccupancy')
?.addEventListener('click', doAddLotOccupancy)
searchResultsContainerElement
.querySelector('tbody')!
.append(rowElement)
.querySelector('tbody')
?.append(rowElement)
}
}
)
@ -646,7 +662,9 @@ document
onshow(modalElement) {
los.populateAliases(modalElement)
searchFormElement = modalElement.querySelector('form')!
searchFormElement = modalElement.querySelector(
'form'
) as HTMLFormElement
searchResultsContainerElement = modalElement.querySelector(
'#resultsContainer--lotOccupancyAdd'
@ -697,9 +715,11 @@ document
})
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) => {
if (success) {
@ -717,24 +737,25 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
event.preventDefault()
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML =
los.getLoadingParagraphHTML('Searching...')
cityssm.postJSON(
los.urlPrefix + '/lots/doSearchLots',
`${los.urlPrefix}/lots/doSearchLots`,
searchFormElement,
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as { lots: recordTypes.Lot[] }
if (responseJSON.lots.length === 0) {
searchResultsContainerElement.innerHTML =
'<div class="message is-info">' +
'<p class="message-body">There are no records that meet the search criteria.</p>' +
'</div>'
searchResultsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no records that meet the search criteria.</p>
</div>`
return
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
@ -751,28 +772,27 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
rowElement.className = 'container--lot'
rowElement.dataset.lotId = lot.lotId.toString()
rowElement.innerHTML =
'<td class="has-text-centered">' +
'<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>' +
'</button>' +
'</td>' +
('<td class="has-text-weight-bold">' +
cityssm.escapeHTML(lot.lotName ?? '') +
'</td>') +
'<td>' +
cityssm.escapeHTML(lot.mapName ?? '') +
'</td>' +
('<td>' + cityssm.escapeHTML(lot.lotType ?? '') + '</td>') +
('<td>' + cityssm.escapeHTML(lot.lotStatus ?? '') + '</td>')
rowElement.innerHTML = `<td class="has-text-centered">
<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>
</button>
</td><td class="has-text-weight-bold">
${cityssm.escapeHTML(lot.lotName ?? '')}
</td><td>
${cityssm.escapeHTML(lot.mapName ?? '')}
</td><td>
${cityssm.escapeHTML(lot.lotType ?? '')}
</td><td>
${cityssm.escapeHTML(lot.lotStatus ?? '')}
</td>`
rowElement
.querySelector('.button--addLot')!
.addEventListener('click', doAddLot)
.querySelector('.button--addLot')
?.addEventListener('click', doAddLot)
searchResultsContainerElement
.querySelector('tbody')!
.append(rowElement)
.querySelector('tbody')
?.append(rowElement)
}
}
)
@ -782,7 +802,7 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
onshow(modalElement) {
los.populateAliases(modalElement)
searchFormElement = modalElement.querySelector('form')!
searchFormElement = modalElement.querySelector('form') as HTMLFormElement
searchResultsContainerElement = modalElement.querySelector(
'#resultsContainer--lotAdd'
@ -817,8 +837,8 @@ document.querySelector('#button--addLot')?.addEventListener('click', () => {
lotNameElement.focus()
modalElement
.querySelector('#lotSearch--lotStatusId')!
.addEventListener('change', doSearch)
.querySelector('#lotSearch--lotStatusId')
?.addEventListener('change', 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