|
77 | 77 | }
|
78 | 78 | }
|
79 | 79 |
|
| 80 | + function getCurrentTask() { |
| 81 | + console.log("current task:" + JSON.stringify(todos.find((task) => task._id === currentTaskTracking.taskId))); |
| 82 | + return todos.find((task) => task._id === currentTaskTracking.taskId); |
| 83 | + } |
| 84 | +
|
| 85 | +
|
80 | 86 | /* const moreThanOneHourInSeconds = 3667;
|
81 | 87 | console.log(timeConvert(moreThanOneHourInSeconds)); */
|
82 | 88 |
|
|
140 | 146 | todos.forEach((todo) => {
|
141 | 147 | todo.duration = todo.durationForToday; // tmp TODO remove!!!!!!!!!!
|
142 | 148 | updateDurationToDisplay(todo);
|
| 149 | + todo.isTracking = false; |
143 | 150 | });
|
144 | 151 |
|
145 | 152 | // get currentTaskTracking
|
|
153 | 160 |
|
154 | 161 | updateCurrentTaskTrackingDuration();
|
155 | 162 |
|
| 163 | + if (currentTaskTracking.isTracking) { |
| 164 | + let currentTask = getCurrentTask(); |
| 165 | + currentTask.isTracking = true; |
| 166 | + } |
| 167 | +
|
156 | 168 | // launch the "eternal" timer that updates the display of the duration
|
157 | 169 | interval = setInterval(() => {
|
158 | 170 | updateCurrentTaskTrackingDuration();
|
|
239 | 251 | // updates the task duration
|
240 | 252 | previousTodo = todos.find((t) => t._id === currentTaskTracking.taskId);
|
241 | 253 | previousTodo.duration += durationSeconds;
|
| 254 | + previousTodo.isTracking = false; |
242 | 255 |
|
243 | 256 | // must save the tracking period we've just ended
|
244 | 257 | previousTodo.trackingByDate.push({
|
|
250 | 263 | // TODO => bug?? useless call ???? sendUpdateCurrentTaskTracking();
|
251 | 264 | // hack to update the array of todos in child Task.svelte,
|
252 | 265 | // in order to update this previousTodo display
|
253 |
| - todos = todos; |
| 266 | + // todos = todos; |
254 | 267 | console.log(previousTodo);
|
255 | 268 | sendUpdateTask(previousTodo);
|
256 | 269 | }
|
257 | 270 |
|
258 |
| - const currentTaskTitle = todos.find((t) => t._id === todoId).title; |
| 271 | + const newTaskTracking = todos.find((t) => t._id === todoId); |
259 | 272 |
|
260 | 273 | // if we were tracking the selected task of id todoId => just stop tracking
|
261 | 274 | if (currentTaskTracking.taskId == todoId) {
|
262 | 275 | currentTaskTracking = { ...NO_TASK_TRACKING };
|
263 |
| - console.log(`${getCurrentTimeString()}: stopped task '${currentTaskTitle}'`); |
| 276 | + console.log(`${getCurrentTimeString()}: stopped task '${newTaskTracking.title}'`); |
264 | 277 | } else {
|
265 | 278 | // else switch to selected task
|
266 | 279 | currentTaskTracking.isTracking = true;
|
267 | 280 | currentTaskTracking.taskId = todoId;
|
268 | 281 | currentTaskTracking.timeBeginTracking = Date.now() - 1000;
|
| 282 | + newTaskTracking.isTracking = true; |
| 283 | + console.log(newTaskTracking); |
| 284 | + console.log(`${getCurrentTimeString()}: switching to task '${newTaskTracking.title}'`); |
269 | 285 | }
|
270 | 286 |
|
271 | 287 | updateCurrentTaskTrackingDuration();
|
272 |
| - sendUpdateCurrentTaskTracking(); |
273 |
| - console.log(`${getCurrentTimeString()}: switching to task '${currentTaskTitle}`); |
| 288 | + sendUpdateCurrentTaskTracking(); |
| 289 | +
|
| 290 | + todos = todos; // hack |
| 291 | +console.log('switched to task:' + JSON.stringify(todos.find((t) => t._id === todoId))); |
274 | 292 |
|
275 | 293 | interval = setInterval(() => {
|
276 | 294 | updateCurrentTaskTrackingDuration();
|
277 | 295 | }, 500);
|
278 | 296 | }
|
279 | 297 |
|
| 298 | + function switchTracking2(todoId) { |
| 299 | + const newTaskTracking = todos.find((t) => t._id === todoId); |
| 300 | + newTaskTracking.isTracking = true; |
| 301 | + todos = todos; |
| 302 | +
|
| 303 | + } |
| 304 | +
|
280 | 305 | const createTodo = (title, done = false, duration = 0, enabled = true) => {
|
281 | 306 | // async function createTodo(title, done = false, duration = 0, enabled = true) {
|
282 | 307 | const newTodo = {
|
|
325 | 350 | vertical-align: top;
|
326 | 351 | } */
|
327 | 352 | .make-children-div-full-height {
|
| 353 | + display: flex; |
328 | 354 | align-items: stretch;
|
329 | 355 | /* a "flex" option apparently, needed to have the info header dv (the one with the nb of tasks) to be full height
|
330 | 356 | to align the text to the new task input field...
|
|
0 commit comments