create new lot occupancy

deepsource-autofix-76c6eb20
Dan Gowans 2022-08-15 13:40:34 -04:00
parent d61419d077
commit 269c18a801
19 changed files with 397 additions and 86 deletions

View File

@ -0,0 +1,3 @@
import type { RequestHandler } from "express";
export declare const handler: RequestHandler;
export default handler;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,3 @@
import type { RequestHandler } from "express";
export declare const handler: RequestHandler;
export default handler;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,3 @@
import type { RequestHandler } from "express";
export declare const handler: RequestHandler;
export default handler;

View File

@ -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;

View File

@ -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;

View File

@ -4,6 +4,8 @@ interface AddLotOccupancyForm {
lotId: string | number;
occupancyStartDateString: string;
occupancyEndDateString: string;
occupancyTypeFieldIds: string;
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
}
export declare const addLotOccupancy: (lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession) => number;
export default addLotOccupancy;

View File

@ -1,6 +1,7 @@
import sqlite from "better-sqlite3";
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
const database = sqlite(databasePath);
const rightNowMillis = Date.now();
@ -20,7 +21,19 @@ export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
lotOccupancyForm.lotId), occupancyStartDate, (lotOccupancyForm.occupancyEndDateString === "" ?
undefined :
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();
return result.lastInsertRowid;
return lotOccupancyId;
};
export default addLotOccupancy;

View File

@ -1,59 +1,85 @@
import sqlite from "better-sqlite3";
import {
lotOccupancyDB as databasePath
lotOccupancyDB as databasePath
} from "../../data/databasePaths.js";
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
import {
addOrUpdateLotOccupancyField
} from "./addOrUpdateLotOccupancyField.js";
import type * as recordTypes from "../../types/recordTypes";
interface AddLotOccupancyForm {
occupancyTypeId: string | number;
lotId: string | number;
occupancyTypeId: string | number;
lotId: string | number;
occupancyStartDateString: string;
occupancyEndDateString: string;
occupancyStartDateString: string;
occupancyEndDateString: string;
occupancyTypeFieldIds: string;
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
}
export const addLotOccupancy =
(lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession): number => {
(lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession): number => {
const database = sqlite(databasePath);
const database = sqlite(databasePath);
const rightNowMillis = Date.now();
const rightNowMillis = Date.now();
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
if (occupancyStartDate <= 0) {
console.error(lotOccupancyForm);
}
if (occupancyStartDate <= 0) {
console.error(lotOccupancyForm);
}
const result = database
.prepare("insert into LotOccupancies (" +
"occupancyTypeId, lotId," +
" occupancyStartDate, occupancyEndDate," +
" recordCreate_userName, recordCreate_timeMillis," +
" recordUpdate_userName, recordUpdate_timeMillis)" +
" values (?, ?, ?, ?, ?, ?, ?, ?)")
.run(lotOccupancyForm.occupancyTypeId,
(lotOccupancyForm.lotId === "" ?
undefined :
lotOccupancyForm.lotId),
occupancyStartDate,
(lotOccupancyForm.occupancyEndDateString === "" ?
undefined :
dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString)),
requestSession.user.userName,
rightNowMillis,
requestSession.user.userName,
rightNowMillis);
const result = database
.prepare("insert into LotOccupancies (" +
"occupancyTypeId, lotId," +
" occupancyStartDate, occupancyEndDate," +
" recordCreate_userName, recordCreate_timeMillis," +
" recordUpdate_userName, recordUpdate_timeMillis)" +
" values (?, ?, ?, ?, ?, ?, ?, ?)")
.run(lotOccupancyForm.occupancyTypeId,
(lotOccupancyForm.lotId === "" ?
undefined :
lotOccupancyForm.lotId),
occupancyStartDate,
(lotOccupancyForm.occupancyEndDateString === "" ?
undefined :
dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString)),
requestSession.user.userName,
rightNowMillis,
requestSession.user.userName,
rightNowMillis);
database.close();
const lotOccupancyId = result.lastInsertRowid as number;
return 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();
return lotOccupancyId;
};
export default addLotOccupancy;

View File

@ -11,6 +11,7 @@ import {
import {
addOrUpdateLotOccupancyField
} from "./addOrUpdateLotOccupancyField.js";
import {
deleteLotOccupancyField
} from "./deleteLotOccupancyField.js";

View File

@ -46,8 +46,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
for (const formInputElement of formInputElements) {
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;
occupancyTypeIdElement.addEventListener("change", () => {
if (occupancyTypeIdElement.value !== originalOccupancyTypeId) {

View File

@ -8,7 +8,8 @@ import type {
} from "@cityssm/bulma-webapp-js/src/types";
import type {
BulmaJS, StringConfigProperties
BulmaJS,
StringConfigProperties
} from "@cityssm/bulma-js/types";
declare const cityssm: cityssmGlobal;
@ -86,9 +87,77 @@ declare const bulmaJS: BulmaJS;
// 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;
@ -264,8 +333,10 @@ declare const bulmaJS: BulmaJS;
submitEvent.preventDefault();
cityssm.postJSON(urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant",
editFormElement,
(responseJSON: { success: boolean; errorMessage?: string; lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; }) => {
editFormElement,
(responseJSON: {
success: boolean;errorMessage ? : string;lotOccupancyOccupants ? : recordTypes.LotOccupancyOccupant[];
}) => {
if (responseJSON.success) {
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
@ -344,21 +415,23 @@ declare const bulmaJS: BulmaJS;
const doDelete = () => {
cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", {
lotOccupancyId,
lotOccupantIndex
},
(responseJSON: { success: boolean; errorMessage?: string; lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[];}) => {
if (responseJSON.success) {
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
renderLotOccupancyOccupants();
} else {
bulmaJS.alert({
title: "Error Removing " + exports.aliases.occupant,
message: responseJSON.errorMessage,
contextualColorName: "danger"
});
}
});
lotOccupancyId,
lotOccupantIndex
},
(responseJSON: {
success: boolean;errorMessage ? : string;lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[];
}) => {
if (responseJSON.success) {
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
renderLotOccupancyOccupants();
} else {
bulmaJS.alert({
title: "Error Removing " + exports.aliases.occupant,
message: responseJSON.errorMessage,
contextualColorName: "danger"
});
}
});
};
bulmaJS.confirm({
@ -444,7 +517,9 @@ declare const bulmaJS: BulmaJS;
cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyOccupant",
addFormElement,
(responseJSON: { success: boolean; errorMessage?: string; lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; }) => {
(responseJSON: {
success: boolean;errorMessage ? : string;lotOccupancyOccupants ? : recordTypes.LotOccupancyOccupant[];
}) => {
if (responseJSON.success) {
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,9 @@ import { Router } from "express";
import handler_search from "../handlers/lotOccupancies-get/search.js";
import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.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_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.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();
router.get("/", handler_search);
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/edit", permissionHandlers.updateGetHandler, handler_edit);
router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);

View File

@ -7,6 +7,10 @@ import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSe
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_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
@ -28,6 +32,19 @@ 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);

View File

@ -14,30 +14,34 @@
<span><%= configFunctions.getProperty("aliases.lots") %> <%= configFunctions.getProperty("aliases.occupancies") %></span>
</a>
</li>
<% if (!isCreate) { %>
<li>
<a href="<%= urlPrefix %>/lotOccupancies/<%= lotOccupancy.lotOccupancyId %>">
<%= configFunctions.getProperty("aliases.occupancy") %>: <%= lotOccupancy.lotName %>
</a>
</li>
<% } %>
<li class="is-active">
<a href="#" aria-current="page">
Update <%= configFunctions.getProperty("aliases.occupancy") %>
<% if (isCreate) { %>
Create a New <%= configFunctions.getProperty("aliases.occupancy") %> Record
<% } else { %>
Update <%= configFunctions.getProperty("aliases.occupancy") %>
<% } %>
</a>
</li>
</ul>
</nav>
<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>
<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 %>" />
@ -52,11 +56,11 @@
<select id="lotOccupancy--occupancyTypeId" name="occupancyTypeId" required>
<% if (isCreate) { %>
<option value="">(No Type)</option>
<% } %>
<% let typeIsFound = false; %>
<% for (const occupancyType of occupancyTypes) { %>
<% } %>
<% let typeIsFound = false; %>
<% for (const occupancyType of occupancyTypes) { %>
<%
if (lotOccupancy.occupancyTypeId === occupancyType.occupancyTypeId) {
if (lotOccupancy.occupancyTypeId === occupancyType.occupancyTypeId) {
typeIsFound = true;
}
%>
@ -70,10 +74,10 @@
<option value="<%= lotOccupancy.occupancyTypeId %>" selected>
<%= lotOccupancy.occupancyType %>
</option>
<% } %>
</select>
</div>
<% } %>
</select>
</div>
</div>
<div class="control">
<button class="button is-unlock-field-button" type="button" title="Unlock Field">
<i class="fas fa-unlock" aria-hidden="true"></i>
@ -90,7 +94,7 @@
<div class="control is-expanded">
<input class="input has-text-left" id="lotOccupancy--lotName" type="button" value="<%= lotOccupancy.lotName %>"
<%= (configFunctions.getProperty("settings.lotOccupancy.lotIdIsRequired") ? " required" : "") %>
disabled />
<%= (isCreate ? "" : " disabled") %> />
</div>
<div class="control">
<button class="button is-unlock-field-button" type="button" title="Unlock Field">
@ -122,7 +126,7 @@
<% if (isCreate) { %>
<div class="message is-info">
<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>
</div>
<% } else if (lotOccupancy.lotOccupancyFields.length === 0) { %>
@ -159,7 +163,16 @@
</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>
<% if (isCreate) { %>
@ -205,16 +218,18 @@
<%- include('_footerA'); -%>
<script>
exports.occupantCityDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantCityDefault") %>";
exports.occupantProvinceDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantProvinceDefault") %>";
exports.lotOccupantTypes = <%- JSON.stringify(lotOccupantTypes) %>;
<% if (!isCreate) { %>
<script>
exports.occupantCityDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantCityDefault") %>";
exports.occupantProvinceDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantProvinceDefault") %>";
exports.lotOccupantTypes = <%- JSON.stringify(lotOccupantTypes) %>;
exports.lotOccupancyOccupants = <%- JSON.stringify(lotOccupancy.lotOccupancyOccupants) %>;
exports.lotOccupancyComments = <%- JSON.stringify(lotOccupancy.lotOccupancyComments) %>;
exports.lotOccupancyFees = <%- JSON.stringify(lotOccupancy.lotOccupancyFees) %>;
exports.lotOccupancyTransactions = <%- JSON.stringify(lotOccupancy.lotOccupancyTransactions) %>;
</script>
exports.lotOccupancyOccupants = <%- JSON.stringify(lotOccupancy.lotOccupancyOccupants) %>;
exports.lotOccupancyComments = <%- JSON.stringify(lotOccupancy.lotOccupancyComments) %>;
exports.lotOccupancyFees = <%- JSON.stringify(lotOccupancy.lotOccupancyFees) %>;
exports.lotOccupancyTransactions = <%- JSON.stringify(lotOccupancy.lotOccupancyTransactions) %>;
</script>
<% } %>
<script src="<%= urlPrefix %>/javascripts/lotOccupancyEdit.min.js"></script>