linting
parent
ca47423bfc
commit
c1d00559e5
|
|
@ -14,9 +14,9 @@ export async function updateWorkOrderMilestone(milestoneForm, requestSession) {
|
||||||
where workOrderMilestoneId = ?`)
|
where workOrderMilestoneId = ?`)
|
||||||
.run(milestoneForm.workOrderMilestoneTypeId === ''
|
.run(milestoneForm.workOrderMilestoneTypeId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: milestoneForm.workOrderMilestoneTypeId, dateStringToInteger(milestoneForm.workOrderMilestoneDateString), milestoneForm.workOrderMilestoneTimeString
|
: milestoneForm.workOrderMilestoneTypeId, dateStringToInteger(milestoneForm.workOrderMilestoneDateString), (milestoneForm.workOrderMilestoneTimeString ?? '') === ''
|
||||||
? timeStringToInteger(milestoneForm.workOrderMilestoneTimeString)
|
? 0
|
||||||
: 0, milestoneForm.workOrderMilestoneDescription, requestSession.user.userName, rightNow.getTime(), milestoneForm.workOrderMilestoneId);
|
: timeStringToInteger(milestoneForm.workOrderMilestoneTimeString), milestoneForm.workOrderMilestoneDescription, requestSession.user.userName, rightNow.getTime(), milestoneForm.workOrderMilestoneId);
|
||||||
database.release();
|
database.release();
|
||||||
return result.changes > 0;
|
return result.changes > 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ export async function updateWorkOrderMilestone(
|
||||||
? undefined
|
? undefined
|
||||||
: milestoneForm.workOrderMilestoneTypeId,
|
: milestoneForm.workOrderMilestoneTypeId,
|
||||||
dateStringToInteger(milestoneForm.workOrderMilestoneDateString),
|
dateStringToInteger(milestoneForm.workOrderMilestoneDateString),
|
||||||
milestoneForm.workOrderMilestoneTimeString
|
(milestoneForm.workOrderMilestoneTimeString ?? '') === ''
|
||||||
? timeStringToInteger(milestoneForm.workOrderMilestoneTimeString)
|
? 0
|
||||||
: 0,
|
: timeStringToInteger(milestoneForm.workOrderMilestoneTimeString!),
|
||||||
milestoneForm.workOrderMilestoneDescription,
|
milestoneForm.workOrderMilestoneDescription,
|
||||||
|
|
||||||
requestSession.user!.userName,
|
requestSession.user!.userName,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
|
||||||
|
var _a;
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
let lotOccupancyOccupants;
|
let lotOccupancyOccupants = exports.lotOccupancyOccupants;
|
||||||
|
delete exports.lotOccupancyOccupants;
|
||||||
function openEditLotOccupancyOccupant(clickEvent) {
|
function openEditLotOccupancyOccupant(clickEvent) {
|
||||||
const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset
|
const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset
|
||||||
.lotOccupantIndex, 10);
|
.lotOccupantIndex, 10);
|
||||||
|
|
@ -192,7 +194,11 @@ function renderLotOccupancyOccupants() {
|
||||||
: cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress)) +
|
: cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress)) +
|
||||||
'</td>') +
|
'</td>') +
|
||||||
('<td>' +
|
('<td>' +
|
||||||
'<span data-tooltip="' + cityssm.escapeHTML(((_j = lotOccupancyOccupant.occupantCommentTitle) !== null && _j !== void 0 ? _j : '') === '' ? 'Comment' : lotOccupancyOccupant.occupantCommentTitle) + '">' +
|
'<span data-tooltip="' +
|
||||||
|
cityssm.escapeHTML(((_j = lotOccupancyOccupant.occupantCommentTitle) !== null && _j !== void 0 ? _j : '') === ''
|
||||||
|
? 'Comment'
|
||||||
|
: lotOccupancyOccupant.occupantCommentTitle) +
|
||||||
|
'">' +
|
||||||
cityssm.escapeHTML((_k = lotOccupancyOccupant.occupantComment) !== null && _k !== void 0 ? _k : '') +
|
cityssm.escapeHTML((_k = lotOccupancyOccupant.occupantComment) !== null && _k !== void 0 ? _k : '') +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'</td>') +
|
'</td>') +
|
||||||
|
|
@ -229,159 +235,155 @@ if (isCreate) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lotOccupancyOccupants = exports.lotOccupancyOccupants;
|
|
||||||
delete exports.lotOccupancyOccupants;
|
|
||||||
document
|
|
||||||
.querySelector('#button--addOccupant')
|
|
||||||
.addEventListener('click', () => {
|
|
||||||
let addCloseModalFunction;
|
|
||||||
let addFormElement;
|
|
||||||
let searchFormElement;
|
|
||||||
let searchResultsElement;
|
|
||||||
function addOccupant(formOrObject) {
|
|
||||||
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doAddLotOccupancyOccupant', formOrObject, (responseJSON) => {
|
|
||||||
var _a;
|
|
||||||
if (responseJSON.success) {
|
|
||||||
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
|
||||||
addCloseModalFunction();
|
|
||||||
renderLotOccupancyOccupants();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bulmaJS.alert({
|
|
||||||
title: `Error Adding ${los.escapedAliases.Occupant}`,
|
|
||||||
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
||||||
contextualColorName: 'danger'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function addOccupantFromForm(submitEvent) {
|
|
||||||
submitEvent.preventDefault();
|
|
||||||
addOccupant(addFormElement);
|
|
||||||
}
|
|
||||||
let pastOccupantSearchResults = [];
|
|
||||||
function addOccupantFromCopy(clickEvent) {
|
|
||||||
clickEvent.preventDefault();
|
|
||||||
const panelBlockElement = clickEvent.currentTarget;
|
|
||||||
const occupant = pastOccupantSearchResults[Number.parseInt(panelBlockElement.dataset.index, 10)];
|
|
||||||
const lotOccupantTypeId = panelBlockElement
|
|
||||||
.closest('.modal')
|
|
||||||
.querySelector('#lotOccupancyOccupantCopy--lotOccupantTypeId').value;
|
|
||||||
if (lotOccupantTypeId === '') {
|
|
||||||
bulmaJS.alert({
|
|
||||||
title: `No ${los.escapedAliases.Occupant} Type Selected`,
|
|
||||||
message: `Select a type to apply to the newly added ${los.escapedAliases.occupant}.`,
|
|
||||||
contextualColorName: 'warning'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
occupant.lotOccupantTypeId = Number.parseInt(lotOccupantTypeId, 10);
|
|
||||||
occupant.lotOccupancyId = Number.parseInt(lotOccupancyId, 10);
|
|
||||||
addOccupant(occupant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function searchOccupants(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
if (searchFormElement.querySelector('#lotOccupancyOccupantCopy--searchFilter').value === '') {
|
|
||||||
searchResultsElement.innerHTML =
|
|
||||||
'<div class="message is-info">' +
|
|
||||||
'<p class="message-body">Enter a partial name or address in the search field above.</p>' +
|
|
||||||
'</div>';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
searchResultsElement.innerHTML =
|
|
||||||
los.getLoadingParagraphHTML('Searching...');
|
|
||||||
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doSearchPastOccupants', searchFormElement, (responseJSON) => {
|
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
||||||
pastOccupantSearchResults = responseJSON.occupants;
|
|
||||||
const panelElement = document.createElement('div');
|
|
||||||
panelElement.className = 'panel';
|
|
||||||
for (const [index, occupant] of pastOccupantSearchResults.entries()) {
|
|
||||||
const panelBlockElement = document.createElement('a');
|
|
||||||
panelBlockElement.className = 'panel-block is-block';
|
|
||||||
panelBlockElement.dataset.index = index.toString();
|
|
||||||
panelBlockElement.innerHTML =
|
|
||||||
'<strong>' +
|
|
||||||
cityssm.escapeHTML((_a = occupant.occupantName) !== null && _a !== void 0 ? _a : '') +
|
|
||||||
'</strong>' +
|
|
||||||
'<br />' +
|
|
||||||
'<div class="columns">' +
|
|
||||||
('<div class="column">' +
|
|
||||||
cityssm.escapeHTML((_b = occupant.occupantAddress1) !== null && _b !== void 0 ? _b : '') +
|
|
||||||
'<br />' +
|
|
||||||
(((_c = occupant.occupantAddress2) !== null && _c !== void 0 ? _c : '') === ''
|
|
||||||
? ''
|
|
||||||
: cityssm.escapeHTML(occupant.occupantAddress2) +
|
|
||||||
'<br />') +
|
|
||||||
cityssm.escapeHTML((_d = occupant.occupantCity) !== null && _d !== void 0 ? _d : '') +
|
|
||||||
', ' +
|
|
||||||
cityssm.escapeHTML((_e = occupant.occupantProvince) !== null && _e !== void 0 ? _e : '') +
|
|
||||||
'<br />' +
|
|
||||||
cityssm.escapeHTML((_f = occupant.occupantPostalCode) !== null && _f !== void 0 ? _f : '') +
|
|
||||||
'</div>') +
|
|
||||||
('<div class="column">' +
|
|
||||||
(((_g = occupant.occupantPhoneNumber) !== null && _g !== void 0 ? _g : '') === ''
|
|
||||||
? ''
|
|
||||||
: cityssm.escapeHTML(occupant.occupantPhoneNumber) +
|
|
||||||
'<br />') +
|
|
||||||
cityssm.escapeHTML((_h = occupant.occupantEmailAddress) !== null && _h !== void 0 ? _h : '') +
|
|
||||||
'<br />' +
|
|
||||||
'</div>') +
|
|
||||||
'</div>';
|
|
||||||
panelBlockElement.addEventListener('click', addOccupantFromCopy);
|
|
||||||
panelElement.append(panelBlockElement);
|
|
||||||
}
|
|
||||||
searchResultsElement.innerHTML = '';
|
|
||||||
searchResultsElement.append(panelElement);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
cityssm.openHtmlModal('lotOccupancy-addOccupant', {
|
|
||||||
onshow(modalElement) {
|
|
||||||
los.populateAliases(modalElement);
|
|
||||||
modalElement.querySelector('#lotOccupancyOccupantAdd--lotOccupancyId').value = lotOccupancyId;
|
|
||||||
const lotOccupantTypeSelectElement = modalElement.querySelector('#lotOccupancyOccupantAdd--lotOccupantTypeId');
|
|
||||||
const lotOccupantTypeCopySelectElement = modalElement.querySelector('#lotOccupancyOccupantCopy--lotOccupantTypeId');
|
|
||||||
for (const lotOccupantType of exports.lotOccupantTypes) {
|
|
||||||
const optionElement = document.createElement('option');
|
|
||||||
optionElement.value = lotOccupantType.lotOccupantTypeId.toString();
|
|
||||||
optionElement.textContent = lotOccupantType.lotOccupantType;
|
|
||||||
optionElement.dataset.occupantCommentTitle =
|
|
||||||
lotOccupantType.occupantCommentTitle;
|
|
||||||
lotOccupantTypeSelectElement.append(optionElement);
|
|
||||||
lotOccupantTypeCopySelectElement.append(optionElement.cloneNode(true));
|
|
||||||
}
|
|
||||||
;
|
|
||||||
modalElement.querySelector('#lotOccupancyOccupantAdd--occupantCity').value = exports.occupantCityDefault;
|
|
||||||
modalElement.querySelector('#lotOccupancyOccupantAdd--occupantProvince').value = exports.occupantProvinceDefault;
|
|
||||||
},
|
|
||||||
onshown: (modalElement, closeModalFunction) => {
|
|
||||||
bulmaJS.toggleHtmlClipped();
|
|
||||||
bulmaJS.init(modalElement);
|
|
||||||
const lotOccupantTypeIdElement = modalElement.querySelector('#lotOccupancyOccupantAdd--lotOccupantTypeId');
|
|
||||||
lotOccupantTypeIdElement.focus();
|
|
||||||
lotOccupantTypeIdElement.addEventListener('change', () => {
|
|
||||||
var _a;
|
|
||||||
let occupantCommentTitle = (_a = lotOccupantTypeIdElement.selectedOptions[0].dataset
|
|
||||||
.occupantCommentTitle) !== null && _a !== void 0 ? _a : '';
|
|
||||||
if (occupantCommentTitle === '') {
|
|
||||||
occupantCommentTitle = 'Comment';
|
|
||||||
}
|
|
||||||
modalElement.querySelector('#lotOccupancyOccupantAdd--occupantCommentTitle').textContent = occupantCommentTitle;
|
|
||||||
});
|
|
||||||
addFormElement = modalElement.querySelector('#form--lotOccupancyOccupantAdd');
|
|
||||||
addFormElement.addEventListener('submit', addOccupantFromForm);
|
|
||||||
searchResultsElement = modalElement.querySelector('#lotOccupancyOccupantCopy--searchResults');
|
|
||||||
searchFormElement = modalElement.querySelector('#form--lotOccupancyOccupantCopy');
|
|
||||||
searchFormElement.addEventListener('submit', (formEvent) => {
|
|
||||||
formEvent.preventDefault();
|
|
||||||
});
|
|
||||||
modalElement.querySelector('#lotOccupancyOccupantCopy--searchFilter').addEventListener('change', searchOccupants);
|
|
||||||
addCloseModalFunction = closeModalFunction;
|
|
||||||
},
|
|
||||||
onremoved: () => {
|
|
||||||
bulmaJS.toggleHtmlClipped();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
renderLotOccupancyOccupants();
|
renderLotOccupancyOccupants();
|
||||||
}
|
}
|
||||||
|
(_a = document
|
||||||
|
.querySelector('#button--addOccupant')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => {
|
||||||
|
let addCloseModalFunction;
|
||||||
|
let addFormElement;
|
||||||
|
let searchFormElement;
|
||||||
|
let searchResultsElement;
|
||||||
|
function addOccupant(formOrObject) {
|
||||||
|
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doAddLotOccupancyOccupant', formOrObject, (responseJSON) => {
|
||||||
|
var _a;
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants;
|
||||||
|
addCloseModalFunction();
|
||||||
|
renderLotOccupancyOccupants();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: `Error Adding ${los.escapedAliases.Occupant}`,
|
||||||
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
||||||
|
contextualColorName: 'danger'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function addOccupantFromForm(submitEvent) {
|
||||||
|
submitEvent.preventDefault();
|
||||||
|
addOccupant(addFormElement);
|
||||||
|
}
|
||||||
|
let pastOccupantSearchResults = [];
|
||||||
|
function addOccupantFromCopy(clickEvent) {
|
||||||
|
clickEvent.preventDefault();
|
||||||
|
const panelBlockElement = clickEvent.currentTarget;
|
||||||
|
const occupant = pastOccupantSearchResults[Number.parseInt(panelBlockElement.dataset.index, 10)];
|
||||||
|
const lotOccupantTypeId = panelBlockElement
|
||||||
|
.closest('.modal')
|
||||||
|
.querySelector('#lotOccupancyOccupantCopy--lotOccupantTypeId').value;
|
||||||
|
if (lotOccupantTypeId === '') {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: `No ${los.escapedAliases.Occupant} Type Selected`,
|
||||||
|
message: `Select a type to apply to the newly added ${los.escapedAliases.occupant}.`,
|
||||||
|
contextualColorName: 'warning'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
occupant.lotOccupantTypeId = Number.parseInt(lotOccupantTypeId, 10);
|
||||||
|
occupant.lotOccupancyId = Number.parseInt(lotOccupancyId, 10);
|
||||||
|
addOccupant(occupant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function searchOccupants(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (searchFormElement.querySelector('#lotOccupancyOccupantCopy--searchFilter').value === '') {
|
||||||
|
searchResultsElement.innerHTML =
|
||||||
|
'<div class="message is-info">' +
|
||||||
|
'<p class="message-body">Enter a partial name or address in the search field above.</p>' +
|
||||||
|
'</div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
searchResultsElement.innerHTML =
|
||||||
|
los.getLoadingParagraphHTML('Searching...');
|
||||||
|
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doSearchPastOccupants', searchFormElement, (responseJSON) => {
|
||||||
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||||
|
pastOccupantSearchResults = responseJSON.occupants;
|
||||||
|
const panelElement = document.createElement('div');
|
||||||
|
panelElement.className = 'panel';
|
||||||
|
for (const [index, occupant] of pastOccupantSearchResults.entries()) {
|
||||||
|
const panelBlockElement = document.createElement('a');
|
||||||
|
panelBlockElement.className = 'panel-block is-block';
|
||||||
|
panelBlockElement.dataset.index = index.toString();
|
||||||
|
panelBlockElement.innerHTML =
|
||||||
|
'<strong>' +
|
||||||
|
cityssm.escapeHTML((_a = occupant.occupantName) !== null && _a !== void 0 ? _a : '') +
|
||||||
|
'</strong>' +
|
||||||
|
'<br />' +
|
||||||
|
'<div class="columns">' +
|
||||||
|
('<div class="column">' +
|
||||||
|
cityssm.escapeHTML((_b = occupant.occupantAddress1) !== null && _b !== void 0 ? _b : '') +
|
||||||
|
'<br />' +
|
||||||
|
(((_c = occupant.occupantAddress2) !== null && _c !== void 0 ? _c : '') === ''
|
||||||
|
? ''
|
||||||
|
: cityssm.escapeHTML(occupant.occupantAddress2) + '<br />') +
|
||||||
|
cityssm.escapeHTML((_d = occupant.occupantCity) !== null && _d !== void 0 ? _d : '') +
|
||||||
|
', ' +
|
||||||
|
cityssm.escapeHTML((_e = occupant.occupantProvince) !== null && _e !== void 0 ? _e : '') +
|
||||||
|
'<br />' +
|
||||||
|
cityssm.escapeHTML((_f = occupant.occupantPostalCode) !== null && _f !== void 0 ? _f : '') +
|
||||||
|
'</div>') +
|
||||||
|
('<div class="column">' +
|
||||||
|
(((_g = occupant.occupantPhoneNumber) !== null && _g !== void 0 ? _g : '') === ''
|
||||||
|
? ''
|
||||||
|
: cityssm.escapeHTML(occupant.occupantPhoneNumber) +
|
||||||
|
'<br />') +
|
||||||
|
cityssm.escapeHTML((_h = occupant.occupantEmailAddress) !== null && _h !== void 0 ? _h : '') +
|
||||||
|
'<br />' +
|
||||||
|
'</div>') +
|
||||||
|
'</div>';
|
||||||
|
panelBlockElement.addEventListener('click', addOccupantFromCopy);
|
||||||
|
panelElement.append(panelBlockElement);
|
||||||
|
}
|
||||||
|
searchResultsElement.innerHTML = '';
|
||||||
|
searchResultsElement.append(panelElement);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
cityssm.openHtmlModal('lotOccupancy-addOccupant', {
|
||||||
|
onshow(modalElement) {
|
||||||
|
los.populateAliases(modalElement);
|
||||||
|
modalElement.querySelector('#lotOccupancyOccupantAdd--lotOccupancyId').value = lotOccupancyId;
|
||||||
|
const lotOccupantTypeSelectElement = modalElement.querySelector('#lotOccupancyOccupantAdd--lotOccupantTypeId');
|
||||||
|
const lotOccupantTypeCopySelectElement = modalElement.querySelector('#lotOccupancyOccupantCopy--lotOccupantTypeId');
|
||||||
|
for (const lotOccupantType of exports.lotOccupantTypes) {
|
||||||
|
const optionElement = document.createElement('option');
|
||||||
|
optionElement.value = lotOccupantType.lotOccupantTypeId.toString();
|
||||||
|
optionElement.textContent = lotOccupantType.lotOccupantType;
|
||||||
|
optionElement.dataset.occupantCommentTitle =
|
||||||
|
lotOccupantType.occupantCommentTitle;
|
||||||
|
lotOccupantTypeSelectElement.append(optionElement);
|
||||||
|
lotOccupantTypeCopySelectElement.append(optionElement.cloneNode(true));
|
||||||
|
}
|
||||||
|
;
|
||||||
|
modalElement.querySelector('#lotOccupancyOccupantAdd--occupantCity').value = exports.occupantCityDefault;
|
||||||
|
modalElement.querySelector('#lotOccupancyOccupantAdd--occupantProvince').value = exports.occupantProvinceDefault;
|
||||||
|
},
|
||||||
|
onshown: (modalElement, closeModalFunction) => {
|
||||||
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
bulmaJS.init(modalElement);
|
||||||
|
const lotOccupantTypeIdElement = modalElement.querySelector('#lotOccupancyOccupantAdd--lotOccupantTypeId');
|
||||||
|
lotOccupantTypeIdElement.focus();
|
||||||
|
lotOccupantTypeIdElement.addEventListener('change', () => {
|
||||||
|
var _a;
|
||||||
|
let occupantCommentTitle = (_a = lotOccupantTypeIdElement.selectedOptions[0].dataset
|
||||||
|
.occupantCommentTitle) !== null && _a !== void 0 ? _a : '';
|
||||||
|
if (occupantCommentTitle === '') {
|
||||||
|
occupantCommentTitle = 'Comment';
|
||||||
|
}
|
||||||
|
modalElement.querySelector('#lotOccupancyOccupantAdd--occupantCommentTitle').textContent = occupantCommentTitle;
|
||||||
|
});
|
||||||
|
addFormElement = modalElement.querySelector('#form--lotOccupancyOccupantAdd');
|
||||||
|
addFormElement.addEventListener('submit', addOccupantFromForm);
|
||||||
|
searchResultsElement = modalElement.querySelector('#lotOccupancyOccupantCopy--searchResults');
|
||||||
|
searchFormElement = modalElement.querySelector('#form--lotOccupancyOccupantCopy');
|
||||||
|
searchFormElement.addEventListener('submit', (formEvent) => {
|
||||||
|
formEvent.preventDefault();
|
||||||
|
});
|
||||||
|
modalElement.querySelector('#lotOccupancyOccupantCopy--searchFilter').addEventListener('change', searchOccupants);
|
||||||
|
addCloseModalFunction = closeModalFunction;
|
||||||
|
},
|
||||||
|
onremoved: () => {
|
||||||
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ declare const lotOccupancyId: string
|
||||||
declare const isCreate: boolean
|
declare const isCreate: boolean
|
||||||
declare const formElement: HTMLFormElement
|
declare const formElement: HTMLFormElement
|
||||||
|
|
||||||
let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[]
|
let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] =
|
||||||
|
exports.lotOccupancyOccupants
|
||||||
|
delete exports.lotOccupancyOccupants
|
||||||
|
|
||||||
function openEditLotOccupancyOccupant(clickEvent: Event): void {
|
function openEditLotOccupancyOccupant(clickEvent: Event): void {
|
||||||
const lotOccupantIndex = Number.parseInt(
|
const lotOccupantIndex = Number.parseInt(
|
||||||
|
|
@ -316,7 +318,13 @@ function renderLotOccupancyOccupants(): void {
|
||||||
: cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress!)) +
|
: cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress!)) +
|
||||||
'</td>') +
|
'</td>') +
|
||||||
('<td>' +
|
('<td>' +
|
||||||
'<span data-tooltip="' + cityssm.escapeHTML((lotOccupancyOccupant.occupantCommentTitle ?? '') === '' ? 'Comment' : lotOccupancyOccupant.occupantCommentTitle!) + '">' +
|
'<span data-tooltip="' +
|
||||||
|
cityssm.escapeHTML(
|
||||||
|
(lotOccupancyOccupant.occupantCommentTitle ?? '') === ''
|
||||||
|
? 'Comment'
|
||||||
|
: lotOccupancyOccupant.occupantCommentTitle!
|
||||||
|
) +
|
||||||
|
'">' +
|
||||||
cityssm.escapeHTML(lotOccupancyOccupant.occupantComment ?? '') +
|
cityssm.escapeHTML(lotOccupancyOccupant.occupantComment ?? '') +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'</td>') +
|
'</td>') +
|
||||||
|
|
@ -362,255 +370,246 @@ if (isCreate) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
lotOccupancyOccupants = exports.lotOccupancyOccupants
|
|
||||||
delete exports.lotOccupancyOccupants
|
|
||||||
|
|
||||||
document
|
|
||||||
.querySelector('#button--addOccupant')!
|
|
||||||
.addEventListener('click', () => {
|
|
||||||
let addCloseModalFunction: () => void
|
|
||||||
|
|
||||||
let addFormElement: HTMLFormElement
|
|
||||||
|
|
||||||
let searchFormElement: HTMLFormElement
|
|
||||||
let searchResultsElement: HTMLElement
|
|
||||||
|
|
||||||
function addOccupant(
|
|
||||||
formOrObject: HTMLFormElement | recordTypes.LotOccupancyOccupant
|
|
||||||
): void {
|
|
||||||
cityssm.postJSON(
|
|
||||||
los.urlPrefix + '/lotOccupancies/doAddLotOccupancyOccupant',
|
|
||||||
formOrObject,
|
|
||||||
(responseJSON: {
|
|
||||||
success: boolean
|
|
||||||
errorMessage?: string
|
|
||||||
lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]
|
|
||||||
}) => {
|
|
||||||
if (responseJSON.success) {
|
|
||||||
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants!
|
|
||||||
addCloseModalFunction()
|
|
||||||
renderLotOccupancyOccupants()
|
|
||||||
} else {
|
|
||||||
bulmaJS.alert({
|
|
||||||
title: `Error Adding ${los.escapedAliases.Occupant}`,
|
|
||||||
message: responseJSON.errorMessage ?? '',
|
|
||||||
contextualColorName: 'danger'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function addOccupantFromForm(submitEvent: SubmitEvent): void {
|
|
||||||
submitEvent.preventDefault()
|
|
||||||
addOccupant(addFormElement)
|
|
||||||
}
|
|
||||||
|
|
||||||
let pastOccupantSearchResults: recordTypes.LotOccupancyOccupant[] = []
|
|
||||||
|
|
||||||
function addOccupantFromCopy(clickEvent: MouseEvent): void {
|
|
||||||
clickEvent.preventDefault()
|
|
||||||
|
|
||||||
const panelBlockElement = clickEvent.currentTarget as HTMLElement
|
|
||||||
|
|
||||||
const occupant =
|
|
||||||
pastOccupantSearchResults[
|
|
||||||
Number.parseInt(panelBlockElement.dataset.index!, 10)
|
|
||||||
]
|
|
||||||
|
|
||||||
const lotOccupantTypeId = (
|
|
||||||
panelBlockElement
|
|
||||||
.closest('.modal')!
|
|
||||||
.querySelector(
|
|
||||||
'#lotOccupancyOccupantCopy--lotOccupantTypeId'
|
|
||||||
) as HTMLSelectElement
|
|
||||||
).value
|
|
||||||
|
|
||||||
if (lotOccupantTypeId === '') {
|
|
||||||
bulmaJS.alert({
|
|
||||||
title: `No ${los.escapedAliases.Occupant} Type Selected`,
|
|
||||||
message: `Select a type to apply to the newly added ${los.escapedAliases.occupant}.`,
|
|
||||||
contextualColorName: 'warning'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
occupant.lotOccupantTypeId = Number.parseInt(lotOccupantTypeId, 10)
|
|
||||||
occupant.lotOccupancyId = Number.parseInt(lotOccupancyId, 10)
|
|
||||||
addOccupant(occupant)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function searchOccupants(event: Event): void {
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
if (
|
|
||||||
(
|
|
||||||
searchFormElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantCopy--searchFilter'
|
|
||||||
) as HTMLInputElement
|
|
||||||
).value === ''
|
|
||||||
) {
|
|
||||||
searchResultsElement.innerHTML =
|
|
||||||
'<div class="message is-info">' +
|
|
||||||
'<p class="message-body">Enter a partial name or address in the search field above.</p>' +
|
|
||||||
'</div>'
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
searchResultsElement.innerHTML =
|
|
||||||
los.getLoadingParagraphHTML('Searching...')
|
|
||||||
|
|
||||||
cityssm.postJSON(
|
|
||||||
los.urlPrefix + '/lotOccupancies/doSearchPastOccupants',
|
|
||||||
searchFormElement,
|
|
||||||
(responseJSON: { occupants: recordTypes.LotOccupancyOccupant[] }) => {
|
|
||||||
pastOccupantSearchResults = responseJSON.occupants
|
|
||||||
|
|
||||||
const panelElement = document.createElement('div')
|
|
||||||
panelElement.className = 'panel'
|
|
||||||
|
|
||||||
for (const [
|
|
||||||
index,
|
|
||||||
occupant
|
|
||||||
] of pastOccupantSearchResults.entries()) {
|
|
||||||
const panelBlockElement = document.createElement('a')
|
|
||||||
panelBlockElement.className = 'panel-block is-block'
|
|
||||||
panelBlockElement.dataset.index = index.toString()
|
|
||||||
|
|
||||||
panelBlockElement.innerHTML =
|
|
||||||
'<strong>' +
|
|
||||||
cityssm.escapeHTML(occupant.occupantName ?? '') +
|
|
||||||
'</strong>' +
|
|
||||||
'<br />' +
|
|
||||||
'<div class="columns">' +
|
|
||||||
('<div class="column">' +
|
|
||||||
cityssm.escapeHTML(occupant.occupantAddress1 ?? '') +
|
|
||||||
'<br />' +
|
|
||||||
((occupant.occupantAddress2 ?? '') === ''
|
|
||||||
? ''
|
|
||||||
: cityssm.escapeHTML(occupant.occupantAddress2!) +
|
|
||||||
'<br />') +
|
|
||||||
cityssm.escapeHTML(occupant.occupantCity ?? '') +
|
|
||||||
', ' +
|
|
||||||
cityssm.escapeHTML(occupant.occupantProvince ?? '') +
|
|
||||||
'<br />' +
|
|
||||||
cityssm.escapeHTML(occupant.occupantPostalCode ?? '') +
|
|
||||||
'</div>') +
|
|
||||||
('<div class="column">' +
|
|
||||||
((occupant.occupantPhoneNumber ?? '') === ''
|
|
||||||
? ''
|
|
||||||
: cityssm.escapeHTML(occupant.occupantPhoneNumber!) +
|
|
||||||
'<br />') +
|
|
||||||
cityssm.escapeHTML(occupant.occupantEmailAddress ?? '') +
|
|
||||||
'<br />' +
|
|
||||||
'</div>') +
|
|
||||||
'</div>'
|
|
||||||
|
|
||||||
panelBlockElement.addEventListener('click', addOccupantFromCopy)
|
|
||||||
|
|
||||||
panelElement.append(panelBlockElement)
|
|
||||||
}
|
|
||||||
|
|
||||||
searchResultsElement.innerHTML = ''
|
|
||||||
searchResultsElement.append(panelElement)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
cityssm.openHtmlModal('lotOccupancy-addOccupant', {
|
|
||||||
onshow(modalElement) {
|
|
||||||
los.populateAliases(modalElement)
|
|
||||||
;(
|
|
||||||
modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantAdd--lotOccupancyId'
|
|
||||||
) as HTMLInputElement
|
|
||||||
).value = lotOccupancyId
|
|
||||||
|
|
||||||
const lotOccupantTypeSelectElement = modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantAdd--lotOccupantTypeId'
|
|
||||||
) as HTMLSelectElement
|
|
||||||
|
|
||||||
const lotOccupantTypeCopySelectElement = modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantCopy--lotOccupantTypeId'
|
|
||||||
) as HTMLSelectElement
|
|
||||||
|
|
||||||
for (const lotOccupantType of exports.lotOccupantTypes as recordTypes.LotOccupantType[]) {
|
|
||||||
const optionElement = document.createElement('option')
|
|
||||||
optionElement.value = lotOccupantType.lotOccupantTypeId.toString()
|
|
||||||
optionElement.textContent = lotOccupantType.lotOccupantType
|
|
||||||
optionElement.dataset.occupantCommentTitle =
|
|
||||||
lotOccupantType.occupantCommentTitle
|
|
||||||
|
|
||||||
lotOccupantTypeSelectElement.append(optionElement)
|
|
||||||
|
|
||||||
lotOccupantTypeCopySelectElement.append(
|
|
||||||
optionElement.cloneNode(true)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
;(
|
|
||||||
modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantAdd--occupantCity'
|
|
||||||
) as HTMLInputElement
|
|
||||||
).value = exports.occupantCityDefault
|
|
||||||
;(
|
|
||||||
modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantAdd--occupantProvince'
|
|
||||||
) as HTMLInputElement
|
|
||||||
).value = exports.occupantProvinceDefault
|
|
||||||
},
|
|
||||||
onshown: (modalElement, closeModalFunction) => {
|
|
||||||
bulmaJS.toggleHtmlClipped()
|
|
||||||
bulmaJS.init(modalElement)
|
|
||||||
|
|
||||||
const lotOccupantTypeIdElement = modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantAdd--lotOccupantTypeId'
|
|
||||||
) as HTMLSelectElement
|
|
||||||
|
|
||||||
lotOccupantTypeIdElement.focus()
|
|
||||||
|
|
||||||
lotOccupantTypeIdElement.addEventListener('change', () => {
|
|
||||||
let occupantCommentTitle =
|
|
||||||
lotOccupantTypeIdElement.selectedOptions[0].dataset
|
|
||||||
.occupantCommentTitle ?? ''
|
|
||||||
|
|
||||||
if (occupantCommentTitle === '') {
|
|
||||||
occupantCommentTitle = 'Comment'
|
|
||||||
}
|
|
||||||
|
|
||||||
modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantAdd--occupantCommentTitle'
|
|
||||||
)!.textContent = occupantCommentTitle
|
|
||||||
})
|
|
||||||
|
|
||||||
addFormElement = modalElement.querySelector(
|
|
||||||
'#form--lotOccupancyOccupantAdd'
|
|
||||||
) as HTMLFormElement
|
|
||||||
addFormElement.addEventListener('submit', addOccupantFromForm)
|
|
||||||
|
|
||||||
searchResultsElement = modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantCopy--searchResults'
|
|
||||||
) as HTMLElement
|
|
||||||
|
|
||||||
searchFormElement = modalElement.querySelector(
|
|
||||||
'#form--lotOccupancyOccupantCopy'
|
|
||||||
) as HTMLFormElement
|
|
||||||
searchFormElement.addEventListener('submit', (formEvent) => {
|
|
||||||
formEvent.preventDefault()
|
|
||||||
})
|
|
||||||
;(
|
|
||||||
modalElement.querySelector(
|
|
||||||
'#lotOccupancyOccupantCopy--searchFilter'
|
|
||||||
) as HTMLInputElement
|
|
||||||
).addEventListener('change', searchOccupants)
|
|
||||||
|
|
||||||
addCloseModalFunction = closeModalFunction
|
|
||||||
},
|
|
||||||
onremoved: () => {
|
|
||||||
bulmaJS.toggleHtmlClipped()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
renderLotOccupancyOccupants()
|
renderLotOccupancyOccupants()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelector('#button--addOccupant')
|
||||||
|
?.addEventListener('click', () => {
|
||||||
|
let addCloseModalFunction: () => void
|
||||||
|
|
||||||
|
let addFormElement: HTMLFormElement
|
||||||
|
|
||||||
|
let searchFormElement: HTMLFormElement
|
||||||
|
let searchResultsElement: HTMLElement
|
||||||
|
|
||||||
|
function addOccupant(
|
||||||
|
formOrObject: HTMLFormElement | recordTypes.LotOccupancyOccupant
|
||||||
|
): void {
|
||||||
|
cityssm.postJSON(
|
||||||
|
los.urlPrefix + '/lotOccupancies/doAddLotOccupancyOccupant',
|
||||||
|
formOrObject,
|
||||||
|
(responseJSON: {
|
||||||
|
success: boolean
|
||||||
|
errorMessage?: string
|
||||||
|
lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]
|
||||||
|
}) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
lotOccupancyOccupants = responseJSON.lotOccupancyOccupants!
|
||||||
|
addCloseModalFunction()
|
||||||
|
renderLotOccupancyOccupants()
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: `Error Adding ${los.escapedAliases.Occupant}`,
|
||||||
|
message: responseJSON.errorMessage ?? '',
|
||||||
|
contextualColorName: 'danger'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function addOccupantFromForm(submitEvent: SubmitEvent): void {
|
||||||
|
submitEvent.preventDefault()
|
||||||
|
addOccupant(addFormElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
let pastOccupantSearchResults: recordTypes.LotOccupancyOccupant[] = []
|
||||||
|
|
||||||
|
function addOccupantFromCopy(clickEvent: MouseEvent): void {
|
||||||
|
clickEvent.preventDefault()
|
||||||
|
|
||||||
|
const panelBlockElement = clickEvent.currentTarget as HTMLElement
|
||||||
|
|
||||||
|
const occupant =
|
||||||
|
pastOccupantSearchResults[
|
||||||
|
Number.parseInt(panelBlockElement.dataset.index!, 10)
|
||||||
|
]
|
||||||
|
|
||||||
|
const lotOccupantTypeId = (
|
||||||
|
panelBlockElement
|
||||||
|
.closest('.modal')!
|
||||||
|
.querySelector(
|
||||||
|
'#lotOccupancyOccupantCopy--lotOccupantTypeId'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
).value
|
||||||
|
|
||||||
|
if (lotOccupantTypeId === '') {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: `No ${los.escapedAliases.Occupant} Type Selected`,
|
||||||
|
message: `Select a type to apply to the newly added ${los.escapedAliases.occupant}.`,
|
||||||
|
contextualColorName: 'warning'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
occupant.lotOccupantTypeId = Number.parseInt(lotOccupantTypeId, 10)
|
||||||
|
occupant.lotOccupancyId = Number.parseInt(lotOccupancyId, 10)
|
||||||
|
addOccupant(occupant)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchOccupants(event: Event): void {
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
searchFormElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantCopy--searchFilter'
|
||||||
|
) as HTMLInputElement
|
||||||
|
).value === ''
|
||||||
|
) {
|
||||||
|
searchResultsElement.innerHTML =
|
||||||
|
'<div class="message is-info">' +
|
||||||
|
'<p class="message-body">Enter a partial name or address in the search field above.</p>' +
|
||||||
|
'</div>'
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
searchResultsElement.innerHTML =
|
||||||
|
los.getLoadingParagraphHTML('Searching...')
|
||||||
|
|
||||||
|
cityssm.postJSON(
|
||||||
|
los.urlPrefix + '/lotOccupancies/doSearchPastOccupants',
|
||||||
|
searchFormElement,
|
||||||
|
(responseJSON: { occupants: recordTypes.LotOccupancyOccupant[] }) => {
|
||||||
|
pastOccupantSearchResults = responseJSON.occupants
|
||||||
|
|
||||||
|
const panelElement = document.createElement('div')
|
||||||
|
panelElement.className = 'panel'
|
||||||
|
|
||||||
|
for (const [index, occupant] of pastOccupantSearchResults.entries()) {
|
||||||
|
const panelBlockElement = document.createElement('a')
|
||||||
|
panelBlockElement.className = 'panel-block is-block'
|
||||||
|
panelBlockElement.dataset.index = index.toString()
|
||||||
|
|
||||||
|
panelBlockElement.innerHTML =
|
||||||
|
'<strong>' +
|
||||||
|
cityssm.escapeHTML(occupant.occupantName ?? '') +
|
||||||
|
'</strong>' +
|
||||||
|
'<br />' +
|
||||||
|
'<div class="columns">' +
|
||||||
|
('<div class="column">' +
|
||||||
|
cityssm.escapeHTML(occupant.occupantAddress1 ?? '') +
|
||||||
|
'<br />' +
|
||||||
|
((occupant.occupantAddress2 ?? '') === ''
|
||||||
|
? ''
|
||||||
|
: cityssm.escapeHTML(occupant.occupantAddress2!) + '<br />') +
|
||||||
|
cityssm.escapeHTML(occupant.occupantCity ?? '') +
|
||||||
|
', ' +
|
||||||
|
cityssm.escapeHTML(occupant.occupantProvince ?? '') +
|
||||||
|
'<br />' +
|
||||||
|
cityssm.escapeHTML(occupant.occupantPostalCode ?? '') +
|
||||||
|
'</div>') +
|
||||||
|
('<div class="column">' +
|
||||||
|
((occupant.occupantPhoneNumber ?? '') === ''
|
||||||
|
? ''
|
||||||
|
: cityssm.escapeHTML(occupant.occupantPhoneNumber!) +
|
||||||
|
'<br />') +
|
||||||
|
cityssm.escapeHTML(occupant.occupantEmailAddress ?? '') +
|
||||||
|
'<br />' +
|
||||||
|
'</div>') +
|
||||||
|
'</div>'
|
||||||
|
|
||||||
|
panelBlockElement.addEventListener('click', addOccupantFromCopy)
|
||||||
|
|
||||||
|
panelElement.append(panelBlockElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
searchResultsElement.innerHTML = ''
|
||||||
|
searchResultsElement.append(panelElement)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
cityssm.openHtmlModal('lotOccupancy-addOccupant', {
|
||||||
|
onshow(modalElement) {
|
||||||
|
los.populateAliases(modalElement)
|
||||||
|
;(
|
||||||
|
modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantAdd--lotOccupancyId'
|
||||||
|
) as HTMLInputElement
|
||||||
|
).value = lotOccupancyId
|
||||||
|
|
||||||
|
const lotOccupantTypeSelectElement = modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantAdd--lotOccupantTypeId'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
const lotOccupantTypeCopySelectElement = modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantCopy--lotOccupantTypeId'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
for (const lotOccupantType of exports.lotOccupantTypes as recordTypes.LotOccupantType[]) {
|
||||||
|
const optionElement = document.createElement('option')
|
||||||
|
optionElement.value = lotOccupantType.lotOccupantTypeId.toString()
|
||||||
|
optionElement.textContent = lotOccupantType.lotOccupantType
|
||||||
|
optionElement.dataset.occupantCommentTitle =
|
||||||
|
lotOccupantType.occupantCommentTitle
|
||||||
|
|
||||||
|
lotOccupantTypeSelectElement.append(optionElement)
|
||||||
|
|
||||||
|
lotOccupantTypeCopySelectElement.append(optionElement.cloneNode(true))
|
||||||
|
}
|
||||||
|
|
||||||
|
;(
|
||||||
|
modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantAdd--occupantCity'
|
||||||
|
) as HTMLInputElement
|
||||||
|
).value = exports.occupantCityDefault
|
||||||
|
;(
|
||||||
|
modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantAdd--occupantProvince'
|
||||||
|
) as HTMLInputElement
|
||||||
|
).value = exports.occupantProvinceDefault
|
||||||
|
},
|
||||||
|
onshown: (modalElement, closeModalFunction) => {
|
||||||
|
bulmaJS.toggleHtmlClipped()
|
||||||
|
bulmaJS.init(modalElement)
|
||||||
|
|
||||||
|
const lotOccupantTypeIdElement = modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantAdd--lotOccupantTypeId'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
lotOccupantTypeIdElement.focus()
|
||||||
|
|
||||||
|
lotOccupantTypeIdElement.addEventListener('change', () => {
|
||||||
|
let occupantCommentTitle =
|
||||||
|
lotOccupantTypeIdElement.selectedOptions[0].dataset
|
||||||
|
.occupantCommentTitle ?? ''
|
||||||
|
|
||||||
|
if (occupantCommentTitle === '') {
|
||||||
|
occupantCommentTitle = 'Comment'
|
||||||
|
}
|
||||||
|
|
||||||
|
modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantAdd--occupantCommentTitle'
|
||||||
|
)!.textContent = occupantCommentTitle
|
||||||
|
})
|
||||||
|
|
||||||
|
addFormElement = modalElement.querySelector(
|
||||||
|
'#form--lotOccupancyOccupantAdd'
|
||||||
|
) as HTMLFormElement
|
||||||
|
addFormElement.addEventListener('submit', addOccupantFromForm)
|
||||||
|
|
||||||
|
searchResultsElement = modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantCopy--searchResults'
|
||||||
|
) as HTMLElement
|
||||||
|
|
||||||
|
searchFormElement = modalElement.querySelector(
|
||||||
|
'#form--lotOccupancyOccupantCopy'
|
||||||
|
) as HTMLFormElement
|
||||||
|
searchFormElement.addEventListener('submit', (formEvent) => {
|
||||||
|
formEvent.preventDefault()
|
||||||
|
})
|
||||||
|
;(
|
||||||
|
modalElement.querySelector(
|
||||||
|
'#lotOccupancyOccupantCopy--searchFilter'
|
||||||
|
) as HTMLInputElement
|
||||||
|
).addEventListener('change', searchOccupants)
|
||||||
|
|
||||||
|
addCloseModalFunction = closeModalFunction
|
||||||
|
},
|
||||||
|
onremoved: () => {
|
||||||
|
bulmaJS.toggleHtmlClipped()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue