diff --git a/handlers/workOrders-post/doUpdateLotStatus.d.ts b/handlers/workOrders-post/doUpdateLotStatus.d.ts
new file mode 100644
index 00000000..9621c611
--- /dev/null
+++ b/handlers/workOrders-post/doUpdateLotStatus.d.ts
@@ -0,0 +1,3 @@
+import type { RequestHandler } from "express";
+export declare const handler: RequestHandler;
+export default handler;
diff --git a/handlers/workOrders-post/doUpdateLotStatus.js b/handlers/workOrders-post/doUpdateLotStatus.js
new file mode 100644
index 00000000..0f5796c9
--- /dev/null
+++ b/handlers/workOrders-post/doUpdateLotStatus.js
@@ -0,0 +1,16 @@
+import { updateLotStatus } from "../../helpers/lotOccupancyDB/updateLot.js";
+import { getLots } from "../../helpers/lotOccupancyDB/getLots.js";
+export const handler = async (request, response) => {
+ const success = updateLotStatus(request.body.lotId, request.body.lotStatusId, request.session);
+ const workOrderLots = getLots({
+ workOrderId: request.body.workOrderId
+ }, {
+ limit: -1,
+ offset: 0
+ }).lots;
+ response.json({
+ success,
+ workOrderLots
+ });
+};
+export default handler;
diff --git a/handlers/workOrders-post/doUpdateLotStatus.ts b/handlers/workOrders-post/doUpdateLotStatus.ts
new file mode 100644
index 00000000..233f8ae5
--- /dev/null
+++ b/handlers/workOrders-post/doUpdateLotStatus.ts
@@ -0,0 +1,26 @@
+import type { RequestHandler } from "express";
+
+import { updateLotStatus } from "../../helpers/lotOccupancyDB/updateLot.js";
+import { getLots } from "../../helpers/lotOccupancyDB/getLots.js";
+
+export const handler: RequestHandler = async (request, response) => {
+
+ const success = updateLotStatus(request.body.lotId, request.body.lotStatusId, request.session);
+
+ const workOrderLots = getLots(
+ {
+ workOrderId: request.body.workOrderId
+ },
+ {
+ limit: -1,
+ offset: 0
+ }
+ ).lots;
+
+ response.json({
+ success,
+ workOrderLots
+ });
+};
+
+export default handler;
diff --git a/helpers/lotOccupancyDB/getLots.js b/helpers/lotOccupancyDB/getLots.js
index cab95d50..79dd24b2 100644
--- a/helpers/lotOccupancyDB/getLots.js
+++ b/helpers/lotOccupancyDB/getLots.js
@@ -66,7 +66,7 @@ export const getLots = (filters, options, connectedDatabase) => {
.prepare("select l.lotId, l.lotName," +
" t.lotType," +
" l.mapId, m.mapName, l.mapKey," +
- " s.lotStatus," +
+ " l.lotStatusId, s.lotStatus," +
" ifnull(o.lotOccupancyCount, 0) as lotOccupancyCount" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
diff --git a/helpers/lotOccupancyDB/getLots.ts b/helpers/lotOccupancyDB/getLots.ts
index ffa54d33..8c5ab147 100644
--- a/helpers/lotOccupancyDB/getLots.ts
+++ b/helpers/lotOccupancyDB/getLots.ts
@@ -111,7 +111,7 @@ export const getLots = (
"select l.lotId, l.lotName," +
" t.lotType," +
" l.mapId, m.mapName, l.mapKey," +
- " s.lotStatus," +
+ " l.lotStatusId, s.lotStatus," +
" ifnull(o.lotOccupancyCount, 0) as lotOccupancyCount" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
diff --git a/public-typescript/workOrderEdit.js b/public-typescript/workOrderEdit.js
index bfe45f45..00aabaca 100644
--- a/public-typescript/workOrderEdit.js
+++ b/public-typescript/workOrderEdit.js
@@ -318,6 +318,70 @@ Object.defineProperty(exports, "__esModule", { value: true });
occupanciesContainerElement.querySelector("tbody").append(rowElement);
}
};
+ const 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) => {
+ submitEvent.preventDefault();
+ cityssm.postJSON(urlPrefix + "/workOrders/doUpdateLotStatus", submitEvent.currentTarget, (responseJSON) => {
+ if (responseJSON.success) {
+ workOrderLots = responseJSON.workOrderLots;
+ renderRelatedLotsAndOccupancies();
+ editCloseModalFunction();
+ }
+ else {
+ bulmaJS.alert({
+ title: "Error Deleting Relationship",
+ message: responseJSON.errorMessage,
+ contextualColorName: "danger"
+ });
+ }
+ });
+ };
+ cityssm.openHtmlModal("lot-editLotStatus", {
+ onshow: (modalElement) => {
+ los.populateAliases(modalElement);
+ modalElement.querySelector("#lotStatusEdit--lotId").value = lotId.toString();
+ modalElement.querySelector("#lotStatusEdit--lotName").value = lot.lotName;
+ const lotStatusElement = modalElement.querySelector("#lotStatusEdit--lotStatusId");
+ let lotStatusFound = false;
+ for (const lotStatus of exports.lotStatuses) {
+ const optionElement = document.createElement("option");
+ optionElement.value = lotStatus.lotStatusId.toString();
+ optionElement.textContent = lotStatus.lotStatus;
+ if (lotStatus.lotStatusId === lot.lotStatusId) {
+ lotStatusFound = true;
+ }
+ lotStatusElement.append(optionElement);
+ }
+ if (!lotStatusFound && lot.lotStatusId) {
+ const optionElement = document.createElement("option");
+ optionElement.value = lot.lotStatusId.toString();
+ optionElement.textContent = lot.lotStatus;
+ lotStatusElement.append(optionElement);
+ }
+ if (lot.lotStatusId) {
+ lotStatusElement.value = lot.lotStatusId.toString();
+ }
+ modalElement
+ .querySelector("form")
+ .insertAdjacentHTML("beforeend", '');
+ },
+ onshown: (modalElement, closeModalFunction) => {
+ editCloseModalFunction = closeModalFunction;
+ bulmaJS.toggleHtmlClipped();
+ modalElement
+ .querySelector("form")
+ .addEventListener("submit", doUpdateLotStatus);
+ },
+ onremoved: () => {
+ bulmaJS.toggleHtmlClipped();
+ }
+ });
+ };
const deleteLot = (clickEvent) => {
const lotId = clickEvent.currentTarget.closest(".container--lot").dataset.lotId;
const doDelete = () => {
@@ -398,12 +462,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
"" +
("
" + cityssm.escapeHTML(lot.mapName) + " | ") +
("" + cityssm.escapeHTML(lot.lotType) + " | ") +
- ("" + cityssm.escapeHTML(lot.lotStatus) + " | ") +
- ("" +
- ' |