mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-25 08:53:50 +00:00
feat(tasks): allow for time spent via short syntax
This commit is contained in:
parent
1baedee1e9
commit
31d8d458ee
1 changed files with 18 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue