From 31d8d458ee5fa4e8caa38316d566a6877a7bb776 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 21 Nov 2018 19:00:51 +0100 Subject: [PATCH] feat(tasks): allow for time spent via short syntax --- src/app/tasks/task.service.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/tasks/task.service.ts b/src/app/tasks/task.service.ts index 43db1ac0fe..719c5a6453 100644 --- a/src/app/tasks/task.service.ts +++ b/src/app/tasks/task.service.ts @@ -309,15 +309,29 @@ export class TaskService { if (!task.title) { return task; } - const timeEstimateRegExp = / t[0-9]+(m|h|d)+ *$/i; + const timeEstimateRegExp = / t?(([0-9]+(m|h|d)+)? *\/ *)?([0-9]+(m|h|d)+) *$/i; const matches = timeEstimateRegExp.exec(task.title); - if (matches) { + if (matches && matches.length >= 3) { + let full; + let timeSpent; + let timeEstimate; + full = matches[0]; + timeSpent = matches[2]; + timeEstimate = matches[4]; + const timeSpentOnDay = timeSpent + ? { + ...(task.timeSpentOnDay || {}), + [getWorklogStr()]: stringToMs(timeSpent) + } : task.timeSpentOnDay; + return { ...task, - timeEstimate: stringToMs(matches[0].replace(' t', '')), - title: task.title.replace(matches[0], '') + timeSpentOnDay: timeSpentOnDay, + timeEstimate: stringToMs(timeEstimate), + title: task.title.replace(full, '') }; + } else { return task; }