refactoring

deepsource-autofix-76c6eb20
Dan Gowans 2022-12-30 12:52:32 -05:00
parent fc64720dcc
commit 5b94b09c7b
6 changed files with 444 additions and 553 deletions

View File

@ -503,10 +503,7 @@ declare const bulmaJS: BulmaJS;
} }
if (!isCreate) { if (!isCreate) {
(document.querySelector("#lotComments--add") as HTMLButtonElement).addEventListener( document.querySelector("#lotComments--add")!.addEventListener("click", openAddCommentModal);
"click",
openAddCommentModal
);
renderLotComments(); renderLotComments();
} }
})(); })();

View File

@ -3,9 +3,8 @@
import * as globalTypes from "../types/globalTypes"; import * as globalTypes from "../types/globalTypes";
(() => { (() => {
const mapContainerElement = document.querySelector( const mapContainerElement = document.querySelector("#lot--map") as HTMLElement;
"#lot--map"
) as HTMLElement;
if (mapContainerElement) { if (mapContainerElement) {
(exports.los as globalTypes.LOS).highlightMap( (exports.los as globalTypes.LOS).highlightMap(
mapContainerElement, mapContainerElement,

View File

@ -137,9 +137,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
delete exports.workOrderLots; delete exports.workOrderLots;
let workOrderLotOccupancies = exports.workOrderLotOccupancies; let workOrderLotOccupancies = exports.workOrderLotOccupancies;
delete exports.workOrderLotOccupancies; delete exports.workOrderLotOccupancies;
const deleteLotOccupancy = (clickEvent) => { function deleteLotOccupancy(clickEvent) {
const lotOccupancyId = clickEvent.currentTarget.closest(".container--lotOccupancy").dataset.lotOccupancyId; const lotOccupancyId = clickEvent.currentTarget.closest(".container--lotOccupancy").dataset.lotOccupancyId;
const doDelete = () => { function doDelete() {
cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLotOccupancy", { cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLotOccupancy", {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
@ -156,22 +156,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
}); });
}; }
bulmaJS.confirm({ bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship", title: `Delete ${exports.aliases.occupancy} Relationship`,
message: "Are you sure you want to remove the relationship to this " + message: `Are you sure you want to remove the relationship to this ${exports.aliases.occupancy.toLowerCase()} record from this work order? Note that the record will remain.`,
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupancy.toLowerCase() +
" record from this work order? Note that the record will remain.",
contextualColorName: "warning", contextualColorName: "warning",
okButton: { okButton: {
text: "Yes, Delete Relationship", text: "Yes, Delete Relationship",
callbackFunction: doDelete callbackFunction: doDelete
} }
}); });
}; }
const addLot = (lotId, callbackFunction) => { function addLot(lotId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLot", { cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLot", {
workOrderId, workOrderId,
lotId lotId
@ -191,8 +187,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
callbackFunction(responseJSON.success); callbackFunction(responseJSON.success);
} }
}); });
}; }
const addLotOccupancy = (lotOccupancyId, callbackFunction) => { function addLotOccupancy(lotOccupancyId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLotOccupancy", { cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLotOccupancy", {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
@ -212,39 +208,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
callbackFunction(responseJSON.success); callbackFunction(responseJSON.success);
} }
}); });
}; }
const addLotFromLotOccupancy = (clickEvent) => { function addLotFromLotOccupancy(clickEvent) {
const lotId = clickEvent.currentTarget.dataset.lotId; const lotId = clickEvent.currentTarget.dataset.lotId;
addLot(lotId); addLot(lotId);
}; }
const renderRelatedOccupancies = () => { function renderRelatedOccupancies() {
var _a; var _a;
const occupanciesContainerElement = document.querySelector("#container--lotOccupancies"); const occupanciesContainerElement = document.querySelector("#container--lotOccupancies");
document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString(); document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString();
if (workOrderLotOccupancies.length === 0) { if (workOrderLotOccupancies.length === 0) {
occupanciesContainerElement.innerHTML = occupanciesContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no ${exports.aliases.occupancies.toLowerCase()} associated with this work order.</p>
'<p class="message-body">There are no ' + </div>`;
exports.aliases.occupancies.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
return; return;
} }
occupanciesContainerElement.innerHTML = occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th><th>${los.escapedAliases.Occupancy} Type</th>
"<tr>" + <th>${los.escapedAliases.Lot}</th><th>${los.escapedAliases.OccupancyStartDate}</th>
'<th class="has-width-1"></th>' + <th>End Date</th><th>${los.escapedAliases.Occupants}</th>
("<th>" + exports.aliases.occupancy + " Type</th>") + <th class="has-width-1"></th>
("<th>" + exports.aliases.lot + "</th>") + </tr></thead>
("<th>" + exports.aliases.occupancyStartDate + "</th>") + <tbody></tbody>
"<th>End Date</th>" + </table>`;
("<th>" + exports.aliases.occupants + "</th>") +
'<th class="has-width-1"></th>' +
"</tr>" +
"</thead>" +
"<tbody></tbody>" +
"</table>";
const currentDateString = cityssm.dateToString(new Date()); const currentDateString = cityssm.dateToString(new Date());
for (const lotOccupancy of workOrderLotOccupancies) { for (const lotOccupancy of workOrderLotOccupancies) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
@ -295,11 +282,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
"</td>"); "</td>");
} }
else { else {
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", `<td><span class="has-text-grey">(No ${exports.aliases.lot})</span></td>`);
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>");
} }
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", "<td>" +
lotOccupancy.occupancyStartDateString + lotOccupancy.occupancyStartDateString +
@ -334,20 +317,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
"</button>" + "</button>" +
"</td>")); "</td>"));
if (lotOccupancy.lotId && !hasLotRecord) { if (lotOccupancy.lotId && !hasLotRecord) {
rowElement.querySelector(".button--addLot").addEventListener("click", addLotFromLotOccupancy); rowElement
.querySelector(".button--addLot")
.addEventListener("click", addLotFromLotOccupancy);
} }
rowElement.querySelector(".button--deleteLotOccupancy").addEventListener("click", deleteLotOccupancy); rowElement
.querySelector(".button--deleteLotOccupancy")
.addEventListener("click", deleteLotOccupancy);
occupanciesContainerElement.querySelector("tbody").append(rowElement); occupanciesContainerElement.querySelector("tbody").append(rowElement);
} }
}; }
const openEditLotStatus = (clickEvent) => { function openEditLotStatus(clickEvent) {
const lotId = Number.parseInt(clickEvent.currentTarget.closest(".container--lot") const lotId = Number.parseInt(clickEvent.currentTarget.closest(".container--lot")
.dataset.lotId, 10); .dataset.lotId, 10);
const lot = workOrderLots.find((possibleLot) => { const lot = workOrderLots.find((possibleLot) => {
return possibleLot.lotId === lotId; return possibleLot.lotId === lotId;
}); });
let editCloseModalFunction; let editCloseModalFunction;
const doUpdateLotStatus = (submitEvent) => { function doUpdateLotStatus(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + "/workOrders/doUpdateLotStatus", submitEvent.currentTarget, (responseJSON) => { cityssm.postJSON(los.urlPrefix + "/workOrders/doUpdateLotStatus", submitEvent.currentTarget, (responseJSON) => {
if (responseJSON.success) { if (responseJSON.success) {
@ -363,9 +350,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
}); });
}; }
cityssm.openHtmlModal("lot-editLotStatus", { cityssm.openHtmlModal("lot-editLotStatus", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector("#lotStatusEdit--lotId").value = modalElement.querySelector("#lotStatusEdit--lotId").value =
lotId.toString(); lotId.toString();
@ -395,19 +382,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
.querySelector("form") .querySelector("form")
.insertAdjacentHTML("beforeend", '<input name="workOrderId" type="hidden" value="' + workOrderId + '" />'); .insertAdjacentHTML("beforeend", '<input name="workOrderId" type="hidden" value="' + workOrderId + '" />');
}, },
onshown: (modalElement, closeModalFunction) => { onshown(modalElement, closeModalFunction) {
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector("form").addEventListener("submit", doUpdateLotStatus); modalElement.querySelector("form").addEventListener("submit", doUpdateLotStatus);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });
}; }
const deleteLot = (clickEvent) => { function deleteLot(clickEvent) {
const lotId = clickEvent.currentTarget.closest(".container--lot").dataset.lotId; const lotId = clickEvent.currentTarget.closest(".container--lot").dataset.lotId;
const doDelete = () => { function doDelete() {
cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLot", { cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLot", {
workOrderId, workOrderId,
lotId lotId
@ -424,47 +411,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
}); });
}; }
bulmaJS.confirm({ bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship", title: `Delete ${los.escapedAliases.Occupancy} Relationship`,
message: "Are you sure you want to remove the relationship to this " + message: `Are you sure you want to remove the relationship to this ${los.escapedAliases.occupancy} record from this work order? Note that the record will remain.`,
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupancy.toLowerCase() +
" record from this work order? Note that the record will remain.",
contextualColorName: "warning", contextualColorName: "warning",
okButton: { okButton: {
text: "Yes, Delete Relationship", text: "Yes, Delete Relationship",
callbackFunction: doDelete callbackFunction: doDelete
} }
}); });
}; }
const renderRelatedLots = () => { function renderRelatedLots() {
const lotsContainerElement = document.querySelector("#container--lots"); const lotsContainerElement = document.querySelector("#container--lots");
document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent = document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent =
workOrderLots.length.toString(); workOrderLots.length.toString();
if (workOrderLots.length === 0) { if (workOrderLots.length === 0) {
lotsContainerElement.innerHTML = lotsContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
'<p class="message-body">There are no ' + </div>`;
exports.aliases.lots.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
return; return;
} }
lotsContainerElement.innerHTML = lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th>${los.escapedAliases.Lot}</th>
"<tr>" + <th>${los.escapedAliases.Map}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>${los.escapedAliases.Lot} Type</th>
("<th>" + exports.aliases.map + "</th>") + <th>Status</th>
("<th>" + exports.aliases.lot + " Type</th>") + <th class="has-width-1"></th>
"<th>Status</th>" + </tr></thead>
'<th class="has-width-1"></th>' + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lot of workOrderLots) { for (const lot of workOrderLots) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
rowElement.className = "container--lot"; rowElement.className = "container--lot";
@ -494,17 +471,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
'<i class="fas fa-trash" aria-hidden="true"></i>' + '<i class="fas fa-trash" aria-hidden="true"></i>' +
"</button>" + "</button>" +
"</td>"); "</td>");
rowElement.querySelector(".button--editLotStatus").addEventListener("click", openEditLotStatus); rowElement
.querySelector(".button--editLotStatus")
.addEventListener("click", openEditLotStatus);
rowElement.querySelector(".button--deleteLot").addEventListener("click", deleteLot); rowElement.querySelector(".button--deleteLot").addEventListener("click", deleteLot);
lotsContainerElement.querySelector("tbody").append(rowElement); lotsContainerElement.querySelector("tbody").append(rowElement);
} }
}; }
const renderRelatedLotsAndOccupancies = () => { function renderRelatedLotsAndOccupancies() {
renderRelatedOccupancies(); renderRelatedOccupancies();
renderRelatedLots(); renderRelatedLots();
}; }
renderRelatedLotsAndOccupancies(); renderRelatedLotsAndOccupancies();
const doAddLotOccupancy = (clickEvent) => { function doAddLotOccupancy(clickEvent) {
const rowElement = clickEvent.currentTarget.closest("tr"); const rowElement = clickEvent.currentTarget.closest("tr");
const lotOccupancyId = rowElement.dataset.lotOccupancyId; const lotOccupancyId = rowElement.dataset.lotOccupancyId;
addLotOccupancy(lotOccupancyId, (success) => { addLotOccupancy(lotOccupancyId, (success) => {
@ -512,11 +491,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
rowElement.remove(); rowElement.remove();
} }
}); });
}; }
document.querySelector("#button--addLotOccupancy").addEventListener("click", () => { document.querySelector("#button--addLotOccupancy").addEventListener("click", () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
const doSearch = (event) => { function doSearch(event) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
@ -533,20 +512,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
"</div>"; "</div>";
return; return;
} }
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th>
"<tr>" + <th>${los.escapedAliases.Occupancy} Type</th>
'<th class="has-width-1"></th>' + <th>${los.escapedAliases.Lot}</th>
("<th>" + exports.aliases.occupancy + " Type</th>") + <th>${los.escapedAliases.OccupancyStartDate}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>End Date</th>
"<th>Start Date</th>" + <th>${los.escapedAliases.Occupants}</th>
"<th>End Date</th>" + </tr></thead>
("<th>" + exports.aliases.occupants + "</th>") + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lotOccupancy of responseJSON.lotOccupancies) { for (const lotOccupancy of responseJSON.lotOccupancies) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
rowElement.className = "container--lotOccupancy"; rowElement.className = "container--lotOccupancy";
@ -564,11 +540,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
rowElement.insertAdjacentHTML("beforeend", "<td>" + cityssm.escapeHTML(lotOccupancy.lotName || "") + "</td>"); rowElement.insertAdjacentHTML("beforeend", "<td>" + cityssm.escapeHTML(lotOccupancy.lotName || "") + "</td>");
} }
else { else {
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`);
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>");
} }
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", "<td>" +
lotOccupancy.occupancyStartDateString + lotOccupancy.occupancyStartDateString +
@ -589,13 +561,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
(lotOccupancy.lotOccupancyOccupants.length - 1) (lotOccupancy.lotOccupancyOccupants.length - 1)
: "")) + : "")) +
"</td>")); "</td>"));
rowElement.querySelector(".button--addLotOccupancy").addEventListener("click", doAddLotOccupancy); rowElement
.querySelector(".button--addLotOccupancy")
.addEventListener("click", doAddLotOccupancy);
searchResultsContainerElement.querySelector("tbody").append(rowElement); searchResultsContainerElement.querySelector("tbody").append(rowElement);
} }
}); });
}; }
cityssm.openHtmlModal("workOrder-addLotOccupancy", { cityssm.openHtmlModal("workOrder-addLotOccupancy", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form"); searchFormElement = modalElement.querySelector("form");
searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotOccupancyAdd"); searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotOccupancyAdd");
@ -603,18 +577,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
modalElement.querySelector("#lotOccupancySearch--occupancyEffectiveDateString").value = document.querySelector("#workOrderEdit--workOrderOpenDateString").value; modalElement.querySelector("#lotOccupancySearch--occupancyEffectiveDateString").value = document.querySelector("#workOrderEdit--workOrderOpenDateString").value;
doSearch(); doSearch();
}, },
onshown: (modalElement) => { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector("#lotOccupancySearch--occupantName").addEventListener("change", doSearch); modalElement.querySelector("#lotOccupancySearch--occupantName").addEventListener("change", doSearch);
modalElement.querySelector("#lotOccupancySearch--lotName").addEventListener("change", doSearch); modalElement.querySelector("#lotOccupancySearch--lotName").addEventListener("change", doSearch);
searchFormElement.addEventListener("submit", doSearch); searchFormElement.addEventListener("submit", doSearch);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });
}); });
const doAddLot = (clickEvent) => { function doAddLot(clickEvent) {
const rowElement = clickEvent.currentTarget.closest("tr"); const rowElement = clickEvent.currentTarget.closest("tr");
const lotId = rowElement.dataset.lotId; const lotId = rowElement.dataset.lotId;
addLot(lotId, (success) => { addLot(lotId, (success) => {
@ -622,11 +596,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
rowElement.remove(); rowElement.remove();
} }
}); });
}; }
document.querySelector("#button--addLot").addEventListener("click", () => { document.querySelector("#button--addLot").addEventListener("click", () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
const doSearch = (event) => { function doSearch(event) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
@ -643,19 +617,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
"</div>"; "</div>";
return; return;
} }
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th>
"<tr>" + <th>${los.escapedAliases.Lot}</th>
'<th class="has-width-1"></th>' + <th>${los.escapedAliases.Map}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>${los.escapedAliases.Lot} Type</th>
("<th>" + exports.aliases.map + "</th>") + <th>Status</th>
("<th>" + exports.aliases.lot + " Type</th>") + </tr></thead>
"<th>Status</th>" + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lot of responseJSON.lots) { for (const lot of responseJSON.lots) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
rowElement.className = "container--lot"; rowElement.className = "container--lot";
@ -674,13 +645,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
"</td>" + "</td>" +
("<td>" + cityssm.escapeHTML(lot.lotType || "") + "</td>") + ("<td>" + cityssm.escapeHTML(lot.lotType || "") + "</td>") +
("<td>" + cityssm.escapeHTML(lot.lotStatus || "") + "</td>"); ("<td>" + cityssm.escapeHTML(lot.lotStatus || "") + "</td>");
rowElement.querySelector(".button--addLot").addEventListener("click", doAddLot); rowElement
.querySelector(".button--addLot")
.addEventListener("click", doAddLot);
searchResultsContainerElement.querySelector("tbody").append(rowElement); searchResultsContainerElement.querySelector("tbody").append(rowElement);
} }
}); });
}; }
cityssm.openHtmlModal("workOrder-addLot", { cityssm.openHtmlModal("workOrder-addLot", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form"); searchFormElement = modalElement.querySelector("form");
searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotAdd"); searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotAdd");
@ -695,13 +668,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
doSearch(); doSearch();
}, },
onshown: (modalElement) => { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector("#lotSearch--lotName").addEventListener("change", doSearch); modalElement.querySelector("#lotSearch--lotName").addEventListener("change", doSearch);
modalElement.querySelector("#lotSearch--lotStatusId").addEventListener("change", doSearch); modalElement.querySelector("#lotSearch--lotStatusId").addEventListener("change", doSearch);
searchFormElement.addEventListener("submit", doSearch); searchFormElement.addEventListener("submit", doSearch);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });

