Skip to content

Commit e681b2a

Browse files
authored
Merge pull request #4 from Hawiak/feature/use-enter-for-new-work-item
Fixed title for submitting with enter
2 parents 10be376 + baae5a7 commit e681b2a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

js/src/timer.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,17 +580,20 @@ function() {
580580
}
581581

582582
function createWorkItem() {
583-
$('#work-input').val($(this).data('work-name'));
584-
startTimer($(this).data('projectid'), $(this).data('tagids'));
583+
var wiPlay = $('.wi-play');
584+
var workName = $('#work-input').val();
585+
586+
$('#work-input').val(wiPlay.data('work-name'));
587+
startTimer(wiPlay.data('projectid'), wiPlay.data('tagids'), workName);
585588
return false;
586589
}
587590

588-
function startTimer(projectId = null, tags = ""){
591+
function startTimer(projectId = null, tags = "", inputWorkName = null){
589592
if(localStorage.getItem('isTimerStarted') === 'true'){
590-
stopTimer(startTimer, [projectId, tags]);
593+
stopTimer(startTimer, [projectId, tags, inputWorkName]);
591594
return;
592595
}
593-
var workName = $('#work-input').val();
596+
var workName = inputWorkName ?? $('#work-input').val();
594597
if (workName == ''){
595598
workName = 'no description';
596599
}
@@ -630,7 +633,7 @@ function() {
630633
localStorage.setItem('isTimerStarted', false);
631634
$('#start-tracking > span').addClass("play-button").removeClass("stop-button");
632635
if (onStopped != null){
633-
onStopped(args[0], args[1]);
636+
onStopped(...args);
634637
} else {
635638
getWorkItems();
636639
}

0 commit comments

Comments
 (0)