add occupant comment

deepsource-autofix-76c6eb20
Dan Gowans 2022-12-07 09:35:40 -05:00
parent f6782b8a34
commit 59fa0ae212
18 changed files with 110 additions and 60 deletions

View File

@ -189,6 +189,7 @@ export const initializeDatabase = () => {
" occupantPhoneNumber varchar(30)," +
" occupantEmailAddress varchar(200)," +
" lotOccupantTypeId integer not null," +
" occupantComment text not null default ''," +
recordColumns +
"," +
" primary key (lotOccupancyId, lotOccupantIndex)," +

View File

@ -256,6 +256,7 @@ export const initializeDatabase = (): boolean => {
" occupantPhoneNumber varchar(30)," +
" occupantEmailAddress varchar(200)," +
" lotOccupantTypeId integer not null," +
" occupantComment text not null default ''," +
recordColumns +
"," +
" primary key (lotOccupancyId, lotOccupantIndex)," +

View File

@ -11,6 +11,7 @@ interface AddLotOccupancyOccupantForm {
occupantPostalCode: string;
occupantPhoneNumber: string;
occupantEmailAddress: string;
occupantComment?: string;
}
export declare const addLotOccupancyOccupant: (lotOccupancyOccupantForm: AddLotOccupancyOccupantForm, requestSession: recordTypes.PartialSession, connectedDatabase?: sqlite.Database) => number;
export default addLotOccupancyOccupant;

View File

@ -21,11 +21,12 @@ export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession
" occupantAddress1, occupantAddress2," +
" occupantCity, occupantProvince, occupantPostalCode," +
" occupantPhoneNumber, occupantEmailAddress," +
" occupantComment," +
" lotOccupantTypeId," +
" recordCreate_userName, recordCreate_timeMillis," +
" recordUpdate_userName, recordUpdate_timeMillis)" +
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.occupantComment || "", lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
if (!connectedDatabase) {
database.close();
}

View File

@ -15,6 +15,7 @@ interface AddLotOccupancyOccupantForm {
occupantPostalCode: string;
occupantPhoneNumber: string;
occupantEmailAddress: string;
occupantComment?: string;
}
export const addLotOccupancyOccupant = (
@ -50,10 +51,11 @@ export const addLotOccupancyOccupant = (
" occupantAddress1, occupantAddress2," +
" occupantCity, occupantProvince, occupantPostalCode," +
" occupantPhoneNumber, occupantEmailAddress," +
" occupantComment," +
" lotOccupantTypeId," +
" recordCreate_userName, recordCreate_timeMillis," +
" recordUpdate_userName, recordUpdate_timeMillis)" +
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
)
.run(
lotOccupancyOccupantForm.lotOccupancyId,
@ -66,6 +68,7 @@ export const addLotOccupancyOccupant = (
lotOccupancyOccupantForm.occupantPostalCode,
lotOccupancyOccupantForm.occupantPhoneNumber,
lotOccupancyOccupantForm.occupantEmailAddress,
lotOccupancyOccupantForm.occupantComment || "",
lotOccupancyOccupantForm.lotOccupantTypeId,
requestSession.user.userName,
rightNowMillis,

View File

@ -9,7 +9,7 @@ export const getLotOccupancyOccupants = (lotOccupancyId, connectedDatabase) => {
.prepare("select o.lotOccupancyId, o.lotOccupantIndex," +
" o.occupantName, o.occupantAddress1, o.occupantAddress2," +
" o.occupantCity, o.occupantProvince, o.occupantPostalCode," +
" o.occupantPhoneNumber, o.occupantEmailAddress," +
" o.occupantPhoneNumber, o.occupantEmailAddress, o.occupantComment," +
" o.lotOccupantTypeId, t.lotOccupantType" +
" from LotOccupancyOccupants o" +
" left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId" +

View File

@ -19,7 +19,7 @@ export const getLotOccupancyOccupants = (
"select o.lotOccupancyId, o.lotOccupantIndex," +
" o.occupantName, o.occupantAddress1, o.occupantAddress2," +
" o.occupantCity, o.occupantProvince, o.occupantPostalCode," +
" o.occupantPhoneNumber, o.occupantEmailAddress," +
" o.occupantPhoneNumber, o.occupantEmailAddress, o.occupantComment," +
" o.lotOccupantTypeId, t.lotOccupantType" +
" from LotOccupancyOccupants o" +
" left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId" +

View File

@ -11,6 +11,7 @@ interface UpdateLotOccupancyOccupantForm {
occupantPostalCode: string;
occupantPhoneNumber: string;
occupantEmailAddress: string;
occupantComment: string;
}
export declare const updateLotOccupancyOccupant: (lotOccupancyOccupantForm: UpdateLotOccupancyOccupantForm, requestSession: recordTypes.PartialSession) => boolean;
export default updateLotOccupancyOccupant;

View File

@ -13,13 +13,14 @@ export const updateLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSess
" occupantPostalCode = ?," +
" occupantPhoneNumber = ?," +
" occupantEmailAddress = ?," +
" occupantComment = ?," +
" lotOccupantTypeId = ?," +
" recordUpdate_userName = ?," +
" recordUpdate_timeMillis = ?" +
" where recordDelete_timeMillis is null" +
" and lotOccupancyId = ?" +
" and lotOccupantIndex = ?")
.run(lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, lotOccupancyOccupantForm.lotOccupancyId, lotOccupancyOccupantForm.lotOccupantIndex);
.run(lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.occupantComment, lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, lotOccupancyOccupantForm.lotOccupancyId, lotOccupancyOccupantForm.lotOccupantIndex);
database.close();
return results.changes > 0;
};

View File

@ -16,6 +16,7 @@ interface UpdateLotOccupancyOccupantForm {
occupantPostalCode: string;
occupantPhoneNumber: string;
occupantEmailAddress: string;
occupantComment: string;
}
export const updateLotOccupancyOccupant = (
@ -37,6 +38,7 @@ export const updateLotOccupancyOccupant = (
" occupantPostalCode = ?," +
" occupantPhoneNumber = ?," +
" occupantEmailAddress = ?," +
" occupantComment = ?," +
" lotOccupantTypeId = ?," +
" recordUpdate_userName = ?," +
" recordUpdate_timeMillis = ?" +
@ -53,6 +55,7 @@ export const updateLotOccupancyOccupant = (
lotOccupancyOccupantForm.occupantPostalCode,
lotOccupancyOccupantForm.occupantPhoneNumber,
lotOccupancyOccupantForm.occupantEmailAddress,
lotOccupancyOccupantForm.occupantComment,
lotOccupancyOccupantForm.lotOccupantTypeId,
requestSession.user.userName,
rightNowMillis,

View File

@ -145,7 +145,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
okButton: {
text: "Yes, Open the Work Order",
callbackFunction: () => {
window.location.href = los.urlPrefix + "/workOrders/" + responseJSON.workOrderId + "/edit";
window.location.href =
los.urlPrefix +
"/workOrders/" +
responseJSON.workOrderId +
"/edit";
}
}
});
@ -522,6 +526,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value = lotOccupancyOccupant.occupantPostalCode;
modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value = lotOccupancyOccupant.occupantPhoneNumber;
modalElement.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value = lotOccupancyOccupant.occupantEmailAddress;
modalElement.querySelector("#lotOccupancyOccupantEdit--occupantComment").value = lotOccupancyOccupant.occupantComment;
},
onshown: (modalElement, closeModalFunction) => {
bulmaJS.toggleHtmlClipped();
@ -584,14 +589,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
tableElement.className = "table is-fullwidth is-striped is-hoverable";
tableElement.innerHTML =
"<thead><tr>" +
"<th>" +
exports.aliases.occupant +
" Type</th>" +
"<th>" +
exports.aliases.occupant +
"</th>" +
("<th>" + exports.aliases.occupant + "</th>") +
"<th>Address</th>" +
"<th>Other Contact</th>" +
"<th>Comment</th>" +
'<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>' +
"</tr></thead>" +
"<tbody></tbody>";
@ -601,11 +602,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
lotOccupancyOccupant.lotOccupantIndex.toString();
tableRowElement.innerHTML =
"<td>" +
cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") +
"<br />" +
'<span class="tag">' +
cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) +
"</span>" +
"</td>" +
("<td>" +
cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "") +
"</td>") +
("<td>" +
(lotOccupancyOccupant.occupantAddress1
? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "<br />"
@ -629,6 +631,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress)
: "") +
"</td>") +
("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment) + "</td>") +
('<td class="is-hidden-print">' +
'<div class="buttons are-small is-justify-content-end">' +
('<button class="button is-primary button--edit" type="button">' +

View File

@ -185,35 +185,43 @@ declare const bulmaJS: BulmaJS;
let createCloseModalFunction: () => void;
const doCreate = (formEvent: SubmitEvent) => {
formEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + "/workOrders/doCreateWorkOrder",
formEvent.currentTarget,
(responseJSON: {success: boolean; errorMessage?: string; workOrderId?: number}) => {
cityssm.postJSON(
los.urlPrefix + "/workOrders/doCreateWorkOrder",
formEvent.currentTarget,
(responseJSON: {
success: boolean;
errorMessage?: string;
workOrderId?: number;
}) => {
if (responseJSON.success) {
createCloseModalFunction();
if (responseJSON.success) {
createCloseModalFunction();
bulmaJS.confirm({
title: "Work Order Created Successfully",
message: "Would you like to open the work order now?",
contextualColorName: "success",
okButton: {
text: "Yes, Open the Work Order",
callbackFunction: () => {
window.location.href = los.urlPrefix + "/workOrders/" + responseJSON.workOrderId + "/edit";
bulmaJS.confirm({
title: "Work Order Created Successfully",
message: "Would you like to open the work order now?",
contextualColorName: "success",
okButton: {
text: "Yes, Open the Work Order",
callbackFunction: () => {
window.location.href =
los.urlPrefix +
"/workOrders/" +
responseJSON.workOrderId +
"/edit";
}
}
}
})
} else {
bulmaJS.alert({
title: "Error Creating Work Order",
message: responseJSON.errorMessage as string,
contextualColorName: "danger"
});
});
} else {
bulmaJS.alert({
title: "Error Creating Work Order",
message: responseJSON.errorMessage as string,
contextualColorName: "danger"
});
}
}
});
);
};
cityssm.openHtmlModal("lotOccupancy-createWorkOrder", {
@ -223,18 +231,22 @@ declare const bulmaJS: BulmaJS;
"#workOrderCreate--lotOccupancyId"
) as HTMLInputElement
).value = lotOccupancyId;
(
modalElement.querySelector(
"#workOrderCreate--workOrderOpenDateString"
) as HTMLInputElement
).value = cityssm.dateToString(new Date());
const workOrderTypeSelectElement = modalElement.querySelector("#workOrderCreate--workOrderTypeId") as HTMLSelectElement;
const workOrderTypeSelectElement = modalElement.querySelector(
"#workOrderCreate--workOrderTypeId"
) as HTMLSelectElement;
for (const workOrderType of (exports.workOrderTypes as recordTypes.WorkOrderType[])) {
for (const workOrderType of exports.workOrderTypes as recordTypes.WorkOrderType[]) {
const optionElement = document.createElement("option");
optionElement.value = (workOrderType.workOrderTypeId as number).toString();
optionElement.value = (
workOrderType.workOrderTypeId as number
).toString();
optionElement.textContent = workOrderType.workOrderType as string;
workOrderTypeSelectElement.append(optionElement);
}
@ -819,6 +831,12 @@ declare const bulmaJS: BulmaJS;
"#lotOccupancyOccupantEdit--occupantEmailAddress"
) as HTMLInputElement
).value = lotOccupancyOccupant.occupantEmailAddress!;
(
modalElement.querySelector(
"#lotOccupancyOccupantEdit--occupantComment"
) as HTMLTextAreaElement
).value = lotOccupancyOccupant.occupantComment!;
},
onshown: (modalElement, closeModalFunction) => {
bulmaJS.toggleHtmlClipped();
@ -907,14 +925,10 @@ declare const bulmaJS: BulmaJS;
tableElement.innerHTML =
"<thead><tr>" +
"<th>" +
exports.aliases.occupant +
" Type</th>" +
"<th>" +
exports.aliases.occupant +
"</th>" +
("<th>" + exports.aliases.occupant + "</th>") +
"<th>Address</th>" +
"<th>Other Contact</th>" +
"<th>Comment</th>" +
'<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>' +
"</tr></thead>" +
"<tbody></tbody>";
@ -926,11 +940,12 @@ declare const bulmaJS: BulmaJS;
tableRowElement.innerHTML =
"<td>" +
cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType as string) +
cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") +
"<br />" +
'<span class="tag">' +
cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType!) +
"</span>" +
"</td>" +
("<td>" +
cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "") +
"</td>") +
("<td>" +
(lotOccupancyOccupant.occupantAddress1
? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "<br />"
@ -954,6 +969,7 @@ declare const bulmaJS: BulmaJS;
? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress)
: "") +
"</td>") +
("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment!) + "</td>") +
('<td class="is-hidden-print">' +
'<div class="buttons are-small is-justify-content-end">' +
('<button class="button is-primary button--edit" type="button">' +

View File

@ -97,6 +97,12 @@
</div>
</div>
</div>
<div class="field">
<label class="label" for="lotOccupancyOccupantAdd--occupantComment">Comment</label>
<div class="control">
<textarea class="textarea" id="lotOccupancyOccupantAdd--occupantComment" name="occupantComment"></textarea>
</div>
</div>
<div class="has-text-right">
<button class="button is-success" type="submit">
<span class="icon"><i class="fas fa-plus" aria-hidden="true"></i></span>
@ -136,7 +142,7 @@
</section>
<footer class="modal-card-foot justify-right">
<button class="button is-close-modal-button" type="button">Close</button>
<button class="button is-close-modal-button" type="button">Cancel</button>
</footer>
</div>
</div>

View File

@ -80,7 +80,12 @@
</div>
</div>
</div>
<div class="field">
<label class="label" for="lotOccupancyOccupantEdit--occupantComment">Comment</label>
<div class="control">
<textarea class="textarea" id="lotOccupancyOccupantEdit--occupantComment" name="occupantComment"></textarea>
</div>
</div>
</form>
</section>
<footer class="modal-card-foot justify-right">

File diff suppressed because one or more lines are too long

View File

@ -154,6 +154,7 @@ export interface LotOccupancyOccupant extends Record {
occupantPostalCode?: string;
occupantPhoneNumber?: string;
occupantEmailAddress?: string;
occupantComment?: string;
lotOccupancyIdCount?: number;
recordUpdate_timeMillisMax?: number;
}

View File

@ -203,6 +203,8 @@ export interface LotOccupancyOccupant extends Record {
occupantPhoneNumber?: string;
occupantEmailAddress?: string;
occupantComment?: string;
lotOccupancyIdCount?: number;
recordUpdate_timeMillisMax?: number;

View File

@ -155,17 +155,19 @@
<table class="table is-fullwidth is-striped is-hoverable">
<thead>
<tr>
<th><%= configFunctions.getProperty("aliases.occupant") %> Type</th>
<th><%= configFunctions.getProperty("aliases.occupant") %></th>
<th>Address</th>
<th>Other Contact</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<% for (const lotOccupancyOccupant of lotOccupancy.lotOccupancyOccupants) { %>
<tr>
<td><%= lotOccupancyOccupant.lotOccupantType %></td>
<td><%= lotOccupancyOccupant.occupantName %></td>
<td>
<%= lotOccupancyOccupant.occupantName %><br />
<span class="tag"><%= lotOccupancyOccupant.lotOccupantType %></span>
</td>
<td>
<% if (lotOccupancyOccupant.occupantAddress1) { %>
<%= lotOccupancyOccupant.occupantAddress1 %><br />
@ -185,6 +187,9 @@
<% } %>
<%= lotOccupancyOccupant.occupantEmailAddress %>
</td>
<td>
<%= lotOccupancyOccupant.occupantComment %>
</td>
</tr>
<% } %>
</tbody>