Prevented modal close and showed correct due class in modal

This commit is contained in:
Keith Holliday
2017-06-16 12:28:42 -06:00
parent 7a8857010e
commit 136dcd27a9
3 changed files with 8 additions and 3 deletions

View File

@@ -42,10 +42,12 @@ habitrpg.controller('NotificationCtrl',
showCompleted: false,
type: 'daily',
};
modalScope.processingYesterdailies = true;
$scope.yesterDailiesModalOpen = true;
$rootScope.openModal('yesterDailies', {
scope: modalScope,
backdrop: 'static',
controller: ['$scope', 'Tasks', 'User', '$rootScope', function ($scope, Tasks, User, $rootScope) {
$rootScope.$on('task:scored', function (event, data) {
var task = data.task;

View File

@@ -17,7 +17,7 @@
scope: true,
link: function($scope, element, attrs) {
$scope.getClasses = function (task, user, list, main) {
return Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main);
return Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main, $scope.processingYesterdailies);
}
$scope.showNoteDetails = function (task) {

View File

@@ -1,6 +1,7 @@
import {
shouldDo,
} from '../cron';
import moment from 'moment';
/*
Task classes given everything about the class
@@ -8,7 +9,7 @@ Task classes given everything about the class
// TODO move to the client
module.exports = function taskClasses (task, filters = [], dayStart = 0, lastCron = Number(new Date()), showCompleted = false, main = false) {
module.exports = function taskClasses (task, filters = [], dayStart = 0, lastCron = Number(new Date()), showCompleted = false, main = false, processingYesterdailies = false) {
if (!task) {
return '';
}
@@ -34,7 +35,9 @@ module.exports = function taskClasses (task, filters = [], dayStart = 0, lastCro
}
if (type === 'todo' || type === 'daily') {
let notDue = !shouldDo(Number(new Date()), task, { dayStart });
let dayShouldDo = moment();
if (processingYesterdailies) dayShouldDo.subtract(1, 'days');
let notDue = !shouldDo(Number(dayShouldDo), task, { dayStart });
let isNotDueDaily = type === 'daily' && notDue;
if (completed || isNotDueDaily) {