"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); (() => { const sunrise = exports.sunrise; const contractId = document.querySelector('#contract--contractId').value; let contractComments = exports.contractComments; delete exports.contractComments; function openEditContractComment(clickEvent) { const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset .contractCommentId ?? '', 10); const contractComment = contractComments.find((currentComment) => currentComment.contractCommentId === contractCommentId); let editFormElement; let editCloseModalFunction; function editContractComment(submitEvent) { submitEvent.preventDefault(); cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doUpdateContractComment`, editFormElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { contractComments = responseJSON.contractComments ?? []; editCloseModalFunction(); renderContractComments(); } else { bulmaJS.alert({ title: 'Error Updating Comment', message: responseJSON.errorMessage ?? '', contextualColorName: 'danger' }); } }); } cityssm.openHtmlModal('contract-editComment', { onshow(modalElement) { sunrise.populateAliases(modalElement); modalElement.querySelector('#contractCommentEdit--contractId').value = contractId; modalElement.querySelector('#contractCommentEdit--contractCommentId').value = contractCommentId.toString(); modalElement.querySelector('#contractCommentEdit--comment').value = contractComment.comment ?? ''; const contractCommentDateStringElement = modalElement.querySelector('#contractCommentEdit--commentDateString'); contractCommentDateStringElement.value = contractComment.commentDateString ?? ''; const currentDateString = cityssm.dateToString(new Date()); contractCommentDateStringElement.max = contractComment.commentDateString <= currentDateString ? currentDateString : contractComment.commentDateString ?? ''; modalElement.querySelector('#contractCommentEdit--commentTimeString').value = contractComment.commentTimeString ?? ''; }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped(); modalElement.querySelector('#contractCommentEdit--comment').focus(); editFormElement = modalElement.querySelector('form'); editFormElement.addEventListener('submit', editContractComment); editCloseModalFunction = closeModalFunction; }, onremoved() { bulmaJS.toggleHtmlClipped(); } }); } function deleteContractComment(clickEvent) { const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset .contractCommentId ?? '', 10); function doDelete() { cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doDeleteContractComment`, { contractId, contractCommentId }, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { contractComments = responseJSON.contractComments; renderContractComments(); } 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' }); } function renderContractComments() { const containerElement = document.querySelector('#container--contractComments'); if (contractComments.length === 0) { containerElement.innerHTML = `
`; return; } const tableElement = document.createElement('table'); tableElement.className = 'table is-fullwidth is-striped is-hoverable'; tableElement.innerHTML = `