From 9b08e87e59d8320122014fa2ed7a6218bce85a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Sun, 24 Jul 2016 23:53:50 +0200 Subject: [PATCH] Fix loading of completed tasks, fix #332 --- .../businesslayer/tasksbusinesslayer.js | 6 ++-- js/app/services/models/listsmodel.js | 2 +- js/app/services/models/tasksmodel.js | 25 ++++++------- js/app/services/models/vtodo.js | 3 -- js/public/app.js | 36 +++++++++---------- 5 files changed, 34 insertions(+), 38 deletions(-) diff --git a/js/app/services/businesslayer/tasksbusinesslayer.js b/js/app/services/businesslayer/tasksbusinesslayer.js index 37f201a4..4cc806bb 100644 --- a/js/app/services/businesslayer/tasksbusinesslayer.js +++ b/js/app/services/businesslayer/tasksbusinesslayer.js @@ -422,7 +422,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ newTask.calendar = newCalendar; if (!TasksModel.hasNoParent(newTask)) { var parent = TasksModel.getByUid(newTask.related); - if (parent.calendaruri !== newTask.calendaruri) { + if (parent.calendar.uri !== newTask.calendar.uri) { newTask.related = null; TasksBusinessLayer.prototype.setPercentComplete(newTask, 0); } @@ -437,7 +437,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ var _i, _len, child; for (_i = 0, _len = children.length; _i < _len; _i++) { child = children[_i]; - if (child.calendaruri !== newTask.calendaruri) { + if (child.calendar.uri !== newTask.calendar.uri) { queries.push(TasksBusinessLayer.prototype.changeCalendar(child, newTask.calendar)); } } @@ -484,7 +484,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ } else { this.doUpdate(parent); } - if (parent.calendaruri !== task.calendaruri) { + if (parent.calendar.uri !== task.calendar.uri) { this.changeCalendar(task, parent.calendar); } else { this.doUpdate(task); diff --git a/js/app/services/models/listsmodel.js b/js/app/services/models/listsmodel.js index 7e93c4bc..adce1ffb 100644 --- a/js/app/services/models/listsmodel.js +++ b/js/app/services/models/listsmodel.js @@ -127,7 +127,7 @@ tasks = this._$tasksmodel.filteredTasks(filter); for (_i = 0, _len = tasks.length; _i < _len; _i++) { task = tasks[_i]; - count += this._$tasksmodel.filterTasks(task, collectionID) && task.calendaruri === calendarID && !task.related; + count += this._$tasksmodel.filterTasks(task, collectionID) && task.calendar.uri === calendarID && !task.related; } // if (collectionID === 'completed' && filter === '') { // count += this.notLoaded(calendarID); diff --git a/js/app/services/models/tasksmodel.js b/js/app/services/models/tasksmodel.js index 15dac254..42829aa1 100644 --- a/js/app/services/models/tasksmodel.js +++ b/js/app/services/models/tasksmodel.js @@ -60,17 +60,18 @@ }; TasksModel.prototype.update = function(task, clearCache) { - var tmptask; - if (clearCache === null) { - clearCache = true; - } - tmptask = this._tmpIdCache[task.tmpID]; - if (angular.isDefined(task.id) && angular.isDefined(tmptask)) { - tmptask.id = task.id; - this._dataMap[task.id] = tmptask; - } - task["void"] = false; - return TasksModel.__super__.update.call(this, task, clearCache); + + var entry, key, value, _results; + if (clearCache === null) { + clearCache = true; + } + if (clearCache) { + this._invalidateCache(); + } + entry = this.getByUri(task.uri); + entry.components = task.components; + entry.components.toString(); + return entry; }; TasksModel.prototype.removeById = function(taskID) { @@ -249,7 +250,7 @@ case 'week': return task.completed === false && (this.week(task.start) || this.week(task.due)); default: - return '' + task.calendaruri === '' + filter; + return '' + task.calendar.uri === '' + filter; } }; diff --git a/js/app/services/models/vtodo.js b/js/app/services/models/vtodo.js index e9e73d43..34f01ece 100644 --- a/js/app/services/models/vtodo.js +++ b/js/app/services/models/vtodo.js @@ -46,9 +46,6 @@ angular.module('Tasks').factory('VTodo', ['$filter', 'ICalFactory', 'RandomStrin } VTodo.prototype = { - get calendaruri() { - return this.calendar.uri; - }, get summary() { var vtodos = this.components.getAllSubcomponents('vtodo'); return vtodos[0].getFirstPropertyValue('summary'); diff --git a/js/public/app.js b/js/public/app.js index f66b96d4..061ee380 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -2080,7 +2080,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ newTask.calendar = newCalendar; if (!TasksModel.hasNoParent(newTask)) { var parent = TasksModel.getByUid(newTask.related); - if (parent.calendaruri !== newTask.calendaruri) { + if (parent.calendar.uri !== newTask.calendar.uri) { newTask.related = null; TasksBusinessLayer.prototype.setPercentComplete(newTask, 0); } @@ -2095,7 +2095,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ var _i, _len, child; for (_i = 0, _len = children.length; _i < _len; _i++) { child = children[_i]; - if (child.calendaruri !== newTask.calendaruri) { + if (child.calendar.uri !== newTask.calendar.uri) { queries.push(TasksBusinessLayer.prototype.changeCalendar(child, newTask.calendar)); } } @@ -2142,7 +2142,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ } else { this.doUpdate(parent); } - if (parent.calendaruri !== task.calendaruri) { + if (parent.calendar.uri !== task.calendar.uri) { this.changeCalendar(task, parent.calendar); } else { this.doUpdate(task); @@ -3244,7 +3244,7 @@ angular.module('Tasks').factory('Calendar', ['$rootScope', '$filter', function($ tasks = this._$tasksmodel.filteredTasks(filter); for (_i = 0, _len = tasks.length; _i < _len; _i++) { task = tasks[_i]; - count += this._$tasksmodel.filterTasks(task, collectionID) && task.calendaruri === calendarID && !task.related; + count += this._$tasksmodel.filterTasks(task, collectionID) && task.calendar.uri === calendarID && !task.related; } // if (collectionID === 'completed' && filter === '') { // count += this.notLoaded(calendarID); @@ -3373,17 +3373,18 @@ angular.module('Tasks').factory('Calendar', ['$rootScope', '$filter', function($ }; TasksModel.prototype.update = function(task, clearCache) { - var tmptask; - if (clearCache === null) { - clearCache = true; - } - tmptask = this._tmpIdCache[task.tmpID]; - if (angular.isDefined(task.id) && angular.isDefined(tmptask)) { - tmptask.id = task.id; - this._dataMap[task.id] = tmptask; - } - task["void"] = false; - return TasksModel.__super__.update.call(this, task, clearCache); + + var entry, key, value, _results; + if (clearCache === null) { + clearCache = true; + } + if (clearCache) { + this._invalidateCache(); + } + entry = this.getByUri(task.uri); + entry.components = task.components; + entry.components.toString(); + return entry; }; TasksModel.prototype.removeById = function(taskID) { @@ -3562,7 +3563,7 @@ angular.module('Tasks').factory('Calendar', ['$rootScope', '$filter', function($ case 'week': return task.completed === false && (this.week(task.start) || this.week(task.due)); default: - return '' + task.calendaruri === '' + filter; + return '' + task.calendar.uri === '' + filter; } }; @@ -3738,9 +3739,6 @@ angular.module('Tasks').factory('VTodo', ['$filter', 'ICalFactory', 'RandomStrin } VTodo.prototype = { - get calendaruri() { - return this.calendar.uri; - }, get summary() { var vtodos = this.components.getAllSubcomponents('vtodo'); return vtodos[0].getFirstPropertyValue('summary');