feat: add optional reset break timer but track when tracking on idle dialog

This commit is contained in:
Johannes Millan 2018-03-26 22:04:26 +02:00
parent db34ac0c98
commit 359ddb2d41
3 changed files with 22 additions and 5 deletions

View file

@ -13,7 +13,7 @@
</div>
</md-toolbar>
<form ng-submit="vm.trackIdleToTask()">
<form ng-submit="vm.trackIdleToTask(false)">
<md-dialog-content>
<div class="md-dialog-content">
@ -32,7 +32,7 @@
<md-item-template>
<span md-highlight-text="vm.searchText"
md-highlight-flags="i"
ng-bind="task.title"></span>
ng-bind="task.title"></span>
</md-item-template>
<md-not-found>
No states matching "<span ng-bind="vm.searchText"></span>" were found.
@ -49,6 +49,13 @@
Track
</md-button>
<md-button ng-click="vm.trackIdleToTask(true)"
ng-if="vm.isShowTrackButResetTakeABreakTimer"
type="button"
class="md-primary md-raised">
Track but reset break timer
</md-button>
<md-button ng-click="vm.cancel()"
type="button"
class="md-raised">

View file

@ -14,7 +14,7 @@
.controller('WasIdleCtrl', WasIdleCtrl);
/* @ngInject */
function WasIdleCtrl($mdDialog, $rootScope, $scope, Tasks, $window, initialIdleTime, minIdleTimeInMs, theme, $filter, $interval) {
function WasIdleCtrl($mdDialog, $rootScope, $scope, Tasks, $window, initialIdleTime, minIdleTimeInMs, theme, $filter, $interval, TakeABreakReminder) {
const POLL_INTERVAL = 1000;
let vm = this;
@ -29,7 +29,13 @@
vm.undoneTasks = Tasks.getUndoneToday(true);
vm.selectedTask = $rootScope.r.currentTask || $rootScope.r.lastActiveTaskTask || undefined;
vm.trackIdleToTask = () => {
vm.isShowTrackButResetTakeABreakTimer = TakeABreakReminder.isEnabled();
vm.trackIdleToTask = (isResetTakeABreakTimer) => {
if (isResetTakeABreakTimer) {
TakeABreakReminder.resetCounter();
}
if (vm.selectedTask && vm.selectedTask.id) {
// add the idle time in milliseconds + the minIdleTime that was
// not tracked or removed

View file

@ -20,6 +20,10 @@
const TOAST_DISPLAY_TIME = 30000;
let toast;
this.isEnabled = () => {
return $rootScope.r.config && $rootScope.r.config.isTakeABreakEnabled;
};
this.resetCounter = () => {
this.lastCounterValBeforeReset = $rootScope.r.currentSession.timeWorkedWithoutBreak;
$rootScope.r.currentSession.timeWorkedWithoutBreak = undefined;
@ -43,7 +47,7 @@
};
this.update = (timeSpentInMs, isIdle) => {
if ($rootScope.r.config && $rootScope.r.config.isTakeABreakEnabled) {
if (this.isEnabled()) {
if (!$rootScope.r.currentSession) {
$rootScope.r.currentSession = {};
}