work order edit add modal focus

deepsource-autofix-76c6eb20
Dan Gowans 2023-01-31 10:48:19 -05:00
parent f2d481fffc
commit 82f0c902a2
8 changed files with 106 additions and 68 deletions

View File

@ -2,7 +2,7 @@
/* eslint-disable spaced-comment, @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ /* eslint-disable spaced-comment, @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
(() => { (() => {
var _a, _b; var _a, _b, _c;
const los = exports.los; const los = exports.los;
const workOrderId = document.querySelector('#workOrderEdit--workOrderId').value; const workOrderId = document.querySelector('#workOrderEdit--workOrderId').value;
const isCreate = workOrderId === ''; const isCreate = workOrderId === '';
@ -136,7 +136,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
*/ */
if (!isCreate) { if (!isCreate) {
"use strict"; "use strict";
/* eslint-disable @typescript-eslint/indent */
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ /* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let workOrderLots = exports.workOrderLots; let workOrderLots = exports.workOrderLots;
delete exports.workOrderLots; delete exports.workOrderLots;
@ -502,9 +504,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
}); });
} }
document (_a = document
.querySelector('#button--addLotOccupancy') .querySelector('#button--addLotOccupancy')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => {
.addEventListener('click', () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
function doSearch(event) { function doSearch(event) {
@ -517,8 +518,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
var _a, _b; var _a, _b;
if (responseJSON.lotOccupancies.length === 0) { if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML = `<div class="message is-info"> searchResultsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no records that meet the search criteria.</p> <p class="message-body">There are no records that meet the search criteria.</p>
</div>`; </div>`;
return; return;
} }
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
@ -593,12 +594,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
}, },
onshown(modalElement) { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector('#lotOccupancySearch--occupantName').addEventListener('change', doSearch); const occupantNameElement = modalElement.querySelector('#lotOccupancySearch--occupantName');
occupantNameElement.addEventListener('change', doSearch);
occupantNameElement.focus();
modalElement.querySelector('#lotOccupancySearch--lotName').addEventListener('change', doSearch); modalElement.querySelector('#lotOccupancySearch--lotName').addEventListener('change', doSearch);
searchFormElement.addEventListener('submit', doSearch); searchFormElement.addEventListener('submit', doSearch);
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addLotOccupancy').focus();
} }
}); });
}); });
@ -611,7 +615,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
}); });
} }
document.querySelector('#button--addLot').addEventListener('click', () => { (_b = document.querySelector('#button--addLot')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
function doSearch(event) { function doSearch(event) {
@ -683,9 +687,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
}, },
onshown(modalElement) { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement const lotNameElement = modalElement.querySelector('#lotSearch--lotName');
.querySelector('#lotSearch--lotName') lotNameElement.addEventListener('change', doSearch);
.addEventListener('change', doSearch); lotNameElement.focus();
modalElement modalElement
.querySelector('#lotSearch--lotStatusId') .querySelector('#lotSearch--lotStatusId')
.addEventListener('change', doSearch); .addEventListener('change', doSearch);
@ -693,6 +697,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addLot').focus();
} }
}); });
}); });
@ -799,17 +804,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
const containerElement = document.querySelector('#container--workOrderComments'); const containerElement = document.querySelector('#container--workOrderComments');
if (workOrderComments.length === 0) { if (workOrderComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info"> containerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no comments to display.</p> <p class="message-body">There are no comments to display.</p>
</div>`; </div>`;
return; return;
} }
const tableElement = document.createElement('table'); const tableElement = document.createElement('table');
tableElement.className = 'table is-fullwidth is-striped is-hoverable'; tableElement.className = 'table is-fullwidth is-striped is-hoverable';
tableElement.innerHTML = `<thead><tr> tableElement.innerHTML = `<thead><tr>
<th>Commentor</th> <th>Commentor</th>
<th>Comment Date</th> <th>Comment Date</th>
<th>Comment</th> <th>Comment</th>
<th class="is-hidden-print"><span class="is-sr-only">Options</span></th></tr></thead><tbody></tbody>`; <th class="is-hidden-print"><span class="is-sr-only">Options</span></th></tr></thead><tbody></tbody>`;
for (const workOrderComment of workOrderComments) { for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr'); const tableRowElement = document.createElement('tr');
tableRowElement.dataset.workOrderCommentId = tableRowElement.dataset.workOrderCommentId =
@ -1122,9 +1127,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.workOrderMilestones; exports.workOrderMilestones;
delete exports.workOrderMilestones; delete exports.workOrderMilestones;
renderMilestones(); renderMilestones();
document (_c = document
.querySelector('#button--addMilestone') .querySelector('#button--addMilestone')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', () => {
.addEventListener('click', () => {
let addModalElement; let addModalElement;
let addFormElement; let addFormElement;
let addCloseModalFunction; let addCloseModalFunction;
@ -1177,11 +1181,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
los.initializeDatePickers(modalElement); los.initializeDatePickers(modalElement);
// los.initializeTimePickers(modalElement); // los.initializeTimePickers(modalElement);
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector('#milestoneAdd--workOrderMilestoneTypeId').focus();
addFormElement = modalElement.querySelector('form'); addFormElement = modalElement.querySelector('form');
addFormElement.addEventListener('submit', doAdd); addFormElement.addEventListener('submit', doAdd);
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addMilestone').focus();
} }
}); });
}); });

View File

@ -2,7 +2,7 @@
/* eslint-disable spaced-comment, @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ /* eslint-disable spaced-comment, @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
(() => { (() => {
var _a, _b; var _a, _b, _c;
const los = exports.los; const los = exports.los;
const workOrderId = document.querySelector('#workOrderEdit--workOrderId').value; const workOrderId = document.querySelector('#workOrderEdit--workOrderId').value;
const isCreate = workOrderId === ''; const isCreate = workOrderId === '';
@ -377,9 +377,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.workOrderMilestones; exports.workOrderMilestones;
delete exports.workOrderMilestones; delete exports.workOrderMilestones;
renderMilestones(); renderMilestones();
document (_c = document
.querySelector('#button--addMilestone') .querySelector('#button--addMilestone')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', () => {
.addEventListener('click', () => {
let addModalElement; let addModalElement;
let addFormElement; let addFormElement;
let addCloseModalFunction; let addCloseModalFunction;
@ -432,11 +431,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
los.initializeDatePickers(modalElement); los.initializeDatePickers(modalElement);
// los.initializeTimePickers(modalElement); // los.initializeTimePickers(modalElement);
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector('#milestoneAdd--workOrderMilestoneTypeId').focus();
addFormElement = modalElement.querySelector('form'); addFormElement = modalElement.querySelector('form');
addFormElement.addEventListener('submit', doAdd); addFormElement.addEventListener('submit', doAdd);
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addMilestone').focus();
} }
}); });
}); });

View File

@ -548,8 +548,8 @@ declare const bulmaJS: BulmaJS
renderMilestones() renderMilestones()
document document
.querySelector('#button--addMilestone')! .querySelector('#button--addMilestone')
.addEventListener('click', () => { ?.addEventListener('click', () => {
let addModalElement: HTMLElement let addModalElement: HTMLElement
let addFormElement: HTMLFormElement let addFormElement: HTMLFormElement
let addCloseModalFunction: () => void let addCloseModalFunction: () => void
@ -579,14 +579,17 @@ declare const bulmaJS: BulmaJS
) )
} }
if (( if (
addModalElement.querySelector( (
'#milestoneAdd--workOrderMilestoneDateString' addModalElement.querySelector(
) as HTMLInputElement '#milestoneAdd--workOrderMilestoneDateString'
).value < currentDateString) { ) as HTMLInputElement
).value < currentDateString
) {
bulmaJS.confirm({ bulmaJS.confirm({
title: 'Milestone Date in the Past', title: 'Milestone Date in the Past',
message: 'Are you sure you want to create a milestone with a date in the past?', message:
'Are you sure you want to create a milestone with a date in the past?',
contextualColorName: 'warning', contextualColorName: 'warning',
okButton: { okButton: {
text: 'Yes, Create a Past Milestone', text: 'Yes, Create a Past Milestone',
@ -634,12 +637,22 @@ declare const bulmaJS: BulmaJS
// los.initializeTimePickers(modalElement); // los.initializeTimePickers(modalElement);
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
;(
modalElement.querySelector(
'#milestoneAdd--workOrderMilestoneTypeId'
) as HTMLSelectElement
).focus()
addFormElement = modalElement.querySelector('form')! addFormElement = modalElement.querySelector('form')!
addFormElement.addEventListener('submit', doAdd) addFormElement.addEventListener('submit', doAdd)
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
;(
document.querySelector(
'#button--addMilestone'
) as HTMLButtonElement
).focus()
} }
}) })
}) })

View File

@ -96,17 +96,17 @@ function renderWorkOrderComments() {
const containerElement = document.querySelector('#container--workOrderComments'); const containerElement = document.querySelector('#container--workOrderComments');
if (workOrderComments.length === 0) { if (workOrderComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info"> containerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no comments to display.</p> <p class="message-body">There are no comments to display.</p>
</div>`; </div>`;
return; return;
} }
const tableElement = document.createElement('table'); const tableElement = document.createElement('table');
tableElement.className = 'table is-fullwidth is-striped is-hoverable'; tableElement.className = 'table is-fullwidth is-striped is-hoverable';
tableElement.innerHTML = `<thead><tr> tableElement.innerHTML = `<thead><tr>
<th>Commentor</th> <th>Commentor</th>
<th>Comment Date</th> <th>Comment Date</th>
<th>Comment</th> <th>Comment</th>
<th class="is-hidden-print"><span class="is-sr-only">Options</span></th></tr></thead><tbody></tbody>`; <th class="is-hidden-print"><span class="is-sr-only">Options</span></th></tr></thead><tbody></tbody>`;
for (const workOrderComment of workOrderComments) { for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr'); const tableRowElement = document.createElement('tr');
tableRowElement.dataset.workOrderCommentId = tableRowElement.dataset.workOrderCommentId =

View File

@ -167,18 +167,18 @@ function renderWorkOrderComments(): void {
if (workOrderComments.length === 0) { if (workOrderComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info"> containerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no comments to display.</p> <p class="message-body">There are no comments to display.</p>
</div>` </div>`
return return
} }
const tableElement = document.createElement('table') const tableElement = document.createElement('table')
tableElement.className = 'table is-fullwidth is-striped is-hoverable' tableElement.className = 'table is-fullwidth is-striped is-hoverable'
tableElement.innerHTML = `<thead><tr> tableElement.innerHTML = `<thead><tr>
<th>Commentor</th> <th>Commentor</th>
<th>Comment Date</th> <th>Comment Date</th>
<th>Comment</th> <th>Comment</th>
<th class="is-hidden-print"><span class="is-sr-only">Options</span></th></tr></thead><tbody></tbody>` <th class="is-hidden-print"><span class="is-sr-only">Options</span></th></tr></thead><tbody></tbody>`
for (const workOrderComment of workOrderComments) { for (const workOrderComment of workOrderComments) {
const tableRowElement = document.createElement('tr') const tableRowElement = document.createElement('tr')

View File

@ -1,5 +1,7 @@
"use strict"; "use strict";
/* eslint-disable @typescript-eslint/indent */
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ /* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let workOrderLots = exports.workOrderLots; let workOrderLots = exports.workOrderLots;
delete exports.workOrderLots; delete exports.workOrderLots;
@ -365,9 +367,8 @@ function doAddLotOccupancy(clickEvent) {
} }
}); });
} }
document (_a = document
.querySelector('#button--addLotOccupancy') .querySelector('#button--addLotOccupancy')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => {
.addEventListener('click', () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
function doSearch(event) { function doSearch(event) {
@ -380,8 +381,8 @@ document
var _a, _b; var _a, _b;
if (responseJSON.lotOccupancies.length === 0) { if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML = `<div class="message is-info"> searchResultsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no records that meet the search criteria.</p> <p class="message-body">There are no records that meet the search criteria.</p>
</div>`; </div>`;
return; return;
} }
searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> searchResultsContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
@ -456,12 +457,15 @@ document
}, },
onshown(modalElement) { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector('#lotOccupancySearch--occupantName').addEventListener('change', doSearch); const occupantNameElement = modalElement.querySelector('#lotOccupancySearch--occupantName');
occupantNameElement.addEventListener('change', doSearch);
occupantNameElement.focus();
modalElement.querySelector('#lotOccupancySearch--lotName').addEventListener('change', doSearch); modalElement.querySelector('#lotOccupancySearch--lotName').addEventListener('change', doSearch);
searchFormElement.addEventListener('submit', doSearch); searchFormElement.addEventListener('submit', doSearch);
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addLotOccupancy').focus();
} }
}); });
}); });
@ -474,7 +478,7 @@ function doAddLot(clickEvent) {
} }
}); });
} }
document.querySelector('#button--addLot').addEventListener('click', () => { (_b = document.querySelector('#button--addLot')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', () => {
let searchFormElement; let searchFormElement;
let searchResultsContainerElement; let searchResultsContainerElement;
function doSearch(event) { function doSearch(event) {
@ -546,9 +550,9 @@ document.querySelector('#button--addLot').addEventListener('click', () => {
}, },
onshown(modalElement) { onshown(modalElement) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement const lotNameElement = modalElement.querySelector('#lotSearch--lotName');
.querySelector('#lotSearch--lotName') lotNameElement.addEventListener('change', doSearch);
.addEventListener('change', doSearch); lotNameElement.focus();
modalElement modalElement
.querySelector('#lotSearch--lotStatusId') .querySelector('#lotSearch--lotStatusId')
.addEventListener('change', doSearch); .addEventListener('change', doSearch);
@ -556,6 +560,7 @@ document.querySelector('#button--addLot').addEventListener('click', () => {
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addLot').focus();
} }
}); });
}); });

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/indent */
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ /* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types'
@ -526,8 +527,8 @@ function doAddLotOccupancy(clickEvent: Event): void {
} }
document document
.querySelector('#button--addLotOccupancy')! .querySelector('#button--addLotOccupancy')
.addEventListener('click', () => { ?.addEventListener('click', () => {
let searchFormElement: HTMLFormElement let searchFormElement: HTMLFormElement
let searchResultsContainerElement: HTMLElement let searchResultsContainerElement: HTMLElement
@ -545,8 +546,8 @@ document
(responseJSON: { lotOccupancies: recordTypes.LotOccupancy[] }) => { (responseJSON: { lotOccupancies: recordTypes.LotOccupancy[] }) => {
if (responseJSON.lotOccupancies.length === 0) { if (responseJSON.lotOccupancies.length === 0) {
searchResultsContainerElement.innerHTML = `<div class="message is-info"> searchResultsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no records that meet the search criteria.</p> <p class="message-body">There are no records that meet the search criteria.</p>
</div>` </div>`
return return
} }
@ -658,11 +659,13 @@ document
}, },
onshown(modalElement) { onshown(modalElement) {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
;(
modalElement.querySelector( const occupantNameElement = modalElement.querySelector(
'#lotOccupancySearch--occupantName' '#lotOccupancySearch--occupantName'
) as HTMLInputElement ) as HTMLInputElement
).addEventListener('change', doSearch)
occupantNameElement.addEventListener('change', doSearch)
occupantNameElement.focus()
;( ;(
modalElement.querySelector( modalElement.querySelector(
'#lotOccupancySearch--lotName' '#lotOccupancySearch--lotName'
@ -673,6 +676,11 @@ document
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
;(
document.querySelector(
'#button--addLotOccupancy'
) as HTMLButtonElement
).focus()
} }
}) })
}) })
@ -689,7 +697,7 @@ function doAddLot(clickEvent: Event): void {
}) })
} }
document.querySelector('#button--addLot')!.addEventListener('click', () => { document.querySelector('#button--addLot')?.addEventListener('click', () => {
let searchFormElement: HTMLFormElement let searchFormElement: HTMLFormElement
let searchResultsContainerElement: HTMLElement let searchResultsContainerElement: HTMLElement
@ -788,9 +796,12 @@ document.querySelector('#button--addLot')!.addEventListener('click', () => {
onshown(modalElement) { onshown(modalElement) {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
modalElement const lotNameElement = modalElement.querySelector(
.querySelector('#lotSearch--lotName')! '#lotSearch--lotName'
.addEventListener('change', doSearch) ) as HTMLInputElement
lotNameElement.addEventListener('change', doSearch)
lotNameElement.focus()
modalElement modalElement
.querySelector('#lotSearch--lotStatusId')! .querySelector('#lotSearch--lotStatusId')!
@ -800,6 +811,8 @@ document.querySelector('#button--addLot')!.addEventListener('click', () => {
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
;(document.querySelector('#button--addLot') as HTMLButtonElement).focus()
} }
}) })
}) })

File diff suppressed because one or more lines are too long