From a800ebc78f0fb8cf9592ff445c470d36104046d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Sun, 15 May 2016 22:27:42 +0200 Subject: [PATCH] Load completed children when opening parent task --- js/app/controllers/taskscontroller.js | 4 +++ .../businesslayer/tasksbusinesslayer.js | 15 ++++++-- js/app/services/vtodoservice.js | 17 ++++++++- js/public/app.js | 36 ++++++++++++++++--- 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/js/app/controllers/taskscontroller.js b/js/app/controllers/taskscontroller.js index 467369ef..c898a087 100644 --- a/js/app/controllers/taskscontroller.js +++ b/js/app/controllers/taskscontroller.js @@ -174,6 +174,10 @@ var calendarID = _$scope.route.calendarID; var collectionID = _$scope.route.collectionID; if ($($event.currentTarget).is($($event.target).closest('.handler'))) { + var task = _$tasksmodel.getByUri(id); + _tasksbusinesslayer.getCompletedByParent(task).then(function() { + $scope.$apply(); + }); if (calendarID) { $location.path('/calendars/' + calendarID + '/tasks/' + id); } else if (collectionID) { diff --git a/js/app/services/businesslayer/tasksbusinesslayer.js b/js/app/services/businesslayer/tasksbusinesslayer.js index 7bf401da..2d4c44d4 100644 --- a/js/app/services/businesslayer/tasksbusinesslayer.js +++ b/js/app/services/businesslayer/tasksbusinesslayer.js @@ -59,9 +59,18 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ }); }; - TasksBusinessLayer.prototype.getCompletedTasks = function(calendarID) { - return true; - } + TasksBusinessLayer.prototype.getCompletedByParent = function(task) { + return this._$vtodoservice.getAll(task.calendar, true, task).then(function(tasks) { + var task, _i, _len, _results; + _results = []; + for (_i = 0, _len = tasks.length; _i < _len; _i++) { + task = tasks[_i]; + var vTodo = new VTodo(task.calendar, task.properties, task.uri); + _results.push(TasksModel.ad(vTodo)); + } + return _results; + }); + }; TasksBusinessLayer.prototype.setPriority = function(task, priority) { if (task.calendar.writable) { diff --git a/js/app/services/vtodoservice.js b/js/app/services/vtodoservice.js index db26fcf7..2005ead4 100644 --- a/js/app/services/vtodoservice.js +++ b/js/app/services/vtodoservice.js @@ -28,10 +28,13 @@ angular.module('Tasks').service('VTodoService', ['DavClient', 'RandomStringServi var _this = this; - this.getAll = function(calendar, completed) { + this.getAll = function(calendar, completed, parent) { if (completed === null) { completed = false; } + if (parent === null) { + parent = false; + } var xmlDoc = document.implementation.createDocument('', '', null); var cCalQuery = xmlDoc.createElement('c:calendar-query'); cCalQuery.setAttribute('xmlns:c', 'urn:ietf:params:xml:ns:caldav'); @@ -69,6 +72,18 @@ angular.module('Tasks').service('VTodoService', ['DavClient', 'RandomStringServi cPropFilterCompleted.appendChild(cIsNotDefined); } + if (parent) { + console.log('parent'); + var cPropFilterRelated = xmlDoc.createElement('c:prop-filter'); + cPropFilterRelated.setAttribute('name', 'RELATED-TO'); + cCompFilterVTodo.appendChild(cPropFilterRelated); + var cTextMatch = xmlDoc.createElement('c:text-match'); + // cTextMatch.setAttribute('negate-condition', 'yes'); + var cTextMatchValue = xmlDoc.createTextNode(parent.uid); + cTextMatch.appendChild(cTextMatchValue); + cPropFilterRelated.appendChild(cTextMatch); + } + // var cPropFilterStatus = xmlDoc.createElement('c:prop-filter'); // cPropFilterStatus.setAttribute('name', 'STATUS'); // cCompFilterVTodo.appendChild(cPropFilterStatus); diff --git a/js/public/app.js b/js/public/app.js index 175f775c..d591f005 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -975,6 +975,10 @@ angular.module('Tasks').controller('SettingsController', [ var calendarID = _$scope.route.calendarID; var collectionID = _$scope.route.collectionID; if ($($event.currentTarget).is($($event.target).closest('.handler'))) { + var task = _$tasksmodel.getByUri(id); + _tasksbusinesslayer.getCompletedByParent(task).then(function() { + $scope.$apply(); + }); if (calendarID) { $location.path('/calendars/' + calendarID + '/tasks/' + id); } else if (collectionID) { @@ -1710,9 +1714,18 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ }); }; - TasksBusinessLayer.prototype.getCompletedTasks = function(calendarID) { - return true; - } + TasksBusinessLayer.prototype.getCompletedByParent = function(task) { + return this._$vtodoservice.getAll(task.calendar, true, task).then(function(tasks) { + var task, _i, _len, _results; + _results = []; + for (_i = 0, _len = tasks.length; _i < _len; _i++) { + task = tasks[_i]; + var vTodo = new VTodo(task.calendar, task.properties, task.uri); + _results.push(TasksModel.ad(vTodo)); + } + return _results; + }); + }; TasksBusinessLayer.prototype.setPriority = function(task, priority) { if (task.calendar.writable) { @@ -4238,10 +4251,13 @@ angular.module('Tasks').service('VTodoService', ['DavClient', 'RandomStringServi var _this = this; - this.getAll = function(calendar, completed) { + this.getAll = function(calendar, completed, parent) { if (completed === null) { completed = false; } + if (parent === null) { + parent = false; + } var xmlDoc = document.implementation.createDocument('', '', null); var cCalQuery = xmlDoc.createElement('c:calendar-query'); cCalQuery.setAttribute('xmlns:c', 'urn:ietf:params:xml:ns:caldav'); @@ -4279,6 +4295,18 @@ angular.module('Tasks').service('VTodoService', ['DavClient', 'RandomStringServi cPropFilterCompleted.appendChild(cIsNotDefined); } + if (parent) { + console.log('parent'); + var cPropFilterRelated = xmlDoc.createElement('c:prop-filter'); + cPropFilterRelated.setAttribute('name', 'RELATED-TO'); + cCompFilterVTodo.appendChild(cPropFilterRelated); + var cTextMatch = xmlDoc.createElement('c:text-match'); + // cTextMatch.setAttribute('negate-condition', 'yes'); + var cTextMatchValue = xmlDoc.createTextNode(parent.uid); + cTextMatch.appendChild(cTextMatchValue); + cPropFilterRelated.appendChild(cTextMatch); + } + // var cPropFilterStatus = xmlDoc.createElement('c:prop-filter'); // cPropFilterStatus.setAttribute('name', 'STATUS'); // cCompFilterVTodo.appendChild(cPropFilterStatus);