Browse Source

Jul 25 : [UPDT] Updated 'project_task_timer'

pull/267/head
AjmalCybro 2 years ago
parent
commit
da88dec353
  1. 17
      project_task_timer/static/src/js/timer.js

17
project_task_timer/static/src/js/timer.js

@ -1,5 +1,4 @@
/** @odoo-module **/ /** @odoo-module **/
import { registry } from "@web/core/registry"; import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks"; import { useService } from "@web/core/utils/hooks";
import { parseFloatTime } from "@web/views/fields/parsers"; import { parseFloatTime } from "@web/views/fields/parsers";
@ -15,11 +14,12 @@ function formatMinutes(value) {
if (isNegative) { if (isNegative) {
value = Math.abs(value); value = Math.abs(value);
} }
let min = Math.floor(value); let hours = Math.floor(value / 60);
let sec = Math.floor((value % 1) * 60); let minutes = Math.floor(value % 60);
sec = `${sec}`.padStart(2, "0"); let seconds = Math.floor((value % 1) * 60);
min = `${min}`.padStart(2, "0"); seconds = `${seconds}`.padStart(2, "0");
return `${isNegative ? "-" : ""}${min}:${sec}`; minutes = `${minutes}`.padStart(2, "0");
return `${isNegative ? "-" : ""}${hours}:${minutes}:${seconds}`;
} }
export class TaskTimer extends Component { export class TaskTimer extends Component {
@ -77,6 +77,11 @@ export class TaskTimer extends Component {
} }
}, 1000); }, 1000);
} }
// add hour to timer
addHour() {
this.state.duration += 60;
}
} }
TaskTimer.supportedTypes = ["float"]; TaskTimer.supportedTypes = ["float"];

Loading…
Cancel
Save