View File

@ -5,9 +5,9 @@ let workOrderLots = exports.workOrderLots;
delete exports.workOrderLots; delete exports.workOrderLots;
let workOrderLotOccupancies = exports.workOrderLotOccupancies; let workOrderLotOccupancies = exports.workOrderLotOccupancies;
delete exports.workOrderLotOccupancies; delete exports.workOrderLotOccupancies;
const deleteLotOccupancy = (clickEvent) => { function deleteLotOccupancy(clickEvent) {
const lotOccupancyId = clickEvent.currentTarget.closest(".container--lotOccupancy").dataset.lotOccupancyId; const lotOccupancyId = clickEvent.currentTarget.closest(".container--lotOccupancy").dataset.lotOccupancyId;
const doDelete = () => { function doDelete() {
cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLotOccupancy", { cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLotOccupancy", {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
@ -24,22 +24,18 @@ const deleteLotOccupancy = (clickEvent) => {
}); });
} }
}); });
}; }
bulmaJS.confirm({ bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship", title: `Delete ${exports.aliases.occupancy} Relationship`,
message: "Are you sure you want to remove the relationship to this " + message: `Are you sure you want to remove the relationship to this ${exports.aliases.occupancy.toLowerCase()} record from this work order? Note that the record will remain.`,
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupancy.toLowerCase() +
" record from this work order? Note that the record will remain.",
contextualColorName: "warning", contextualColorName: "warning",
okButton: { okButton: {
text: "Yes, Delete Relationship", text: "Yes, Delete Relationship",
callbackFunction: doDelete callbackFunction: doDelete
} }
}); });
}; }
const addLot = (lotId, callbackFunction) => { function addLot(lotId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLot", { cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLot", {
workOrderId, workOrderId,
lotId lotId
@ -59,8 +55,8 @@ const addLot = (lotId, callbackFunction) => {
callbackFunction(responseJSON.success); callbackFunction(responseJSON.success);
} }
}); });
}; }
const addLotOccupancy = (lotOccupancyId, callbackFunction) => { function addLotOccupancy(lotOccupancyId, callbackFunction) {
cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLotOccupancy", { cityssm.postJSON(los.urlPrefix + "/workOrders/doAddWorkOrderLotOccupancy", {
workOrderId, workOrderId,
lotOccupancyId lotOccupancyId
@ -80,39 +76,30 @@ const addLotOccupancy = (lotOccupancyId, callbackFunction) => {
callbackFunction(responseJSON.success); callbackFunction(responseJSON.success);
} }
}); });
}; }
const addLotFromLotOccupancy = (clickEvent) => { function addLotFromLotOccupancy(clickEvent) {
const lotId = clickEvent.currentTarget.dataset.lotId; const lotId = clickEvent.currentTarget.dataset.lotId;
addLot(lotId); addLot(lotId);
}; }
const renderRelatedOccupancies = () => { function renderRelatedOccupancies() {
var _a; var _a;
const occupanciesContainerElement = document.querySelector("#container--lotOccupancies"); const occupanciesContainerElement = document.querySelector("#container--lotOccupancies");
document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString(); document.querySelector(".tabs a[href='#relatedTab--lotOccupancies'] .tag").textContent = workOrderLotOccupancies.length.toString();
if (workOrderLotOccupancies.length === 0) { if (workOrderLotOccupancies.length === 0) {
occupanciesContainerElement.innerHTML = occupanciesContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no ${exports.aliases.occupancies.toLowerCase()} associated with this work order.</p>
'<p class="message-body">There are no ' + </div>`;
exports.aliases.occupancies.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
return; return;
} }
occupanciesContainerElement.innerHTML = occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th><th>${los.escapedAliases.Occupancy} Type</th>
"<tr>" + <th>${los.escapedAliases.Lot}</th><th>${los.escapedAliases.OccupancyStartDate}</th>
'<th class="has-width-1"></th>' + <th>End Date</th><th>${los.escapedAliases.Occupants}</th>
("<th>" + exports.aliases.occupancy + " Type</th>") + <th class="has-width-1"></th>
("<th>" + exports.aliases.lot + "</th>") + </tr></thead>
("<th>" + exports.aliases.occupancyStartDate + "</th>") + <tbody></tbody>
"<th>End Date</th>" + </table>`;
("<th>" + exports.aliases.occupants + "</th>") +
'<th class="has-width-1"></th>' +
"</tr>" +
"</thead>" +
"<tbody></tbody>" +
"</table>";
const currentDateString = cityssm.dateToString(new Date()); const currentDateString = cityssm.dateToString(new Date());
for (const lotOccupancy of workOrderLotOccupancies) { for (const lotOccupancy of workOrderLotOccupancies) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
@ -163,11 +150,7 @@ const renderRelatedOccupancies = () => {
"</td>"); "</td>");
} }
else { else {
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", `<td><span class="has-text-grey">(No ${exports.aliases.lot})</span></td>`);
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>");
} }
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", "<td>" +
lotOccupancy.occupancyStartDateString + lotOccupancy.occupancyStartDateString +
@ -202,20 +185,24 @@ const renderRelatedOccupancies = () => {
"</button>" + "</button>" +
"</td>")); "</td>"));
if (lotOccupancy.lotId && !hasLotRecord) { if (lotOccupancy.lotId && !hasLotRecord) {
rowElement.querySelector(".button--addLot").addEventListener("click", addLotFromLotOccupancy); rowElement
.querySelector(".button--addLot")
.addEventListener("click", addLotFromLotOccupancy);
} }
rowElement.querySelector(".button--deleteLotOccupancy").addEventListener("click", deleteLotOccupancy); rowElement
.querySelector(".button--deleteLotOccupancy")
.addEventListener("click", deleteLotOccupancy);
occupanciesContainerElement.querySelector("tbody").append(rowElement); occupanciesContainerElement.querySelector("tbody").append(rowElement);
} }
}; }
const openEditLotStatus = (clickEvent) => { function openEditLotStatus(clickEvent) {
const lotId = Number.parseInt(clickEvent.currentTarget.closest(".container--lot") const lotId = Number.parseInt(clickEvent.currentTarget.closest(".container--lot")
.dataset.lotId, 10); .dataset.lotId, 10);
const lot = workOrderLots.find((possibleLot) => { const lot = workOrderLots.find((possibleLot) => {
return possibleLot.lotId === lotId; return possibleLot.lotId === lotId;
}); });
let editCloseModalFunction; let editCloseModalFunction;
const doUpdateLotStatus = (submitEvent) => { function doUpdateLotStatus(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + "/workOrders/doUpdateLotStatus", submitEvent.currentTarget, (responseJSON) => { cityssm.postJSON(los.urlPrefix + "/workOrders/doUpdateLotStatus", submitEvent.currentTarget, (responseJSON) => {
if (responseJSON.success) { if (responseJSON.success) {
@ -231,9 +218,9 @@ const openEditLotStatus = (clickEvent) => {
}); });
} }
}); });
}; }
cityssm.openHtmlModal("lot-editLotStatus", { cityssm.openHtmlModal("lot-editLotStatus", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector("#lotStatusEdit--lotId").value = modalElement.querySelector("#lotStatusEdit--lotId").value =
lotId.toString(); lotId.toString();
@ -263,19 +250,19 @@ const openEditLotStatus = (clickEvent) => {
.querySelector("form") .querySelector("form")
.insertAdjacentHTML("beforeend", '<input name="workOrderId" type="hidden" value="' + workOrderId + '" />'); .insertAdjacentHTML("beforeend", '<input name="workOrderId" type="hidden" value="' + workOrderId + '" />');
}, },
onshown: (modalElement, closeModalFunction) => { onshown(modalElement, closeModalFunction) {
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector("form").addEventListener("submit", doUpdateLotStatus); modalElement.querySelector("form").addEventListener("submit", doUpdateLotStatus);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });
}; }
const deleteLot = (clickEvent) => { function deleteLot(clickEvent) {
const lotId = clickEvent.currentTarget.closest(".container--lot").dataset.lotId; const lotId = clickEvent.currentTarget.closest(".container--lot").dataset.lotId;
const doDelete = () => { function doDelete() {
cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLot", { cityssm.postJSON(los.urlPrefix + "/workOrders/doDeleteWorkOrderLot", {
workOrderId, workOrderId,
lotId lotId
@ -292,47 +279,37 @@ const deleteLot = (clickEvent) => {
}); });
} }
}); });
}; }
bulmaJS.confirm({ bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship", title: `Delete ${los.escapedAliases.Occupancy} Relationship`,
message: "Are you sure you want to remove the relationship to this " + message: `Are you sure you want to remove the relationship to this ${los.escapedAliases.occupancy} record from this work order? Note that the record will remain.`,
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupancy.toLowerCase() +
" record from this work order? Note that the record will remain.",
contextualColorName: "warning", contextualColorName: "warning",
okButton: { okButton: {
text: "Yes, Delete Relationship", text: "Yes, Delete Relationship",
callbackFunction: doDelete callbackFunction: doDelete
} }
}); });
}; }
const renderRelatedLots = () => { function renderRelatedLots() {
const lotsContainerElement = document.querySelector("#container--lots"); const lotsContainerElement = document.querySelector("#container--lots");
document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent = document.querySelector(".tabs a[href='#relatedTab--lots'] .tag").textContent =
workOrderLots.length.toString(); workOrderLots.length.toString();
if (workOrderLots.length === 0) { if (workOrderLots.length === 0) {
lotsContainerElement.innerHTML = lotsContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
'<p class="message-body">There are no ' + </div>`;
exports.aliases.lots.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
return; return;
} }
lotsContainerElement.innerHTML = lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th>${los.escapedAliases.Lot}</th>
"<tr>" + <th>${los.escapedAliases.Map}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>${los.escapedAliases.Lot} Type</th>
("<th>" + exports.aliases.map + "</th>") + <th>Status</th>
("<th>" + exports.aliases.lot + " Type</th>") + <th class="has-width-1"></th>
"<th>Status</th>" + </tr></thead>
'<th class="has-width-1"></th>' + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lot of workOrderLots) { for (const lot of workOrderLots) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
rowElement.className = "container--lot"; rowElement.className = "container--lot";
@ -362,17 +339,19 @@ const renderRelatedLots = () => {
'<i class="fas fa-trash" aria-hidden="true"></i>' + '<i class="fas fa-trash" aria-hidden="true"></i>' +
"</button>" + "</button>" +
"</td>"); "</td>");
rowElement.querySelector(".button--editLotStatus").addEventListener("click", openEditLotStatus); rowElement
.querySelector(".button--editLotStatus")
.addEventListener("click", openEditLotStatus);
rowElement.querySelector(".button--deleteLot").addEventListener("click", deleteLot); rowElement.querySelector(".button--deleteLot").addEventListener("click", deleteLot);
lotsContainerElement.querySelector("tbody").append(rowElement); lotsContainerElement.querySelector("tbody").append(rowElement);
} }
}; }
const renderRelatedLotsAndOccupancies = () => { function renderRelatedLotsAndOccupancies() {
renderRelatedOccupancies(); renderRelatedOccupancies();
renderRelatedLots(); renderRelatedLots();
}; }
renderRelatedLotsAndOccupancies(); renderRelatedLotsAndOccupancies();
const doAddLotOccupancy = (clickEvent) => { function doAddLotOccupancy(clickEvent) {
const rowElement = clickEvent.currentTarget.closest("tr"); const rowElement = clickEvent.currentTarget.closest("tr");
const lotOccupancyId = rowElement.dataset.lotOccupancyId; const lotOccupancyId = rowElement.dataset.lotOccupancyId;
addLotOccupancy(lotOccupancyId, (success) => { addLotOccupancy(lotOccupancyId, (success) => {
@ -380,11 +359,11 @@ const doAddLotOccupancy = (clickEvent) => {
rowElement.remove(); rowElement.remove();
} }
}); });
}; }
document.querySelector("#button--addLotOccupancy").addEventListener("click", () => { document.querySelector("#button--addLotOccupancy").addEventListener("click", () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
const doSearch = (event) => { function doSearch(event) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
@ -401,20 +380,17 @@ document.querySelector("#button--addLotOccupancy").addEventListener("click", ()
"</div>"; "</div>";
return; return;
} }
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th>
"<tr>" + <th>${los.escapedAliases.Occupancy} Type</th>
'<th class="has-width-1"></th>' + <th>${los.escapedAliases.Lot}</th>
("<th>" + exports.aliases.occupancy + " Type</th>") + <th>${los.escapedAliases.OccupancyStartDate}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>End Date</th>
"<th>Start Date</th>" + <th>${los.escapedAliases.Occupants}</th>
"<th>End Date</th>" + </tr></thead>
("<th>" + exports.aliases.occupants + "</th>") + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lotOccupancy of responseJSON.lotOccupancies) { for (const lotOccupancy of responseJSON.lotOccupancies) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
rowElement.className = "container--lotOccupancy"; rowElement.className = "container--lotOccupancy";
@ -432,11 +408,7 @@ document.querySelector("#button--addLotOccupancy").addEventListener("click", ()
rowElement.insertAdjacentHTML("beforeend", "<td>" + cityssm.escapeHTML(lotOccupancy.lotName || "") + "</td>"); rowElement.insertAdjacentHTML("beforeend", "<td>" + cityssm.escapeHTML(lotOccupancy.lotName || "") + "</td>");
} }
else { else {
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`);
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>");
} }
rowElement.insertAdjacentHTML("beforeend", "<td>" + rowElement.insertAdjacentHTML("beforeend", "<td>" +
lotOccupancy.occupancyStartDateString + lotOccupancy.occupancyStartDateString +
@ -457,13 +429,15 @@ document.querySelector("#button--addLotOccupancy").addEventListener("click", ()
(lotOccupancy.lotOccupancyOccupants.length - 1) (lotOccupancy.lotOccupancyOccupants.length - 1)
: "")) + : "")) +
"</td>")); "</td>"));
rowElement.querySelector(".button--addLotOccupancy").addEventListener("click", doAddLotOccupancy); rowElement
.querySelector(".button--addLotOccupancy")
.addEventListener("click", doAddLotOccupancy);
searchResultsContainerElement.querySelector("tbody").append(rowElement); searchResultsContainerElement.querySelector("tbody").append(rowElement);
} }
}); });
}; }
cityssm.openHtmlModal("workOrder-addLotOccupancy", { cityssm.openHtmlModal("workOrder-addLotOccupancy", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form"); searchFormElement = modalElement.querySelector("form");
searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotOccupancyAdd"); searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotOccupancyAdd");
@ -471,18 +445,18 @@ document.querySelector("#button--addLotOccupancy").addEventListener("click", ()
modalElement.querySelector("#lotOccupancySearch--occupancyEffectiveDateString").value = document.querySelector("#workOrderEdit--workOrderOpenDateString").value; modalElement.querySelector("#lotOccupancySearch--occupancyEffectiveDateString").value = document.querySelector("#workOrderEdit--workOrderOpenDateString").value;
doSearch(); doSearch();
}, },
onshown: (modalElement) => { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector("#lotOccupancySearch--occupantName").addEventListener("change", doSearch); modalElement.querySelector("#lotOccupancySearch--occupantName").addEventListener("change", doSearch);
modalElement.querySelector("#lotOccupancySearch--lotName").addEventListener("change", doSearch); modalElement.querySelector("#lotOccupancySearch--lotName").addEventListener("change", doSearch);
searchFormElement.addEventListener("submit", doSearch); searchFormElement.addEventListener("submit", doSearch);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });
}); });
const doAddLot = (clickEvent) => { function doAddLot(clickEvent) {
const rowElement = clickEvent.currentTarget.closest("tr"); const rowElement = clickEvent.currentTarget.closest("tr");
const lotId = rowElement.dataset.lotId; const lotId = rowElement.dataset.lotId;
addLot(lotId, (success) => { addLot(lotId, (success) => {
@ -490,11 +464,11 @@ const doAddLot = (clickEvent) => {
rowElement.remove(); rowElement.remove();
} }
}); });
}; }
document.querySelector("#button--addLot").addEventListener("click", () => { document.querySelector("#button--addLot").addEventListener("click", () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
const doSearch = (event) => { function doSearch(event) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
@ -511,19 +485,16 @@ document.querySelector("#button--addLot").addEventListener("click", () => {
"</div>"; "</div>";
return; return;
} }
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th>
"<tr>" + <th>${los.escapedAliases.Lot}</th>
'<th class="has-width-1"></th>' + <th>${los.escapedAliases.Map}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>${los.escapedAliases.Lot} Type</th>
("<th>" + exports.aliases.map + "</th>") + <th>Status</th>
("<th>" + exports.aliases.lot + " Type</th>") + </tr></thead>
"<th>Status</th>" + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lot of responseJSON.lots) { for (const lot of responseJSON.lots) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
rowElement.className = "container--lot"; rowElement.className = "container--lot";
@ -542,13 +513,15 @@ document.querySelector("#button--addLot").addEventListener("click", () => {
"</td>" + "</td>" +
("<td>" + cityssm.escapeHTML(lot.lotType || "") + "</td>") + ("<td>" + cityssm.escapeHTML(lot.lotType || "") + "</td>") +
("<td>" + cityssm.escapeHTML(lot.lotStatus || "") + "</td>"); ("<td>" + cityssm.escapeHTML(lot.lotStatus || "") + "</td>");
rowElement.querySelector(".button--addLot").addEventListener("click", doAddLot); rowElement
.querySelector(".button--addLot")
.addEventListener("click", doAddLot);
searchResultsContainerElement.querySelector("tbody").append(rowElement); searchResultsContainerElement.querySelector("tbody").append(rowElement);
} }
}); });
}; }
cityssm.openHtmlModal("workOrder-addLot", { cityssm.openHtmlModal("workOrder-addLot", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form"); searchFormElement = modalElement.querySelector("form");
searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotAdd"); searchResultsContainerElement = modalElement.querySelector("#resultsContainer--lotAdd");
@ -563,13 +536,13 @@ document.querySelector("#button--addLot").addEventListener("click", () => {
} }
doSearch(); doSearch();
}, },
onshown: (modalElement) => { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector("#lotSearch--lotName").addEventListener("change", doSearch); modalElement.querySelector("#lotSearch--lotName").addEventListener("change", doSearch);
modalElement.querySelector("#lotSearch--lotStatusId").addEventListener("change", doSearch); modalElement.querySelector("#lotSearch--lotStatusId").addEventListener("change", doSearch);
searchFormElement.addEventListener("submit", doSearch); searchFormElement.addEventListener("submit", doSearch);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });

