update occupant comment title on create

deepsource-autofix-76c6eb20
Dan Gowans 2023-02-01 13:23:55 -05:00
parent 584f33fb98
commit b2077f2f9a
7 changed files with 235 additions and 211 deletions

View File

@ -2,7 +2,7 @@
/* eslint-disable spaced-comment, @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true });
(() => {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f;
const los = exports.los;
const lotOccupancyId = document.querySelector('#lotOccupancy--lotOccupancyId').value;
const isCreate = lotOccupancyId === '';
@ -418,9 +418,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
});
});
document
.querySelector('.is-lot-view-button')
.addEventListener('click', () => {
(_d = document
.querySelector('.is-lot-view-button')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', () => {
const lotId = document.querySelector('#lotOccupancy--lotId').value;
if (lotId === '') {
bulmaJS.alert({
@ -432,9 +431,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
window.open(los.urlPrefix + '/lots/' + lotId);
}
});
document
.querySelector('.is-clear-lot-button')
.addEventListener('click', () => {
(_e = document
.querySelector('.is-clear-lot-button')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', () => {
if (lotNameElement.disabled) {
bulmaJS.alert({
message: 'You need to unlock the field before clearing it.',
@ -449,9 +447,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
// Start Date
los.initializeDatePickers(formElement);
document
.querySelector('#lotOccupancy--occupancyStartDateString')
.addEventListener('change', () => {
(_f = document
.querySelector('#lotOccupancy--occupancyStartDateString')) === null || _f === void 0 ? void 0 : _f.addEventListener('change', () => {
const endDatePicker = document.querySelector('#lotOccupancy--occupancyEndDateString').bulmaCalendar.datePicker;
endDatePicker.min = document.querySelector('#lotOccupancy--occupancyStartDateString').value;
endDatePicker.refresh();
@ -699,10 +696,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector('#lotOccupancy--lotOccupantTypeId');
lotOccupantTypeIdElement.addEventListener('change', () => {
var _a;
const occupantFields = formElement.querySelectorAll("[data-table='LotOccupancyOccupant']");
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === '';
}
let occupantCommentTitle = (_a = lotOccupantTypeIdElement.selectedOptions[0].dataset
.occupantCommentTitle) !== null && _a !== void 0 ? _a : '';
if (occupantCommentTitle === '') {
occupantCommentTitle = 'Comment';
}
formElement.querySelector('#lotOccupancy--occupantCommentTitle').textContent = occupantCommentTitle;
});
}
else {

View File

@ -2,7 +2,7 @@
/* eslint-disable spaced-comment, @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true });
(() => {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f;
const los = exports.los;
const lotOccupancyId = document.querySelector('#lotOccupancy--lotOccupancyId').value;
const isCreate = lotOccupancyId === '';
@ -418,9 +418,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
});
});
document
.querySelector('.is-lot-view-button')
.addEventListener('click', () => {
(_d = document
.querySelector('.is-lot-view-button')) === null || _d === void 0 ? void 0 : _d.addEventListener('click', () => {
const lotId = document.querySelector('#lotOccupancy--lotId').value;
if (lotId === '') {
bulmaJS.alert({
@ -432,9 +431,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
window.open(los.urlPrefix + '/lots/' + lotId);
}
});
document
.querySelector('.is-clear-lot-button')
.addEventListener('click', () => {
(_e = document
.querySelector('.is-clear-lot-button')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', () => {
if (lotNameElement.disabled) {
bulmaJS.alert({
message: 'You need to unlock the field before clearing it.',
@ -449,9 +447,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
// Start Date
los.initializeDatePickers(formElement);
document
.querySelector('#lotOccupancy--occupancyStartDateString')
.addEventListener('change', () => {
(_f = document
.querySelector('#lotOccupancy--occupancyStartDateString')) === null || _f === void 0 ? void 0 : _f.addEventListener('change', () => {
const endDatePicker = document.querySelector('#lotOccupancy--occupancyEndDateString').bulmaCalendar.datePicker;
endDatePicker.min = document.querySelector('#lotOccupancy--occupancyStartDateString').value;
endDatePicker.refresh();

View File

@ -645,8 +645,8 @@ declare const bulmaJS: BulmaJS
})
document
.querySelector('.is-lot-view-button')!
.addEventListener('click', () => {
.querySelector('.is-lot-view-button')
?.addEventListener('click', () => {
const lotId = (
document.querySelector('#lotOccupancy--lotId') as HTMLInputElement
).value
@ -662,8 +662,8 @@ declare const bulmaJS: BulmaJS
})
document
.querySelector('.is-clear-lot-button')!
.addEventListener('click', () => {
.querySelector('.is-clear-lot-button')
?.addEventListener('click', () => {
if (lotNameElement.disabled) {
bulmaJS.alert({
message: 'You need to unlock the field before clearing it.',
@ -683,8 +683,8 @@ declare const bulmaJS: BulmaJS
los.initializeDatePickers(formElement)
document
.querySelector('#lotOccupancy--occupancyStartDateString')!
.addEventListener('change', () => {
.querySelector('#lotOccupancy--occupancyStartDateString')
?.addEventListener('change', () => {
const endDatePicker = (
document.querySelector(
'#lotOccupancy--occupancyEndDateString'

View File

@ -237,10 +237,17 @@ function renderLotOccupancyOccupants() {
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector('#lotOccupancy--lotOccupantTypeId');
lotOccupantTypeIdElement.addEventListener('change', () => {
var _a;
const occupantFields = formElement.querySelectorAll("[data-table='LotOccupancyOccupant']");
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === '';
}
let occupantCommentTitle = (_a = lotOccupantTypeIdElement.selectedOptions[0].dataset
.occupantCommentTitle) !== null && _a !== void 0 ? _a : '';
if (occupantCommentTitle === '') {
occupantCommentTitle = 'Comment';
}
formElement.querySelector('#lotOccupancy--occupantCommentTitle').textContent = occupantCommentTitle;
});
}
else {

View File

@ -392,6 +392,17 @@ if (isCreate) {
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === ''
}
let occupantCommentTitle =
lotOccupantTypeIdElement.selectedOptions[0].dataset
.occupantCommentTitle ?? ''
if (occupantCommentTitle === '') {
occupantCommentTitle = 'Comment'
}
formElement.querySelector(
'#lotOccupancy--occupantCommentTitle'
)!.textContent = occupantCommentTitle
})
} else {
renderLotOccupancyOccupants()

File diff suppressed because one or more lines are too long

View File

@ -319,9 +319,14 @@
<div class="control">
<div class="select is-fullwidth">
<select id="lotOccupancy--lotOccupantTypeId" name="lotOccupantTypeId">
<option value="">(Select a Type to Create a <%= configFunctions.getProperty("aliases.occupant") %>)</option>
<option value="" data-occupant-comment-title="Comment">
(Select a Type to Create a <%= configFunctions.getProperty("aliases.occupant") %>)
</option>
<% for (const lotOccupantType of lotOccupantTypes) { %>
<option value="<%= lotOccupantType.lotOccupantTypeId %>"><%= lotOccupantType.lotOccupantType %></option>
<option value="<%= lotOccupantType.lotOccupantTypeId %>"
data-occupant-comment-title="<%= lotOccupantType.occupantCommentTitle %>">
<%= lotOccupantType.lotOccupantType %>
</option>
<% } %>
</select>
</div>
@ -391,7 +396,7 @@
</div>
</div>
<div class="field">
<label class="label" for="lotOccupancy--occupantComment">Comment</label>
<label class="label" id="lotOccupancy--occupantCommentTitle" for="lotOccupancy--occupantComment">Comment</label>
<div class="control">
<textarea class="textarea" id="lotOccupancy--occupantComment" data-table="LotOccupancyOccupant" name="occupantComment" disabled></textarea>
</div>