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) {
(document.querySelector("#lotComments--add") as HTMLButtonElement).addEventListener(
"click",
openAddCommentModal
);
document.querySelector("#lotComments--add")!.addEventListener("click", openAddCommentModal);
renderLotComments();
}
})();

View File

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

View File

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

View File

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

View File

@ -19,12 +19,12 @@ delete exports.workOrderLots;
let workOrderLotOccupancies: recordTypes.LotOccupancy[] = exports.workOrderLotOccupancies;
delete exports.workOrderLotOccupancies;
const deleteLotOccupancy = (clickEvent: Event) => {
function deleteLotOccupancy(clickEvent: Event): void {
const lotOccupancyId = (
(clickEvent.currentTarget as HTMLElement).closest(".container--lotOccupancy") as HTMLElement
).dataset.lotOccupancyId;
const doDelete = () => {
function doDelete(): void {
cityssm.postJSON(
los.urlPrefix + "/workOrders/doDeleteWorkOrderLotOccupancy",
{
@ -48,25 +48,20 @@ const deleteLotOccupancy = (clickEvent: Event) => {
}
}
);
};
}
bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship",
message:
"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.",
title: `Delete ${exports.aliases.occupancy} Relationship`,
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.`,
contextualColorName: "warning",
okButton: {
text: "Yes, Delete Relationship",
callbackFunction: doDelete
}
});
};
}
const addLot = (lotId: number | string, callbackFunction?: (success?: boolean) => void) => {
function addLot(lotId: number | string, callbackFunction?: (success?: boolean) => void): void {
cityssm.postJSON(
los.urlPrefix + "/workOrders/doAddWorkOrderLot",
{
@ -94,12 +89,12 @@ const addLot = (lotId: number | string, callbackFunction?: (success?: boolean) =
}
}
);
};
}
const addLotOccupancy = (
function addLotOccupancy(
lotOccupancyId: number | string,
callbackFunction?: (success?: boolean) => void
) => {
): void {
cityssm.postJSON(
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!;
addLot(lotId);
};
}
const renderRelatedOccupancies = () => {
function renderRelatedOccupancies(): void {
const occupanciesContainerElement = document.querySelector(
"#container--lotOccupancies"
) as HTMLElement;
@ -144,31 +139,22 @@ const renderRelatedOccupancies = () => {
).textContent = workOrderLotOccupancies.length.toString();
if (workOrderLotOccupancies.length === 0) {
occupanciesContainerElement.innerHTML =
'<div class="message is-info">' +
'<p class="message-body">There are no ' +
exports.aliases.occupancies.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
occupanciesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no ${exports.aliases.occupancies.toLowerCase()} associated with this work order.</p>
</div>`;
return;
}
occupanciesContainerElement.innerHTML =
'<table class="table is-fullwidth is-striped is-hoverable">' +
"<thead>" +
"<tr>" +
'<th class="has-width-1"></th>' +
("<th>" + exports.aliases.occupancy + " Type</th>") +
("<th>" + exports.aliases.lot + "</th>") +
("<th>" + exports.aliases.occupancyStartDate + "</th>") +
"<th>End Date</th>" +
("<th>" + exports.aliases.occupants + "</th>") +
'<th class="has-width-1"></th>' +
"</tr>" +
"</thead>" +
"<tbody></tbody>" +
"</table>";
occupanciesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th><th>${los.escapedAliases.Occupancy} Type</th>
<th>${los.escapedAliases.Lot}</th><th>${los.escapedAliases.OccupancyStartDate}</th>
<th>End Date</th><th>${los.escapedAliases.Occupants}</th>
<th class="has-width-1"></th>
</tr></thead>
<tbody></tbody>
</table>`;
const currentDateString = cityssm.dateToString(new Date());
@ -232,11 +218,7 @@ const renderRelatedOccupancies = () => {
} else {
rowElement.insertAdjacentHTML(
"beforeend",
"<td>" +
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>"
`<td><span class="has-text-grey">(No ${exports.aliases.lot})</span></td>`
);
}
@ -279,21 +261,20 @@ const renderRelatedOccupancies = () => {
);
if (lotOccupancy.lotId && !hasLotRecord) {
(rowElement.querySelector(".button--addLot") as HTMLButtonElement).addEventListener(
"click",
addLotFromLotOccupancy
);
rowElement
.querySelector(".button--addLot")!
.addEventListener("click", addLotFromLotOccupancy);
}
(
rowElement.querySelector(".button--deleteLotOccupancy") as HTMLButtonElement
).addEventListener("click", deleteLotOccupancy);
rowElement
.querySelector(".button--deleteLotOccupancy")!
.addEventListener("click", deleteLotOccupancy);
occupanciesContainerElement.querySelector("tbody")!.append(rowElement);
}
};
}
const openEditLotStatus = (clickEvent: Event) => {
function openEditLotStatus(clickEvent: Event): void {
const lotId = Number.parseInt(
((clickEvent.currentTarget as HTMLElement).closest(".container--lot") as HTMLElement)
.dataset.lotId!,
@ -306,7 +287,7 @@ const openEditLotStatus = (clickEvent: Event) => {
let editCloseModalFunction: () => void;
const doUpdateLotStatus = (submitEvent: SubmitEvent) => {
function doUpdateLotStatus(submitEvent: SubmitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(
@ -330,10 +311,10 @@ const openEditLotStatus = (clickEvent: Event) => {
}
}
);
};
}
cityssm.openHtmlModal("lot-editLotStatus", {
onshow: (modalElement) => {
onshow(modalElement) {
los.populateAliases(modalElement);
(modalElement.querySelector("#lotStatusEdit--lotId") as HTMLInputElement).value =
@ -378,25 +359,25 @@ const openEditLotStatus = (clickEvent: Event) => {
'<input name="workOrderId" type="hidden" value="' + workOrderId + '" />'
);
},
onshown: (modalElement, closeModalFunction) => {
onshown(modalElement, closeModalFunction) {
editCloseModalFunction = closeModalFunction;
bulmaJS.toggleHtmlClipped();
modalElement.querySelector("form")!.addEventListener("submit", doUpdateLotStatus);
},
onremoved: () => {
onremoved() {
bulmaJS.toggleHtmlClipped();
}
});
};
}
const deleteLot = (clickEvent: Event) => {
function deleteLot(clickEvent: Event): void {
const lotId = (
(clickEvent.currentTarget as HTMLElement).closest(".container--lot") as HTMLElement
).dataset.lotId;
const doDelete = () => {
function doDelete(): void {
cityssm.postJSON(
los.urlPrefix + "/workOrders/doDeleteWorkOrderLot",
{
@ -420,54 +401,43 @@ const deleteLot = (clickEvent: Event) => {
}
}
);
};
}
bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupancy + " Relationship",
message:
"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.",
title: `Delete ${los.escapedAliases.Occupancy} Relationship`,
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.`,
contextualColorName: "warning",
okButton: {
text: "Yes, Delete Relationship",
callbackFunction: doDelete
}
});
};
}
const renderRelatedLots = () => {
function renderRelatedLots() {
const lotsContainerElement = document.querySelector("#container--lots") as HTMLElement;
(document.querySelector(".tabs a[href='#relatedTab--lots'] .tag") as HTMLElement).textContent =
workOrderLots.length.toString();
if (workOrderLots.length === 0) {
lotsContainerElement.innerHTML =
'<div class="message is-info">' +
'<p class="message-body">There are no ' +
exports.aliases.lots.toLowerCase() +
" associated with this work order.</p>" +
"</div>";
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;
}
lotsContainerElement.innerHTML =
'<table class="table is-fullwidth is-striped is-hoverable">' +
"<thead>" +
"<tr>" +
("<th>" + exports.aliases.lot + "</th>") +
("<th>" + exports.aliases.map + "</th>") +
("<th>" + exports.aliases.lot + " Type</th>") +
"<th>Status</th>" +
'<th class="has-width-1"></th>' +
"</tr>" +
"</thead>" +
"<tbody></tbody>" +
"</table>";
lotsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th>${los.escapedAliases.Lot}</th>
<th>${los.escapedAliases.Map}</th>
<th>${los.escapedAliases.Lot} Type</th>
<th>Status</th>
<th class="has-width-1"></th>
</tr></thead>
<tbody></tbody>
</table>`;
for (const lot of workOrderLots) {
const rowElement = document.createElement("tr");
@ -501,28 +471,24 @@ const renderRelatedLots = () => {
"</button>" +
"</td>");
(rowElement.querySelector(".button--editLotStatus") as HTMLButtonElement).addEventListener(
"click",
openEditLotStatus
);
rowElement
.querySelector(".button--editLotStatus")!
.addEventListener("click", openEditLotStatus);
(rowElement.querySelector(".button--deleteLot") as HTMLButtonElement).addEventListener(
"click",
deleteLot
);
rowElement.querySelector(".button--deleteLot")!.addEventListener("click", deleteLot);
lotsContainerElement.querySelector("tbody")!.append(rowElement);
}
};
}
const renderRelatedLotsAndOccupancies = () => {
function renderRelatedLotsAndOccupancies(): void {
renderRelatedOccupancies();
renderRelatedLots();
};
}
renderRelatedLotsAndOccupancies();
const doAddLotOccupancy = (clickEvent: Event) => {
function doAddLotOccupancy(clickEvent: Event) {
const rowElement = (clickEvent.currentTarget as HTMLElement).closest("tr")!;
const lotOccupancyId = rowElement.dataset.lotOccupancyId!;
@ -532,15 +498,13 @@ const doAddLotOccupancy = (clickEvent: Event) => {
rowElement.remove();
}
});
};
}
(document.querySelector("#button--addLotOccupancy") as HTMLButtonElement).addEventListener(
"click",
() => {
document.querySelector("#button--addLotOccupancy")!.addEventListener("click", () => {
let searchFormElement: HTMLFormElement;
let searchResultsContainerElement: HTMLElement;
const doSearch = (event?: Event) => {
function doSearch(event?: Event) {
if (event) {
event.preventDefault();
}
@ -564,20 +528,17 @@ const doAddLotOccupancy = (clickEvent: Event) => {
return;
}
searchResultsContainerElement.innerHTML =
'<table class="table is-fullwidth is-striped is-hoverable">' +
"<thead>" +
"<tr>" +
'<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>";
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
<th>${los.escapedAliases.Occupancy} Type</th>
<th>${los.escapedAliases.Lot}</th>
<th>${los.escapedAliases.OccupancyStartDate}</th>
<th>End Date</th>
<th>${los.escapedAliases.Occupants}</th>
</tr></thead>
<tbody></tbody>
</table>`;
for (const lotOccupancy of responseJSON.lotOccupancies) {
const rowElement = document.createElement("tr");
@ -602,11 +563,7 @@ const doAddLotOccupancy = (clickEvent: Event) => {
} else {
rowElement.insertAdjacentHTML(
"beforeend",
"<td>" +
'<span class="has-text-grey">(No ' +
exports.aliases.lot +
")</span>" +
"</td>"
`<td><span class="has-text-grey">(No ${los.escapedAliases.Lot})</span></td>`
);
}
@ -635,20 +592,18 @@ const doAddLotOccupancy = (clickEvent: Event) => {
"</td>")
);
(
rowElement.querySelector(
".button--addLotOccupancy"
) as HTMLButtonElement
).addEventListener("click", doAddLotOccupancy);
rowElement
.querySelector(".button--addLotOccupancy")!
.addEventListener("click", doAddLotOccupancy);
searchResultsContainerElement.querySelector("tbody")!.append(rowElement);
}
}
);
};
}
cityssm.openHtmlModal("workOrder-addLotOccupancy", {
onshow: (modalElement) => {
onshow(modalElement) {
los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form")!;
@ -675,13 +630,11 @@ const doAddLotOccupancy = (clickEvent: Event) => {
doSearch();
},
onshown: (modalElement) => {
onshown(modalElement) {
bulmaJS.toggleHtmlClipped();
(
modalElement.querySelector(
"#lotOccupancySearch--occupantName"
) as HTMLInputElement
modalElement.querySelector("#lotOccupancySearch--occupantName") as HTMLInputElement
).addEventListener("change", doSearch);
(
@ -690,14 +643,13 @@ const doAddLotOccupancy = (clickEvent: Event) => {
searchFormElement.addEventListener("submit", doSearch);
},
onremoved: () => {
onremoved() {
bulmaJS.toggleHtmlClipped();
}
});
}
);
});
const doAddLot = (clickEvent: Event) => {
function doAddLot(clickEvent: Event): void {
const rowElement = (clickEvent.currentTarget as HTMLElement).closest("tr")!;
const lotId = rowElement.dataset.lotId!;
@ -707,13 +659,13 @@ const doAddLot = (clickEvent: Event) => {
rowElement.remove();
}
});
};
}
(document.querySelector("#button--addLot") as HTMLButtonElement).addEventListener("click", () => {
document.querySelector("#button--addLot")!.addEventListener("click", () => {
let searchFormElement: HTMLFormElement;
let searchResultsContainerElement: HTMLElement;
const doSearch = (event?: Event) => {
function doSearch(event?: Event) {
if (event) {
event.preventDefault();
}
@ -737,19 +689,16 @@ const doAddLot = (clickEvent: Event) => {
return;
}
searchResultsContainerElement.innerHTML =
'<table class="table is-fullwidth is-striped is-hoverable">' +
"<thead>" +
"<tr>" +
'<th class="has-width-1"></th>' +
("<th>" + exports.aliases.lot + "</th>") +
("<th>" + exports.aliases.map + "</th>") +
("<th>" + exports.aliases.lot + " Type</th>") +
"<th>Status</th>" +
"</tr>" +
"</thead>" +
"<tbody></tbody>" +
"</table>";
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th class="has-width-1"></th>
<th>${los.escapedAliases.Lot}</th>
<th>${los.escapedAliases.Map}</th>
<th>${los.escapedAliases.Lot} Type</th>
<th>Status</th>
</tr></thead>
<tbody></tbody>
</table>`;
for (const lot of responseJSON.lots) {
const rowElement = document.createElement("tr");
@ -771,18 +720,18 @@ const doAddLot = (clickEvent: Event) => {
("<td>" + cityssm.escapeHTML(lot.lotType || "") + "</td>") +
("<td>" + cityssm.escapeHTML(lot.lotStatus || "") + "</td>");
(
rowElement.querySelector(".button--addLot") as HTMLButtonElement
).addEventListener("click", doAddLot);
rowElement
.querySelector(".button--addLot")!
.addEventListener("click", doAddLot);
searchResultsContainerElement.querySelector("tbody")!.append(rowElement);
}
}
);
};
}
cityssm.openHtmlModal("workOrder-addLot", {
onshow: (modalElement) => {
onshow(modalElement) {
los.populateAliases(modalElement);
searchFormElement = modalElement.querySelector("form")!;
@ -807,7 +756,7 @@ const doAddLot = (clickEvent: Event) => {
doSearch();
},
onshown: (modalElement) => {
onshown(modalElement) {
bulmaJS.toggleHtmlClipped();
(
@ -820,7 +769,7 @@ const doAddLot = (clickEvent: Event) => {
searchFormElement.addEventListener("submit", doSearch);
},
onremoved: () => {
onremoved() {
bulmaJS.toggleHtmlClipped();
}
});

File diff suppressed because one or more lines are too long