Merged in feature/IO-2677-Tasks (pull request #1431)
Feature/IO-2677 Tasks Approved-by: Patrick Fic
This commit is contained in:
@@ -99,14 +99,16 @@ const formatPriority = (priority) => {
|
||||
* @param priority
|
||||
* @param description
|
||||
* @param dueDate
|
||||
* @param bodyshop
|
||||
* @param job
|
||||
* @param taskId
|
||||
* @returns {{header, body: string, subHeader: string}}
|
||||
*/
|
||||
const generateTemplateArgs = (title, priority, description, dueDate, taskId) => {
|
||||
const generateTemplateArgs = (title, priority, description, dueDate, bodyshop, job, taskId) => {
|
||||
return {
|
||||
header: title,
|
||||
subHeader: `Priority: ${formatPriority(priority)} ${formatDate(dueDate)}`,
|
||||
body: `${description || ""}<br><a href="${endPoints}/manage/tasks/alltasks?taskid=${taskId}">View this task.</a>`
|
||||
subHeader: `Body Shop: ${bodyshop.shopname} | Priority: ${formatPriority(priority)} ${formatDate(dueDate)}`,
|
||||
body: `Reference: ${job.ro_number || "N/A"} | ${job.ownr_co_nm ? job.ownr_co_nm : `${job.ownr_fn || ""} ${job.ownr_ln || ""}`.trim()} | ${`${job.v_model_yr || ""} ${job.v_make_desc || ""} ${job.v_model_desc || ""}`.trim()}<br>${description ? description.concat("<br>") : ""}<a href="${endPoints}/manage/tasks/alltasks?taskid=${taskId}">View this task.</a>`
|
||||
};
|
||||
};
|
||||
|
||||
@@ -175,7 +177,15 @@ const taskAssignedEmail = async (req, res) => {
|
||||
user_email,
|
||||
`A ${formatPriority(newTask.priority)} priority task has been ${dirty ? "reassigned to" : "created for"} you - ${newTask.title}`,
|
||||
generateEmailTemplate(
|
||||
generateTemplateArgs(newTask.title, newTask.priority, newTask.description, newTask.due_date, newTask.id)
|
||||
generateTemplateArgs(
|
||||
newTask.title,
|
||||
newTask.priority,
|
||||
newTask.description,
|
||||
newTask.due_date,
|
||||
newTask.bodyshop,
|
||||
newTask.job,
|
||||
newTask.id
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -240,7 +250,15 @@ const tasksRemindEmail = async (req, res) => {
|
||||
`New ${formatPriority(onlyTask.priority)} Priority Task Reminder - ${onlyTask.title} ${onlyTask.due_date ? `- ${formatDate(onlyTask.due_date)}` : ""}`.trim();
|
||||
|
||||
emailData.html = generateEmailTemplate(
|
||||
generateTemplateArgs(onlyTask.title, onlyTask.priority, onlyTask.description, onlyTask.due_date, onlyTask.id)
|
||||
generateTemplateArgs(
|
||||
onlyTask.title,
|
||||
onlyTask.priority,
|
||||
onlyTask.description,
|
||||
onlyTask.due_date,
|
||||
onlyTask.bodyshop,
|
||||
onlyTask.job,
|
||||
onlyTask.id
|
||||
)
|
||||
);
|
||||
}
|
||||
// There are multiple emails to send to this author.
|
||||
@@ -249,11 +267,11 @@ const tasksRemindEmail = async (req, res) => {
|
||||
emailData.subject = `New Tasks Reminder - ${allTasks.length} Tasks require your attention`;
|
||||
emailData.html = generateEmailTemplate({
|
||||
header: `${allTasks.length} Tasks require your attention`,
|
||||
subHeader: `Please sign in to your account to view the Task details.`,
|
||||
subHeader: `Please click on the Tasks below to view the Task.`,
|
||||
body: `<ul>
|
||||
${allTasks
|
||||
.map((task) =>
|
||||
`<li><a href="${endPoints}/manage/tasks/alltasks?taskid=${task.id}">${task.title} - Priority: ${formatPriority(task.priority)} ${task.due_date ? `${formatDate(task.due_date)}` : ""}</a></li>`.trim()
|
||||
`<li><a href="${endPoints}/manage/tasks/alltasks?taskid=${task.id}">${task.title} - Priority: ${formatPriority(task.priority)} ${task.due_date ? `${formatDate(task.due_date)}` : ""} | Bodyshop: ${task.bodyshop.shopname}</a></li>`.trim()
|
||||
)
|
||||
.join("")}
|
||||
</ul>`
|
||||
|
||||
@@ -2420,9 +2420,19 @@ exports.QUERY_REMIND_TASKS = `
|
||||
priority
|
||||
job {
|
||||
id
|
||||
ownr_co_nm
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
v_make_desc
|
||||
v_model_desc
|
||||
v_model_yr
|
||||
ro_number
|
||||
}
|
||||
jobid
|
||||
bodyshop {
|
||||
shopname
|
||||
}
|
||||
bodyshopid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user