Merge pull request #33051 from deepeshgarg007/timesheet_timer_button
fix: Timesheet timer button
This commit is contained in:
commit
e25d0ead1a
@ -48,21 +48,23 @@ erpnext.timesheet.control_timer = function(frm, dialog, row, timestamp=0) {
|
|||||||
var $btn_complete = dialog.$wrapper.find(".playpause .btn-complete");
|
var $btn_complete = dialog.$wrapper.find(".playpause .btn-complete");
|
||||||
var interval = null;
|
var interval = null;
|
||||||
var currentIncrement = timestamp;
|
var currentIncrement = timestamp;
|
||||||
var initialised = row ? true : false;
|
var initialized = row ? true : false;
|
||||||
var clicked = false;
|
var clicked = false;
|
||||||
var flag = true; // Alert only once
|
var flag = true; // Alert only once
|
||||||
// If row with not completed status, initialize timer with the time elapsed on click of 'Start Timer'.
|
// If row with not completed status, initialize timer with the time elapsed on click of 'Start Timer'.
|
||||||
if (row) {
|
if (row) {
|
||||||
initialised = true;
|
initialized = true;
|
||||||
$btn_start.hide();
|
$btn_start.hide();
|
||||||
$btn_complete.show();
|
$btn_complete.show();
|
||||||
initialiseTimer();
|
initializeTimer();
|
||||||
}
|
}
|
||||||
if (!initialised) {
|
|
||||||
|
if (!initialized) {
|
||||||
$btn_complete.hide();
|
$btn_complete.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$btn_start.click(function(e) {
|
$btn_start.click(function(e) {
|
||||||
if (!initialised) {
|
if (!initialized) {
|
||||||
// New activity if no activities found
|
// New activity if no activities found
|
||||||
var args = dialog.get_values();
|
var args = dialog.get_values();
|
||||||
if(!args) return;
|
if(!args) return;
|
||||||
@ -90,11 +92,11 @@ erpnext.timesheet.control_timer = function(frm, dialog, row, timestamp=0) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initialised) {
|
if (!initialized) {
|
||||||
initialised = true;
|
initialized = true;
|
||||||
$btn_start.hide();
|
$btn_start.hide();
|
||||||
$btn_complete.show();
|
$btn_complete.show();
|
||||||
initialiseTimer();
|
initializeTimer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -110,11 +112,13 @@ erpnext.timesheet.control_timer = function(frm, dialog, row, timestamp=0) {
|
|||||||
grid_row.doc.hours = currentIncrement / 3600;
|
grid_row.doc.hours = currentIncrement / 3600;
|
||||||
grid_row.doc.to_time = frappe.datetime.now_datetime();
|
grid_row.doc.to_time = frappe.datetime.now_datetime();
|
||||||
grid_row.refresh();
|
grid_row.refresh();
|
||||||
|
frm.dirty();
|
||||||
frm.save();
|
frm.save();
|
||||||
reset();
|
reset();
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
});
|
});
|
||||||
function initialiseTimer() {
|
|
||||||
|
function initializeTimer() {
|
||||||
interval = setInterval(function() {
|
interval = setInterval(function() {
|
||||||
var current = setCurrentIncrement();
|
var current = setCurrentIncrement();
|
||||||
updateStopwatch(current);
|
updateStopwatch(current);
|
||||||
@ -151,7 +155,7 @@ erpnext.timesheet.control_timer = function(frm, dialog, row, timestamp=0) {
|
|||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
currentIncrement = 0;
|
currentIncrement = 0;
|
||||||
initialised = false;
|
initialized = false;
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
$(".hours").text("00");
|
$(".hours").text("00");
|
||||||
$(".minutes").text("00");
|
$(".minutes").text("00");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user