reduce complexity
parent
eda8483e62
commit
147163b61f
|
|
@ -43,20 +43,11 @@ function buildEventSummary(milestone) {
|
||||||
}
|
}
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
function buildEventDescriptionHTML(request, milestone) {
|
function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
const urlRoot = getUrlRoot(request);
|
let descriptionHTML = "";
|
||||||
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
|
||||||
let descriptionHTML = "<h1>Milestone Description</h1>" +
|
|
||||||
"<p>" +
|
|
||||||
escapeHTML(milestone.workOrderMilestoneDescription) +
|
|
||||||
"</p>" +
|
|
||||||
"<h2>Work Order #" +
|
|
||||||
milestone.workOrderNumber +
|
|
||||||
"</h2>" +
|
|
||||||
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
|
||||||
("<p>" + workOrderUrl + "</p>");
|
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
descriptionHTML +=
|
const urlRoot = getUrlRoot(request);
|
||||||
|
descriptionHTML =
|
||||||
"<h2>Related " +
|
"<h2>Related " +
|
||||||
escapeHTML(configFunctions.getProperty("aliases.occupancies")) +
|
escapeHTML(configFunctions.getProperty("aliases.occupancies")) +
|
||||||
"</h2>" +
|
"</h2>" +
|
||||||
|
|
@ -98,7 +89,12 @@ function buildEventDescriptionHTML(request, milestone) {
|
||||||
}
|
}
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += "</tbody></table>";
|
||||||
}
|
}
|
||||||
|
return descriptionHTML;
|
||||||
|
}
|
||||||
|
function buildEventDescriptionHTML_lots(request, milestone) {
|
||||||
|
let descriptionHTML = "";
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<h2>Related " +
|
"<h2>Related " +
|
||||||
escapeHTML(configFunctions.getProperty("aliases.lots")) +
|
escapeHTML(configFunctions.getProperty("aliases.lots")) +
|
||||||
|
|
@ -128,8 +124,13 @@ function buildEventDescriptionHTML(request, milestone) {
|
||||||
}
|
}
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += "</tbody></table>";
|
||||||
}
|
}
|
||||||
|
return descriptionHTML;
|
||||||
|
}
|
||||||
|
function buildEventDescriptionHTML_prints(request, milestone) {
|
||||||
|
let descriptionHTML = "";
|
||||||
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
||||||
if (prints.length > 0) {
|
if (prints.length > 0) {
|
||||||
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML += "<h2>Prints</h2>";
|
descriptionHTML += "<h2>Prints</h2>";
|
||||||
for (const printName of prints) {
|
for (const printName of prints) {
|
||||||
const printConfig = getPrintConfig(printName);
|
const printConfig = getPrintConfig(printName);
|
||||||
|
|
@ -145,6 +146,41 @@ function buildEventDescriptionHTML(request, milestone) {
|
||||||
}
|
}
|
||||||
return descriptionHTML;
|
return descriptionHTML;
|
||||||
}
|
}
|
||||||
|
function buildEventDescriptionHTML(request, milestone) {
|
||||||
|
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
||||||
|
let descriptionHTML = "<h1>Milestone Description</h1>" +
|
||||||
|
"<p>" +
|
||||||
|
escapeHTML(milestone.workOrderMilestoneDescription) +
|
||||||
|
"</p>" +
|
||||||
|
"<h2>Work Order #" +
|
||||||
|
milestone.workOrderNumber +
|
||||||
|
"</h2>" +
|
||||||
|
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
||||||
|
("<p>" + workOrderUrl + "</p>");
|
||||||
|
descriptionHTML += buildEventDescriptionHTML_occupancies(request, milestone);
|
||||||
|
descriptionHTML += buildEventDescriptionHTML_lots(request, milestone);
|
||||||
|
descriptionHTML += buildEventDescriptionHTML_prints(request, milestone);
|
||||||
|
return descriptionHTML;
|
||||||
|
}
|
||||||
|
function buildEventCategoryList(milestone) {
|
||||||
|
const categories = [];
|
||||||
|
if (milestone.workOrderMilestoneTypeId) {
|
||||||
|
categories.push(milestone.workOrderMilestoneType, milestone.workOrderType);
|
||||||
|
}
|
||||||
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
|
categories.push("Completed");
|
||||||
|
}
|
||||||
|
return categories;
|
||||||
|
}
|
||||||
|
function buildEventLocation(milestone) {
|
||||||
|
const lotNames = [];
|
||||||
|
if (milestone.workOrderLots.length > 0) {
|
||||||
|
for (const lot of milestone.workOrderLots) {
|
||||||
|
lotNames.push(lot.mapName + ": " + lot.lotName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lotNames.join(", ");
|
||||||
|
}
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
const workOrderMilestoneFilters = {
|
const workOrderMilestoneFilters = {
|
||||||
|
|
@ -203,26 +239,14 @@ export const handler = (request, response) => {
|
||||||
if (milestone.workOrderMilestoneCompletionDate) {
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
calendarEvent.status(ICalEventStatus.CONFIRMED);
|
calendarEvent.status(ICalEventStatus.CONFIRMED);
|
||||||
}
|
}
|
||||||
if (milestone.workOrderMilestoneTypeId) {
|
const categories = buildEventCategoryList(milestone);
|
||||||
|
for (const category of categories) {
|
||||||
calendarEvent.createCategory({
|
calendarEvent.createCategory({
|
||||||
name: milestone.workOrderMilestoneType
|
name: category
|
||||||
});
|
|
||||||
calendarEvent.createCategory({
|
|
||||||
name: milestone.workOrderType
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (milestone.workOrderMilestoneCompletionDate) {
|
const location = buildEventLocation(milestone);
|
||||||
calendarEvent.createCategory({
|
calendarEvent.location(location);
|
||||||
name: "Completed"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (milestone.workOrderLots.length > 0) {
|
|
||||||
const lotNames = [];
|
|
||||||
for (const lot of milestone.workOrderLots) {
|
|
||||||
lotNames.push(lot.mapName + ": " + lot.lotName);
|
|
||||||
}
|
|
||||||
calendarEvent.location(lotNames.join(", "));
|
|
||||||
}
|
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
let organizerSet = false;
|
let organizerSet = false;
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies) {
|
for (const lotOccupancy of milestone.workOrderLotOccupancies) {
|
||||||
|
|
|
||||||
|
|
@ -71,26 +71,16 @@ function buildEventSummary(milestone: recordTypes.WorkOrderMilestone): string {
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventDescriptionHTML(
|
function buildEventDescriptionHTML_occupancies(
|
||||||
request: Request,
|
request: Request,
|
||||||
milestone: recordTypes.WorkOrderMilestone
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
): string {
|
): string {
|
||||||
const urlRoot = getUrlRoot(request);
|
let descriptionHTML = "";
|
||||||
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
|
||||||
|
|
||||||
let descriptionHTML =
|
|
||||||
"<h1>Milestone Description</h1>" +
|
|
||||||
"<p>" +
|
|
||||||
escapeHTML(milestone.workOrderMilestoneDescription) +
|
|
||||||
"</p>" +
|
|
||||||
"<h2>Work Order #" +
|
|
||||||
milestone.workOrderNumber +
|
|
||||||
"</h2>" +
|
|
||||||
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
|
||||||
("<p>" + workOrderUrl + "</p>");
|
|
||||||
|
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
descriptionHTML +=
|
const urlRoot = getUrlRoot(request);
|
||||||
|
|
||||||
|
descriptionHTML =
|
||||||
"<h2>Related " +
|
"<h2>Related " +
|
||||||
escapeHTML(configFunctions.getProperty("aliases.occupancies")) +
|
escapeHTML(configFunctions.getProperty("aliases.occupancies")) +
|
||||||
"</h2>" +
|
"</h2>" +
|
||||||
|
|
@ -137,7 +127,18 @@ function buildEventDescriptionHTML(
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += "</tbody></table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return descriptionHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildEventDescriptionHTML_lots(
|
||||||
|
request: Request,
|
||||||
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
|
): string {
|
||||||
|
let descriptionHTML = "";
|
||||||
|
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
|
const urlRoot = getUrlRoot(request);
|
||||||
|
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<h2>Related " +
|
"<h2>Related " +
|
||||||
escapeHTML(configFunctions.getProperty("aliases.lots")) +
|
escapeHTML(configFunctions.getProperty("aliases.lots")) +
|
||||||
|
|
@ -170,9 +171,20 @@ function buildEventDescriptionHTML(
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += "</tbody></table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return descriptionHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildEventDescriptionHTML_prints(
|
||||||
|
request: Request,
|
||||||
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
|
): string {
|
||||||
|
let descriptionHTML = "";
|
||||||
|
|
||||||
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
||||||
|
|
||||||
if (prints.length > 0) {
|
if (prints.length > 0) {
|
||||||
|
const urlRoot = getUrlRoot(request);
|
||||||
|
|
||||||
descriptionHTML += "<h2>Prints</h2>";
|
descriptionHTML += "<h2>Prints</h2>";
|
||||||
|
|
||||||
for (const printName of prints) {
|
for (const printName of prints) {
|
||||||
|
|
@ -192,6 +204,55 @@ function buildEventDescriptionHTML(
|
||||||
return descriptionHTML;
|
return descriptionHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildEventDescriptionHTML(
|
||||||
|
request: Request,
|
||||||
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
|
): string {
|
||||||
|
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
||||||
|
|
||||||
|
let descriptionHTML =
|
||||||
|
"<h1>Milestone Description</h1>" +
|
||||||
|
"<p>" +
|
||||||
|
escapeHTML(milestone.workOrderMilestoneDescription) +
|
||||||
|
"</p>" +
|
||||||
|
"<h2>Work Order #" +
|
||||||
|
milestone.workOrderNumber +
|
||||||
|
"</h2>" +
|
||||||
|
("<p>" + escapeHTML(milestone.workOrderDescription) + "</p>") +
|
||||||
|
("<p>" + workOrderUrl + "</p>");
|
||||||
|
|
||||||
|
descriptionHTML += buildEventDescriptionHTML_occupancies(request, milestone);
|
||||||
|
descriptionHTML += buildEventDescriptionHTML_lots(request, milestone);
|
||||||
|
descriptionHTML += buildEventDescriptionHTML_prints(request, milestone);
|
||||||
|
|
||||||
|
return descriptionHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildEventCategoryList(milestone: recordTypes.WorkOrderMilestone): string[] {
|
||||||
|
const categories: string[] = [];
|
||||||
|
|
||||||
|
if (milestone.workOrderMilestoneTypeId) {
|
||||||
|
categories.push(milestone.workOrderMilestoneType, milestone.workOrderType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
|
categories.push("Completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
return categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildEventLocation(milestone: recordTypes.WorkOrderMilestone): string {
|
||||||
|
const lotNames = [];
|
||||||
|
|
||||||
|
if (milestone.workOrderLots.length > 0) {
|
||||||
|
for (const lot of milestone.workOrderLots) {
|
||||||
|
lotNames.push(lot.mapName + ": " + lot.lotName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lotNames.join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
|
|
||||||
|
|
@ -304,33 +365,17 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
// Add categories
|
// Add categories
|
||||||
|
|
||||||
if (milestone.workOrderMilestoneTypeId) {
|
const categories = buildEventCategoryList(milestone);
|
||||||
|
for (const category of categories) {
|
||||||
calendarEvent.createCategory({
|
calendarEvent.createCategory({
|
||||||
name: milestone.workOrderMilestoneType
|
name: category
|
||||||
});
|
|
||||||
|
|
||||||
calendarEvent.createCategory({
|
|
||||||
name: milestone.workOrderType
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (milestone.workOrderMilestoneCompletionDate) {
|
|
||||||
calendarEvent.createCategory({
|
|
||||||
name: "Completed"
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set location
|
// Set location
|
||||||
|
|
||||||
if (milestone.workOrderLots.length > 0) {
|
const location = buildEventLocation(milestone);
|
||||||
const lotNames = [];
|
calendarEvent.location(location);
|
||||||
|
|
||||||
for (const lot of milestone.workOrderLots) {
|
|
||||||
lotNames.push(lot.mapName + ": " + lot.lotName);
|
|
||||||
}
|
|
||||||
|
|
||||||
calendarEvent.location(lotNames.join(", "));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set organizer / attendees
|
// Set organizer / attendees
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue