Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/tasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorRaimund Schlüßler <raimund.schluessler@googlemail.com>2016-08-31 00:42:19 +0300
committerRaimund Schlüßler <raimund.schluessler@googlemail.com>2016-09-03 00:07:30 +0300
commitdf50d3a8eb4a0b01039f9eac16a3cd410b760d38 (patch)
treef36a66dc3fdefe303f0ea4e618c6f89af96a46e2 /js
parent35574fb9e5d64c1c755d9b0735c35180df262023 (diff)
Implement custom sorting
Diffstat (limited to 'js')
-rw-r--r--js/app/controllers/taskscontroller.js47
-rw-r--r--js/public/app.js47
2 files changed, 80 insertions, 14 deletions
diff --git a/js/app/controllers/taskscontroller.js b/js/app/controllers/taskscontroller.js
index 26b09e57..95a77303 100644
--- a/js/app/controllers/taskscontroller.js
+++ b/js/app/controllers/taskscontroller.js
@@ -52,6 +52,8 @@
this._$scope.focusInputField = false;
this._$scope.TasksModel = this._$tasksmodel;
this._$scope.TasksBusinessLayer = this._tasksbusinesslayer;
+ this._$scope.sortOrder = 'default';
+ this._$scope.sortDirection = false;
this._$scope.addTask = function(taskName, related, calendar, parent) {
var _ref, _this = this;
@@ -316,13 +318,44 @@
return _$listsmodel.loadedCompleted(calendarID);
};
- this._$scope.sortDue = function(task) {
- if (task.due === null) {
- return 'last';
- } else {
- return task.due;
- }
- };
+ this._$scope.sortDue = function(task) {
+ if (task.due === null) {
+ return 'last';
+ } else {
+ return task.due;
+ }
+ };
+
+ this._$scope.sortStart = function(task) {
+ if (task.start === null) {
+ return 'last';
+ } else {
+ return task.start;
+ }
+ };
+
+ this._$scope.getSortOrder = function() {
+ switch (_$scope.sortOrder) {
+ case 'due':
+ return _$scope.sortDue;
+ case 'start':
+ return _$scope.sortStart;
+ case 'priority':
+ return '-priority';
+ case 'alphabetically':
+ return 'summary';
+ case 'manual':
+ return 'manual';
+ default:
+ return ['completed', _$scope.sortDue, '-priority', _$scope.sortStart, 'summary'];
+ }
+ };
+
+ this._$scope.setSortOrder = function($event, order) {
+ $event.stopPropagation();
+ _$scope.sortDirection = (_$scope.sortOrder === order) ? !_$scope.sortDirection : false;
+ _$scope.sortOrder = order;
+ };
this._$scope.dropAsSubtask = function($event, item, index) {
if ($event.dataTransfer.dropEffect === 'move') {
diff --git a/js/public/app.js b/js/public/app.js
index aee93610..b477bbc1 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -931,6 +931,8 @@ angular.module('Tasks').controller('SettingsController', [
this._$scope.focusInputField = false;
this._$scope.TasksModel = this._$tasksmodel;
this._$scope.TasksBusinessLayer = this._tasksbusinesslayer;
+ this._$scope.sortOrder = 'default';
+ this._$scope.sortDirection = false;
this._$scope.addTask = function(taskName, related, calendar, parent) {
var _ref, _this = this;
@@ -1195,13 +1197,44 @@ angular.module('Tasks').controller('SettingsController', [
return _$listsmodel.loadedCompleted(calendarID);
};
- this._$scope.sortDue = function(task) {
- if (task.due === null) {
- return 'last';
- } else {
- return task.due;
- }
- };
+ this._$scope.sortDue = function(task) {
+ if (task.due === null) {
+ return 'last';
+ } else {
+ return task.due;
+ }
+ };
+
+ this._$scope.sortStart = function(task) {
+ if (task.start === null) {
+ return 'last';
+ } else {
+ return task.start;
+ }
+ };
+
+ this._$scope.getSortOrder = function() {
+ switch (_$scope.sortOrder) {
+ case 'due':
+ return _$scope.sortDue;
+ case 'start':
+ return _$scope.sortStart;
+ case 'priority':
+ return '-priority';
+ case 'alphabetically':
+ return 'summary';
+ case 'manual':
+ return 'manual';
+ default:
+ return ['completed', _$scope.sortDue, '-priority', _$scope.sortStart, 'summary'];
+ }
+ };
+
+ this._$scope.setSortOrder = function($event, order) {
+ $event.stopPropagation();
+ _$scope.sortDirection = (_$scope.sortOrder === order) ? !_$scope.sortDirection : false;
+ _$scope.sortOrder = order;
+ };
this._$scope.dropAsSubtask = function($event, item, index) {
if ($event.dataTransfer.dropEffect === 'move') {