calendar updates
- add completed checkmark to summary - add completed category - add print linksdeepsource-autofix-76c6eb20
parent
a29f380a9c
commit
82b0ae1aa2
|
|
@ -1,6 +1,7 @@
|
||||||
import ical, { ICalEventStatus } from "ical-generator";
|
import ical, { ICalEventStatus } from "ical-generator";
|
||||||
import { getWorkOrderMilestones } from "../../helpers/lotOccupancyDB/getWorkOrderMilestones.js";
|
import { getWorkOrderMilestones } from "../../helpers/lotOccupancyDB/getWorkOrderMilestones.js";
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
import { getPrintConfig } from "../../helpers/functions.print.js";
|
||||||
const timeStringSplitRegex = /[ :-]/;
|
const timeStringSplitRegex = /[ :-]/;
|
||||||
function escapeHTML(stringToEscape) {
|
function escapeHTML(stringToEscape) {
|
||||||
return stringToEscape.replace(/[^\d A-Za-z]/g, (c) => "&#" + c.codePointAt(0) + ";");
|
return stringToEscape.replace(/[^\d A-Za-z]/g, (c) => "&#" + c.codePointAt(0) + ";");
|
||||||
|
|
@ -45,7 +46,8 @@ 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 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());
|
const milestoneEndDate = new Date(milestoneDate.getTime());
|
||||||
milestoneEndDate.setHours(milestoneEndDate.getHours() + 1);
|
milestoneEndDate.setHours(milestoneEndDate.getHours() + 1);
|
||||||
let summary = (milestone.workOrderMilestoneTypeId
|
let summary = (milestone.workOrderMilestoneCompletionDate ? "✔ " : "") +
|
||||||
|
(milestone.workOrderMilestoneTypeId
|
||||||
? milestone.workOrderMilestoneType
|
? milestone.workOrderMilestoneType
|
||||||
: milestone.workOrderMilestoneDescription).trim();
|
: milestone.workOrderMilestoneDescription).trim();
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
|
|
@ -87,7 +89,7 @@ export const handler = (request, response) => {
|
||||||
milestone.workOrderNumber +
|
milestone.workOrderNumber +
|
||||||
"</h2>" +
|
"</h2>" +
|
||||||
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
||||||
('<p><a href="' + workOrderURL + '">' + workOrderURL + "</a></p>");
|
("<p>" + workOrderURL + "</p>");
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<h2>Related " +
|
"<h2>Related " +
|
||||||
|
|
@ -164,6 +166,25 @@ export const handler = (request, response) => {
|
||||||
}
|
}
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += "</tbody></table>";
|
||||||
}
|
}
|
||||||
|
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
||||||
|
if (prints.length > 0) {
|
||||||
|
descriptionHTML += "<h2>Prints</h2>";
|
||||||
|
for (const printName of prints) {
|
||||||
|
const printConfig = getPrintConfig(printName);
|
||||||
|
if (printConfig) {
|
||||||
|
descriptionHTML +=
|
||||||
|
"<p>" +
|
||||||
|
escapeHTML(printConfig.title) +
|
||||||
|
"<br />" +
|
||||||
|
(urlRoot +
|
||||||
|
"/print/" +
|
||||||
|
printName +
|
||||||
|
"/?workOrderId=" +
|
||||||
|
milestone.workOrderId) +
|
||||||
|
"</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
calendarEvent.description({
|
calendarEvent.description({
|
||||||
plain: workOrderURL,
|
plain: workOrderURL,
|
||||||
html: descriptionHTML
|
html: descriptionHTML
|
||||||
|
|
@ -179,6 +200,11 @@ export const handler = (request, response) => {
|
||||||
name: milestone.workOrderType
|
name: milestone.workOrderType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
|
calendarEvent.createCategory({
|
||||||
|
name: "Completed"
|
||||||
|
});
|
||||||
|
}
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
const lotNames = [];
|
const lotNames = [];
|
||||||
for (const lot of milestone.workOrderLots) {
|
for (const lot of milestone.workOrderLots) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import {
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from "express";
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
import { getPrintConfig } from "../../helpers/functions.print.js";
|
||||||
|
|
||||||
const timeStringSplitRegex = /[ :-]/;
|
const timeStringSplitRegex = /[ :-]/;
|
||||||
|
|
||||||
|
|
@ -77,8 +78,9 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
// Build summary (title in Outlook)
|
// Build summary (title in Outlook)
|
||||||
|
|
||||||
let summary = (
|
let summary =
|
||||||
milestone.workOrderMilestoneTypeId
|
(milestone.workOrderMilestoneCompletionDate ? "✔ " : "") +
|
||||||
|
(milestone.workOrderMilestoneTypeId
|
||||||
? milestone.workOrderMilestoneType
|
? milestone.workOrderMilestoneType
|
||||||
: milestone.workOrderMilestoneDescription
|
: milestone.workOrderMilestoneDescription
|
||||||
).trim();
|
).trim();
|
||||||
|
|
@ -143,7 +145,7 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
milestone.workOrderNumber +
|
milestone.workOrderNumber +
|
||||||
"</h2>" +
|
"</h2>" +
|
||||||
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
||||||
('<p><a href="' + workOrderURL + '">' + workOrderURL + "</a></p>");
|
("<p>" + workOrderURL + "</p>");
|
||||||
|
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
|
|
@ -229,6 +231,29 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += "</tbody></table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
||||||
|
|
||||||
|
if (prints.length > 0) {
|
||||||
|
descriptionHTML += "<h2>Prints</h2>";
|
||||||
|
|
||||||
|
for (const printName of prints) {
|
||||||
|
const printConfig = getPrintConfig(printName);
|
||||||
|
|
||||||
|
if (printConfig) {
|
||||||
|
descriptionHTML +=
|
||||||
|
"<p>" +
|
||||||
|
escapeHTML(printConfig.title) +
|
||||||
|
"<br />" +
|
||||||
|
(urlRoot +
|
||||||
|
"/print/" +
|
||||||
|
printName +
|
||||||
|
"/?workOrderId=" +
|
||||||
|
milestone.workOrderId) +
|
||||||
|
"</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
calendarEvent.description({
|
calendarEvent.description({
|
||||||
plain: workOrderURL,
|
plain: workOrderURL,
|
||||||
html: descriptionHTML
|
html: descriptionHTML
|
||||||
|
|
@ -252,6 +277,12 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
|
calendarEvent.createCategory({
|
||||||
|
name: "Completed"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Set location
|
// Set location
|
||||||
|
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue