Load completed children when opening parent task

This commit is contained in:
Raimund Schlüßler 2016-05-15 22:27:42 +02:00
parent c496d62b0c
commit a800ebc78f
4 changed files with 64 additions and 8 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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);

View file

@ -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);