lot comments
parent
91e6a23fbb
commit
817c32502c
|
|
@ -1,6 +0,0 @@
|
|||
import * as configFunctions from "../../helpers/functions.config.js";
|
||||
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
||||
const __dirname = ".";
|
||||
export const handler = async (request, response, next) => {
|
||||
};
|
||||
export default handler;
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
import type { RequestHandler } from "express";
|
||||
|
||||
import path from "path";
|
||||
import * as ejs from "ejs";
|
||||
|
||||
import * as configFunctions from "../../helpers/functions.config.js";
|
||||
|
||||
// import convertHTMLToPDF from "pdf-puppeteer";
|
||||
|
||||
|
||||
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
||||
|
||||
const __dirname = ".";
|
||||
|
||||
|
||||
export const handler: RequestHandler = async(request, response, next) => {
|
||||
|
||||
/*
|
||||
const reportPath = path.join(__dirname, "reports", printTemplate);
|
||||
|
||||
const pdfCallbackFunction = (pdf: Buffer) => {
|
||||
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;" +
|
||||
" filename=licence-" + licenceID.toString() + "-" + licence.recordUpdate_timeMillis.toString() + ".pdf"
|
||||
);
|
||||
|
||||
response.setHeader("Content-Type", "application/pdf");
|
||||
|
||||
response.send(pdf);
|
||||
};
|
||||
|
||||
await ejs.renderFile(
|
||||
reportPath, {
|
||||
configFunctions,
|
||||
licence,
|
||||
licenceTicketTypeSummary,
|
||||
organization
|
||||
}, {},
|
||||
async(ejsError, ejsData) => {
|
||||
|
||||
if (ejsError) {
|
||||
return next(ejsError);
|
||||
}
|
||||
|
||||
await convertHTMLToPDF(ejsData, pdfCallbackFunction, {
|
||||
format: "letter",
|
||||
printBackground: true,
|
||||
preferCSSPageSize: true
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
);
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { addLotComment } from "../../helpers/lotOccupancyDB/addLotComment.js";
|
||||
import { getLotComments } from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||
export const handler = async (request, response) => {
|
||||
addLotComment(request.body, request.session);
|
||||
const lotComments = getLotComments(request.body.lotId);
|
||||
response.json({
|
||||
success: true,
|
||||
lotComments
|
||||
});
|
||||
};
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import type {
|
||||
RequestHandler
|
||||
} from "express";
|
||||
|
||||
import {
|
||||
addLotComment
|
||||
} from "../../helpers/lotOccupancyDB/addLotComment.js";
|
||||
|
||||
import {
|
||||
getLotComments
|
||||
} from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||
|
||||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
|
||||
addLotComment(request.body, request.session);
|
||||
|
||||
const lotComments = getLotComments(request.body.lotId);
|
||||
|
||||
response.json({
|
||||
success: true,
|
||||
lotComments
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
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 { deleteLotComment } from "../../helpers/lotOccupancyDB/deleteLotComment.js";
|
||||
import { getLotComments } from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = deleteLotComment(request.body.lotCommentId, request.session);
|
||||
const lotComments = getLotComments(request.body.lotId);
|
||||
response.json({
|
||||
success,
|
||||
lotComments
|
||||
});
|
||||
};
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import type {
|
||||
RequestHandler
|
||||
} from "express";
|
||||
|
||||
import {
|
||||
deleteLotComment
|
||||
} from "../../helpers/lotOccupancyDB/deleteLotComment.js";
|
||||
|
||||
import {
|
||||
getLotComments
|
||||
} from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||
|
||||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
|
||||
const success = deleteLotComment(request.body.lotCommentId, request.session);
|
||||
|
||||
const lotComments = getLotComments(request.body.lotId);
|
||||
|
||||
response.json({
|
||||
success,
|
||||
lotComments
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
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 { updateLotComment } from "../../helpers/lotOccupancyDB/updateLotComment.js";
|
||||
import { getLotComments } from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = updateLotComment(request.body, request.session);
|
||||
const lotComments = getLotComments(request.body.lotId);
|
||||
response.json({
|
||||
success,
|
||||
lotComments
|
||||
});
|
||||
};
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import type {
|
||||
RequestHandler
|
||||
} from "express";
|
||||
|
||||
import {
|
||||
updateLotComment
|
||||
} from "../../helpers/lotOccupancyDB/updateLotComment.js";
|
||||
|
||||
import {
|
||||
getLotComments
|
||||
} from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||
|
||||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
|
||||
const success = updateLotComment(request.body, request.session);
|
||||
|
||||
const lotComments = getLotComments(request.body.lotId);
|
||||
|
||||
response.json({
|
||||
success,
|
||||
lotComments
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
export declare const deleteLotComment: (lotCommentId: number | string, requestSession: recordTypes.PartialSession) => boolean;
|
||||
export default deleteLotComment;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
export const deleteLotComment = (lotCommentId, requestSession) => {
|
||||
const database = sqlite(databasePath);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare("update LotComments" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotCommentId = ?")
|
||||
.run(requestSession.user.userName, rightNowMillis, lotCommentId);
|
||||
database.close();
|
||||
return (result.changes > 0);
|
||||
};
|
||||
export default deleteLotComment;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
export const deleteLotComment =
|
||||
(lotCommentId: number | string,
|
||||
requestSession: recordTypes.PartialSession): boolean => {
|
||||
|
||||
const database = sqlite(databasePath);
|
||||
|
||||
const rightNowMillis = Date.now();
|
||||
|
||||
const result = database
|
||||
.prepare("update LotComments" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotCommentId = ?")
|
||||
.run(requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
lotCommentId);
|
||||
|
||||
database.close();
|
||||
|
||||
return (result.changes > 0);
|
||||
};
|
||||
|
||||
|
||||
export default deleteLotComment;
|
||||
|
|
@ -11,7 +11,8 @@ export const getLotComments = (lotId, connectedDatabase) => {
|
|||
.prepare("select lotCommentId," +
|
||||
" lotCommentDate, userFn_dateIntegerToString(lotCommentDate) as lotCommentDateString," +
|
||||
" lotCommentTime, userFn_timeIntegerToString(lotCommentTime) as lotCommentTimeString," +
|
||||
" lotComment" +
|
||||
" lotComment," +
|
||||
" recordCreate_userName, recordUpdate_userName" +
|
||||
" from LotComments" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and lotId = ?" +
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ export const getLotComments = (lotId: number | string, connectedDatabase ? : sql
|
|||
.prepare("select lotCommentId," +
|
||||
" lotCommentDate, userFn_dateIntegerToString(lotCommentDate) as lotCommentDateString," +
|
||||
" lotCommentTime, userFn_timeIntegerToString(lotCommentTime) as lotCommentTimeString," +
|
||||
" lotComment" +
|
||||
" lotComment," +
|
||||
" recordCreate_userName, recordUpdate_userName" +
|
||||
" from LotComments" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and lotId = ?" +
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
interface UpdateLotCommentForm {
|
||||
lotCommentId: string | number;
|
||||
lotCommentDateString: string;
|
||||
lotCommentTimeString: string;
|
||||
lotComment: string;
|
||||
}
|
||||
export declare const updateLotComment: (commentForm: UpdateLotCommentForm, requestSession: recordTypes.PartialSession) => boolean;
|
||||
export default updateLotComment;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { dateStringToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
export const updateLotComment = (commentForm, requestSession) => {
|
||||
const rightNowMillis = Date.now();
|
||||
const database = sqlite(databasePath);
|
||||
const result = database
|
||||
.prepare("update LotComments" +
|
||||
" set lotCommentDate = ?," +
|
||||
" lotCommentTime = ?," +
|
||||
" lotComment = ?," +
|
||||
" recordUpdate_userName = ?," +
|
||||
" recordUpdate_timeMillis = ?" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and lotCommentId = ?")
|
||||
.run(dateStringToInteger(commentForm.lotCommentDateString), dateStringToInteger(commentForm.lotCommentTimeString), commentForm.lotComment, requestSession.user.userName, rightNowMillis, commentForm.lotCommentId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
};
|
||||
export default updateLotComment;
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
dateStringToInteger
|
||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
interface UpdateLotCommentForm {
|
||||
lotCommentId: string | number;
|
||||
lotCommentDateString: string;
|
||||
lotCommentTimeString: string;
|
||||
lotComment: string;
|
||||
}
|
||||
|
||||
|
||||
export const updateLotComment =
|
||||
(commentForm: UpdateLotCommentForm, requestSession: recordTypes.PartialSession): boolean => {
|
||||
|
||||
const rightNowMillis = Date.now();
|
||||
|
||||
const database = sqlite(databasePath);
|
||||
|
||||
const result = database
|
||||
.prepare("update LotComments" +
|
||||
" set lotCommentDate = ?," +
|
||||
" lotCommentTime = ?," +
|
||||
" lotComment = ?," +
|
||||
" recordUpdate_userName = ?," +
|
||||
" recordUpdate_timeMillis = ?" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and lotCommentId = ?")
|
||||
.run(dateStringToInteger(commentForm.lotCommentDateString),
|
||||
dateStringToInteger(commentForm.lotCommentTimeString),
|
||||
commentForm.lotComment,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
commentForm.lotCommentId);
|
||||
|
||||
database.close();
|
||||
|
||||
return result.changes > 0;
|
||||
};
|
||||
|
||||
|
||||
export default updateLotComment;
|
||||
|
|
@ -32,13 +32,124 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
formElement.addEventListener("submit", updateLot);
|
||||
los.initializeUnlockFieldButtons(formElement);
|
||||
let lotComments = exports.lotComments;
|
||||
const openEditLotComment = (clickEvent) => {
|
||||
const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotCommentId, 10);
|
||||
const lotComment = lotComments.find((currentLotComment) => {
|
||||
return currentLotComment.lotCommentId === lotCommentId;
|
||||
});
|
||||
let editFormElement;
|
||||
let editCloseModalFunction;
|
||||
const editComment = (submitEvent) => {
|
||||
submitEvent.preventDefault();
|
||||
cityssm.postJSON(urlPrefix + "/lots/doUpdateLotComment", editFormElement, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
lotComments = responseJSON.lotComments;
|
||||
editCloseModalFunction();
|
||||
renderLotComments();
|
||||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Updating Comment",
|
||||
message: responseJSON.errorMessage,
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
cityssm.openHtmlModal("lot-editComment", {
|
||||
onshow: (modalElement) => {
|
||||
los.populateAliases(modalElement);
|
||||
modalElement.querySelector("#lotCommentEdit--lotId").value = lotId;
|
||||
modalElement.querySelector("#lotCommentEdit--lotCommentId").value = lotCommentId.toString();
|
||||
modalElement.querySelector("#lotCommentEdit--lotComment").value = lotComment.lotComment;
|
||||
modalElement.querySelector("#lotCommentEdit--lotCommentDateString").value = lotComment.lotCommentDateString;
|
||||
modalElement.querySelector("#lotCommentEdit--lotCommentTimeString").value = lotComment.lotCommentTimeString;
|
||||
},
|
||||
onshown: (modalElement, closeModalFunction) => {
|
||||
bulmaJS.toggleHtmlClipped();
|
||||
modalElement.querySelector("#lotCommentEdit--lotComment").focus();
|
||||
editFormElement = modalElement.querySelector("form");
|
||||
editFormElement.addEventListener("submit", editComment);
|
||||
editCloseModalFunction = closeModalFunction;
|
||||
},
|
||||
onremoved: () => {
|
||||
bulmaJS.toggleHtmlClipped();
|
||||
}
|
||||
});
|
||||
};
|
||||
const deleteLotComment = (clickEvent) => {
|
||||
const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotCommentId, 10);
|
||||
const doDelete = () => {
|
||||
cityssm.postJSON(urlPrefix + "/lots/doDeleteLotComment", {
|
||||
lotId,
|
||||
lotCommentId
|
||||
}, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
lotComments = responseJSON.lotComments;
|
||||
renderLotComments();
|
||||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Removing Comment",
|
||||
message: responseJSON.errorMessage,
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
bulmaJS.confirm({
|
||||
title: "Remove Comment?",
|
||||
message: "Are you sure you want to remove this comment?",
|
||||
okButton: {
|
||||
text: "Yes, Remove Comment",
|
||||
callbackFunction: doDelete
|
||||
},
|
||||
contextualColorName: "warning"
|
||||
});
|
||||
};
|
||||
const renderLotComments = () => {
|
||||
const lotCommentsContainerElement = document.querySelector("#container--lotComments");
|
||||
const containerElement = document.querySelector("#container--lotComments");
|
||||
if (lotComments.length === 0) {
|
||||
lotCommentsContainerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||
containerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||
"<p class=\"message-body\">There are no comments to display.</p>" +
|
||||
"</div>";
|
||||
return;
|
||||
}
|
||||
const tableElement = document.createElement("table");
|
||||
tableElement.className = "table is-fullwidth is-striped is-hoverable";
|
||||
tableElement.innerHTML = "<thead><tr>" +
|
||||
"<th>Commentor</th>" +
|
||||
"<th>Comment Date</th>" +
|
||||
"<th>Comment</th>" +
|
||||
"<th class=\"is-hidden-print\"><span class=\"is-sr-only\">Options</span></th>" +
|
||||
"</tr></thead>" +
|
||||
"<tbody></tbody>";
|
||||
for (const lotComment of lotComments) {
|
||||
const tableRowElement = document.createElement("tr");
|
||||
tableRowElement.dataset.lotCommentId = lotComment.lotCommentId.toString();
|
||||
tableRowElement.innerHTML = "<td>" + cityssm.escapeHTML(lotComment.recordCreate_userName) + "</td>" +
|
||||
"<td>" +
|
||||
lotComment.lotCommentDateString +
|
||||
(lotComment.lotCommentTime === 0 ? "" : " " + lotComment.lotCommentTimeString) +
|
||||
"</td>" +
|
||||
"<td>" + cityssm.escapeHTML(lotComment.lotComment) + "</td>" +
|
||||
("<td class=\"is-hidden-print\">" +
|
||||
"<div class=\"buttons are-small is-justify-content-end\">" +
|
||||
("<button class=\"button is-primary button--edit\" type=\"button\">" +
|
||||
"<span class=\"icon is-small\"><i class=\"fas fa-pencil-alt\" aria-hidden=\"true\"></i></span>" +
|
||||
" <span>Edit</span>" +
|
||||
"</button>") +
|
||||
("<button class=\"button is-light is-danger button--delete\" data-tooltip=\"Delete Comment\" type=\"button\" aria-label=\"Delete\">" +
|
||||
"<i class=\"fas fa-trash\" aria-hidden=\"true\"></i>" +
|
||||
"</button>") +
|
||||
"</div>" +
|
||||
"</td>");
|
||||
tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotComment);
|
||||
tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotComment);
|
||||
tableElement.querySelector("tbody").append(tableRowElement);
|
||||
}
|
||||
containerElement.innerHTML = "";
|
||||
containerElement.append(tableElement);
|
||||
};
|
||||
const openAddCommentModal = () => {
|
||||
let addCommentCloseModalFunction;
|
||||
|
|
@ -52,7 +163,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
}
|
||||
});
|
||||
};
|
||||
cityssm.openHtmlModal("lotComment-add", {
|
||||
cityssm.openHtmlModal("lot-addComment", {
|
||||
onshow(modalElement) {
|
||||
los.populateAliases(modalElement);
|
||||
modalElement.querySelector("#lotCommentAdd--lotId").value = lotId;
|
||||
|
|
|
|||
|
|
@ -63,15 +63,163 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
let lotComments: recordTypes.LotComment[] = exports.lotComments;
|
||||
|
||||
|
||||
const openEditLotComment = (clickEvent: Event) => {
|
||||
|
||||
const lotCommentId = Number.parseInt((clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotCommentId, 10);
|
||||
|
||||
const lotComment = lotComments.find((currentLotComment) => {
|
||||
return currentLotComment.lotCommentId === lotCommentId;
|
||||
});
|
||||
|
||||
let editFormElement: HTMLFormElement;
|
||||
let editCloseModalFunction: () => void;
|
||||
|
||||
const editComment = (submitEvent: SubmitEvent) => {
|
||||
|
||||
submitEvent.preventDefault();
|
||||
|
||||
cityssm.postJSON(urlPrefix + "/lots/doUpdateLotComment",
|
||||
editFormElement,
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
errorMessage ? : string;
|
||||
lotComments ? : recordTypes.LotComment[];
|
||||
}) => {
|
||||
|
||||
if (responseJSON.success) {
|
||||
lotComments = responseJSON.lotComments;
|
||||
editCloseModalFunction();
|
||||
renderLotComments();
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Updating Comment",
|
||||
message: responseJSON.errorMessage,
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
cityssm.openHtmlModal("lot-editComment", {
|
||||
onshow: (modalElement) => {
|
||||
los.populateAliases(modalElement);
|
||||
|
||||
(modalElement.querySelector("#lotCommentEdit--lotId") as HTMLInputElement).value = lotId;
|
||||
(modalElement.querySelector("#lotCommentEdit--lotCommentId") as HTMLInputElement).value = lotCommentId.toString();
|
||||
|
||||
(modalElement.querySelector("#lotCommentEdit--lotComment") as HTMLInputElement).value = lotComment.lotComment;
|
||||
(modalElement.querySelector("#lotCommentEdit--lotCommentDateString") as HTMLInputElement).value = lotComment.lotCommentDateString;
|
||||
(modalElement.querySelector("#lotCommentEdit--lotCommentTimeString") as HTMLInputElement).value = lotComment.lotCommentTimeString;
|
||||
},
|
||||
onshown: (modalElement, closeModalFunction) => {
|
||||
|
||||
bulmaJS.toggleHtmlClipped();
|
||||
|
||||
(modalElement.querySelector("#lotCommentEdit--lotComment") as HTMLTextAreaElement).focus();
|
||||
|
||||
editFormElement = modalElement.querySelector("form");
|
||||
editFormElement.addEventListener("submit", editComment);
|
||||
|
||||
editCloseModalFunction = closeModalFunction;
|
||||
},
|
||||
onremoved: () => {
|
||||
bulmaJS.toggleHtmlClipped();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const deleteLotComment = (clickEvent: Event) => {
|
||||
|
||||
const lotCommentId = Number.parseInt((clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotCommentId, 10);
|
||||
|
||||
const doDelete = () => {
|
||||
cityssm.postJSON(urlPrefix + "/lots/doDeleteLotComment", {
|
||||
lotId,
|
||||
lotCommentId
|
||||
},
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
errorMessage ? : string;
|
||||
lotComments: recordTypes.LotComment[];
|
||||
}) => {
|
||||
if (responseJSON.success) {
|
||||
lotComments = responseJSON.lotComments;
|
||||
renderLotComments();
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Removing Comment",
|
||||
message: responseJSON.errorMessage,
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
bulmaJS.confirm({
|
||||
title: "Remove Comment?",
|
||||
message: "Are you sure you want to remove this comment?",
|
||||
okButton: {
|
||||
text: "Yes, Remove Comment",
|
||||
callbackFunction: doDelete
|
||||
},
|
||||
contextualColorName: "warning"
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const renderLotComments = () => {
|
||||
|
||||
const lotCommentsContainerElement = document.querySelector("#container--lotComments") as HTMLElement;
|
||||
const containerElement = document.querySelector("#container--lotComments") as HTMLElement;
|
||||
|
||||
if (lotComments.length === 0) {
|
||||
lotCommentsContainerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||
containerElement.innerHTML = "<div class=\"message is-info\">" +
|
||||
"<p class=\"message-body\">There are no comments to display.</p>" +
|
||||
"</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
const tableElement = document.createElement("table");
|
||||
tableElement.className = "table is-fullwidth is-striped is-hoverable";
|
||||
tableElement.innerHTML = "<thead><tr>" +
|
||||
"<th>Commentor</th>" +
|
||||
"<th>Comment Date</th>" +
|
||||
"<th>Comment</th>" +
|
||||
"<th class=\"is-hidden-print\"><span class=\"is-sr-only\">Options</span></th>" +
|
||||
"</tr></thead>" +
|
||||
"<tbody></tbody>";
|
||||
|
||||
for (const lotComment of lotComments) {
|
||||
|
||||
const tableRowElement = document.createElement("tr");
|
||||
tableRowElement.dataset.lotCommentId = lotComment.lotCommentId.toString();
|
||||
|
||||
tableRowElement.innerHTML = "<td>" + cityssm.escapeHTML(lotComment.recordCreate_userName) + "</td>" +
|
||||
"<td>" +
|
||||
lotComment.lotCommentDateString +
|
||||
(lotComment.lotCommentTime === 0 ? "" : " " + lotComment.lotCommentTimeString) +
|
||||
"</td>" +
|
||||
"<td>" + cityssm.escapeHTML(lotComment.lotComment) + "</td>" +
|
||||
("<td class=\"is-hidden-print\">" +
|
||||
"<div class=\"buttons are-small is-justify-content-end\">" +
|
||||
("<button class=\"button is-primary button--edit\" type=\"button\">" +
|
||||
"<span class=\"icon is-small\"><i class=\"fas fa-pencil-alt\" aria-hidden=\"true\"></i></span>" +
|
||||
" <span>Edit</span>" +
|
||||
"</button>") +
|
||||
("<button class=\"button is-light is-danger button--delete\" data-tooltip=\"Delete Comment\" type=\"button\" aria-label=\"Delete\">" +
|
||||
"<i class=\"fas fa-trash\" aria-hidden=\"true\"></i>" +
|
||||
"</button>") +
|
||||
"</div>" +
|
||||
"</td>");
|
||||
|
||||
tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotComment);
|
||||
tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotComment);
|
||||
|
||||
tableElement.querySelector("tbody").append(tableRowElement);
|
||||
}
|
||||
|
||||
containerElement.innerHTML = "";
|
||||
containerElement.append(tableElement);
|
||||
};
|
||||
|
||||
const openAddCommentModal = () => {
|
||||
|
|
@ -93,7 +241,7 @@ declare const bulmaJS: BulmaJS;
|
|||
});
|
||||
};
|
||||
|
||||
cityssm.openHtmlModal("lotComment-add", {
|
||||
cityssm.openHtmlModal("lot-addComment", {
|
||||
onshow(modalElement) {
|
||||
los.populateAliases(modalElement);
|
||||
(modalElement.querySelector("#lotCommentAdd--lotId") as HTMLInputElement).value = lotId;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
<div class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<header class="modal-card-head">
|
||||
<h3 class="modal-card-title">
|
||||
Edit Comment
|
||||
</h3>
|
||||
<button class="delete is-close-modal-button" aria-label="close" type="button"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
<form id="form--lotCommentEdit">
|
||||
<input id="lotCommentEdit--lotId" name="lotId" type="hidden" value="" />
|
||||
<input id="lotCommentEdit--lotCommentId" name="lotCommentId" type="hidden" value="" />
|
||||
<div class="field">
|
||||
<label class="label" for="lotCommentEdit--lotComment">Comment</label>
|
||||
<div class="control">
|
||||
<textarea class="textarea" id="lotCommentEdit--lotComment" name="lotComment" required></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="lotCommentEdit--lotCommentDateString">Comment Date</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotCommentEdit--lotCommentDateString" name="lotCommentDateString" type="date" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="lotCommentEdit--lotCommentTimeString">Comment Time</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotCommentEdit--lotCommentTimeString" name="lotCommentTimeString" type="time" required />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<footer class="modal-card-foot justify-right">
|
||||
<button class="button is-success" type="submit" form="form--lotCommentEdit">
|
||||
<span class="icon"><i class="fas fa-plus" aria-hidden="true"></i></span>
|
||||
<span>Update Comment</span>
|
||||
</button>
|
||||
<button class="button is-close-modal-button" type="button">Cancel</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1 +1 @@
|
|||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=exports.los,t=document.querySelector("main").dataset.urlPrefix,o=document.querySelector("#lot--lotId").value,s=""===o,l=document.querySelector("#form--lot");l.addEventListener("submit",e=>{e.preventDefault(),cityssm.postJSON(t+"/lots/"+(s?"doCreateLot":"doUpdateLot"),l,e=>{e.success?s?window.location.href=t+"/lots/"+e.lotId+"/edit":bulmaJS.alert({message:exports.aliases.lot+" Updated Successfully",contextualColorName:"success"}):bulmaJS.alert({title:"Error Updating "+exports.aliases.lot,message:e.errorMessage,contextualColorName:"danger"})})}),e.initializeUnlockFieldButtons(l);let r=exports.lotComments;const n=()=>{const e=document.querySelector("#container--lotComments");0===r.length&&(e.innerHTML='<div class="message is-info"><p class="message-body">There are no comments to display.</p></div>')},m=()=>{let s;const l=e=>{e.preventDefault(),cityssm.postJSON(t+"/lots/doAddLotComment",e.currentTarget,e=>{e.success&&(r=e.lotComments,n(),s())})};cityssm.openHtmlModal("lotComment-add",{onshow(t){e.populateAliases(t),t.querySelector("#lotCommentAdd--lotId").value=o,t.querySelector("form").addEventListener("submit",l)},onshown(e,t){bulmaJS.toggleHtmlClipped(),s=t,e.querySelector("#lotCommentAdd--lotComment").focus()},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#lotComments--add").focus()}})};s||(document.querySelector("#lotComments--add").addEventListener("click",m),n())})();
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const t=exports.los,e=document.querySelector("main").dataset.urlPrefix,o=document.querySelector("#lot--lotId").value,l=""===o,s=document.querySelector("#form--lot");s.addEventListener("submit",t=>{t.preventDefault(),cityssm.postJSON(e+"/lots/"+(l?"doCreateLot":"doUpdateLot"),s,t=>{t.success?l?window.location.href=e+"/lots/"+t.lotId+"/edit":bulmaJS.alert({message:exports.aliases.lot+" Updated Successfully",contextualColorName:"success"}):bulmaJS.alert({title:"Error Updating "+exports.aliases.lot,message:t.errorMessage,contextualColorName:"danger"})})}),t.initializeUnlockFieldButtons(s);let n=exports.lotComments;const m=l=>{const s=Number.parseInt(l.currentTarget.closest("tr").dataset.lotCommentId,10),m=n.find(t=>t.lotCommentId===s);let r,d;const i=t=>{t.preventDefault(),cityssm.postJSON(e+"/lots/doUpdateLotComment",r,t=>{t.success?(n=t.lotComments,d(),a()):bulmaJS.alert({title:"Error Updating Comment",message:t.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lot-editComment",{onshow:e=>{t.populateAliases(e),e.querySelector("#lotCommentEdit--lotId").value=o,e.querySelector("#lotCommentEdit--lotCommentId").value=s.toString(),e.querySelector("#lotCommentEdit--lotComment").value=m.lotComment,e.querySelector("#lotCommentEdit--lotCommentDateString").value=m.lotCommentDateString,e.querySelector("#lotCommentEdit--lotCommentTimeString").value=m.lotCommentTimeString},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),t.querySelector("#lotCommentEdit--lotComment").focus(),(r=t.querySelector("form")).addEventListener("submit",i),d=e},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},r=t=>{const l=Number.parseInt(t.currentTarget.closest("tr").dataset.lotCommentId,10);bulmaJS.confirm({title:"Remove Comment?",message:"Are you sure you want to remove this comment?",okButton:{text:"Yes, Remove Comment",callbackFunction:()=>{cityssm.postJSON(e+"/lots/doDeleteLotComment",{lotId:o,lotCommentId:l},t=>{t.success?(n=t.lotComments,a()):bulmaJS.alert({title:"Error Removing Comment",message:t.errorMessage,contextualColorName:"danger"})})}},contextualColorName:"warning"})},a=()=>{const t=document.querySelector("#container--lotComments");if(0===n.length)return void(t.innerHTML='<div class="message is-info"><p class="message-body">There are no comments to display.</p></div>');const e=document.createElement("table");e.className="table is-fullwidth is-striped is-hoverable",e.innerHTML='<thead><tr><th>Commentor</th><th>Comment Date</th><th>Comment</th><th class="is-hidden-print"><span class="is-sr-only">Options</span></th></tr></thead><tbody></tbody>';for(const t of n){const o=document.createElement("tr");o.dataset.lotCommentId=t.lotCommentId.toString(),o.innerHTML="<td>"+cityssm.escapeHTML(t.recordCreate_userName)+"</td><td>"+t.lotCommentDateString+(0===t.lotCommentTime?"":" "+t.lotCommentTimeString)+"</td><td>"+cityssm.escapeHTML(t.lotComment)+'</td><td class="is-hidden-print"><div class="buttons are-small is-justify-content-end"><button class="button is-primary button--edit" type="button"><span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span> <span>Edit</span></button><button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete"><i class="fas fa-trash" aria-hidden="true"></i></button></div></td>',o.querySelector(".button--edit").addEventListener("click",m),o.querySelector(".button--delete").addEventListener("click",r),e.querySelector("tbody").append(o)}t.innerHTML="",t.append(e)},d=()=>{let l;const s=t=>{t.preventDefault(),cityssm.postJSON(e+"/lots/doAddLotComment",t.currentTarget,t=>{t.success&&(n=t.lotComments,a(),l())})};cityssm.openHtmlModal("lot-addComment",{onshow(e){t.populateAliases(e),e.querySelector("#lotCommentAdd--lotId").value=o,e.querySelector("form").addEventListener("submit",s)},onshown(t,e){bulmaJS.toggleHtmlClipped(),l=e,t.querySelector("#lotCommentAdd--lotComment").focus()},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#lotComments--add").focus()}})};l||(document.querySelector("#lotComments--add").addEventListener("click",d),a())})();
|
||||
|
|
@ -5,9 +5,11 @@ import handler_doSearchLots from "../handlers/lots-post/doSearchLots.js";
|
|||
import handler_view from "../handlers/lots-get/view.js";
|
||||
import handler_new from "../handlers/lots-get/new.js";
|
||||
import handler_edit from "../handlers/lots-get/edit.js";
|
||||
import handler_print from "../handlers/lots-get/print.js";
|
||||
import handler_doCreateLot from "../handlers/lots-post/doCreateLot.js";
|
||||
import handler_doUpdateLot from "../handlers/lots-post/doUpdateLot.js";
|
||||
import handler_doAddLotComment from "../handlers/lots-post/doAddLotComment.js";
|
||||
import handler_doUpdateLotComment from "../handlers/lots-post/doUpdateLotComment.js";
|
||||
import handler_doDeleteLotComment from "../handlers/lots-post/doDeleteLotComment.js";
|
||||
export const router = Router();
|
||||
router.get("/", handler_search);
|
||||
router.post("/doSearchLots", handler_doSearchLots);
|
||||
|
|
@ -16,5 +18,7 @@ router.get("/:lotId", handler_view);
|
|||
router.get("/:lotId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
||||
router.post("/doCreateLot", permissionHandlers.updatePostHandler, handler_doCreateLot);
|
||||
router.post("/doUpdateLot", permissionHandlers.updatePostHandler, handler_doUpdateLot);
|
||||
router.get("/:lotId/print", handler_print);
|
||||
router.post("/doAddLotComment", permissionHandlers.updatePostHandler, handler_doAddLotComment);
|
||||
router.post("/doUpdateLotComment", permissionHandlers.updatePostHandler, handler_doUpdateLotComment);
|
||||
router.post("/doDeleteLotComment", permissionHandlers.updatePostHandler, handler_doDeleteLotComment);
|
||||
export default router;
|
||||
|
|
|
|||
|
|
@ -8,11 +8,14 @@ import handler_doSearchLots from "../handlers/lots-post/doSearchLots.js";
|
|||
import handler_view from "../handlers/lots-get/view.js";
|
||||
import handler_new from "../handlers/lots-get/new.js";
|
||||
import handler_edit from "../handlers/lots-get/edit.js";
|
||||
import handler_print from "../handlers/lots-get/print.js";
|
||||
|
||||
import handler_doCreateLot from "../handlers/lots-post/doCreateLot.js";
|
||||
import handler_doUpdateLot from "../handlers/lots-post/doUpdateLot.js";
|
||||
|
||||
import handler_doAddLotComment from "../handlers/lots-post/doAddLotComment.js";
|
||||
import handler_doUpdateLotComment from "../handlers/lots-post/doUpdateLotComment.js";
|
||||
import handler_doDeleteLotComment from "../handlers/lots-post/doDeleteLotComment.js";
|
||||
|
||||
|
||||
export const router = Router();
|
||||
|
||||
|
|
@ -39,7 +42,6 @@ router.get("/new",
|
|||
handler_new);
|
||||
|
||||
|
||||
|
||||
router.get("/:lotId",
|
||||
handler_view);
|
||||
|
||||
|
|
@ -59,9 +61,19 @@ router.post("/doUpdateLot",
|
|||
handler_doUpdateLot);
|
||||
|
||||
|
||||
router.post("/doAddLotComment",
|
||||
permissionHandlers.updatePostHandler,
|
||||
handler_doAddLotComment);
|
||||
|
||||
router.get("/:lotId/print",
|
||||
handler_print);
|
||||
|
||||
router.post("/doUpdateLotComment",
|
||||
permissionHandlers.updatePostHandler,
|
||||
handler_doUpdateLotComment);
|
||||
|
||||
|
||||
router.post("/doDeleteLotComment",
|
||||
permissionHandlers.updatePostHandler,
|
||||
handler_doDeleteLotComment);
|
||||
|
||||
|
||||
export default router;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,35 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<% if (lot.lotComments.length > 0) { %>
|
||||
<div class="panel">
|
||||
<h2 class="panel-heading">Comments</h2>
|
||||
<div class="panel-block is-block">
|
||||
<table class="table is-fullwidth is-striped is-hoverable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Commentor</th>
|
||||
<th>Comment Date</th>
|
||||
<th>Comment</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% for (const lotComment of lot.lotComments) { %>
|
||||
<tr>
|
||||
<td><%= lotComment.recordCreate_userName %></td>
|
||||
<td>
|
||||
<%= lotComment.lotCommentDateString %>
|
||||
<%= (lotComment.lotCommentTime === 0 ? "" : lotComment.lotCommentTimeString) %>
|
||||
</td>
|
||||
<td><%= lotComment.lotComment %></td>
|
||||
</tr>
|
||||
<% } %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="panel">
|
||||
<h2 class="panel-heading">
|
||||
<%= configFunctions.getProperty("aliases.occupancies") %>
|
||||
|
|
|
|||
Loading…
Reference in New Issue