mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 12:40:00 +00:00
Merge pull request #5022 from gisikw/dated-tasks-correct-impl
Dated tasks correct impl
This commit is contained in:
commit
7c36e49243
7 changed files with 47 additions and 10 deletions
|
|
@ -44,7 +44,6 @@
|
||||||
"remaining": "Active",
|
"remaining": "Active",
|
||||||
"complete": "Done",
|
"complete": "Done",
|
||||||
"dated": "Dated",
|
"dated": "Dated",
|
||||||
"datedNotSorted": "Dated To-Dos are NOT sorted by date. Sorting will probably be implemented in future.",
|
|
||||||
"due": "Due",
|
"due": "Due",
|
||||||
"grey": "Grey",
|
"grey": "Grey",
|
||||||
"score": "Score",
|
"score": "Score",
|
||||||
|
|
|
||||||
30
test/spec/filtersSpec.js
Normal file
30
test/spec/filtersSpec.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Custom Filters', function() {
|
||||||
|
var filter
|
||||||
|
, orderBySpy = sinon.spy();
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
module(function($provide) {
|
||||||
|
$provide.value('orderByFilter', orderBySpy);
|
||||||
|
});
|
||||||
|
inject(function($rootScope, $filter) {
|
||||||
|
filter = $filter;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('conditionalOrderBy', function() {
|
||||||
|
describe('when the predicate is true', function() {
|
||||||
|
it('delegates the arguments to the orderBy filter', function() {
|
||||||
|
filter('conditionalOrderBy')('array', true, 'sortPredicate', 'reverseOrder');
|
||||||
|
expect(orderBySpy).to.have.been.calledWith('array','sortPredicate','reverseOrder');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the predicate is false', function() {
|
||||||
|
it('returns the initial array', function() {
|
||||||
|
expect(filter('conditionalOrderBy')([1,2,3], false)).to.eql([1,2,3]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -58,7 +58,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||||
var groupsWithChallenges = _.uniq(_.pluck($scope.groupsFilter, '_id'));
|
var groupsWithChallenges = _.uniq(_.pluck($scope.groupsFilter, '_id'));
|
||||||
var len = groupsWithChallenges.length;
|
var len = groupsWithChallenges.length;
|
||||||
var filterCount = 0;
|
var filterCount = 0;
|
||||||
|
|
||||||
for ( var i = 0; i < len; i += 1 ) {
|
for ( var i = 0; i < len; i += 1 ) {
|
||||||
if ( $scope.search.group[groupsWithChallenges[i]] == true ) {
|
if ( $scope.search.group[groupsWithChallenges[i]] == true ) {
|
||||||
filterCount += 1;
|
filterCount += 1;
|
||||||
|
|
@ -186,11 +186,11 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||||
delete listDef.newTask;
|
delete listDef.newTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.removeTask = function(list, $index) {
|
$scope.removeTask = function(task, list) {
|
||||||
if (!confirm(window.env.t('sureDelete'))) return;
|
if (!confirm(window.env.t('sureDelete'))) return;
|
||||||
//TODO persist
|
//TODO persist
|
||||||
// User.log({op: "delTask", data: task});
|
// User.log({op: "delTask", data: task});
|
||||||
list.splice($index, 1);
|
_.remove(list, task);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.saveTask = function(task){
|
$scope.saveTask = function(task){
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.removeTask = function(list, $index) {
|
$scope.removeTask = function(task) {
|
||||||
if (!confirm(window.env.t('sureDelete'))) return;
|
if (!confirm(window.env.t('sureDelete'))) return;
|
||||||
User.user.ops.deleteTask({params:{id:list[$index].id}})
|
User.user.ops.deleteTask({params:{id:task.id}})
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
$scope.saveTask = function(task, stayOpen, isSaveAndClose) {
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,11 @@ angular.module('habitrpg')
|
||||||
(gp > 999) ? (gp / Math.pow(10, 3)).toFixed(1) + "k" : gp;
|
(gp > 999) ? (gp / Math.pow(10, 3)).toFixed(1) + "k" : gp;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.filter('conditionalOrderBy', function($filter) {
|
||||||
|
return function (array, predicate, sortPredicate, reverseOrder) {
|
||||||
|
if (predicate) {
|
||||||
|
return $filter('orderBy')(array, sortPredicate, reverseOrder);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
|
||||||
ul.task-filter
|
ul.task-filter
|
||||||
li(ng-class='{active: list.view == "remaining"}')
|
li(ng-class='{active: list.view == "remaining"}')
|
||||||
a(ng-click='list.view = "remaining"')=env.t('remaining')
|
a(ng-click='list.view = "remaining"')=env.t('remaining')
|
||||||
li(ng-class='{active: list.view == "dated"}', tooltip=env.t('datedNotSorted'))
|
li(ng-class='{active: list.view == "dated"}')
|
||||||
a(ng-click='list.view = "dated"')=env.t('dated')
|
a(ng-click='list.view = "dated"')=env.t('dated')
|
||||||
li(ng-class='{active: list.view == "complete"}')
|
li(ng-class='{active: list.view == "complete"}')
|
||||||
a(ng-click='list.view = "complete"')=env.t('complete')
|
a(ng-click='list.view = "complete"')=env.t('complete')
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s"]', class='task {{Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}', ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)', ng-class='{"cast-target":spell && (list.type != "reward"), "locked-task":obj._locked === true}', popover-trigger='mouseenter', data-popover-html="{{task.notes | markdown}}", popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}', ng-show='shouldShow(task, list, user.preferences)')
|
li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s"] | conditionalOrderBy: list.view=="dated":"date"', class='task {{Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}', ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)', ng-class='{"cast-target":spell && (list.type != "reward"), "locked-task":obj._locked === true}', popover-trigger='mouseenter', data-popover-html="{{task.notes | markdown}}", popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}', ng-show='shouldShow(task, list, user.preferences)')
|
||||||
// right-hand side control buttons
|
// right-hand side control buttons
|
||||||
.task-meta-controls
|
.task-meta-controls
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s
|
||||||
span.glyphicon.glyphicon-bullhorn(tooltip=env.t('challenge'))
|
span.glyphicon.glyphicon-bullhorn(tooltip=env.t('challenge'))
|
||||||
|
|
|
|
||||||
// delete
|
// delete
|
||||||
a(ng-if='!task.challenge.id', ng-click='removeTask(obj[list.type+"s"], $index)', tooltip=env.t('delete'))
|
a(ng-if='!task.challenge.id', ng-click='removeTask(task, obj[list.type+"s"])', tooltip=env.t('delete'))
|
||||||
span.glyphicon.glyphicon-trash
|
span.glyphicon.glyphicon-trash
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s
|
||||||
p
|
p
|
||||||
a(ng-click='unlink(task, "keep")')=env.t('keepIt')
|
a(ng-click='unlink(task, "keep")')=env.t('keepIt')
|
||||||
|
|
|
|
||||||
a(ng-click="removeTask(obj[list.type+'s'], $index)")=env.t('removeIt')
|
a(ng-click="removeTask(task, obj[list.type+'s'])")=env.t('removeIt')
|
||||||
div(ng-if='task.challenge.broken=="CHALLENGE_DELETED"')
|
div(ng-if='task.challenge.broken=="CHALLENGE_DELETED"')
|
||||||
p
|
p
|
||||||
|
|
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue