mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Fixed display of next due dates
This commit is contained in:
@@ -263,6 +263,7 @@ angular.module('habitrpg')
|
||||
modalScope.task._tags = !user.preferences.tagsCollapsed;
|
||||
modalScope.task._advanced = !user.preferences.advancedCollapsed;
|
||||
modalScope.task._edit = angular.copy(task);
|
||||
modalScope.user = user;
|
||||
if($rootScope.charts[task._id]) $rootScope.charts[task.id] = false;
|
||||
|
||||
modalScope.taskStatus = taskStatus;
|
||||
@@ -294,7 +295,7 @@ angular.module('habitrpg')
|
||||
$scope.$watch('task._edit', function (newValue, oldValue) {
|
||||
if ($scope.task.type !== 'daily' || !task._edit) return;
|
||||
$scope.summary = generateSummary($scope.task);
|
||||
$scope.nextDue = generateNextDue($scope.task);
|
||||
$scope.nextDue = generateNextDue($scope.task._edit, $scope.user);
|
||||
|
||||
$scope.repeatSuffix = generateRepeatSuffix($scope.task);
|
||||
if ($scope.task._edit.repeatsOn == 'dayOfMonth') {
|
||||
@@ -388,12 +389,15 @@ angular.module('habitrpg')
|
||||
}
|
||||
};
|
||||
|
||||
function generateNextDue (task) {
|
||||
if (!task.nextDue) return;
|
||||
let nextDue = task.nextDue.map((date) => {
|
||||
let dateObject = new Date(date);
|
||||
return [dateObject.getFullYear(), dateObject.getMonth() + 1, dateObject.getDate()].join('-');
|
||||
})
|
||||
function generateNextDue (task, user) {
|
||||
let options = angular.copy(user);
|
||||
options.nextDue = true;
|
||||
let nextDueDates = Shared.shouldDo(new Date, task, options);
|
||||
|
||||
let nextDue = nextDueDates.map((date) => {
|
||||
return date.format('MM-DD-YYYY');
|
||||
});
|
||||
|
||||
return nextDue.join(', ');
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
let schedule = moment(startDate).recur()
|
||||
.every(dailyTask.everyX).days();
|
||||
|
||||
if (options.nextDue) return schedule.fromDate(startOfDayWithCDSTime).next(3);
|
||||
if (options.nextDue) return schedule.fromDate(startOfDayWithCDSTime).next(6);
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime);
|
||||
} else if (dailyTask.frequency === 'weekly') {
|
||||
@@ -133,7 +133,15 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
|
||||
schedule = schedule.every(daysOfTheWeek).daysOfWeek();
|
||||
|
||||
if (options.nextDue) return schedule.fromDate(startOfDayWithCDSTime).next(3);
|
||||
if (options.nextDue) {
|
||||
let dates = schedule.fromDate(startOfDayWithCDSTime).next(6);
|
||||
let filterDates = dates.filter((momentDate) => {
|
||||
let weekDiff = momentDate.week() - moment(startDate).week();
|
||||
let matchX = weekDiff % dailyTask.everyX === 0;
|
||||
return matchX;
|
||||
});
|
||||
return filterDates;
|
||||
}
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime) && matchEveryX;
|
||||
} else if (dailyTask.frequency === 'monthly') {
|
||||
@@ -149,7 +157,15 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
schedule = schedule.every(dailyTask.daysOfMonth).daysOfMonth();
|
||||
}
|
||||
|
||||
if (options.nextDue) return schedule.fromDate(startOfDayWithCDSTime).next(3);
|
||||
if (options.nextDue) {
|
||||
let dates = schedule.fromDate(startOfDayWithCDSTime).next(6);
|
||||
let filterDates = dates.filter((momentDate) => {
|
||||
let monthDiff = momentDate.month() - moment(startDate).month();
|
||||
let matchX = monthDiff % dailyTask.everyX === 0;
|
||||
return matchX;
|
||||
});
|
||||
return filterDates;
|
||||
}
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime) && matchEveryX;
|
||||
} else if (dailyTask.frequency === 'yearly') {
|
||||
@@ -157,7 +173,15 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
|
||||
schedule = schedule.every(dailyTask.everyX).years();
|
||||
|
||||
if (options.nextDue) return schedule.fromDate(startOfDayWithCDSTime).next(3);
|
||||
if (options.nextDue) {
|
||||
let dates = schedule.fromDate(startOfDayWithCDSTime).next(6);
|
||||
let filterDates = dates.filter((momentDate) => {
|
||||
let monthDiff = momentDate.years() - moment(startDate).years();
|
||||
let matchX = monthDiff % dailyTask.everyX === 0;
|
||||
return matchX;
|
||||
});
|
||||
return filterDates;
|
||||
}
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user