Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Jun 25, 2024
1 parent a09fcfa commit b2550ca
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 52 deletions.
23 changes: 12 additions & 11 deletions public-typescript/workOrderEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
workOrderFormElement.addEventListener('submit', (submitEvent) => {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix +
'/workOrders/' +
(isCreate ? 'doCreateWorkOrder' : 'doUpdateWorkOrder'), submitEvent.currentTarget, (rawResponseJSON) => {
cityssm.postJSON(`${los.urlPrefix}/workOrders/${isCreate ? 'doCreateWorkOrder' : 'doUpdateWorkOrder'}`, submitEvent.currentTarget, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
Expand Down Expand Up @@ -987,7 +985,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
return currentMilestone.workOrderMilestoneId === workOrderMilestoneId;
});
function doComplete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doCompleteWorkOrderMilestone', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doCompleteWorkOrderMilestone`, {
workOrderId,
workOrderMilestoneId
}, processMilestoneResponse);
Expand Down Expand Up @@ -1030,7 +1028,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
clickEvent.preventDefault();
const workOrderMilestoneId = clickEvent.currentTarget.closest('.container--milestone').dataset.workOrderMilestoneId;
function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderMilestone', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderMilestone`, {
workOrderMilestoneId,
workOrderId
}, processMilestoneResponse);
Expand All @@ -1046,8 +1044,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
}
function editMilestone(clickEvent) {
var _a;
clickEvent.preventDefault();
const workOrderMilestoneId = Number.parseInt(clickEvent.currentTarget.closest('.container--milestone').dataset.workOrderMilestoneId, 10);
const workOrderMilestoneId = Number.parseInt((_a = clickEvent.currentTarget.closest('.container--milestone').dataset.workOrderMilestoneId) !== null && _a !== void 0 ? _a : '', 10);
const workOrderMilestone = workOrderMilestones.find((currentMilestone) => {
return currentMilestone.workOrderMilestoneId === workOrderMilestoneId;
});
Expand All @@ -1065,7 +1064,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
cityssm.openHtmlModal('workOrder-editMilestone', {
onshow(modalElement) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f;
;
modalElement.querySelector('#milestoneEdit--workOrderId').value = workOrderId;
modalElement.querySelector('#milestoneEdit--workOrderMilestoneId').value = (_b = (_a = workOrderMilestone.workOrderMilestoneId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
Expand All @@ -1088,18 +1087,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
const optionElement = document.createElement('option');
optionElement.value =
workOrderMilestone.workOrderMilestoneTypeId.toString();
optionElement.textContent = workOrderMilestone.workOrderMilestoneType;
optionElement.textContent = (_c = workOrderMilestone.workOrderMilestoneType) !== null && _c !== void 0 ? _c : '';
optionElement.selected = true;
milestoneTypeElement.append(optionElement);
}
workOrderMilestoneDateStringElement = modalElement.querySelector('#milestoneEdit--workOrderMilestoneDateString');
workOrderMilestoneDateStringElement.value = (_c = workOrderMilestone.workOrderMilestoneDateString) !== null && _c !== void 0 ? _c : '';
workOrderMilestoneDateStringElement.value =
(_d = workOrderMilestone.workOrderMilestoneDateString) !== null && _d !== void 0 ? _d : '';
if (workOrderMilestone.workOrderMilestoneTime) {
;
modalElement.querySelector('#milestoneEdit--workOrderMilestoneTimeString').value = (_d = workOrderMilestone.workOrderMilestoneTimeString) !== null && _d !== void 0 ? _d : '';
modalElement.querySelector('#milestoneEdit--workOrderMilestoneTimeString').value = (_e = workOrderMilestone.workOrderMilestoneTimeString) !== null && _e !== void 0 ? _e : '';
}
;
modalElement.querySelector('#milestoneEdit--workOrderMilestoneDescription').value = (_e = workOrderMilestone.workOrderMilestoneDescription) !== null && _e !== void 0 ? _e : '';
modalElement.querySelector('#milestoneEdit--workOrderMilestoneDescription').value = (_f = workOrderMilestone.workOrderMilestoneDescription) !== null && _f !== void 0 ? _f : '';
},
onshown(modalElement, closeModalFunction) {
var _a;
Expand Down Expand Up @@ -1132,6 +1132,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
panelBlockElement.className = 'panel-block is-block container--milestone';
panelBlockElement.dataset.workOrderMilestoneId =
milestone.workOrderMilestoneId.toString();
// eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML =
'<div class="columns is-mobile">' +
('<div class="column is-narrow">' +
Expand Down
23 changes: 12 additions & 11 deletions public-typescript/workOrderEdit/workOrderEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
workOrderFormElement.addEventListener('submit', (submitEvent) => {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix +
'/workOrders/' +
(isCreate ? 'doCreateWorkOrder' : 'doUpdateWorkOrder'), submitEvent.currentTarget, (rawResponseJSON) => {
cityssm.postJSON(`${los.urlPrefix}/workOrders/${isCreate ? 'doCreateWorkOrder' : 'doUpdateWorkOrder'}`, submitEvent.currentTarget, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
Expand Down Expand Up @@ -236,7 +234,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
return currentMilestone.workOrderMilestoneId === workOrderMilestoneId;
});
function doComplete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doCompleteWorkOrderMilestone', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doCompleteWorkOrderMilestone`, {
workOrderId,
workOrderMilestoneId
}, processMilestoneResponse);
Expand Down Expand Up @@ -279,7 +277,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
clickEvent.preventDefault();
const workOrderMilestoneId = clickEvent.currentTarget.closest('.container--milestone').dataset.workOrderMilestoneId;
function doDelete() {
cityssm.postJSON(los.urlPrefix + '/workOrders/doDeleteWorkOrderMilestone', {
cityssm.postJSON(`${los.urlPrefix}/workOrders/doDeleteWorkOrderMilestone`, {
workOrderMilestoneId,
workOrderId
}, processMilestoneResponse);
Expand All @@ -295,8 +293,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
}
function editMilestone(clickEvent) {
var _a;
clickEvent.preventDefault();
const workOrderMilestoneId = Number.parseInt(clickEvent.currentTarget.closest('.container--milestone').dataset.workOrderMilestoneId, 10);
const workOrderMilestoneId = Number.parseInt((_a = clickEvent.currentTarget.closest('.container--milestone').dataset.workOrderMilestoneId) !== null && _a !== void 0 ? _a : '', 10);
const workOrderMilestone = workOrderMilestones.find((currentMilestone) => {
return currentMilestone.workOrderMilestoneId === workOrderMilestoneId;
});
Expand All @@ -314,7 +313,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
cityssm.openHtmlModal('workOrder-editMilestone', {
onshow(modalElement) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f;
;
modalElement.querySelector('#milestoneEdit--workOrderId').value = workOrderId;
modalElement.querySelector('#milestoneEdit--workOrderMilestoneId').value = (_b = (_a = workOrderMilestone.workOrderMilestoneId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
Expand All @@ -337,18 +336,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
const optionElement = document.createElement('option');
optionElement.value =
workOrderMilestone.workOrderMilestoneTypeId.toString();
optionElement.textContent = workOrderMilestone.workOrderMilestoneType;
optionElement.textContent = (_c = workOrderMilestone.workOrderMilestoneType) !== null && _c !== void 0 ? _c : '';
optionElement.selected = true;
milestoneTypeElement.append(optionElement);
}
workOrderMilestoneDateStringElement = modalElement.querySelector('#milestoneEdit--workOrderMilestoneDateString');
workOrderMilestoneDateStringElement.value = (_c = workOrderMilestone.workOrderMilestoneDateString) !== null && _c !== void 0 ? _c : '';
workOrderMilestoneDateStringElement.value =
(_d = workOrderMilestone.workOrderMilestoneDateString) !== null && _d !== void 0 ? _d : '';
if (workOrderMilestone.workOrderMilestoneTime) {
;
modalElement.querySelector('#milestoneEdit--workOrderMilestoneTimeString').value = (_d = workOrderMilestone.workOrderMilestoneTimeString) !== null && _d !== void 0 ? _d : '';
modalElement.querySelector('#milestoneEdit--workOrderMilestoneTimeString').value = (_e = workOrderMilestone.workOrderMilestoneTimeString) !== null && _e !== void 0 ? _e : '';
}
;
modalElement.querySelector('#milestoneEdit--workOrderMilestoneDescription').value = (_e = workOrderMilestone.workOrderMilestoneDescription) !== null && _e !== void 0 ? _e : '';
modalElement.querySelector('#milestoneEdit--workOrderMilestoneDescription').value = (_f = workOrderMilestone.workOrderMilestoneDescription) !== null && _f !== void 0 ? _f : '';
},
onshown(modalElement, closeModalFunction) {
var _a;
Expand Down Expand Up @@ -381,6 +381,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
panelBlockElement.className = 'panel-block is-block container--milestone';
panelBlockElement.dataset.workOrderMilestoneId =
milestone.workOrderMilestoneId.toString();
// eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML =
'<div class="columns is-mobile">' +
('<div class="column is-narrow">' +
Expand Down
51 changes: 22 additions & 29 deletions public-typescript/workOrderEdit/workOrderEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ declare const exports: Record<string, unknown>
submitEvent.preventDefault()

cityssm.postJSON(
los.urlPrefix +
'/workOrders/' +
(isCreate ? 'doCreateWorkOrder' : 'doUpdateWorkOrder'),
`${los.urlPrefix}/workOrders/${isCreate ? 'doCreateWorkOrder' : 'doUpdateWorkOrder'}`,
submitEvent.currentTarget,
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
Expand Down Expand Up @@ -346,7 +344,7 @@ declare const exports: Record<string, unknown>

function doComplete(): void {
cityssm.postJSON(
los.urlPrefix + '/workOrders/doCompleteWorkOrderMilestone',
`${los.urlPrefix}/workOrders/doCompleteWorkOrderMilestone`,
{
workOrderId,
workOrderMilestoneId
Expand Down Expand Up @@ -415,7 +413,7 @@ declare const exports: Record<string, unknown>

function doDelete(): void {
cityssm.postJSON(
los.urlPrefix + '/workOrders/doDeleteWorkOrderMilestone',
`${los.urlPrefix}/workOrders/doDeleteWorkOrderMilestone`,
{
workOrderMilestoneId,
workOrderId
Expand Down Expand Up @@ -443,13 +441,13 @@ declare const exports: Record<string, unknown>
(clickEvent.currentTarget as HTMLElement).closest(
'.container--milestone'
) as HTMLElement
).dataset.workOrderMilestoneId!,
).dataset.workOrderMilestoneId ?? '',
10
)

const workOrderMilestone = workOrderMilestones.find((currentMilestone) => {
return currentMilestone.workOrderMilestoneId === workOrderMilestoneId
})!
}) as recordTypes.WorkOrderMilestone

let editCloseModalFunction: () => void
let workOrderMilestoneDateStringElement: HTMLInputElement
Expand Down Expand Up @@ -519,18 +517,17 @@ declare const exports: Record<string, unknown>
const optionElement = document.createElement('option')
optionElement.value =
workOrderMilestone.workOrderMilestoneTypeId.toString()
optionElement.textContent = workOrderMilestone.workOrderMilestoneType!
optionElement.textContent = workOrderMilestone.workOrderMilestoneType ?? ''
optionElement.selected = true
milestoneTypeElement.append(optionElement)
}

workOrderMilestoneDateStringElement = (
modalElement.querySelector(
'#milestoneEdit--workOrderMilestoneDateString'
) as HTMLInputElement
)

workOrderMilestoneDateStringElement.value = workOrderMilestone.workOrderMilestoneDateString ?? ''
workOrderMilestoneDateStringElement = modalElement.querySelector(
'#milestoneEdit--workOrderMilestoneDateString'
) as HTMLInputElement

workOrderMilestoneDateStringElement.value =
workOrderMilestone.workOrderMilestoneDateString ?? ''

if (workOrderMilestone.workOrderMilestoneTime) {
;(
Expand Down Expand Up @@ -559,15 +556,12 @@ declare const exports: Record<string, unknown>
'#milestoneEdit--conflictingMilestonesPanel'
) as HTMLElement

workOrderMilestoneDateStringElement.addEventListener(
'change',
() => {
refreshConflictingMilestones(
workOrderMilestoneDateStringElement.value,
conflictingMilestonePanelElement
)
}
)
workOrderMilestoneDateStringElement.addEventListener('change', () => {
refreshConflictingMilestones(
workOrderMilestoneDateStringElement.value,
conflictingMilestonePanelElement
)
})

refreshConflictingMilestones(
workOrderMilestoneDateStringElement.value,
Expand Down Expand Up @@ -600,14 +594,15 @@ declare const exports: Record<string, unknown>
panelBlockElement.dataset.workOrderMilestoneId =
milestone.workOrderMilestoneId!.toString()

// eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML =
'<div class="columns is-mobile">' +
('<div class="column is-narrow">' +
(milestone.workOrderMilestoneCompletionDate
? '<span class="button is-static" data-tooltip="Completed ' +
milestone.workOrderMilestoneCompletionDateString! +
milestone.workOrderMilestoneCompletionDateString +
'" aria-label="Completed ' +
milestone.workOrderMilestoneCompletionDateString! +
milestone.workOrderMilestoneCompletionDateString +
'">' +
'<span class="icon is-small"><i class="fas fa-check" aria-hidden="true"></i></span>' +
'</span>'
Expand All @@ -625,7 +620,7 @@ declare const exports: Record<string, unknown>
? '<span class="has-text-grey">(No Set Date)</span>'
: milestone.workOrderMilestoneDateString) +
(milestone.workOrderMilestoneTime
? ' ' + milestone.workOrderMilestoneTimePeriodString!
? ' ' + milestone.workOrderMilestoneTimePeriodString
: '') +
'<br />' +
'<span class="is-size-7">' +
Expand Down Expand Up @@ -692,7 +687,6 @@ declare const exports: Record<string, unknown>
document
.querySelector('#button--addMilestone')
?.addEventListener('click', () => {

let addFormElement: HTMLFormElement
let workOrderMilestoneDateStringElement: HTMLInputElement
let addCloseModalFunction: () => void
Expand Down Expand Up @@ -774,7 +768,6 @@ declare const exports: Record<string, unknown>
workOrderMilestoneDateStringElement.valueAsDate = new Date()
},
onshown(modalElement, closeModalFunction) {

addCloseModalFunction = closeModalFunction

los.initializeDatePickers(modalElement)
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/workOrderEdit.min.js

Large diffs are not rendered by default.

0 comments on commit b2550ca

Please sign in to comment.