View File

@ -19,12 +19,12 @@ delete exports.workOrderLots;
let workOrderLotOccupancies: recordTypes.LotOccupancy[] = exports.workOrderLotOccupancies; let workOrderLotOccupancies: recordTypes.LotOccupancy[] = exports.workOrderLotOccupancies;
delete exports.workOrderLotOccupancies; delete exports.workOrderLotOccupancies;
const deleteLotOccupancy = (clickEvent: Event) => { function deleteLotOccupancy(clickEvent: Event): void {
const lotOccupancyId = ( const lotOccupancyId = (
(clickEvent.currentTarget as HTMLElement).closest(".container--lotOccupancy") as HTMLElement (clickEvent.currentTarget as HTMLElement).closest(".container--lotOccupancy") as HTMLElement
).dataset.lotOccupancyId; ).dataset.lotOccupancyId;
const doDelete = () => { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + "/workOrders/doDeleteWorkOrderLotOccupancy", los.urlPrefix + "/workOrders/doDeleteWorkOrderLotOccupancy",
{ {
@ -48,25 +48,20 @@ const deleteLotOccupancy = (clickEvent: Event) => {
} }
} }
); );
}; }
bulmaJS.confirm({ bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship", title: `Delete ${exports.aliases.occupancy} Relationship`,
message: message: `Are you sure you want to remove the relationship to this ${exports.aliases.occupancy.toLowerCase()} record from this work order? Note that the record will remain.`,
"Are you sure you want to remove the relationship to this " +
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupancy.toLowerCase() +
" record from this work order? Note that the record will remain.",
contextualColorName: "warning", contextualColorName: "warning",
okButton: { okButton: {
text: "Yes, Delete Relationship", text: "Yes, Delete Relationship",
callbackFunction: doDelete callbackFunction: doDelete
} }
}); });
}; }
const addLot = (lotId: number | string, callbackFunction?: (success?: boolean) => void) => { function addLot(lotId: number | string, callbackFunction?: (success?: boolean) => void): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + "/workOrders/doAddWorkOrderLot", los.urlPrefix + "/workOrders/doAddWorkOrderLot",
{ {
@ -94,12 +89,12 @@ const addLot = (lotId: number | string, callbackFunction?: (success?: boolean) =
} }
} }
); );
}; }
const addLotOccupancy = ( function addLotOccupancy(
lotOccupancyId: number | string, lotOccupancyId: number | string,
callbackFunction?: (success?: boolean) => void callbackFunction?: (success?: boolean) => void
) => { ): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + "/workOrders/doAddWorkOrderLotOccupancy", los.urlPrefix + "/workOrders/doAddWorkOrderLotOccupancy",
{ {
@ -127,14 +122,14 @@ const addLotOccupancy = (
} }
} }
); );
}; }
const addLotFromLotOccupancy = (clickEvent: Event) => { function addLotFromLotOccupancy(clickEvent: Event): void {
const lotId = (clickEvent.currentTarget as HTMLElement).dataset.lotId!; const lotId = (clickEvent.currentTarget as HTMLElement).dataset.lotId!;
addLot(lotId); addLot(lotId);
}; }
const renderRelatedOccupancies = () => { function renderRelatedOccupancies(): void {
const occupanciesContainerElement = document.querySelector( const occupanciesContainerElement = document.querySelector(
"#container--lotOccupancies" "#container--lotOccupancies"
) as HTMLElement; ) as HTMLElement;
@ -144,31 +139,22 @@ const renderRelatedOccupancies = () => {
).textContent = workOrderLotOccupancies.length.toString(); ).textContent = workOrderLotOccupancies.length.toString();
if (workOrderLotOccupancies.length === 0) { if (workOrderLotOccupancies.length === 0) {
occupanciesContainerElement.innerHTML = occupanciesContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no ${exports.aliases.occupancies.toLowerCase()} associated with this work order.</p>
'<p class="message-body">There are no ' + </div>`;
exports.aliases.occupancies.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
return; return;
} }
occupanciesContainerElement.innerHTML = occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th><th>${los.escapedAliases.Occupancy} Type</th>
"<tr>" + <th>${los.escapedAliases.Lot}</th><th>${los.escapedAliases.OccupancyStartDate}</th>
'<th class="has-width-1"></th>' + <th>End Date</th><th>${los.escapedAliases.Occupants}</th>
("<th>" + exports.aliases.occupancy + " Type</th>") + <th class="has-width-1"></th>
("<th>" + exports.aliases.lot + "</th>") + </tr></thead>
("<th>" + exports.aliases.occupancyStartDate + "</th>") + <tbody></tbody>
"<th>End Date</th>" + </table>`;
("<th>" + exports.aliases.occupants + "</th>") +
'<th class="has-width-1"></th>' +
"</tr>" +
"</thead>" +
"<tbody></tbody>" +
"</table>";
const currentDateString = cityssm.dateToString(new Date()); const currentDateString = cityssm.dateToString(new Date());
@ -232,11 +218,7 @@ const renderRelatedOccupancies = () => {
} else { } else {
rowElement.insertAdjacentHTML( rowElement.insertAdjacentHTML(
"beforeend", "beforeend",
"<td>" + `<td><span class="has-text-grey">(No ${exports.aliases.lot})</span></td>`
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>"
); );
} }
@ -279,21 +261,20 @@ const renderRelatedOccupancies = () => {
); );
if (lotOccupancy.lotId && !hasLotRecord) { if (lotOccupancy.lotId && !hasLotRecord) {
(rowElement.querySelector(".button--addLot") as HTMLButtonElement).addEventListener( rowElement
"click", .querySelector(".button--addLot")!
addLotFromLotOccupancy .addEventListener("click", addLotFromLotOccupancy);
);
} }
( rowElement
rowElement.querySelector(".button--deleteLotOccupancy") as HTMLButtonElement .querySelector(".button--deleteLotOccupancy")!
).addEventListener("click", deleteLotOccupancy); .addEventListener("click", deleteLotOccupancy);
occupanciesContainerElement.querySelector("tbody")!.append(rowElement); occupanciesContainerElement.querySelector("tbody")!.append(rowElement);
} }
}; }
const openEditLotStatus = (clickEvent: Event) => { function openEditLotStatus(clickEvent: Event): void {
const lotId = Number.parseInt( const lotId = Number.parseInt(
((clickEvent.currentTarget as HTMLElement).closest(".container--lot") as HTMLElement) ((clickEvent.currentTarget as HTMLElement).closest(".container--lot") as HTMLElement)
.dataset.lotId!, .dataset.lotId!,
@ -306,7 +287,7 @@ const openEditLotStatus = (clickEvent: Event) => {
let editCloseModalFunction: () => void; let editCloseModalFunction: () => void;
const doUpdateLotStatus = (submitEvent: SubmitEvent) => { function doUpdateLotStatus(submitEvent: SubmitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON( cityssm.postJSON(
@ -330,10 +311,10 @@ const openEditLotStatus = (clickEvent: Event) => {
} }
} }
); );
}; }
cityssm.openHtmlModal("lot-editLotStatus", { cityssm.openHtmlModal("lot-editLotStatus", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
(modalElement.querySelector("#lotStatusEdit--lotId") as HTMLInputElement).value = (modalElement.querySelector("#lotStatusEdit--lotId") as HTMLInputElement).value =
@ -378,25 +359,25 @@ const openEditLotStatus = (clickEvent: Event) => {
'<input name="workOrderId" type="hidden" value="' + workOrderId + '" />' '<input name="workOrderId" type="hidden" value="' + workOrderId + '" />'
); );
}, },
onshown: (modalElement, closeModalFunction) => { onshown(modalElement, closeModalFunction) {
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector("form")!.addEventListener("submit", doUpdateLotStatus); modalElement.querySelector("form")!.addEventListener("submit", doUpdateLotStatus);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });
}; }
const deleteLot = (clickEvent: Event) => { function deleteLot(clickEvent: Event): void {
const lotId = ( const lotId = (
(clickEvent.currentTarget as HTMLElement).closest(".container--lot") as HTMLElement (clickEvent.currentTarget as HTMLElement).closest(".container--lot") as HTMLElement
).dataset.lotId; ).dataset.lotId;
const doDelete = () => { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + "/workOrders/doDeleteWorkOrderLot", los.urlPrefix + "/workOrders/doDeleteWorkOrderLot",
{ {
@ -420,54 +401,43 @@ const deleteLot = (clickEvent: Event) => {
} }
} }
); );
}; }
bulmaJS.confirm({ bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship", title: `Delete ${los.escapedAliases.Occupancy} Relationship`,
message: message: `Are you sure you want to remove the relationship to this ${los.escapedAliases.occupancy} record from this work order? Note that the record will remain.`,
"Are you sure you want to remove the relationship to this " +
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupancy.toLowerCase() +
" record from this work order? Note that the record will remain.",
contextualColorName: "warning", contextualColorName: "warning",
okButton: { okButton: {
text: "Yes, Delete Relationship", text: "Yes, Delete Relationship",
callbackFunction: doDelete callbackFunction: doDelete
} }
}); });
}; }
const renderRelatedLots = () => { function renderRelatedLots() {
const lotsContainerElement = document.querySelector("#container--lots") as HTMLElement; const lotsContainerElement = document.querySelector("#container--lots") as HTMLElement;
(document.querySelector(".tabs a[href='#relatedTab--lots'] .tag") as HTMLElement).textContent = (document.querySelector(".tabs a[href='#relatedTab--lots'] .tag") as HTMLElement).textContent =
workOrderLots.length.toString(); workOrderLots.length.toString();
if (workOrderLots.length === 0) { if (workOrderLots.length === 0) {
lotsContainerElement.innerHTML = lotsContainerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no ${los.escapedAliases.lots} associated with this work order.</p>
'<p class="message-body">There are no ' + </div>`;
exports.aliases.lots.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
return; return;
} }
lotsContainerElement.innerHTML = lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th>${los.escapedAliases.Lot}</th>
"<tr>" + <th>${los.escapedAliases.Map}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>${los.escapedAliases.Lot} Type</th>
("<th>" + exports.aliases.map + "</th>") + <th>Status</th>
("<th>" + exports.aliases.lot + " Type</th>") + <th class="has-width-1"></th>
"<th>Status</th>" + </tr></thead>
'<th class="has-width-1"></th>' + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lot of workOrderLots) { for (const lot of workOrderLots) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
@ -501,28 +471,24 @@ const renderRelatedLots = () => {
"</button>" + "</button>" +
"</td>"); "</td>");
(rowElement.querySelector(".button--editLotStatus") as HTMLButtonElement).addEventListener( rowElement
"click", .querySelector(".button--editLotStatus")!
openEditLotStatus .addEventListener("click", openEditLotStatus);
);
(rowElement.querySelector(".button--deleteLot") as HTMLButtonElement).addEventListener( rowElement.querySelector(".button--deleteLot")!.addEventListener("click", deleteLot);
"click",
deleteLot
);
lotsContainerElement.querySelector("tbody")!.append(rowElement); lotsContainerElement.querySelector("tbody")!.append(rowElement);
} }
}; }
const renderRelatedLotsAndOccupancies = () => { function renderRelatedLotsAndOccupancies(): void {
renderRelatedOccupancies(); renderRelatedOccupancies();
renderRelatedLots(); renderRelatedLots();
}; }
renderRelatedLotsAndOccupancies(); renderRelatedLotsAndOccupancies();
const doAddLotOccupancy = (clickEvent: Event) => { function doAddLotOccupancy(clickEvent: Event) {
const rowElement = (clickEvent.currentTarget as HTMLElement).closest("tr")!; const rowElement = (clickEvent.currentTarget as HTMLElement).closest("tr")!;
const lotOccupancyId = rowElement.dataset.lotOccupancyId!; const lotOccupancyId = rowElement.dataset.lotOccupancyId!;
@ -532,172 +498,158 @@ const doAddLotOccupancy = (clickEvent: Event) => {
rowElement.remove(); rowElement.remove();
} }
}); });
}; }
(document.querySelector("#button--addLotOccupancy") as HTMLButtonElement).addEventListener( document.querySelector("#button--addLotOccupancy")!.addEventListener("click", () => {
"click", let searchFormElement: HTMLFormElement;
() => { let searchResultsContainerElement: HTMLElement;
let searchFormElement: HTMLFormElement;
let searchResultsContainerElement: HTMLElement;
const doSearch = (event?: Event) => { function doSearch(event?: Event) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
'<p class="has-text-centered has-text-grey-dark">' + '<p class="has-text-centered has-text-grey-dark">' +
'<i class="fas fa-5x fa-circle-notch fa-spin" aria-hidden="true"></i><br />' + '<i class="fas fa-5x fa-circle-notch fa-spin" aria-hidden="true"></i><br />' +
"Searching..." + "Searching..." +
"</p>"; "</p>";
cityssm.postJSON(
los.urlPrefix + "/lotOccupancies/doSearchLotOccupancies",
searchFormElement,
(responseJSON: { lotOccupancies: recordTypes.LotOccupancy[] }) => {
if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML =
'<div class="message is-info">' +
'<p class="message-body">There are no records that meet the search criteria.</p>' +
"</div>";
return;
}
cityssm.postJSON(
los.urlPrefix + "/lotOccupancies/doSearchLotOccupancies",
searchFormElement,
(responseJSON: { lotOccupancies: recordTypes.LotOccupancy[] }) => {
if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML =
'<table class="table is-fullwidth is-striped is-hoverable">' + '<div class="message is-info">' +
"<thead>" + '<p class="message-body">There are no records that meet the search criteria.</p>' +
"<tr>" + "</div>";
'<th class="has-width-1"></th>' +
("<th>" + exports.aliases.occupancy + " Type</th>") +
("<th>" + exports.aliases.lot + "</th>") +
"<th>Start Date</th>" +
"<th>End Date</th>" +
("<th>" + exports.aliases.occupants + "</th>") +
"</tr>" +
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lotOccupancy of responseJSON.lotOccupancies) { return;
const rowElement = document.createElement("tr"); }
rowElement.className = "container--lotOccupancy";
rowElement.dataset.lotOccupancyId = lotOccupancy.lotOccupancyId!.toString();
rowElement.innerHTML = searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<td class="has-text-centered">' + <thead><tr>
'<button class="button is-small is-success button--addLotOccupancy" data-tooltip="Add" type="button" aria-label="Add">' + <th class="has-width-1"></th>
'<i class="fas fa-plus" aria-hidden="true"></i>' + <th>${los.escapedAliases.Occupancy} Type</th>
"</button>" + <th>${los.escapedAliases.Lot}</th>
"</td>" + <th>${los.escapedAliases.OccupancyStartDate}</th>
('<td class="has-text-weight-bold">' + <th>End Date</th>
cityssm.escapeHTML(lotOccupancy.occupancyType || "") + <th>${los.escapedAliases.Occupants}</th>
"</td>"); </tr></thead>
<tbody></tbody>
</table>`;
if (lotOccupancy.lotId) { for (const lotOccupancy of responseJSON.lotOccupancies) {
rowElement.insertAdjacentHTML( const rowElement = document.createElement("tr");
"beforeend", rowElement.className = "container--lotOccupancy";
"<td>" + cityssm.escapeHTML(lotOccupancy.lotName || "") + "</td>" rowElement.dataset.lotOccupancyId = lotOccupancy.lotOccupancyId!.toString();
);
} else {
rowElement.insertAdjacentHTML(
"beforeend",
"<td>" +
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>"
);
}
rowElement.innerHTML =
'<td class="has-text-centered">' +
'<button class="button is-small is-success button--addLotOccupancy" 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(lotOccupancy.occupancyType || "") +
"</td>");
if (lotOccupancy.lotId) {
rowElement.insertAdjacentHTML( rowElement.insertAdjacentHTML(
"beforeend", "beforeend",
"<td>" + "<td>" + cityssm.escapeHTML(lotOccupancy.lotName || "") + "</td>"
lotOccupancy.occupancyStartDateString + );
"</td>" + } else {
("<td>" + rowElement.insertAdjacentHTML(
(lotOccupancy.occupancyEndDate "beforeend",
? lotOccupancy.occupancyEndDateString `<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`
: '<span class="has-text-grey">(No End Date)</span>') +
"</td>") +
("<td>" +
(lotOccupancy.lotOccupancyOccupants!.length === 0
? '<span class="has-text-grey">(No ' +
cityssm.escapeHTML(exports.aliases.occupants) +
")</span>"
: cityssm.escapeHTML(
lotOccupancy.lotOccupancyOccupants![0].occupantName!
) +
(lotOccupancy.lotOccupancyOccupants!.length > 1
? " plus " +
(lotOccupancy.lotOccupancyOccupants!.length - 1)
: "")) +
"</td>")
); );
(
rowElement.querySelector(
".button--addLotOccupancy"
) as HTMLButtonElement
).addEventListener("click", doAddLotOccupancy);
searchResultsContainerElement.querySelector("tbody")!.append(rowElement);
} }
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(exports.aliases.occupants) +
")</span>"
: cityssm.escapeHTML(
lotOccupancy.lotOccupancyOccupants![0].occupantName!
) +
(lotOccupancy.lotOccupancyOccupants!.length > 1
? " plus " +
(lotOccupancy.lotOccupancyOccupants!.length - 1)
: "")) +
"</td>")
);
rowElement
.querySelector(".button--addLotOccupancy")!
.addEventListener("click", doAddLotOccupancy);
searchResultsContainerElement.querySelector("tbody")!.append(rowElement);
} }
);
};
cityssm.openHtmlModal("workOrder-addLotOccupancy", {
onshow: (modalElement) => {
los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form")!;
searchResultsContainerElement = modalElement.querySelector(
"#resultsContainer--lotOccupancyAdd"
) as HTMLElement;
(
modalElement.querySelector(
"#lotOccupancySearch--notWorkOrderId"
) as HTMLInputElement
).value = workOrderId;
(
modalElement.querySelector(
"#lotOccupancySearch--occupancyEffectiveDateString"
) as HTMLInputElement
).value = (
document.querySelector(
"#workOrderEdit--workOrderOpenDateString"
) as HTMLInputElement
).value;
doSearch();
},
onshown: (modalElement) => {
bulmaJS.toggleHtmlClipped();
(
modalElement.querySelector(
"#lotOccupancySearch--occupantName"
) as HTMLInputElement
).addEventListener("change", doSearch);
(
modalElement.querySelector("#lotOccupancySearch--lotName") as HTMLInputElement
).addEventListener("change", doSearch);
searchFormElement.addEventListener("submit", doSearch);
},
onremoved: () => {
bulmaJS.toggleHtmlClipped();
} }
}); );
} }
);
const doAddLot = (clickEvent: Event) => { cityssm.openHtmlModal("workOrder-addLotOccupancy", {
onshow(modalElement) {
los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form")!;
searchResultsContainerElement = modalElement.querySelector(
"#resultsContainer--lotOccupancyAdd"
) as HTMLElement;
(
modalElement.querySelector(
"#lotOccupancySearch--notWorkOrderId"
) as HTMLInputElement
).value = workOrderId;
(
modalElement.querySelector(
"#lotOccupancySearch--occupancyEffectiveDateString"
) as HTMLInputElement
).value = (
document.querySelector(
"#workOrderEdit--workOrderOpenDateString"
) as HTMLInputElement
).value;
doSearch();
},
onshown(modalElement) {
bulmaJS.toggleHtmlClipped();
(
modalElement.querySelector("#lotOccupancySearch--occupantName") as HTMLInputElement
).addEventListener("change", doSearch);
(
modalElement.querySelector("#lotOccupancySearch--lotName") as HTMLInputElement
).addEventListener("change", doSearch);
searchFormElement.addEventListener("submit", doSearch);
},
onremoved() {
bulmaJS.toggleHtmlClipped();
}
});
});
function doAddLot(clickEvent: Event): void {
const rowElement = (clickEvent.currentTarget as HTMLElement).closest("tr")!; const rowElement = (clickEvent.currentTarget as HTMLElement).closest("tr")!;
const lotId = rowElement.dataset.lotId!; const lotId = rowElement.dataset.lotId!;
@ -707,13 +659,13 @@ const doAddLot = (clickEvent: Event) => {
rowElement.remove(); rowElement.remove();
} }
}); });
}; }
(document.querySelector("#button--addLot") as HTMLButtonElement).addEventListener("click", () => { document.querySelector("#button--addLot")!.addEventListener("click", () => {
let searchFormElement: HTMLFormElement; let searchFormElement: HTMLFormElement;
let searchResultsContainerElement: HTMLElement; let searchResultsContainerElement: HTMLElement;
const doSearch = (event?: Event) => { function doSearch(event?: Event) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
@ -737,19 +689,16 @@ const doAddLot = (clickEvent: Event) => {
return; return;
} }
searchResultsContainerElement.innerHTML = searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
'<table class="table is-fullwidth is-striped is-hoverable">' + <thead><tr>
"<thead>" + <th class="has-width-1"></th>
"<tr>" + <th>${los.escapedAliases.Lot}</th>
'<th class="has-width-1"></th>' + <th>${los.escapedAliases.Map}</th>
("<th>" + exports.aliases.lot + "</th>") + <th>${los.escapedAliases.Lot} Type</th>
("<th>" + exports.aliases.map + "</th>") + <th>Status</th>
("<th>" + exports.aliases.lot + " Type</th>") + </tr></thead>
"<th>Status</th>" + <tbody></tbody>
"</tr>" + </table>`;
"</thead>" +
"<tbody></tbody>" +
"</table>";
for (const lot of responseJSON.lots) { for (const lot of responseJSON.lots) {
const rowElement = document.createElement("tr"); const rowElement = document.createElement("tr");
@ -771,18 +720,18 @@ const doAddLot = (clickEvent: Event) => {
("<td>" + cityssm.escapeHTML(lot.lotType || "") + "</td>") + ("<td>" + cityssm.escapeHTML(lot.lotType || "") + "</td>") +
("<td>" + cityssm.escapeHTML(lot.lotStatus || "") + "</td>"); ("<td>" + cityssm.escapeHTML(lot.lotStatus || "") + "</td>");
( rowElement
rowElement.querySelector(".button--addLot") as HTMLButtonElement .querySelector(".button--addLot")!
).addEventListener("click", doAddLot); .addEventListener("click", doAddLot);
searchResultsContainerElement.querySelector("tbody")!.append(rowElement); searchResultsContainerElement.querySelector("tbody")!.append(rowElement);
} }
} }
); );
}; }
cityssm.openHtmlModal("workOrder-addLot", { cityssm.openHtmlModal("workOrder-addLot", {
onshow: (modalElement) => { onshow(modalElement) {
los.populateAliases(modalElement); los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form")!; searchFormElement = modalElement.querySelector("form")!;
@ -807,7 +756,7 @@ const doAddLot = (clickEvent: Event) => {
doSearch(); doSearch();
}, },
onshown: (modalElement) => { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
( (
@ -820,7 +769,7 @@ const doAddLot = (clickEvent: Event) => {
searchFormElement.addEventListener("submit", doSearch); searchFormElement.addEventListener("submit", doSearch);
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
} }
}); });

File diff suppressed because one or more lines are too long