diff --git a/js/app/controllers/taskscontroller.coffee b/js/app/controllers/taskscontroller.coffee index 65ade4c1..ff25cbae 100644 --- a/js/app/controllers/taskscontroller.coffee +++ b/js/app/controllers/taskscontroller.coffee @@ -108,6 +108,24 @@ SettingsBusinessLayer) -> return (task) -> return _$tasksmodel.filterTasks(task, _$scope.route.listID) + @_$scope.dayHasEntry = () -> + return (date) -> + tasks = _$tasksmodel.getAll() + for task in tasks + if task.completed + continue + if _$tasksmodel.taskAtDay(task, date) + return true + return false + + @_$scope.getTasksAtDay = (tasks, day) -> + ret = [] + for task in tasks + if _$tasksmodel.taskAtDay(task, day) + ret.push(task) + return ret + + @_$scope.filterTasksByCalendar = (task, listID) -> return (task) -> return ''+task.calendarid == ''+listID @@ -166,10 +184,6 @@ SettingsBusinessLayer) -> _$scope.taskName = "" _$scope.status.focusTaskInput = false - @_$scope.dayHasEntry = () -> - return (date) -> - return _$tasksmodel.dayHasEntry(date) - @_$scope.getCompletedTasks = (listID) -> _tasksbusinesslayer.getCompletedTasks(listID) diff --git a/js/app/filters/taskAtDay.coffee b/js/app/filters/taskAtDay.coffee deleted file mode 100644 index b18877f5..00000000 --- a/js/app/filters/taskAtDay.coffee +++ /dev/null @@ -1,44 +0,0 @@ -### - -ownCloud - Tasks - -@author Raimund Schlüßler -@copyright 2013 - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -License as published by the Free Software Foundation; either -version 3 of the License, or any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU AFFERO GENERAL PUBLIC LICENSE for more details. - -You should have received a copy of the GNU Affero General Public -License along with this library. If not, see . - -### -angular.module('Tasks').filter 'taskAtDay', () -> - return (tasks, date) -> - ret = [] - for task in tasks - start = moment(task.start, "YYYYMMDDTHHmmss") - if start.isValid() - diff = start.diff(moment().startOf('day'), 'days', true) - if !date && diff < date+1 - ret.push(task) - continue - else if diff < date+1 && diff >= date - ret.push(task) - continue - due = moment(task.due, "YYYYMMDDTHHmmss") - if due.isValid() - diff = due.diff(moment().startOf('day'), 'days', true) - if !date && diff < date+1 - ret.push(task) - continue - else if diff < date+1 && diff >= date - ret.push(task) - continue - return ret \ No newline at end of file diff --git a/js/app/services/models/tasksmodel.coffee b/js/app/services/models/tasksmodel.coffee index 4fff22a0..d90052c3 100644 --- a/js/app/services/models/tasksmodel.coffee +++ b/js/app/services/models/tasksmodel.coffee @@ -87,31 +87,31 @@ angular.module('Tasks').factory 'TasksModel', for id in taskIDs @removeById(id) - dayHasEntry: (date) -> - tasks = @getAll() - ret = false - for task in tasks - if task.completed - continue - start = moment(task.start, "YYYYMMDDTHHmmss") - if start.isValid() - diff = start.diff(moment().startOf('day'), 'days', true) - if !date && diff < date+1 - ret = true - break - else if diff < date+1 && diff >= date - ret = true - break - due = moment(task.due, "YYYYMMDDTHHmmss") - if due.isValid() - diff = due.diff(moment().startOf('day'), 'days', true) - if !date && diff < date+1 - ret = true - break - else if diff < date+1 && diff >= date - ret = true - break - return ret + taskAtDay: (task, date) -> + start = moment(task.start, "YYYYMMDDTHHmmss") + due = moment(task.due, "YYYYMMDDTHHmmss") + if start.isValid() && !due.isValid() + diff = start.diff(moment().startOf('day'), 'days', true) + if !date && diff < date+1 + return true + else if diff < date+1 && diff >= date + return true + if due.isValid() && !start.isValid() + diff = due.diff(moment().startOf('day'), 'days', true) + if !date && diff < date+1 + return true + else if diff < date+1 && diff >= date + return true + if start.isValid() && due.isValid() + startdiff = start.diff(moment().startOf('day'), 'days', true) + duediff = due.diff(moment().startOf('day'), 'days', true) + if !date && (startdiff < date+1 || duediff < date+1) + return true + else if startdiff < date+1 && startdiff >= date && duediff >= date + return true + else if duediff < date+1 && duediff >= date && startdiff >= date + return true + return false filterTasks: (task, collectionID) -> switch collectionID diff --git a/js/public/app.js b/js/public/app.js index af90e558..4e216040 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -1174,6 +1174,33 @@ return _$tasksmodel.filterTasks(task, _$scope.route.listID); }; }; + this._$scope.dayHasEntry = function() { + return function(date) { + var task, tasks, _i, _len; + tasks = _$tasksmodel.getAll(); + for (_i = 0, _len = tasks.length; _i < _len; _i++) { + task = tasks[_i]; + if (task.completed) { + continue; + } + if (_$tasksmodel.taskAtDay(task, date)) { + return true; + } + } + return false; + }; + }; + this._$scope.getTasksAtDay = function(tasks, day) { + var ret, task, _i, _len; + ret = []; + for (_i = 0, _len = tasks.length; _i < _len; _i++) { + task = tasks[_i]; + if (_$tasksmodel.taskAtDay(task, day)) { + ret.push(task); + } + } + return ret; + }; this._$scope.filterTasksByCalendar = function(task, listID) { return function(task) { return '' + task.calendarid === '' + listID; @@ -1233,11 +1260,6 @@ return _$scope.status.focusTaskInput = false; } }; - this._$scope.dayHasEntry = function() { - return function(date) { - return _$tasksmodel.dayHasEntry(date); - }; - }; this._$scope.getCompletedTasks = function(listID) { return _tasksbusinesslayer.getCompletedTasks(listID); }; @@ -2194,39 +2216,38 @@ return _results; }; - TasksModel.prototype.dayHasEntry = function(date) { - var diff, due, ret, start, task, tasks, _i, _len; - tasks = this.getAll(); - ret = false; - for (_i = 0, _len = tasks.length; _i < _len; _i++) { - task = tasks[_i]; - if (task.completed) { - continue; - } - start = moment(task.start, "YYYYMMDDTHHmmss"); - if (start.isValid()) { - diff = start.diff(moment().startOf('day'), 'days', true); - if (!date && diff < date + 1) { - ret = true; - break; - } else if (diff < date + 1 && diff >= date) { - ret = true; - break; - } - } - due = moment(task.due, "YYYYMMDDTHHmmss"); - if (due.isValid()) { - diff = due.diff(moment().startOf('day'), 'days', true); - if (!date && diff < date + 1) { - ret = true; - break; - } else if (diff < date + 1 && diff >= date) { - ret = true; - break; - } + TasksModel.prototype.taskAtDay = function(task, date) { + var diff, due, duediff, start, startdiff; + start = moment(task.start, "YYYYMMDDTHHmmss"); + due = moment(task.due, "YYYYMMDDTHHmmss"); + if (start.isValid() && !due.isValid()) { + diff = start.diff(moment().startOf('day'), 'days', true); + if (!date && diff < date + 1) { + return true; + } else if (diff < date + 1 && diff >= date) { + return true; } } - return ret; + if (due.isValid() && !start.isValid()) { + diff = due.diff(moment().startOf('day'), 'days', true); + if (!date && diff < date + 1) { + return true; + } else if (diff < date + 1 && diff >= date) { + return true; + } + } + if (start.isValid() && due.isValid()) { + startdiff = start.diff(moment().startOf('day'), 'days', true); + duediff = due.diff(moment().startOf('day'), 'days', true); + if (!date && (startdiff < date + 1 || duediff < date + 1)) { + return true; + } else if (startdiff < date + 1 && startdiff >= date && duediff >= date) { + return true; + } else if (duediff < date + 1 && duediff >= date && startdiff >= date) { + return true; + } + } + return false; }; TasksModel.prototype.filterTasks = function(task, collectionID) { @@ -3060,42 +3081,6 @@ }).call(this); -(function() { - angular.module('Tasks').filter('taskAtDay', function() { - return function(tasks, date) { - var diff, due, ret, start, task, _i, _len; - ret = []; - for (_i = 0, _len = tasks.length; _i < _len; _i++) { - task = tasks[_i]; - start = moment(task.start, "YYYYMMDDTHHmmss"); - if (start.isValid()) { - diff = start.diff(moment().startOf('day'), 'days', true); - if (!date && diff < date + 1) { - ret.push(task); - continue; - } else if (diff < date + 1 && diff >= date) { - ret.push(task); - continue; - } - } - due = moment(task.due, "YYYYMMDDTHHmmss"); - if (due.isValid()) { - diff = due.diff(moment().startOf('day'), 'days', true); - if (!date && diff < date + 1) { - ret.push(task); - continue; - } else if (diff < date + 1 && diff >= date) { - ret.push(task); - continue; - } - } - } - return ret; - }; - }); - -}).call(this); - (function() { angular.module('Tasks').filter('timeTaskList', function() { return function(due) { diff --git a/templates/part.collectionweek.php b/templates/part.collectionweek.php index cdbb6ad9..74920fc5 100644 --- a/templates/part.collectionweek.php +++ b/templates/part.collectionweek.php @@ -4,7 +4,7 @@ {{ day | day }}
    -