lot status maintenance
parent
e8106c5229
commit
8b798443ed
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { addLotStatus } from "../../helpers/lotOccupancyDB/addLotStatus.js";
|
||||||
|
import { getLotStatuses } from "../../helpers/functions.cache.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const lotStatusId = addLotStatus(request.body, request.session);
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
lotStatusId,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import {
|
||||||
|
addLotStatus
|
||||||
|
} from "../../helpers/lotOccupancyDB/addLotStatus.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getLotStatuses
|
||||||
|
} from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
|
const lotStatusId = addLotStatus(request.body, request.session);
|
||||||
|
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
lotStatusId,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { deleteLotStatus } from "../../helpers/lotOccupancyDB/deleteLotStatus.js";
|
||||||
|
import { getLotStatuses } from "../../helpers/functions.cache.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const success = deleteLotStatus(request.body.lotStatusId, request.session);
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import {
|
||||||
|
deleteLotStatus
|
||||||
|
} from "../../helpers/lotOccupancyDB/deleteLotStatus.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getLotStatuses
|
||||||
|
} from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
|
const success = deleteLotStatus(request.body.lotStatusId, request.session);
|
||||||
|
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { moveLotStatusDown } from "../../helpers/lotOccupancyDB/moveLotStatusDown.js";
|
||||||
|
import { getLotStatuses } from "../../helpers/functions.cache.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const success = moveLotStatusDown(request.body.lotStatusId);
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import {
|
||||||
|
moveLotStatusDown
|
||||||
|
} from "../../helpers/lotOccupancyDB/moveLotStatusDown.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getLotStatuses
|
||||||
|
} from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
|
const success = moveLotStatusDown(request.body.lotStatusId);
|
||||||
|
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { moveLotStatusUp } from "../../helpers/lotOccupancyDB/moveLotStatusUp.js";
|
||||||
|
import { getLotStatuses } from "../../helpers/functions.cache.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const success = moveLotStatusUp(request.body.lotStatusId);
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import {
|
||||||
|
moveLotStatusUp
|
||||||
|
} from "../../helpers/lotOccupancyDB/moveLotStatusUp.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getLotStatuses
|
||||||
|
} from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
|
const success = moveLotStatusUp(request.body.lotStatusId);
|
||||||
|
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { updateLotStatus } from "../../helpers/lotOccupancyDB/updateLotStatus.js";
|
||||||
|
import { getLotStatuses } from "../../helpers/functions.cache.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const success = updateLotStatus(request.body, request.session);
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import {
|
||||||
|
updateLotStatus
|
||||||
|
} from "../../helpers/lotOccupancyDB/updateLotStatus.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getLotStatuses
|
||||||
|
} from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
|
const success = updateLotStatus(request.body, request.session);
|
||||||
|
|
||||||
|
const lotStatuses = getLotStatuses();
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
lotStatuses
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -10,7 +10,7 @@ export const addLotStatus = (lotStatusForm, requestSession) => {
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)")
|
||||||
.run(lotStatusForm.lotStatus, (lotStatusForm.orderNumber || 0), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotStatusForm.lotStatus, (lotStatusForm.orderNumber || -1), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
clearLotStatusesCache();
|
clearLotStatusesCache();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ export const addLotStatus =
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)")
|
||||||
.run(lotStatusForm.lotStatus,
|
.run(lotStatusForm.lotStatus,
|
||||||
(lotStatusForm.orderNumber || 0),
|
(lotStatusForm.orderNumber || -1),
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
export declare const deleteLotStatus: (lotStatusId: number | string, requestSession: recordTypes.PartialSession) => boolean;
|
||||||
|
export default deleteLotStatus;
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
import { clearLotStatusesCache } from "../functions.cache.js";
|
||||||
|
export const deleteLotStatus = (lotStatusId, requestSession) => {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
const rightNowMillis = Date.now();
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set recordDelete_userName = ?," +
|
||||||
|
" recordDelete_timeMillis = ?" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(requestSession.user.userName, rightNowMillis, lotStatusId);
|
||||||
|
database.close();
|
||||||
|
clearLotStatusesCache();
|
||||||
|
return (result.changes > 0);
|
||||||
|
};
|
||||||
|
export default deleteLotStatus;
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
|
import {
|
||||||
|
lotOccupancyDB as databasePath
|
||||||
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
clearLotStatusesCache
|
||||||
|
} from "../functions.cache.js";
|
||||||
|
|
||||||
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
|
export const deleteLotStatus =
|
||||||
|
(lotStatusId: number | string,
|
||||||
|
requestSession: recordTypes.PartialSession): boolean => {
|
||||||
|
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set recordDelete_userName = ?," +
|
||||||
|
" recordDelete_timeMillis = ?" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(requestSession.user.userName,
|
||||||
|
rightNowMillis,
|
||||||
|
lotStatusId);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearLotStatusesCache();
|
||||||
|
|
||||||
|
return (result.changes > 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default deleteLotStatus;
|
||||||
|
|
@ -4,8 +4,11 @@ import {
|
||||||
lotOccupancyDB as databasePath
|
lotOccupancyDB as databasePath
|
||||||
} from "../../data/databasePaths.js";
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
clearWorkOrderTypesCache
|
||||||
|
} from "../functions.cache.js";
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
import { clearWorkOrderTypesCache } from "../functions.cache.js";
|
|
||||||
|
|
||||||
|
|
||||||
export const deleteWorkOrderType =
|
export const deleteWorkOrderType =
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,24 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
export const getLotStatuses = () => {
|
export const getLotStatuses = () => {
|
||||||
const database = sqlite(databasePath, {
|
const database = sqlite(databasePath);
|
||||||
readonly: true
|
|
||||||
});
|
|
||||||
const lotStatuses = database
|
const lotStatuses = database
|
||||||
.prepare("select lotStatusId, lotStatus" +
|
.prepare("select lotStatusId, lotStatus" +
|
||||||
" from LotStatuses" +
|
" from LotStatuses" +
|
||||||
" where recordDelete_timeMillis is null" +
|
" where recordDelete_timeMillis is null" +
|
||||||
" order by orderNumber, lotStatus")
|
" order by orderNumber, lotStatus")
|
||||||
.all();
|
.all();
|
||||||
|
let expectedOrderNumber = 0;
|
||||||
|
for (const lotStatus of lotStatuses) {
|
||||||
|
if (lotStatus.orderNumber !== expectedOrderNumber) {
|
||||||
|
database.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = ?" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(expectedOrderNumber, lotStatus.lotStatusId);
|
||||||
|
lotStatus.orderNumber = expectedOrderNumber;
|
||||||
|
}
|
||||||
|
expectedOrderNumber += 1;
|
||||||
|
}
|
||||||
database.close();
|
database.close();
|
||||||
return lotStatuses;
|
return lotStatuses;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
|
||||||
|
import {
|
||||||
|
lotOccupancyDB as databasePath
|
||||||
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
export const getLotStatuses = (): recordTypes.LotStatus[] => {
|
export const getLotStatuses = (): recordTypes.LotStatus[] => {
|
||||||
|
|
||||||
const database = sqlite(databasePath, {
|
const database = sqlite(databasePath);
|
||||||
readonly: true
|
|
||||||
});
|
|
||||||
|
|
||||||
const lotStatuses: recordTypes.LotStatus[] = database
|
const lotStatuses: recordTypes.LotStatus[] = database
|
||||||
.prepare("select lotStatusId, lotStatus" +
|
.prepare("select lotStatusId, lotStatus" +
|
||||||
|
|
@ -17,6 +18,24 @@ export const getLotStatuses = (): recordTypes.LotStatus[] => {
|
||||||
" order by orderNumber, lotStatus")
|
" order by orderNumber, lotStatus")
|
||||||
.all();
|
.all();
|
||||||
|
|
||||||
|
let expectedOrderNumber = 0;
|
||||||
|
|
||||||
|
for (const lotStatus of lotStatuses) {
|
||||||
|
|
||||||
|
if (lotStatus.orderNumber !== expectedOrderNumber) {
|
||||||
|
|
||||||
|
database.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = ?" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(expectedOrderNumber,
|
||||||
|
lotStatus.lotStatusId);
|
||||||
|
|
||||||
|
lotStatus.orderNumber = expectedOrderNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedOrderNumber += 1;
|
||||||
|
}
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
return lotStatuses;
|
return lotStatuses;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare const moveLotStatusDown: (lotStatusId: number | string) => boolean;
|
||||||
|
export default moveLotStatusDown;
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
import { clearLotStatusesCache } from "../functions.cache.js";
|
||||||
|
export const moveLotStatusDown = (lotStatusId) => {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
const currentOrderNumber = database.prepare("select orderNumber" +
|
||||||
|
" from LotStatuses" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.get(lotStatusId)
|
||||||
|
.orderNumber;
|
||||||
|
database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = orderNumber - 1" +
|
||||||
|
" where recordDelete_timeMillis is null" +
|
||||||
|
" and orderNumber = ? + 1")
|
||||||
|
.run(currentOrderNumber);
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = ? + 1" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(currentOrderNumber, lotStatusId);
|
||||||
|
database.close();
|
||||||
|
clearLotStatusesCache();
|
||||||
|
return result.changes > 0;
|
||||||
|
};
|
||||||
|
export default moveLotStatusDown;
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
|
import {
|
||||||
|
lotOccupancyDB as databasePath
|
||||||
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
clearLotStatusesCache
|
||||||
|
} from "../functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const moveLotStatusDown =
|
||||||
|
(lotStatusId: number | string): boolean => {
|
||||||
|
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
|
const currentOrderNumber: number = database.prepare("select orderNumber" +
|
||||||
|
" from LotStatuses" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.get(lotStatusId)
|
||||||
|
.orderNumber;
|
||||||
|
|
||||||
|
database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = orderNumber - 1" +
|
||||||
|
" where recordDelete_timeMillis is null" +
|
||||||
|
" and orderNumber = ? + 1")
|
||||||
|
.run(currentOrderNumber);
|
||||||
|
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = ? + 1" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(currentOrderNumber, lotStatusId);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearLotStatusesCache();
|
||||||
|
|
||||||
|
return result.changes > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default moveLotStatusDown;
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare const moveLotStatusUp: (lotStatusId: number | string) => boolean;
|
||||||
|
export default moveLotStatusUp;
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
import { clearLotStatusesCache } from "../functions.cache.js";
|
||||||
|
export const moveLotStatusUp = (lotStatusId) => {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
const currentOrderNumber = database.prepare("select orderNumber" +
|
||||||
|
" from LotStatuses" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.get(lotStatusId)
|
||||||
|
.orderNumber;
|
||||||
|
if (currentOrderNumber <= 0) {
|
||||||
|
database.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = orderNumber + 1" +
|
||||||
|
" where recordDelete_timeMillis is null" +
|
||||||
|
" and orderNumber = ? - 1")
|
||||||
|
.run(currentOrderNumber);
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = ? - 1" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(currentOrderNumber, lotStatusId);
|
||||||
|
database.close();
|
||||||
|
clearLotStatusesCache();
|
||||||
|
return result.changes > 0;
|
||||||
|
};
|
||||||
|
export default moveLotStatusUp;
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
|
import {
|
||||||
|
lotOccupancyDB as databasePath
|
||||||
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
clearLotStatusesCache
|
||||||
|
} from "../functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const moveLotStatusUp =
|
||||||
|
(lotStatusId: number | string): boolean => {
|
||||||
|
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
|
const currentOrderNumber: number = database.prepare("select orderNumber" +
|
||||||
|
" from LotStatuses" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.get(lotStatusId)
|
||||||
|
.orderNumber;
|
||||||
|
|
||||||
|
if (currentOrderNumber <= 0) {
|
||||||
|
database.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = orderNumber + 1" +
|
||||||
|
" where recordDelete_timeMillis is null" +
|
||||||
|
" and orderNumber = ? - 1")
|
||||||
|
.run(currentOrderNumber);
|
||||||
|
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set orderNumber = ? - 1" +
|
||||||
|
" where lotStatusId = ?")
|
||||||
|
.run(currentOrderNumber, lotStatusId);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearLotStatusesCache();
|
||||||
|
|
||||||
|
return result.changes > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default moveLotStatusUp;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
interface UpdateLotStatusForm {
|
||||||
|
lotStatusId: number | string;
|
||||||
|
lotStatus: string;
|
||||||
|
}
|
||||||
|
export declare const updateLotStatus: (lotStatusForm: UpdateLotStatusForm, requestSession: recordTypes.PartialSession) => boolean;
|
||||||
|
export default updateLotStatus;
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
import { clearLotStatusesCache } from "../functions.cache.js";
|
||||||
|
export const updateLotStatus = (lotStatusForm, requestSession) => {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
const rightNowMillis = Date.now();
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set lotStatus = ?," +
|
||||||
|
" recordUpdate_userName = ?," +
|
||||||
|
" recordUpdate_timeMillis = ?" +
|
||||||
|
" where lotStatusId = ?" +
|
||||||
|
" and recordDelete_timeMillis is null")
|
||||||
|
.run(lotStatusForm.lotStatus, requestSession.user.userName, rightNowMillis, lotStatusForm.lotStatusId);
|
||||||
|
database.close();
|
||||||
|
clearLotStatusesCache();
|
||||||
|
return result.changes > 0;
|
||||||
|
};
|
||||||
|
export default updateLotStatus;
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
|
import {
|
||||||
|
lotOccupancyDB as databasePath
|
||||||
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
clearLotStatusesCache
|
||||||
|
} from "../functions.cache.js";
|
||||||
|
|
||||||
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
|
interface UpdateLotStatusForm {
|
||||||
|
lotStatusId: number | string;
|
||||||
|
lotStatus: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const updateLotStatus =
|
||||||
|
(lotStatusForm: UpdateLotStatusForm, requestSession: recordTypes.PartialSession): boolean => {
|
||||||
|
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
|
const result = database
|
||||||
|
.prepare("update LotStatuses" +
|
||||||
|
" set lotStatus = ?," +
|
||||||
|
" recordUpdate_userName = ?," +
|
||||||
|
" recordUpdate_timeMillis = ?" +
|
||||||
|
" where lotStatusId = ?" +
|
||||||
|
" and recordDelete_timeMillis is null")
|
||||||
|
.run(lotStatusForm.lotStatus,
|
||||||
|
requestSession.user.userName,
|
||||||
|
rightNowMillis,
|
||||||
|
lotStatusForm.lotStatusId);
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
clearLotStatusesCache();
|
||||||
|
|
||||||
|
return result.changes > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default updateLotStatus;
|
||||||
|
|
@ -4,8 +4,11 @@ import {
|
||||||
lotOccupancyDB as databasePath
|
lotOccupancyDB as databasePath
|
||||||
} from "../../data/databasePaths.js";
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
clearWorkOrderTypesCache
|
||||||
|
} from "../functions.cache.js";
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
import { clearWorkOrderTypesCache } from "../functions.cache.js";
|
|
||||||
|
|
||||||
|
|
||||||
interface UpdateWorkOrderTypeForm {
|
interface UpdateWorkOrderTypeForm {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
(() => {
|
(() => {
|
||||||
const los = exports.los;
|
|
||||||
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
||||||
let workOrderTypes = exports.workOrderTypes;
|
let workOrderTypes = exports.workOrderTypes;
|
||||||
delete exports.workOrderTypes;
|
delete exports.workOrderTypes;
|
||||||
|
|
@ -178,4 +177,179 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
renderWorkOrderTypes();
|
renderWorkOrderTypes();
|
||||||
|
let lotStatuses = exports.lotStatuses;
|
||||||
|
delete exports.lotStatuses;
|
||||||
|
const updateLotStatus = (submitEvent) => {
|
||||||
|
submitEvent.preventDefault();
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doUpdateLotStatus", submitEvent.currentTarget, (responseJSON) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
bulmaJS.alert({
|
||||||
|
message: exports.aliases.lot + " Status Updated Successfully",
|
||||||
|
contextualColorName: "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Updating " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const deleteLotStatus = (clickEvent) => {
|
||||||
|
const tableRowElement = clickEvent.currentTarget.closest("tr");
|
||||||
|
const lotStatusId = tableRowElement.dataset.lotStatusId;
|
||||||
|
const doDelete = () => {
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doDeleteLotStatus", {
|
||||||
|
lotStatusId
|
||||||
|
}, (responseJSON) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
if (lotStatuses.length === 0) {
|
||||||
|
renderLotStatuses();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tableRowElement.remove();
|
||||||
|
}
|
||||||
|
bulmaJS.alert({
|
||||||
|
message: exports.aliases.lot + " Status Deleted Successfully",
|
||||||
|
contextualColorName: "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Deleting " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
bulmaJS.confirm({
|
||||||
|
title: "Delete " + exports.aliases.lot + " Status",
|
||||||
|
message: "Are you sure you want to delete this status?<br />" +
|
||||||
|
"Note that no " + exports.aliases.lots.toLowerCase() + " will be removed.",
|
||||||
|
messageIsHtml: true,
|
||||||
|
contextualColorName: "warning",
|
||||||
|
okButton: {
|
||||||
|
text: "Yes, Delete Status",
|
||||||
|
callbackFunction: doDelete
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const moveLotStatusUp = (clickEvent) => {
|
||||||
|
const tableRowElement = clickEvent.currentTarget.closest("tr");
|
||||||
|
const lotStatusId = tableRowElement.dataset.lotStatusId;
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doMoveLotStatusUp", {
|
||||||
|
lotStatusId
|
||||||
|
}, (responseJSON) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
renderLotStatuses();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Moving " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const moveLotStatusDown = (clickEvent) => {
|
||||||
|
const tableRowElement = clickEvent.currentTarget.closest("tr");
|
||||||
|
const lotStatusId = tableRowElement.dataset.lotStatusId;
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doMoveLotStatusDown", {
|
||||||
|
lotStatusId
|
||||||
|
}, (responseJSON) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
renderLotStatuses();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Moving " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const renderLotStatuses = () => {
|
||||||
|
const containerElement = document.querySelector("#container--lotStatuses");
|
||||||
|
if (workOrderTypes.length === 0) {
|
||||||
|
containerElement.innerHTML = "<tr>" +
|
||||||
|
"<td colspan=\"2\">" +
|
||||||
|
"<div class=\"message is-warning\">" +
|
||||||
|
"<p class=\"message-body\">There are no active " + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + " statuses.</p>" +
|
||||||
|
"</div>" +
|
||||||
|
"</td>" +
|
||||||
|
"</tr>";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
containerElement.innerHTML = "";
|
||||||
|
for (const lotStatus of lotStatuses) {
|
||||||
|
const tableRowElement = document.createElement("tr");
|
||||||
|
tableRowElement.dataset.lotStatusId = lotStatus.lotStatusId.toString();
|
||||||
|
tableRowElement.innerHTML = "<td>" +
|
||||||
|
"<form>" +
|
||||||
|
"<input name=\"lotStatusId\" type=\"hidden\" value=\"" + lotStatus.lotStatusId.toString() + "\" />" +
|
||||||
|
("<div class=\"field has-addons\">" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<input class=\"input\" name=\"lotStatus\" type=\"text\" value=\"" + cityssm.escapeHTML(lotStatus.lotStatus) + "\" maxlength=\"100\" required />" +
|
||||||
|
"</div>" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button is-success\" type=\"submit\"><i class=\"fas fa-save\" aria-hidden=\"true\"></i></button>" +
|
||||||
|
"</div>" +
|
||||||
|
"</div>") +
|
||||||
|
"</form>" +
|
||||||
|
"</td>" +
|
||||||
|
"<td class=\"is-nowrap\">" +
|
||||||
|
"<div class=\"field is-grouped\">" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
("<div class=\"field has-addons\">" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button button--moveLotStatusUp\" data-tooltip=\"Move Up\" type=\"button\" aria-label=\"Move Up\"><i class=\"fas fa-arrow-up\" aria-hidden=\"true\"></i></button>" +
|
||||||
|
"</div>" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button button--moveLotStatusDown\" data-tooltip=\"Move Down\" type=\"button\" aria-label=\"Move Down\"><i class=\"fas fa-arrow-down\" aria-hidden=\"true\"></i></button>" +
|
||||||
|
"</div>" +
|
||||||
|
"</div>") +
|
||||||
|
"</div>" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button is-danger is-light button--deleteLotStatus\" data-tooltip=\"Delete Status\" type=\"button\" aria-label=\"Delete Status\">" +
|
||||||
|
"<i class=\"fas fa-trash\" aria-hidden=\"true\"></i>" +
|
||||||
|
"</button>" +
|
||||||
|
"</div>" +
|
||||||
|
"</div>" +
|
||||||
|
"</td>";
|
||||||
|
tableRowElement.querySelector("form").addEventListener("submit", updateLotStatus);
|
||||||
|
tableRowElement.querySelector(".button--moveLotStatusUp").addEventListener("click", moveLotStatusUp);
|
||||||
|
tableRowElement.querySelector(".button--moveLotStatusDown").addEventListener("click", moveLotStatusDown);
|
||||||
|
tableRowElement.querySelector(".button--deleteLotStatus").addEventListener("click", deleteLotStatus);
|
||||||
|
containerElement.append(tableRowElement);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.querySelector("#form--addLotStatus").addEventListener("submit", (submitEvent) => {
|
||||||
|
submitEvent.preventDefault();
|
||||||
|
const formElement = submitEvent.currentTarget;
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doAddLotStatus", formElement, (responseJSON) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
renderLotStatuses();
|
||||||
|
formElement.reset();
|
||||||
|
formElement.querySelector("input").focus();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Adding " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
renderLotStatuses();
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
/* eslint-disable unicorn/prefer-module */
|
/* eslint-disable unicorn/prefer-module */
|
||||||
|
|
||||||
import type * as globalTypes from "../types/globalTypes";
|
|
||||||
import type * as recordTypes from "../types/recordTypes";
|
import type * as recordTypes from "../types/recordTypes";
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -16,8 +15,6 @@ declare const bulmaJS: BulmaJS;
|
||||||
|
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
const los = (exports.los as globalTypes.LOS);
|
|
||||||
|
|
||||||
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -270,4 +267,253 @@ declare const bulmaJS: BulmaJS;
|
||||||
|
|
||||||
renderWorkOrderTypes();
|
renderWorkOrderTypes();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lot Statuses
|
||||||
|
*/
|
||||||
|
|
||||||
|
let lotStatuses: recordTypes.LotStatus[] = exports.lotStatuses;
|
||||||
|
delete exports.lotStatuses;
|
||||||
|
|
||||||
|
const updateLotStatus = (submitEvent: SubmitEvent) => {
|
||||||
|
|
||||||
|
submitEvent.preventDefault();
|
||||||
|
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doUpdateLotStatus",
|
||||||
|
submitEvent.currentTarget,
|
||||||
|
(responseJSON: {
|
||||||
|
success: boolean;
|
||||||
|
errorMessage ? : string;
|
||||||
|
lotStatuses ? : recordTypes.LotStatus[];
|
||||||
|
}) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
|
||||||
|
bulmaJS.alert({
|
||||||
|
message: exports.aliases.lot + " Status Updated Successfully",
|
||||||
|
contextualColorName: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Updating " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteLotStatus = (clickEvent: Event) => {
|
||||||
|
|
||||||
|
const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr");
|
||||||
|
|
||||||
|
const lotStatusId = tableRowElement.dataset.lotStatusId;
|
||||||
|
|
||||||
|
const doDelete = () => {
|
||||||
|
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doDeleteLotStatus", {
|
||||||
|
lotStatusId
|
||||||
|
},
|
||||||
|
(responseJSON: {
|
||||||
|
success: boolean;
|
||||||
|
errorMessage ? : string;
|
||||||
|
lotStatuses ? : recordTypes.LotStatus[];
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
if (responseJSON.success) {
|
||||||
|
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
|
||||||
|
if (lotStatuses.length === 0) {
|
||||||
|
renderLotStatuses();
|
||||||
|
} else {
|
||||||
|
tableRowElement.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
bulmaJS.alert({
|
||||||
|
message: exports.aliases.lot + " Status Deleted Successfully",
|
||||||
|
contextualColorName: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Deleting " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
bulmaJS.confirm({
|
||||||
|
title: "Delete " + exports.aliases.lot + " Status",
|
||||||
|
message: "Are you sure you want to delete this status?<br />" +
|
||||||
|
"Note that no " + exports.aliases.lots.toLowerCase() + " will be removed.",
|
||||||
|
messageIsHtml: true,
|
||||||
|
contextualColorName: "warning",
|
||||||
|
okButton: {
|
||||||
|
text: "Yes, Delete Status",
|
||||||
|
callbackFunction: doDelete
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const moveLotStatusUp = (clickEvent: Event) => {
|
||||||
|
|
||||||
|
const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr");
|
||||||
|
|
||||||
|
const lotStatusId = tableRowElement.dataset.lotStatusId;
|
||||||
|
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doMoveLotStatusUp", {
|
||||||
|
lotStatusId
|
||||||
|
},
|
||||||
|
(responseJSON: {
|
||||||
|
success: boolean;
|
||||||
|
errorMessage ? : string;
|
||||||
|
lotStatuses ? : recordTypes.LotStatus[];
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
if (responseJSON.success) {
|
||||||
|
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
renderLotStatuses();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Moving " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const moveLotStatusDown = (clickEvent: Event) => {
|
||||||
|
|
||||||
|
const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr");
|
||||||
|
|
||||||
|
const lotStatusId = tableRowElement.dataset.lotStatusId;
|
||||||
|
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doMoveLotStatusDown", {
|
||||||
|
lotStatusId
|
||||||
|
},
|
||||||
|
(responseJSON: {
|
||||||
|
success: boolean;
|
||||||
|
errorMessage ? : string;
|
||||||
|
lotStatuses ? : recordTypes.LotStatus[];
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
if (responseJSON.success) {
|
||||||
|
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
renderLotStatuses();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Moving " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderLotStatuses = () => {
|
||||||
|
|
||||||
|
const containerElement = document.querySelector("#container--lotStatuses") as HTMLTableSectionElement;
|
||||||
|
|
||||||
|
if (workOrderTypes.length === 0) {
|
||||||
|
containerElement.innerHTML = "<tr>" +
|
||||||
|
"<td colspan=\"2\">" +
|
||||||
|
"<div class=\"message is-warning\">" +
|
||||||
|
"<p class=\"message-body\">There are no active " + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + " statuses.</p>" +
|
||||||
|
"</div>" +
|
||||||
|
"</td>" +
|
||||||
|
"</tr>";
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
containerElement.innerHTML = "";
|
||||||
|
|
||||||
|
for (const lotStatus of lotStatuses) {
|
||||||
|
|
||||||
|
const tableRowElement = document.createElement("tr");
|
||||||
|
|
||||||
|
tableRowElement.dataset.lotStatusId = lotStatus.lotStatusId.toString();
|
||||||
|
|
||||||
|
tableRowElement.innerHTML = "<td>" +
|
||||||
|
"<form>" +
|
||||||
|
"<input name=\"lotStatusId\" type=\"hidden\" value=\"" + lotStatus.lotStatusId.toString() + "\" />" +
|
||||||
|
("<div class=\"field has-addons\">" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<input class=\"input\" name=\"lotStatus\" type=\"text\" value=\"" + cityssm.escapeHTML(lotStatus.lotStatus) + "\" maxlength=\"100\" required />" +
|
||||||
|
"</div>" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button is-success\" type=\"submit\"><i class=\"fas fa-save\" aria-hidden=\"true\"></i></button>" +
|
||||||
|
"</div>" +
|
||||||
|
"</div>") +
|
||||||
|
"</form>" +
|
||||||
|
"</td>" +
|
||||||
|
"<td class=\"is-nowrap\">" +
|
||||||
|
"<div class=\"field is-grouped\">" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
("<div class=\"field has-addons\">" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button button--moveLotStatusUp\" data-tooltip=\"Move Up\" type=\"button\" aria-label=\"Move Up\"><i class=\"fas fa-arrow-up\" aria-hidden=\"true\"></i></button>" +
|
||||||
|
"</div>" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button button--moveLotStatusDown\" data-tooltip=\"Move Down\" type=\"button\" aria-label=\"Move Down\"><i class=\"fas fa-arrow-down\" aria-hidden=\"true\"></i></button>" +
|
||||||
|
"</div>" +
|
||||||
|
"</div>") +
|
||||||
|
"</div>" +
|
||||||
|
"<div class=\"control\">" +
|
||||||
|
"<button class=\"button is-danger is-light button--deleteLotStatus\" data-tooltip=\"Delete Status\" type=\"button\" aria-label=\"Delete Status\">" +
|
||||||
|
"<i class=\"fas fa-trash\" aria-hidden=\"true\"></i>" +
|
||||||
|
"</button>" +
|
||||||
|
"</div>" +
|
||||||
|
"</div>" +
|
||||||
|
"</td>";
|
||||||
|
|
||||||
|
tableRowElement.querySelector("form").addEventListener("submit", updateLotStatus);
|
||||||
|
tableRowElement.querySelector(".button--moveLotStatusUp").addEventListener("click", moveLotStatusUp);
|
||||||
|
tableRowElement.querySelector(".button--moveLotStatusDown").addEventListener("click", moveLotStatusDown);
|
||||||
|
tableRowElement.querySelector(".button--deleteLotStatus").addEventListener("click", deleteLotStatus);
|
||||||
|
|
||||||
|
containerElement.append(tableRowElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
document.querySelector("#form--addLotStatus").addEventListener("submit", (submitEvent: SubmitEvent) => {
|
||||||
|
|
||||||
|
submitEvent.preventDefault();
|
||||||
|
|
||||||
|
const formElement = submitEvent.currentTarget as HTMLFormElement;
|
||||||
|
|
||||||
|
cityssm.postJSON(urlPrefix + "/admin/doAddLotStatus",
|
||||||
|
formElement,
|
||||||
|
(responseJSON: {
|
||||||
|
success: boolean;
|
||||||
|
errorMessage ? : string;
|
||||||
|
lotStatuses ? : recordTypes.LotStatus[];
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotStatuses = responseJSON.lotStatuses;
|
||||||
|
renderLotStatuses();
|
||||||
|
formElement.reset();
|
||||||
|
formElement.querySelector("input").focus();
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Adding " + exports.aliases.lot + " Status",
|
||||||
|
message: responseJSON.errorMessage,
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
renderLotStatuses();
|
||||||
})();
|
})();
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -13,6 +13,11 @@ import handler_doUpdateWorkOrderType from "../handlers/admin-post/doUpdateWorkOr
|
||||||
import handler_doMoveWorkOrderTypeUp from "../handlers/admin-post/doMoveWorkOrderTypeUp.js";
|
import handler_doMoveWorkOrderTypeUp from "../handlers/admin-post/doMoveWorkOrderTypeUp.js";
|
||||||
import handler_doMoveWorkOrderTypeDown from "../handlers/admin-post/doMoveWorkOrderTypeDown.js";
|
import handler_doMoveWorkOrderTypeDown from "../handlers/admin-post/doMoveWorkOrderTypeDown.js";
|
||||||
import handler_doDeleteWorkOrderType from "../handlers/admin-post/doDeleteWorkOrderType.js";
|
import handler_doDeleteWorkOrderType from "../handlers/admin-post/doDeleteWorkOrderType.js";
|
||||||
|
import handler_doAddLotStatus from "../handlers/admin-post/doAddLotStatus.js";
|
||||||
|
import handler_doUpdateLotStatus from "../handlers/admin-post/doUpdateLotStatus.js";
|
||||||
|
import handler_doMoveLotStatusUp from "../handlers/admin-post/doMoveLotStatusUp.js";
|
||||||
|
import handler_doMoveLotStatusDown from "../handlers/admin-post/doMoveLotStatusDown.js";
|
||||||
|
import handler_doDeleteLotStatus from "../handlers/admin-post/doDeleteLotStatus.js";
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
router.get("/fees", permissionHandlers.adminGetHandler, handler_fees);
|
router.get("/fees", permissionHandlers.adminGetHandler, handler_fees);
|
||||||
router.post("/doAddFeeCategory", permissionHandlers.adminPostHandler, handler_doAddFeeCategory);
|
router.post("/doAddFeeCategory", permissionHandlers.adminPostHandler, handler_doAddFeeCategory);
|
||||||
|
|
@ -27,4 +32,9 @@ router.post("/doUpdateWorkOrderType", permissionHandlers.adminPostHandler, handl
|
||||||
router.post("/doMoveWorkOrderTypeUp", permissionHandlers.adminPostHandler, handler_doMoveWorkOrderTypeUp);
|
router.post("/doMoveWorkOrderTypeUp", permissionHandlers.adminPostHandler, handler_doMoveWorkOrderTypeUp);
|
||||||
router.post("/doMoveWorkOrderTypeDown", permissionHandlers.adminPostHandler, handler_doMoveWorkOrderTypeDown);
|
router.post("/doMoveWorkOrderTypeDown", permissionHandlers.adminPostHandler, handler_doMoveWorkOrderTypeDown);
|
||||||
router.post("/doDeleteWorkOrderType", permissionHandlers.adminPostHandler, handler_doDeleteWorkOrderType);
|
router.post("/doDeleteWorkOrderType", permissionHandlers.adminPostHandler, handler_doDeleteWorkOrderType);
|
||||||
|
router.post("/doAddLotStatus", permissionHandlers.adminPostHandler, handler_doAddLotStatus);
|
||||||
|
router.post("/doUpdateLotStatuse", permissionHandlers.adminPostHandler, handler_doUpdateLotStatus);
|
||||||
|
router.post("/doMoveLotStatusUp", permissionHandlers.adminPostHandler, handler_doMoveLotStatusUp);
|
||||||
|
router.post("/doMoveLotStatusDown", permissionHandlers.adminPostHandler, handler_doMoveLotStatusDown);
|
||||||
|
router.post("/doDeleteLotStatus", permissionHandlers.adminPostHandler, handler_doDeleteLotStatus);
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,12 @@ import handler_doMoveWorkOrderTypeUp from "../handlers/admin-post/doMoveWorkOrde
|
||||||
import handler_doMoveWorkOrderTypeDown from "../handlers/admin-post/doMoveWorkOrderTypeDown.js";
|
import handler_doMoveWorkOrderTypeDown from "../handlers/admin-post/doMoveWorkOrderTypeDown.js";
|
||||||
import handler_doDeleteWorkOrderType from "../handlers/admin-post/doDeleteWorkOrderType.js";
|
import handler_doDeleteWorkOrderType from "../handlers/admin-post/doDeleteWorkOrderType.js";
|
||||||
|
|
||||||
|
import handler_doAddLotStatus from "../handlers/admin-post/doAddLotStatus.js";
|
||||||
|
import handler_doUpdateLotStatus from "../handlers/admin-post/doUpdateLotStatus.js";
|
||||||
|
import handler_doMoveLotStatusUp from "../handlers/admin-post/doMoveLotStatusUp.js";
|
||||||
|
import handler_doMoveLotStatusDown from "../handlers/admin-post/doMoveLotStatusDown.js";
|
||||||
|
import handler_doDeleteLotStatus from "../handlers/admin-post/doDeleteLotStatus.js";
|
||||||
|
|
||||||
|
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
|
|
||||||
|
|
@ -61,6 +67,8 @@ router.get("/tables",
|
||||||
permissionHandlers.adminGetHandler,
|
permissionHandlers.adminGetHandler,
|
||||||
handler_tables);
|
handler_tables);
|
||||||
|
|
||||||
|
// Config Tables - Work Order Types
|
||||||
|
|
||||||
router.post("/doAddWorkOrderType",
|
router.post("/doAddWorkOrderType",
|
||||||
permissionHandlers.adminPostHandler,
|
permissionHandlers.adminPostHandler,
|
||||||
handler_doAddWorkOrderType);
|
handler_doAddWorkOrderType);
|
||||||
|
|
@ -81,5 +89,28 @@ router.post("/doDeleteWorkOrderType",
|
||||||
permissionHandlers.adminPostHandler,
|
permissionHandlers.adminPostHandler,
|
||||||
handler_doDeleteWorkOrderType);
|
handler_doDeleteWorkOrderType);
|
||||||
|
|
||||||
|
// Config Tables - Lot Statuses
|
||||||
|
|
||||||
|
|
||||||
|
router.post("/doAddLotStatus",
|
||||||
|
permissionHandlers.adminPostHandler,
|
||||||
|
handler_doAddLotStatus);
|
||||||
|
|
||||||
|
router.post("/doUpdateLotStatuse",
|
||||||
|
permissionHandlers.adminPostHandler,
|
||||||
|
handler_doUpdateLotStatus);
|
||||||
|
|
||||||
|
router.post("/doMoveLotStatusUp",
|
||||||
|
permissionHandlers.adminPostHandler,
|
||||||
|
handler_doMoveLotStatusUp);
|
||||||
|
|
||||||
|
router.post("/doMoveLotStatusDown",
|
||||||
|
permissionHandlers.adminPostHandler,
|
||||||
|
handler_doMoveLotStatusDown);
|
||||||
|
|
||||||
|
router.post("/doDeleteLotStatus",
|
||||||
|
permissionHandlers.adminPostHandler,
|
||||||
|
handler_doDeleteLotStatus);
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
export {};
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
export {};
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,33 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="is-hidden" id="tab--lotStatuses">
|
<div class="is-hidden" id="tab--lotStatuses">
|
||||||
<h2 class="title is-4"><%= configFunctions.getProperty("aliases.lot") %> Statuses</h2>
|
<h2 class="title is-4"><%= configFunctions.getProperty("aliases.lot") %> Statuses</h2>
|
||||||
|
<table class="table is-striped is-hoverable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= configFunctions.getProperty("aliases.lot") %> Status</th>
|
||||||
|
<th class="has-text-centered has-width-1">Options</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<form id="form--addLotStatus">
|
||||||
|
<div class="field has-addons">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<input class="input" name="lotStatus" type="text" maxlength="100" placeholder="New <%= configFunctions.getProperty("aliases.lot") %> Status" required />
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-success" data-tooltip="Add Status" type="submit" aria-label="Add Status">
|
||||||
|
<i class="fas fa-plus" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tbody id="container--lotStatuses"></tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="is-hidden" id="tab--lotOccupantTypes">
|
<div class="is-hidden" id="tab--lotOccupantTypes">
|
||||||
<h2 class="title is-4"><%= configFunctions.getProperty("aliases.lot") %> <%= configFunctions.getProperty("aliases.occupant") %> Types</h2>
|
<h2 class="title is-4"><%= configFunctions.getProperty("aliases.lot") %> <%= configFunctions.getProperty("aliases.occupant") %> Types</h2>
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<% if (lotOccupancy.lotOccupancyComments.length > 0) { %>
|
<% if (lotOccupancy.lotOccupancyComments.length > 0) { %>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2 class="panel-heading">Comments</h2>
|
<h2 class="panel-heading">Comments</h2>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue