delete lot
parent
726aa540d2
commit
040f1bd553
|
|
@ -0,0 +1,3 @@
|
|||
import type { RequestHandler } from "express";
|
||||
export declare const handler: RequestHandler;
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { deleteLot } from "../../helpers/lotOccupancyDB/deleteLot.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = deleteLot(request.body.lotId, request.session);
|
||||
response.json({
|
||||
success
|
||||
});
|
||||
};
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import type { RequestHandler } from "express";
|
||||
|
||||
import { deleteLot } from "../../helpers/lotOccupancyDB/deleteLot.js";
|
||||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success = deleteLot(
|
||||
request.body.lotId,
|
||||
request.session
|
||||
);
|
||||
|
||||
response.json({
|
||||
success
|
||||
});
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
export declare const deleteLot: (lotId: number | string, requestSession: recordTypes.PartialSession) => boolean;
|
||||
export default deleteLot;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
export const deleteLot = (lotId, requestSession) => {
|
||||
const database = sqlite(databasePath);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare("update Lots" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotId = ?")
|
||||
.run(requestSession.user.userName, rightNowMillis, lotId);
|
||||
database
|
||||
.prepare("update LotComments" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotId = ?")
|
||||
.run(requestSession.user.userName, rightNowMillis, lotId);
|
||||
database
|
||||
.prepare("update LotFields" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotId = ?")
|
||||
.run(requestSession.user.userName, rightNowMillis, lotId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
};
|
||||
export default deleteLot;
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
export const deleteLot = (
|
||||
lotId: number | string,
|
||||
requestSession: recordTypes.PartialSession
|
||||
): boolean => {
|
||||
const database = sqlite(databasePath);
|
||||
|
||||
const rightNowMillis = Date.now();
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
"update Lots" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotId = ?"
|
||||
)
|
||||
.run(requestSession.user.userName, rightNowMillis, lotId);
|
||||
|
||||
database
|
||||
.prepare(
|
||||
"update LotComments" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotId = ?"
|
||||
)
|
||||
.run(requestSession.user.userName, rightNowMillis, lotId);
|
||||
|
||||
database
|
||||
.prepare(
|
||||
"update LotFields" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotId = ?"
|
||||
)
|
||||
.run(requestSession.user.userName, rightNowMillis, lotId);
|
||||
|
||||
database.close();
|
||||
|
||||
return result.changes > 0;
|
||||
};
|
||||
|
||||
export default deleteLot;
|
||||
|
|
@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
(() => {
|
||||
const los = exports.los;
|
||||
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
||||
const lotId = document.querySelector("#lot--lotId")
|
||||
.value;
|
||||
const lotId = document.querySelector("#lot--lotId").value;
|
||||
const isCreate = lotId === "";
|
||||
const formElement = document.querySelector("#form--lot");
|
||||
const updateLot = (formEvent) => {
|
||||
|
|
@ -12,8 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
cityssm.postJSON(urlPrefix + "/lots/" + (isCreate ? "doCreateLot" : "doUpdateLot"), formElement, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
if (isCreate) {
|
||||
window.location.href =
|
||||
urlPrefix + "/lots/" + responseJSON.lotId + "/edit";
|
||||
window.location.href = urlPrefix + "/lots/" + responseJSON.lotId + "/edit";
|
||||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
|
|
@ -33,11 +31,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
};
|
||||
formElement.addEventListener("submit", updateLot);
|
||||
los.initializeUnlockFieldButtons(formElement);
|
||||
if (!isCreate) {
|
||||
document.querySelector("#button--deleteLot").addEventListener("click", (clickEvent) => {
|
||||
clickEvent.preventDefault();
|
||||
const doDelete = () => {
|
||||
cityssm.postJSON(urlPrefix + "/lots/doDeleteLot", {
|
||||
lotId
|
||||
}, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
cityssm.disableNavBlocker();
|
||||
window.location.href = urlPrefix + "/lots/?t=" + Date.now();
|
||||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Deleting " + exports.aliases.lot,
|
||||
message: responseJSON.errorMessage,
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
bulmaJS.confirm({
|
||||
title: "Delete " + exports.aliases.lot,
|
||||
message: "Are you sure you want to delete this " +
|
||||
exports.aliases.lot.toLowerCase() +
|
||||
"?",
|
||||
contextualColorName: "warning",
|
||||
okButton: {
|
||||
text: "Yes, Delete " + exports.aliases.lot,
|
||||
callbackFunction: doDelete
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
let lotComments = exports.lotComments;
|
||||
delete exports.lotComments;
|
||||
const openEditLotComment = (clickEvent) => {
|
||||
const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset
|
||||
.lotCommentId, 10);
|
||||
const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotCommentId, 10);
|
||||
const lotComment = lotComments.find((currentLotComment) => {
|
||||
return currentLotComment.lotCommentId === lotCommentId;
|
||||
});
|
||||
|
|
@ -63,7 +93,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
cityssm.openHtmlModal("lot-editComment", {
|
||||
onshow: (modalElement) => {
|
||||
los.populateAliases(modalElement);
|
||||
modalElement.querySelector("#lotCommentEdit--lotId").value = lotId;
|
||||
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;
|
||||
|
|
@ -82,8 +113,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
});
|
||||
};
|
||||
const deleteLotComment = (clickEvent) => {
|
||||
const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset
|
||||
.lotCommentId, 10);
|
||||
const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotCommentId, 10);
|
||||
const doDelete = () => {
|
||||
cityssm.postJSON(urlPrefix + "/lots/doDeleteLotComment", {
|
||||
lotId,
|
||||
|
|
@ -133,17 +163,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
"<tbody></tbody>";
|
||||
for (const lotComment of lotComments) {
|
||||
const tableRowElement = document.createElement("tr");
|
||||
tableRowElement.dataset.lotCommentId =
|
||||
lotComment.lotCommentId.toString();
|
||||
tableRowElement.dataset.lotCommentId = lotComment.lotCommentId.toString();
|
||||
tableRowElement.innerHTML =
|
||||
"<td>" +
|
||||
cityssm.escapeHTML(lotComment.recordCreate_userName) +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
lotComment.lotCommentDateString +
|
||||
(lotComment.lotCommentTime === 0
|
||||
? ""
|
||||
: " " + lotComment.lotCommentTimeString) +
|
||||
(lotComment.lotCommentTime === 0 ? "" : " " + lotComment.lotCommentTimeString) +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
cityssm.escapeHTML(lotComment.lotComment) +
|
||||
|
|
@ -185,10 +212,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
cityssm.openHtmlModal("lot-addComment", {
|
||||
onshow(modalElement) {
|
||||
los.populateAliases(modalElement);
|
||||
modalElement.querySelector("#lotCommentAdd--lotId").value = lotId;
|
||||
modalElement
|
||||
.querySelector("form")
|
||||
.addEventListener("submit", doAddComment);
|
||||
modalElement.querySelector("#lotCommentAdd--lotId").value =
|
||||
lotId;
|
||||
modalElement.querySelector("form").addEventListener("submit", doAddComment);
|
||||
},
|
||||
onshown(modalElement, closeModalFunction) {
|
||||
bulmaJS.toggleHtmlClipped();
|
||||
|
|
@ -202,9 +228,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
});
|
||||
};
|
||||
if (!isCreate) {
|
||||
document
|
||||
.querySelector("#lotComments--add")
|
||||
.addEventListener("click", openAddCommentModal);
|
||||
document.querySelector("#lotComments--add").addEventListener("click", openAddCommentModal);
|
||||
renderLotComments();
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
||||
|
||||
const lotId = (document.querySelector("#lot--lotId") as HTMLInputElement)
|
||||
.value;
|
||||
const lotId = (document.querySelector("#lot--lotId") as HTMLInputElement).value;
|
||||
const isCreate = lotId === "";
|
||||
|
||||
// Main form
|
||||
|
|
@ -29,19 +28,13 @@ declare const bulmaJS: BulmaJS;
|
|||
cityssm.postJSON(
|
||||
urlPrefix + "/lots/" + (isCreate ? "doCreateLot" : "doUpdateLot"),
|
||||
formElement,
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
lotId?: number;
|
||||
errorMessage?: string;
|
||||
}) => {
|
||||
(responseJSON: { success: boolean; lotId?: number; errorMessage?: string }) => {
|
||||
if (responseJSON.success) {
|
||||
if (isCreate) {
|
||||
window.location.href =
|
||||
urlPrefix + "/lots/" + responseJSON.lotId + "/edit";
|
||||
window.location.href = urlPrefix + "/lots/" + responseJSON.lotId + "/edit";
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
message:
|
||||
exports.aliases.lot + " Updated Successfully",
|
||||
message: exports.aliases.lot + " Updated Successfully",
|
||||
contextualColorName: "success"
|
||||
});
|
||||
}
|
||||
|
|
@ -60,6 +53,46 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
los.initializeUnlockFieldButtons(formElement);
|
||||
|
||||
if (!isCreate) {
|
||||
document.querySelector("#button--deleteLot").addEventListener("click", (clickEvent) => {
|
||||
clickEvent.preventDefault();
|
||||
|
||||
const doDelete = () => {
|
||||
cityssm.postJSON(
|
||||
urlPrefix + "/lots/doDeleteLot",
|
||||
{
|
||||
lotId
|
||||
},
|
||||
(responseJSON: { success: boolean; errorMessage?: string }) => {
|
||||
if (responseJSON.success) {
|
||||
cityssm.disableNavBlocker();
|
||||
window.location.href = urlPrefix + "/lots/?t=" + Date.now();
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Deleting " + exports.aliases.lot,
|
||||
message: responseJSON.errorMessage,
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
bulmaJS.confirm({
|
||||
title: "Delete " + exports.aliases.lot,
|
||||
message:
|
||||
"Are you sure you want to delete this " +
|
||||
exports.aliases.lot.toLowerCase() +
|
||||
"?",
|
||||
contextualColorName: "warning",
|
||||
okButton: {
|
||||
text: "Yes, Delete " + exports.aliases.lot,
|
||||
callbackFunction: doDelete
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Comments
|
||||
|
||||
let lotComments: recordTypes.LotComment[] = exports.lotComments;
|
||||
|
|
@ -67,8 +100,7 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
const openEditLotComment = (clickEvent: Event) => {
|
||||
const lotCommentId = Number.parseInt(
|
||||
(clickEvent.currentTarget as HTMLElement).closest("tr").dataset
|
||||
.lotCommentId,
|
||||
(clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotCommentId,
|
||||
10
|
||||
);
|
||||
|
||||
|
|
@ -109,21 +141,14 @@ declare const bulmaJS: BulmaJS;
|
|||
onshow: (modalElement) => {
|
||||
los.populateAliases(modalElement);
|
||||
|
||||
(modalElement.querySelector("#lotCommentEdit--lotId") as HTMLInputElement).value =
|
||||
lotId;
|
||||
(
|
||||
modalElement.querySelector(
|
||||
"#lotCommentEdit--lotId"
|
||||
) as HTMLInputElement
|
||||
).value = lotId;
|
||||
(
|
||||
modalElement.querySelector(
|
||||
"#lotCommentEdit--lotCommentId"
|
||||
) as HTMLInputElement
|
||||
modalElement.querySelector("#lotCommentEdit--lotCommentId") as HTMLInputElement
|
||||
).value = lotCommentId.toString();
|
||||
|
||||
(
|
||||
modalElement.querySelector(
|
||||
"#lotCommentEdit--lotComment"
|
||||
) as HTMLInputElement
|
||||
modalElement.querySelector("#lotCommentEdit--lotComment") as HTMLInputElement
|
||||
).value = lotComment.lotComment;
|
||||
(
|
||||
modalElement.querySelector(
|
||||
|
|
@ -140,9 +165,7 @@ declare const bulmaJS: BulmaJS;
|
|||
bulmaJS.toggleHtmlClipped();
|
||||
|
||||
(
|
||||
modalElement.querySelector(
|
||||
"#lotCommentEdit--lotComment"
|
||||
) as HTMLTextAreaElement
|
||||
modalElement.querySelector("#lotCommentEdit--lotComment") as HTMLTextAreaElement
|
||||
).focus();
|
||||
|
||||
editFormElement = modalElement.querySelector("form");
|
||||
|
|
@ -158,8 +181,7 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
const deleteLotComment = (clickEvent: Event) => {
|
||||
const lotCommentId = Number.parseInt(
|
||||
(clickEvent.currentTarget as HTMLElement).closest("tr").dataset
|
||||
.lotCommentId,
|
||||
(clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotCommentId,
|
||||
10
|
||||
);
|
||||
|
||||
|
|
@ -201,9 +223,7 @@ declare const bulmaJS: BulmaJS;
|
|||
};
|
||||
|
||||
const renderLotComments = () => {
|
||||
const containerElement = document.querySelector(
|
||||
"#container--lotComments"
|
||||
) as HTMLElement;
|
||||
const containerElement = document.querySelector("#container--lotComments") as HTMLElement;
|
||||
|
||||
if (lotComments.length === 0) {
|
||||
containerElement.innerHTML =
|
||||
|
|
@ -226,8 +246,7 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
for (const lotComment of lotComments) {
|
||||
const tableRowElement = document.createElement("tr");
|
||||
tableRowElement.dataset.lotCommentId =
|
||||
lotComment.lotCommentId.toString();
|
||||
tableRowElement.dataset.lotCommentId = lotComment.lotCommentId.toString();
|
||||
|
||||
tableRowElement.innerHTML =
|
||||
"<td>" +
|
||||
|
|
@ -235,9 +254,7 @@ declare const bulmaJS: BulmaJS;
|
|||
"</td>" +
|
||||
"<td>" +
|
||||
lotComment.lotCommentDateString +
|
||||
(lotComment.lotCommentTime === 0
|
||||
? ""
|
||||
: " " + lotComment.lotCommentTimeString) +
|
||||
(lotComment.lotCommentTime === 0 ? "" : " " + lotComment.lotCommentTimeString) +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
cityssm.escapeHTML(lotComment.lotComment) +
|
||||
|
|
@ -277,10 +294,7 @@ declare const bulmaJS: BulmaJS;
|
|||
cityssm.postJSON(
|
||||
urlPrefix + "/lots/doAddLotComment",
|
||||
formEvent.currentTarget,
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
lotComments?: recordTypes.LotComment[];
|
||||
}) => {
|
||||
(responseJSON: { success: boolean; lotComments?: recordTypes.LotComment[] }) => {
|
||||
if (responseJSON.success) {
|
||||
lotComments = responseJSON.lotComments;
|
||||
renderLotComments();
|
||||
|
|
@ -293,39 +307,26 @@ declare const bulmaJS: BulmaJS;
|
|||
cityssm.openHtmlModal("lot-addComment", {
|
||||
onshow(modalElement) {
|
||||
los.populateAliases(modalElement);
|
||||
(
|
||||
modalElement.querySelector(
|
||||
"#lotCommentAdd--lotId"
|
||||
) as HTMLInputElement
|
||||
).value = lotId;
|
||||
modalElement
|
||||
.querySelector("form")
|
||||
.addEventListener("submit", doAddComment);
|
||||
(modalElement.querySelector("#lotCommentAdd--lotId") as HTMLInputElement).value =
|
||||
lotId;
|
||||
modalElement.querySelector("form").addEventListener("submit", doAddComment);
|
||||
},
|
||||
onshown(modalElement, closeModalFunction) {
|
||||
bulmaJS.toggleHtmlClipped();
|
||||
addCommentCloseModalFunction = closeModalFunction;
|
||||
(
|
||||
modalElement.querySelector(
|
||||
"#lotCommentAdd--lotComment"
|
||||
) as HTMLTextAreaElement
|
||||
modalElement.querySelector("#lotCommentAdd--lotComment") as HTMLTextAreaElement
|
||||
).focus();
|
||||
},
|
||||
onremoved() {
|
||||
bulmaJS.toggleHtmlClipped();
|
||||
(
|
||||
document.querySelector(
|
||||
"#lotComments--add"
|
||||
) as HTMLButtonElement
|
||||
).focus();
|
||||
(document.querySelector("#lotComments--add") as HTMLButtonElement).focus();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (!isCreate) {
|
||||
document
|
||||
.querySelector("#lotComments--add")
|
||||
.addEventListener("click", openAddCommentModal);
|
||||
document.querySelector("#lotComments--add").addEventListener("click", openAddCommentModal);
|
||||
renderLotComments();
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"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;delete 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())})();
|
||||
"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),l||document.querySelector("#button--deleteLot").addEventListener("click",t=>{t.preventDefault();bulmaJS.confirm({title:"Delete "+exports.aliases.lot,message:"Are you sure you want to delete this "+exports.aliases.lot.toLowerCase()+"?",contextualColorName:"warning",okButton:{text:"Yes, Delete "+exports.aliases.lot,callbackFunction:()=>{cityssm.postJSON(e+"/lots/doDeleteLot",{lotId:o},t=>{t.success?(cityssm.disableNavBlocker(),window.location.href=e+"/lots/?t="+Date.now()):bulmaJS.alert({title:"Error Deleting "+exports.aliases.lot,message:t.errorMessage,contextualColorName:"danger"})})}}})});let n=exports.lotComments;delete exports.lotComments;const r=l=>{const s=Number.parseInt(l.currentTarget.closest("tr").dataset.lotCommentId,10),r=n.find(t=>t.lotCommentId===s);let a,i;const d=t=>{t.preventDefault(),cityssm.postJSON(e+"/lots/doUpdateLotComment",a,t=>{t.success?(n=t.lotComments,i(),m()):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=r.lotComment,e.querySelector("#lotCommentEdit--lotCommentDateString").value=r.lotCommentDateString,e.querySelector("#lotCommentEdit--lotCommentTimeString").value=r.lotCommentTimeString},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),t.querySelector("#lotCommentEdit--lotComment").focus(),(a=t.querySelector("form")).addEventListener("submit",d),i=e},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},a=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,m()):bulmaJS.alert({title:"Error Removing Comment",message:t.errorMessage,contextualColorName:"danger"})})}},contextualColorName:"warning"})},m=()=>{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",r),o.querySelector(".button--delete").addEventListener("click",a),e.querySelector("tbody").append(o)}t.innerHTML="",t.append(e)},i=()=>{let l;const s=t=>{t.preventDefault(),cityssm.postJSON(e+"/lots/doAddLotComment",t.currentTarget,t=>{t.success&&(n=t.lotComments,m(),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",i),m())})();
|
||||
|
|
@ -9,6 +9,7 @@ import handler_new from "../handlers/lots-get/new.js";
|
|||
import handler_edit from "../handlers/lots-get/edit.js";
|
||||
import handler_doCreateLot from "../handlers/lots-post/doCreateLot.js";
|
||||
import handler_doUpdateLot from "../handlers/lots-post/doUpdateLot.js";
|
||||
import handler_doDeleteLot from "../handlers/lots-post/doDeleteLot.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";
|
||||
|
|
@ -22,6 +23,7 @@ router.get("/:lotId/previous", handler_previous);
|
|||
router.get("/:lotId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
||||
router.post("/doCreateLot", permissionHandlers.updatePostHandler, handler_doCreateLot);
|
||||
router.post("/doUpdateLot", permissionHandlers.updatePostHandler, handler_doUpdateLot);
|
||||
router.post("/doDeleteLot", permissionHandlers.updatePostHandler, handler_doDeleteLot);
|
||||
router.post("/doAddLotComment", permissionHandlers.updatePostHandler, handler_doAddLotComment);
|
||||
router.post("/doUpdateLotComment", permissionHandlers.updatePostHandler, handler_doUpdateLotComment);
|
||||
router.post("/doDeleteLotComment", permissionHandlers.updatePostHandler, handler_doDeleteLotComment);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import handler_edit from "../handlers/lots-get/edit.js";
|
|||
|
||||
import handler_doCreateLot from "../handlers/lots-post/doCreateLot.js";
|
||||
import handler_doUpdateLot from "../handlers/lots-post/doUpdateLot.js";
|
||||
import handler_doDeleteLot from "../handlers/lots-post/doDeleteLot.js";
|
||||
|
||||
import handler_doAddLotComment from "../handlers/lots-post/doAddLotComment.js";
|
||||
import handler_doUpdateLotComment from "../handlers/lots-post/doUpdateLotComment.js";
|
||||
|
|
@ -43,23 +44,13 @@ router.get("/:lotId/previous", handler_previous);
|
|||
|
||||
router.get("/:lotId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
||||
|
||||
router.post(
|
||||
"/doCreateLot",
|
||||
permissionHandlers.updatePostHandler,
|
||||
handler_doCreateLot
|
||||
);
|
||||
router.post("/doCreateLot", permissionHandlers.updatePostHandler, handler_doCreateLot);
|
||||
|
||||
router.post(
|
||||
"/doUpdateLot",
|
||||
permissionHandlers.updatePostHandler,
|
||||
handler_doUpdateLot
|
||||
);
|
||||
router.post("/doUpdateLot", permissionHandlers.updatePostHandler, handler_doUpdateLot);
|
||||
|
||||
router.post(
|
||||
"/doAddLotComment",
|
||||
permissionHandlers.updatePostHandler,
|
||||
handler_doAddLotComment
|
||||
);
|
||||
router.post("/doDeleteLot", permissionHandlers.updatePostHandler, handler_doDeleteLot);
|
||||
|
||||
router.post("/doAddLotComment", permissionHandlers.updatePostHandler, handler_doAddLotComment);
|
||||
|
||||
router.post(
|
||||
"/doUpdateLotComment",
|
||||
|
|
|
|||
|
|
@ -64,7 +64,11 @@
|
|||
<div class="field has-addons">
|
||||
<div class="control is-expanded">
|
||||
<div class="select is-fullwidth">
|
||||
<select id="lot--lotTypeId" name="lotTypeId" required>
|
||||
<select
|
||||
<% if (!isCreate) { %>
|
||||
class="is-readonly"
|
||||
<% } %>
|
||||
id="lot--lotTypeId" name="lotTypeId" required>
|
||||
<% if (isCreate) { %>
|
||||
<option value="">(No Type)</option>
|
||||
<% } %>
|
||||
|
|
@ -139,13 +143,13 @@
|
|||
<div class="field">
|
||||
<label class="label" for="lot--lotLatitude">Latitude</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lot--lotLatitude" name="lotLatitude" type="number" min="-90" max="90" step="0.00000001" value="<%= lot.lotLatitude %>" />
|
||||
<input class="input" id="lot--lotLatitude" name="lotLatitude" type="number" min="-90" max="90" step="0.00000001" value="<%= lot.lotLatitude %>" onwheel="return false" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="lot--lotLongitude">Longitude</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lot--lotLongitude" name="lotLongitude" type="number" min="-180" max="180" step="0.00000001" value="<%= lot.lotLongitude %>" />
|
||||
<input class="input" id="lot--lotLongitude" name="lotLongitude" type="number" min="-180" max="180" step="0.00000001" value="<%= lot.lotLongitude %>" onwheel="return false" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -159,7 +163,11 @@
|
|||
<div class="field has-addons">
|
||||
<div class="control is-expanded">
|
||||
<div class="select is-fullwidth">
|
||||
<select id="lot--mapId" name="mapId">
|
||||
<select
|
||||
<% if (!isCreate) { %>
|
||||
class="is-readonly"
|
||||
<% } %>
|
||||
id="lot--mapId" name="mapId">
|
||||
<option value="" <%= (!isCreate && lot.mapId ? " disabled" : "") %>>
|
||||
(No <%= configFunctions.getProperty("aliases.map") %> Selected)
|
||||
</option>
|
||||
|
|
@ -209,12 +217,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel mb-5">
|
||||
<h2 class="panel-heading">
|
||||
Additional Details
|
||||
</h2>
|
||||
<div class="panel-block"></div>
|
||||
</div>
|
||||
|
||||
<div class="has-text-right mb-4 is-hidden-print">
|
||||
<button class="button is-primary" type="submit">
|
||||
|
|
@ -224,6 +226,26 @@
|
|||
<%= configFunctions.getProperty("aliases.lot") %>
|
||||
</span>
|
||||
</button>
|
||||
<% if (!isCreate) { %>
|
||||
<div class="dropdown is-right ml-2">
|
||||
<div class="dropdown-trigger">
|
||||
<button class="button" type="button">
|
||||
<span>More Options</span>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-angle-down" aria-hidden="true"></i>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-content">
|
||||
<a class="dropdown-item" id="button--deleteLot" href="#">
|
||||
<span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>
|
||||
<span>Delete <%= configFunctions.getProperty("aliases.lot") %></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue