1 line
4.9 KiB
JavaScript
1 line
4.9 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const t=exports.los,e=document.querySelector("#lot--lotId").value,o=""===e,l=document.querySelector("#form--lot");l.addEventListener("submit",e=>{e.preventDefault(),cityssm.postJSON(t.urlPrefix+"/lots/"+(o?"doCreateLot":"doUpdateLot"),l,e=>{e.success?o?window.location.href=t.urlPrefix+"/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"})})}),t.initializeUnlockFieldButtons(l),o||document.querySelector("#button--deleteLot").addEventListener("click",o=>{o.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(t.urlPrefix+"/lots/doDeleteLot",{lotId:e},e=>{e.success?(cityssm.disableNavBlocker(),window.location.href=t.urlPrefix+"/lots/?t="+Date.now()):bulmaJS.alert({title:"Error Deleting "+exports.aliases.lot,message:e.errorMessage||"",contextualColorName:"danger"})})}}})});let s=exports.lotComments;delete exports.lotComments;const n=o=>{const l=Number.parseInt(o.currentTarget.closest("tr").dataset.lotCommentId,10),n=s.find(t=>t.lotCommentId===l);let r,m;const i=e=>{e.preventDefault(),cityssm.postJSON(t.urlPrefix+"/lots/doUpdateLotComment",r,t=>{t.success?(s=t.lotComments,m(),a()):bulmaJS.alert({title:"Error Updating Comment",message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lot-editComment",{onshow:o=>{t.populateAliases(o),o.querySelector("#lotCommentEdit--lotId").value=e,o.querySelector("#lotCommentEdit--lotCommentId").value=l.toString(),o.querySelector("#lotCommentEdit--lotComment").value=n.lotComment;const s=o.querySelector("#lotCommentEdit--lotCommentDateString");s.value=n.lotCommentDateString;const r=cityssm.dateToString(new Date);s.max=n.lotCommentDateString<=r?r:n.lotCommentDateString,o.querySelector("#lotCommentEdit--lotCommentTimeString").value=n.lotCommentTimeString},onshown:(e,o)=>{bulmaJS.toggleHtmlClipped(),t.initializeDatePickers(e),t.initializeTimePickers(e),e.querySelector("#lotCommentEdit--lotComment").focus(),(r=e.querySelector("form")).addEventListener("submit",i),m=o},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},r=o=>{const l=Number.parseInt(o.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(t.urlPrefix+"/lots/doDeleteLotComment",{lotId:e,lotCommentId:l},t=>{t.success?(s=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===s.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 s){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",n),o.querySelector(".button--delete").addEventListener("click",r),e.querySelector("tbody").append(o)}t.innerHTML="",t.append(e)},m=()=>{let o;const l=e=>{e.preventDefault(),cityssm.postJSON(t.urlPrefix+"/lots/doAddLotComment",e.currentTarget,t=>{t.success&&(s=t.lotComments,a(),o())})};cityssm.openHtmlModal("lot-addComment",{onshow(o){t.populateAliases(o),o.querySelector("#lotCommentAdd--lotId").value=e,o.querySelector("form").addEventListener("submit",l)},onshown(t,e){bulmaJS.toggleHtmlClipped(),o=e,t.querySelector("#lotCommentAdd--lotComment").focus()},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#lotComments--add").focus()}})};o||(document.querySelector("#lotComments--add").addEventListener("click",m),a())})(); |