mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Repeatables fixes (#8538)
* Prevented watch functions from being called when task._edit is removed * Added start date support on the UI task summary * Fixed setting of monthly and calculations * Fixed linting issues * Added check for existence * Added existence check * Ensured correct start date is used on update * Hid repeat options from anything not a daily * Added missing locales * Moved repeatables out of advance options
This commit is contained in:
@@ -283,7 +283,7 @@ angular.module('habitrpg')
|
||||
modalScope.cancelTaskEdit = cancelTaskEdit;
|
||||
|
||||
modalScope.task._edit.repeatsOn = 'dayOfMonth';
|
||||
if (modalScope.task === 'daily' && modalScope.task._edit.weeksOfMonth.length > 0) {
|
||||
if (modalScope.task.type === 'daily' && modalScope.task._edit.weeksOfMonth && modalScope.task._edit.weeksOfMonth.length > 0) {
|
||||
modalScope.task._edit.repeatsOn = 'dayOfWeek';
|
||||
}
|
||||
|
||||
@@ -292,20 +292,19 @@ angular.module('habitrpg')
|
||||
templateUrl: 'modals/task-edit.html',
|
||||
controller: ['$scope', function ($scope) {
|
||||
$scope.$watch('task._edit', function (newValue, oldValue) {
|
||||
if ($scope.task.type !== 'daily') return;
|
||||
if ($scope.task.type !== 'daily' || !task._edit) return;
|
||||
$scope.summary = generateSummary($scope.task);
|
||||
|
||||
$scope.repeatSuffix = generateRepeatSuffix($scope.task);
|
||||
|
||||
if ($scope.task._edit.repeatsOn == 'dayOfMonth') {
|
||||
var date = moment().date();
|
||||
var date = moment(task._edit.startDate).date();
|
||||
$scope.task._edit.weeksOfMonth = [];
|
||||
$scope.task._edit.dayOfMonth = [date]; // @TODO This can handle multiple dates later
|
||||
$scope.task._edit.daysOfMonth = [date]; // @TODO This can handle multiple dates later
|
||||
} else if ($scope.task._edit.repeatsOn == 'dayOfWeek') {
|
||||
var week = Math.ceil(moment().date() / 7) - 1;
|
||||
var dayOfWeek = moment().day();
|
||||
var week = Math.ceil(moment(task._edit.startDate).date() / 7) - 1;
|
||||
var dayOfWeek = moment(task._edit.startDate).day();
|
||||
var shortDay = numberToShortDay[dayOfWeek];
|
||||
$scope.task._edit.dayOfMonth = [];
|
||||
$scope.task._edit.daysOfMonth = [];
|
||||
$scope.task._edit.weeksOfMonth = [week]; // @TODO: This can handle multiple weeks
|
||||
for (var key in $scope.task._edit.repeat) {
|
||||
$scope.task._edit.repeat[key] = false;
|
||||
@@ -358,11 +357,11 @@ angular.module('habitrpg')
|
||||
if (task._edit.frequency === 'weekly') summary += ' on ' + repeatDays;
|
||||
|
||||
if (task._edit.frequency === 'monthly' && task._edit.repeatsOn == 'dayOfMonth') {
|
||||
var date = moment().date();
|
||||
var date = moment(task._edit.startDate).date();
|
||||
summary += ' on the ' + date;
|
||||
} else if (task._edit.frequency === 'monthly' && task._edit.repeatsOn == 'dayOfWeek') {
|
||||
var week = Math.ceil(moment().date() / 7) - 1;
|
||||
var dayOfWeek = moment().day();
|
||||
var week = Math.ceil(moment(task._edit.startDate).date() / 7) - 1;
|
||||
var dayOfWeek = moment(task._edit.startDate).day();
|
||||
var shortDay = numberToShortDay[dayOfWeek];
|
||||
var longDay = shortDayToLongDayMap[shortDay];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user