Added support in daily tasks for specifying ’every X days’ and ‘every X weeks on specific days of the week’.

- shouldDo() now takes the entire task as an input instead of just the ‘repeat’ (days of the week) dictionary.
- the ‘start’ date for a task can be specified (and can also be in the future, in which case it will be greyed out until then.) ‘start’ date also affects ‘every X days’ and ‘every X weeks’.
- no migration code yet.
This commit is contained in:
Allen Pan
2015-05-07 15:23:54 -07:00
parent 2ba1a1fc85
commit 1ecf608408
5 changed files with 122 additions and 24 deletions

View File

@@ -4,6 +4,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
function($scope, $rootScope, $location, User, Notification, $http, ApiUrl, $timeout, Shared, Guide) {
$scope.obj = User.user; // used for task-lists
$scope.user = User.user;
// HACK: flagDict is for storing whether the datePicker popup is open or not. This should just be a boolean flag,
// but apparently due to angular bug need to put the bool in intermediate dict...
$scope.flagDict = {};
$scope.score = function(task, direction) {
switch (task.type) {
@@ -127,6 +130,24 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
*/
$scope._today = moment().add({days: 1});
/*
------------------------
Dailies
------------------------
*/
$scope.updateTaskStartDate = function(task) {
// TODO: Weirdness here...startDate should be a Date and _dateString
// should be a string, but the datePicker input fields sets _dateString
// to a Date even though input type="text"...
task.startDate = task._dateString;
};
$scope.open = function($event) {
$event.stopPropagation();
$scope.flagDict['opened'] = !$scope.flagDict['opened'];
}
/*
------------------------
Checklists
@@ -212,7 +233,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
$scope.shouldShow = function(task, list, prefs){
if (task._editing) // never hide a task while being edited
return true;
var shouldDo = task.type == 'daily' ? habitrpgShared.shouldDo(new Date, task.repeat, prefs) : true;
var shouldDo = task.type == 'daily' ? habitrpgShared.shouldDo(new Date, task, prefs) : true;
switch (list.view) {
case "yellowred": // Habits
return task.value < 1;