diff --git a/handlers/api-get/milestoneICS.js b/handlers/api-get/milestoneICS.js index e2989344..8ddbc3e3 100644 --- a/handlers/api-get/milestoneICS.js +++ b/handlers/api-get/milestoneICS.js @@ -1,6 +1,7 @@ import ical, { ICalEventStatus } from "ical-generator"; import { getWorkOrderMilestones } from "../../helpers/lotOccupancyDB/getWorkOrderMilestones.js"; import * as configFunctions from "../../helpers/functions.config.js"; +import { getPrintConfig } from "../../helpers/functions.print.js"; const timeStringSplitRegex = /[ :-]/; function escapeHTML(stringToEscape) { return stringToEscape.replace(/[^\d A-Za-z]/g, (c) => "&#" + c.codePointAt(0) + ";"); @@ -45,9 +46,10 @@ export const handler = (request, response) => { const milestoneDate = new Date(Number.parseInt(milestoneTimePieces[0], 10), Number.parseInt(milestoneTimePieces[1], 10) - 1, Number.parseInt(milestoneTimePieces[2], 10), Number.parseInt(milestoneTimePieces[3], 10), Number.parseInt(milestoneTimePieces[4], 10)); const milestoneEndDate = new Date(milestoneDate.getTime()); milestoneEndDate.setHours(milestoneEndDate.getHours() + 1); - let summary = (milestone.workOrderMilestoneTypeId - ? milestone.workOrderMilestoneType - : milestone.workOrderMilestoneDescription).trim(); + let summary = (milestone.workOrderMilestoneCompletionDate ? "✔ " : "") + + (milestone.workOrderMilestoneTypeId + ? milestone.workOrderMilestoneType + : milestone.workOrderMilestoneDescription).trim(); if (milestone.workOrderLotOccupancies.length > 0) { let occupantCount = 0; for (const lotOccupancy of milestone.workOrderLotOccupancies) { @@ -87,7 +89,7 @@ export const handler = (request, response) => { milestone.workOrderNumber + "" + ("

" + escapeHTML(milestone.workOrderDescription) + "

") + - ('

' + workOrderURL + "

"); + ("

" + workOrderURL + "

"); if (milestone.workOrderLotOccupancies.length > 0) { descriptionHTML += "

Related " + @@ -164,6 +166,25 @@ export const handler = (request, response) => { } descriptionHTML += ""; } + const prints = configFunctions.getProperty("settings.workOrders.prints"); + if (prints.length > 0) { + descriptionHTML += "

Prints

"; + for (const printName of prints) { + const printConfig = getPrintConfig(printName); + if (printConfig) { + descriptionHTML += + "

" + + escapeHTML(printConfig.title) + + "
" + + (urlRoot + + "/print/" + + printName + + "/?workOrderId=" + + milestone.workOrderId) + + "

"; + } + } + } calendarEvent.description({ plain: workOrderURL, html: descriptionHTML @@ -179,6 +200,11 @@ export const handler = (request, response) => { name: milestone.workOrderType }); } + if (milestone.workOrderMilestoneCompletionDate) { + calendarEvent.createCategory({ + name: "Completed" + }); + } if (milestone.workOrderLots.length > 0) { const lotNames = []; for (const lot of milestone.workOrderLots) { diff --git a/handlers/api-get/milestoneICS.ts b/handlers/api-get/milestoneICS.ts index 48e4937c..781ede88 100644 --- a/handlers/api-get/milestoneICS.ts +++ b/handlers/api-get/milestoneICS.ts @@ -10,6 +10,7 @@ import { import type { RequestHandler } from "express"; import * as configFunctions from "../../helpers/functions.config.js"; +import { getPrintConfig } from "../../helpers/functions.print.js"; const timeStringSplitRegex = /[ :-]/; @@ -77,11 +78,12 @@ export const handler: RequestHandler = (request, response) => { // Build summary (title in Outlook) - let summary = ( - milestone.workOrderMilestoneTypeId + let summary = + (milestone.workOrderMilestoneCompletionDate ? "✔ " : "") + + (milestone.workOrderMilestoneTypeId ? milestone.workOrderMilestoneType : milestone.workOrderMilestoneDescription - ).trim(); + ).trim(); if (milestone.workOrderLotOccupancies.length > 0) { let occupantCount = 0; @@ -143,7 +145,7 @@ export const handler: RequestHandler = (request, response) => { milestone.workOrderNumber + "" + ("

" + escapeHTML(milestone.workOrderDescription) + "

") + - ('

' + workOrderURL + "

"); + ("

" + workOrderURL + "

"); if (milestone.workOrderLotOccupancies.length > 0) { descriptionHTML += @@ -229,6 +231,29 @@ export const handler: RequestHandler = (request, response) => { descriptionHTML += ""; } + const prints = configFunctions.getProperty("settings.workOrders.prints"); + + if (prints.length > 0) { + descriptionHTML += "

Prints

"; + + for (const printName of prints) { + const printConfig = getPrintConfig(printName); + + if (printConfig) { + descriptionHTML += + "

" + + escapeHTML(printConfig.title) + + "
" + + (urlRoot + + "/print/" + + printName + + "/?workOrderId=" + + milestone.workOrderId) + + "

"; + } + } + } + calendarEvent.description({ plain: workOrderURL, html: descriptionHTML @@ -252,6 +277,12 @@ export const handler: RequestHandler = (request, response) => { }); } + if (milestone.workOrderMilestoneCompletionDate) { + calendarEvent.createCategory({ + name: "Completed" + }); + } + // Set location if (milestone.workOrderLots.length > 0) {