create new lot occupancy
parent
d61419d077
commit
269c18a801
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
export const handler = (request, response) => {
|
||||||
|
const lotOccupancy = {};
|
||||||
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
return response.render("lotOccupancy-edit", {
|
||||||
|
headTitle: "Create a New " + configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Record",
|
||||||
|
lotOccupancy,
|
||||||
|
occupancyTypes,
|
||||||
|
isCreate: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getLotOccupantTypes,
|
||||||
|
getOccupancyTypes
|
||||||
|
} from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
|
const lotOccupancy: recordTypes.LotOccupancy = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
||||||
|
return response.render("lotOccupancy-edit", {
|
||||||
|
headTitle: "Create a New " + configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Record",
|
||||||
|
lotOccupancy,
|
||||||
|
|
||||||
|
occupancyTypes,
|
||||||
|
isCreate: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { addLotOccupancy } from "../../helpers/lotOccupancyDB/addLotOccupancy.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const lotOccupancyId = addLotOccupancy(request.body, request.session);
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
lotOccupancyId
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import {
|
||||||
|
addLotOccupancy
|
||||||
|
} from "../../helpers/lotOccupancyDB/addLotOccupancy.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
|
const lotOccupancyId = addLotOccupancy(request.body, request.session);
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
lotOccupancyId
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { getOccupancyTypeById } from "../../helpers/functions.cache.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const result = getOccupancyTypeById(Number.parseInt(request.body.occupancyTypeId, 10));
|
||||||
|
response.json({
|
||||||
|
occupancyTypeFields: result.occupancyTypeFields
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import type {
|
||||||
|
RequestHandler
|
||||||
|
} from "express";
|
||||||
|
|
||||||
|
import { getOccupancyTypeById } from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
|
const result = getOccupancyTypeById(Number.parseInt(request.body.occupancyTypeId, 10));
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
occupancyTypeFields: result.occupancyTypeFields
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -4,6 +4,8 @@ interface AddLotOccupancyForm {
|
||||||
lotId: string | number;
|
lotId: string | number;
|
||||||
occupancyStartDateString: string;
|
occupancyStartDateString: string;
|
||||||
occupancyEndDateString: string;
|
occupancyEndDateString: string;
|
||||||
|
occupancyTypeFieldIds: string;
|
||||||
|
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
||||||
}
|
}
|
||||||
export declare const addLotOccupancy: (lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession) => number;
|
export declare const addLotOccupancy: (lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession) => number;
|
||||||
export default addLotOccupancy;
|
export default addLotOccupancy;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
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 * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
|
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
|
||||||
export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
|
export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -20,7 +21,19 @@ export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
|
||||||
lotOccupancyForm.lotId), occupancyStartDate, (lotOccupancyForm.occupancyEndDateString === "" ?
|
lotOccupancyForm.lotId), occupancyStartDate, (lotOccupancyForm.occupancyEndDateString === "" ?
|
||||||
undefined :
|
undefined :
|
||||||
dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString)), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString)), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
|
const lotOccupancyId = result.lastInsertRowid;
|
||||||
|
const occupancyTypeFieldIds = lotOccupancyForm.occupancyTypeFieldIds.split(",");
|
||||||
|
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||||
|
const lotOccupancyFieldValue = lotOccupancyForm["lotOccupancyFieldValue_" + occupancyTypeFieldId];
|
||||||
|
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
||||||
|
addOrUpdateLotOccupancyField({
|
||||||
|
lotOccupancyId,
|
||||||
|
occupancyTypeFieldId,
|
||||||
|
lotOccupancyFieldValue
|
||||||
|
}, requestSession, database);
|
||||||
|
}
|
||||||
|
}
|
||||||
database.close();
|
database.close();
|
||||||
return result.lastInsertRowid;
|
return lotOccupancyId;
|
||||||
};
|
};
|
||||||
export default addLotOccupancy;
|
export default addLotOccupancy;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
lotOccupancyDB as databasePath
|
lotOccupancyDB as databasePath
|
||||||
} from "../../data/databasePaths.js";
|
} from "../../data/databasePaths.js";
|
||||||
|
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
addOrUpdateLotOccupancyField
|
||||||
|
} from "./addOrUpdateLotOccupancyField.js";
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,6 +19,9 @@ interface AddLotOccupancyForm {
|
||||||
|
|
||||||
occupancyStartDateString: string;
|
occupancyStartDateString: string;
|
||||||
occupancyEndDateString: string;
|
occupancyEndDateString: string;
|
||||||
|
|
||||||
|
occupancyTypeFieldIds: string;
|
||||||
|
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,9 +58,27 @@ export const addLotOccupancy =
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis);
|
rightNowMillis);
|
||||||
|
|
||||||
|
const lotOccupancyId = result.lastInsertRowid as number;
|
||||||
|
|
||||||
|
const occupancyTypeFieldIds = lotOccupancyForm.occupancyTypeFieldIds.split(",");
|
||||||
|
|
||||||
|
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||||
|
|
||||||
|
const lotOccupancyFieldValue = lotOccupancyForm["lotOccupancyFieldValue_" + occupancyTypeFieldId] as string;
|
||||||
|
|
||||||
|
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
||||||
|
addOrUpdateLotOccupancyField({
|
||||||
|
lotOccupancyId,
|
||||||
|
occupancyTypeFieldId,
|
||||||
|
lotOccupancyFieldValue
|
||||||
|
}, requestSession, database);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return lotOccupancyId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import {
|
import {
|
||||||
addOrUpdateLotOccupancyField
|
addOrUpdateLotOccupancyField
|
||||||
} from "./addOrUpdateLotOccupancyField.js";
|
} from "./addOrUpdateLotOccupancyField.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
deleteLotOccupancyField
|
deleteLotOccupancyField
|
||||||
} from "./deleteLotOccupancyField.js";
|
} from "./deleteLotOccupancyField.js";
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
for (const formInputElement of formInputElements) {
|
for (const formInputElement of formInputElements) {
|
||||||
formInputElement.addEventListener("change", setUnsavedChanges);
|
formInputElement.addEventListener("change", setUnsavedChanges);
|
||||||
}
|
}
|
||||||
if (!isCreate) {
|
|
||||||
const occupancyTypeIdElement = document.querySelector("#lotOccupancy--occupancyTypeId");
|
const occupancyTypeIdElement = document.querySelector("#lotOccupancy--occupancyTypeId");
|
||||||
|
if (isCreate) {
|
||||||
|
const lotOccupancyFieldsContainerElement = document.querySelector("#container--lotOccupancyFields");
|
||||||
|
occupancyTypeIdElement.addEventListener("change", () => {
|
||||||
|
if (occupancyTypeIdElement.value === "") {
|
||||||
|
lotOccupancyFieldsContainerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||||
|
"<p class=\"message-body\">Select the " + exports.aliases.occupancy.toLowerCase() + " type to load the available fields.</p>" +
|
||||||
|
"</div>";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cityssm.postJSON(urlPrefix + "/lotOccupancies/doGetOccupancyTypeFields", {
|
||||||
|
occupancyTypeId: occupancyTypeIdElement.value
|
||||||
|
}, (responseJSON) => {
|
||||||
|
if (responseJSON.occupancyTypeFields.length === 0) {
|
||||||
|
lotOccupancyFieldsContainerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||||
|
"<p class=\"message-body\">There are no additional fields for this " + exports.aliases.occupancy.toLowerCase() + " type.</p>" +
|
||||||
|
"</div>";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lotOccupancyFieldsContainerElement.innerHTML = "";
|
||||||
|
let occupancyTypeFieldIds = "";
|
||||||
|
for (const occupancyTypeField of responseJSON.occupancyTypeFields) {
|
||||||
|
occupancyTypeFieldIds += "," + occupancyTypeField.occupancyTypeFieldId;
|
||||||
|
const fieldElement = document.createElement("div");
|
||||||
|
fieldElement.className = "field";
|
||||||
|
fieldElement.innerHTML = "<label class=\"label\" for=\"lotOccupancy--lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId + "\"></label>" +
|
||||||
|
"<div class=\"control\"></div>";
|
||||||
|
fieldElement.querySelector("label").textContent = occupancyTypeField.occupancyTypeField;
|
||||||
|
const inputElement = document.createElement("input");
|
||||||
|
inputElement.className = "input";
|
||||||
|
inputElement.id = "lotOccupancy--lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId;
|
||||||
|
inputElement.name = "lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId;
|
||||||
|
inputElement.type = "text";
|
||||||
|
inputElement.required = occupancyTypeField.isRequired;
|
||||||
|
inputElement.minLength = occupancyTypeField.minimumLength;
|
||||||
|
inputElement.maxLength = occupancyTypeField.maximumLength;
|
||||||
|
if (occupancyTypeField.pattern && occupancyTypeField.pattern !== "") {
|
||||||
|
inputElement.pattern = occupancyTypeField.pattern;
|
||||||
|
}
|
||||||
|
fieldElement.querySelector(".control").append(inputElement);
|
||||||
|
lotOccupancyFieldsContainerElement.append(fieldElement);
|
||||||
|
}
|
||||||
|
lotOccupancyFieldsContainerElement.insertAdjacentHTML("beforeend", "<input name=\"occupancyTypeFieldIds\" type=\"hidden\" value=\"" + occupancyTypeFieldIds.slice(1) + "\" />");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
const originalOccupancyTypeId = occupancyTypeIdElement.value;
|
const originalOccupancyTypeId = occupancyTypeIdElement.value;
|
||||||
occupancyTypeIdElement.addEventListener("change", () => {
|
occupancyTypeIdElement.addEventListener("change", () => {
|
||||||
if (occupancyTypeIdElement.value !== originalOccupancyTypeId) {
|
if (occupancyTypeIdElement.value !== originalOccupancyTypeId) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ import type {
|
||||||
} from "@cityssm/bulma-webapp-js/src/types";
|
} from "@cityssm/bulma-webapp-js/src/types";
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
BulmaJS, StringConfigProperties
|
BulmaJS,
|
||||||
|
StringConfigProperties
|
||||||
} from "@cityssm/bulma-js/types";
|
} from "@cityssm/bulma-js/types";
|
||||||
|
|
||||||
declare const cityssm: cityssmGlobal;
|
declare const cityssm: cityssmGlobal;
|
||||||
|
|
@ -86,10 +87,78 @@ declare const bulmaJS: BulmaJS;
|
||||||
|
|
||||||
// Occupancy Type
|
// Occupancy Type
|
||||||
|
|
||||||
if (!isCreate) {
|
|
||||||
|
|
||||||
const occupancyTypeIdElement = document.querySelector("#lotOccupancy--occupancyTypeId") as HTMLSelectElement;
|
const occupancyTypeIdElement = document.querySelector("#lotOccupancy--occupancyTypeId") as HTMLSelectElement;
|
||||||
|
|
||||||
|
if (isCreate) {
|
||||||
|
|
||||||
|
const lotOccupancyFieldsContainerElement = document.querySelector("#container--lotOccupancyFields") as HTMLElement;
|
||||||
|
|
||||||
|
occupancyTypeIdElement.addEventListener("change", () => {
|
||||||
|
|
||||||
|
if (occupancyTypeIdElement.value === "") {
|
||||||
|
lotOccupancyFieldsContainerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||||
|
"<p class=\"message-body\">Select the " + exports.aliases.occupancy.toLowerCase() + " type to load the available fields.</p>" +
|
||||||
|
"</div>";
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cityssm.postJSON(urlPrefix + "/lotOccupancies/doGetOccupancyTypeFields", {
|
||||||
|
occupancyTypeId: occupancyTypeIdElement.value
|
||||||
|
},
|
||||||
|
(responseJSON: {
|
||||||
|
occupancyTypeFields: recordTypes.OccupancyTypeField[]
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
if (responseJSON.occupancyTypeFields.length === 0) {
|
||||||
|
lotOccupancyFieldsContainerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||||
|
"<p class=\"message-body\">There are no additional fields for this " + exports.aliases.occupancy.toLowerCase() + " type.</p>" +
|
||||||
|
"</div>";
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
lotOccupancyFieldsContainerElement.innerHTML = "";
|
||||||
|
|
||||||
|
let occupancyTypeFieldIds = "";
|
||||||
|
|
||||||
|
for (const occupancyTypeField of responseJSON.occupancyTypeFields) {
|
||||||
|
|
||||||
|
occupancyTypeFieldIds += "," + occupancyTypeField.occupancyTypeFieldId;
|
||||||
|
|
||||||
|
const fieldElement = document.createElement("div");
|
||||||
|
fieldElement.className = "field";
|
||||||
|
fieldElement.innerHTML = "<label class=\"label\" for=\"lotOccupancy--lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId + "\"></label>" +
|
||||||
|
"<div class=\"control\"></div>";
|
||||||
|
|
||||||
|
fieldElement.querySelector("label").textContent = occupancyTypeField.occupancyTypeField;
|
||||||
|
|
||||||
|
const inputElement = document.createElement("input");
|
||||||
|
inputElement.className = "input";
|
||||||
|
inputElement.id = "lotOccupancy--lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId;
|
||||||
|
inputElement.name = "lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId;
|
||||||
|
inputElement.type = "text";
|
||||||
|
|
||||||
|
inputElement.required = occupancyTypeField.isRequired;
|
||||||
|
inputElement.minLength = occupancyTypeField.minimumLength;
|
||||||
|
inputElement.maxLength = occupancyTypeField.maximumLength;
|
||||||
|
|
||||||
|
if (occupancyTypeField.pattern && occupancyTypeField.pattern !== "") {
|
||||||
|
inputElement.pattern = occupancyTypeField.pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldElement.querySelector(".control").append(inputElement);
|
||||||
|
|
||||||
|
lotOccupancyFieldsContainerElement.append(fieldElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
lotOccupancyFieldsContainerElement.insertAdjacentHTML("beforeend",
|
||||||
|
"<input name=\"occupancyTypeFieldIds\" type=\"hidden\" value=\"" + occupancyTypeFieldIds.slice(1) + "\" />");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
const originalOccupancyTypeId = occupancyTypeIdElement.value;
|
const originalOccupancyTypeId = occupancyTypeIdElement.value;
|
||||||
|
|
||||||
occupancyTypeIdElement.addEventListener("change", () => {
|
occupancyTypeIdElement.addEventListener("change", () => {
|
||||||
|
|
@ -265,7 +334,9 @@ declare const bulmaJS: BulmaJS;
|
||||||
|
|
||||||
cityssm.postJSON(urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant",
|
cityssm.postJSON(urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant",
|
||||||
editFormElement,
|
editFormElement,
|
||||||
(responseJSON: { success: boolean; errorMessage?: string; lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; }) => {
|
(responseJSON: {
|
||||||
|
success: boolean;errorMessage ? : string;lotOccupancyOccupants ? : recordTypes.LotOccupancyOccupant[];
|
||||||
|
}) => {
|
||||||
|
|
||||||
if (responseJSON.success) {
|
if (responseJSON.success) {
|
||||||
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
||||||
|
|
@ -347,7 +418,9 @@ declare const bulmaJS: BulmaJS;
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
lotOccupantIndex
|
lotOccupantIndex
|
||||||
},
|
},
|
||||||
(responseJSON: { success: boolean; errorMessage?: string; lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[];}) => {
|
(responseJSON: {
|
||||||
|
success: boolean;errorMessage ? : string;lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[];
|
||||||
|
}) => {
|
||||||
if (responseJSON.success) {
|
if (responseJSON.success) {
|
||||||
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
||||||
renderLotOccupancyOccupants();
|
renderLotOccupancyOccupants();
|
||||||
|
|
@ -444,7 +517,9 @@ declare const bulmaJS: BulmaJS;
|
||||||
|
|
||||||
cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyOccupant",
|
cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyOccupant",
|
||||||
addFormElement,
|
addFormElement,
|
||||||
(responseJSON: { success: boolean; errorMessage?: string; lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; }) => {
|
(responseJSON: {
|
||||||
|
success: boolean;errorMessage ? : string;lotOccupancyOccupants ? : recordTypes.LotOccupancyOccupant[];
|
||||||
|
}) => {
|
||||||
|
|
||||||
if (responseJSON.success) {
|
if (responseJSON.success) {
|
||||||
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -2,6 +2,9 @@ import { Router } from "express";
|
||||||
import handler_search from "../handlers/lotOccupancies-get/search.js";
|
import handler_search from "../handlers/lotOccupancies-get/search.js";
|
||||||
import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js";
|
import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js";
|
||||||
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
||||||
|
import handler_new from "../handlers/lotOccupancies-get/new.js";
|
||||||
|
import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js";
|
||||||
|
import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCreateLotOccupancy.js";
|
||||||
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
||||||
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
||||||
import handler_doAddLotOccupancyOccupant from "../handlers/lotOccupancies-post/doAddLotOccupancyOccupant.js";
|
import handler_doAddLotOccupancyOccupant from "../handlers/lotOccupancies-post/doAddLotOccupancyOccupant.js";
|
||||||
|
|
@ -11,6 +14,9 @@ import * as permissionHandlers from "../handlers/permissions.js";
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
router.get("/", handler_search);
|
router.get("/", handler_search);
|
||||||
router.post("/doSearchLotOccupancies", handler_doSearchLotOccupancies);
|
router.post("/doSearchLotOccupancies", handler_doSearchLotOccupancies);
|
||||||
|
router.get("/new", permissionHandlers.updateGetHandler, handler_new);
|
||||||
|
router.post("/doGetOccupancyTypeFields", permissionHandlers.updatePostHandler, handler_doGetOccupancyTypeFields);
|
||||||
|
router.post("/doCreateLotOccupancy", permissionHandlers.updatePostHandler, handler_doCreateLotOccupancy);
|
||||||
router.get("/:lotOccupancyId", handler_view);
|
router.get("/:lotOccupancyId", handler_view);
|
||||||
router.get("/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
router.get("/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
||||||
router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);
|
router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSe
|
||||||
|
|
||||||
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
||||||
|
|
||||||
|
import handler_new from "../handlers/lotOccupancies-get/new.js";
|
||||||
|
import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js";
|
||||||
|
import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCreateLotOccupancy.js";
|
||||||
|
|
||||||
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
||||||
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
||||||
|
|
||||||
|
|
@ -28,6 +32,19 @@ router.post("/doSearchLotOccupancies",
|
||||||
handler_doSearchLotOccupancies);
|
handler_doSearchLotOccupancies);
|
||||||
|
|
||||||
|
|
||||||
|
router.get("/new",
|
||||||
|
permissionHandlers.updateGetHandler,
|
||||||
|
handler_new);
|
||||||
|
|
||||||
|
router.post("/doGetOccupancyTypeFields",
|
||||||
|
permissionHandlers.updatePostHandler,
|
||||||
|
handler_doGetOccupancyTypeFields);
|
||||||
|
|
||||||
|
router.post("/doCreateLotOccupancy",
|
||||||
|
permissionHandlers.updatePostHandler,
|
||||||
|
handler_doCreateLotOccupancy);
|
||||||
|
|
||||||
|
|
||||||
router.get("/:lotOccupancyId",
|
router.get("/:lotOccupancyId",
|
||||||
handler_view);
|
handler_view);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,30 +14,34 @@
|
||||||
<span><%= configFunctions.getProperty("aliases.lots") %> <%= configFunctions.getProperty("aliases.occupancies") %></span>
|
<span><%= configFunctions.getProperty("aliases.lots") %> <%= configFunctions.getProperty("aliases.occupancies") %></span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<% if (!isCreate) { %>
|
||||||
<li>
|
<li>
|
||||||
<a href="<%= urlPrefix %>/lotOccupancies/<%= lotOccupancy.lotOccupancyId %>">
|
<a href="<%= urlPrefix %>/lotOccupancies/<%= lotOccupancy.lotOccupancyId %>">
|
||||||
<%= configFunctions.getProperty("aliases.occupancy") %>: <%= lotOccupancy.lotName %>
|
<%= configFunctions.getProperty("aliases.occupancy") %>: <%= lotOccupancy.lotName %>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<% } %>
|
||||||
<li class="is-active">
|
<li class="is-active">
|
||||||
<a href="#" aria-current="page">
|
<a href="#" aria-current="page">
|
||||||
|
<% if (isCreate) { %>
|
||||||
|
Create a New <%= configFunctions.getProperty("aliases.occupancy") %> Record
|
||||||
|
<% } else { %>
|
||||||
Update <%= configFunctions.getProperty("aliases.occupancy") %>
|
Update <%= configFunctions.getProperty("aliases.occupancy") %>
|
||||||
|
<% } %>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<h1 class="title is-1">
|
<h1 class="title is-1">
|
||||||
<%= configFunctions.getProperty("aliases.occupancy") %> Update
|
<% if (isCreate) { %>
|
||||||
|
Create a New <%= configFunctions.getProperty("aliases.occupancy") %> Record
|
||||||
|
<% } else { %>
|
||||||
|
Update <%= configFunctions.getProperty("aliases.occupancy") %>
|
||||||
|
<% } %>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<form id="form--lotOccupancy">
|
<form id="form--lotOccupancy">
|
||||||
<div class="fixed-container is-fixed-bottom-right mx-4 my-4 has-text-right is-hidden-print">
|
|
||||||
<button class="button is-circle is-primary has-tooltip-left" data-tooltip="Update <%= configFunctions.getProperty("aliases.occupancy") %>" type="submit">
|
|
||||||
<i class="fas fa-save" aria-hidden="true"></i>
|
|
||||||
<span class="sr-only">Update <%= configFunctions.getProperty("aliases.occupancy") %></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input id="lotOccupancy--lotOccupancyId" name="lotOccupancyId" type="hidden" value="<%= lotOccupancy.lotOccupancyId %>" />
|
<input id="lotOccupancy--lotOccupancyId" name="lotOccupancyId" type="hidden" value="<%= lotOccupancy.lotOccupancyId %>" />
|
||||||
|
|
||||||
|
|
@ -90,7 +94,7 @@
|
||||||
<div class="control is-expanded">
|
<div class="control is-expanded">
|
||||||
<input class="input has-text-left" id="lotOccupancy--lotName" type="button" value="<%= lotOccupancy.lotName %>"
|
<input class="input has-text-left" id="lotOccupancy--lotName" type="button" value="<%= lotOccupancy.lotName %>"
|
||||||
<%= (configFunctions.getProperty("settings.lotOccupancy.lotIdIsRequired") ? " required" : "") %>
|
<%= (configFunctions.getProperty("settings.lotOccupancy.lotIdIsRequired") ? " required" : "") %>
|
||||||
disabled />
|
<%= (isCreate ? "" : " disabled") %> />
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button class="button is-unlock-field-button" type="button" title="Unlock Field">
|
<button class="button is-unlock-field-button" type="button" title="Unlock Field">
|
||||||
|
|
@ -122,7 +126,7 @@
|
||||||
<% if (isCreate) { %>
|
<% if (isCreate) { %>
|
||||||
<div class="message is-info">
|
<div class="message is-info">
|
||||||
<p class="message-body">
|
<p class="message-body">
|
||||||
Select the <%= configFunctions.getProperty("aliases.occupancy").toLowerCase() %> type to get the available fields.
|
Select the <%= configFunctions.getProperty("aliases.occupancy").toLowerCase() %> type to load the available fields.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% } else if (lotOccupancy.lotOccupancyFields.length === 0) { %>
|
<% } else if (lotOccupancy.lotOccupancyFields.length === 0) { %>
|
||||||
|
|
@ -159,7 +163,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="has-text-right">
|
||||||
|
<button class="button is-primary" type="submit">
|
||||||
|
<span class="icon is-small"><i class="fas fa-save" aria-hidden="true"></i></span>
|
||||||
|
<span>
|
||||||
|
<%= (isCreate ? "Create" : "Update") %>
|
||||||
|
<%= configFunctions.getProperty("aliases.occupancy") %>
|
||||||
|
Record
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<% if (isCreate) { %>
|
<% if (isCreate) { %>
|
||||||
|
|
@ -205,6 +218,7 @@
|
||||||
|
|
||||||
<%- include('_footerA'); -%>
|
<%- include('_footerA'); -%>
|
||||||
|
|
||||||
|
<% if (!isCreate) { %>
|
||||||
<script>
|
<script>
|
||||||
exports.occupantCityDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantCityDefault") %>";
|
exports.occupantCityDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantCityDefault") %>";
|
||||||
exports.occupantProvinceDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantProvinceDefault") %>";
|
exports.occupantProvinceDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantProvinceDefault") %>";
|
||||||
|
|
@ -215,6 +229,7 @@
|
||||||
exports.lotOccupancyFees = <%- JSON.stringify(lotOccupancy.lotOccupancyFees) %>;
|
exports.lotOccupancyFees = <%- JSON.stringify(lotOccupancy.lotOccupancyFees) %>;
|
||||||
exports.lotOccupancyTransactions = <%- JSON.stringify(lotOccupancy.lotOccupancyTransactions) %>;
|
exports.lotOccupancyTransactions = <%- JSON.stringify(lotOccupancy.lotOccupancyTransactions) %>;
|
||||||
</script>
|
</script>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<script src="<%= urlPrefix %>/javascripts/lotOccupancyEdit.min.js"></script>
|
<script src="<%= urlPrefix %>/javascripts/lotOccupancyEdit.min.js"></script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue