diff --git a/js/app/controllers/taskscontroller.coffee b/js/app/controllers/taskscontroller.coffee index b1740376..d8c3947f 100644 --- a/js/app/controllers/taskscontroller.coffee +++ b/js/app/controllers/taskscontroller.coffee @@ -79,6 +79,15 @@ SettingsBusinessLayer, SearchBusinessLayer) -> @_$scope.showSubtaskInput = (uid) -> _$scope.status.addSubtaskTo = uid + @_$scope.hideSubtasks = (task) -> + descendants = _$tasksmodel.getDescendantID(task.id) + if task.id == _$scope.route.taskID + return false + else if _$scope.route.taskID in descendants + return false + else + return task.hidesubtasks + @_$scope.showInput = () -> if _$scope.route.listID in ['completed', 'week'] return false diff --git a/js/app/services/models/tasksmodel.coffee b/js/app/services/models/tasksmodel.coffee index 97ebe91f..1d2b2e6e 100644 --- a/js/app/services/models/tasksmodel.coffee +++ b/js/app/services/models/tasksmodel.coffee @@ -149,6 +149,14 @@ angular.module('Tasks').factory 'TasksModel', childrenID.push t.id return childrenID + getDescendantID: (taskID) -> + childrenID = @getChildrenID(taskID) + descendantID = [] + descendantID = descendantID.concat childrenID + for childID in childrenID + descendantID = descendantID.concat @getDescendantID(childID) + return descendantID + filterTasks: (task, filter) -> switch filter when 'completed' diff --git a/js/public/app.js b/js/public/app.js index d460df3a..44bfec22 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -987,6 +987,8 @@ }).call(this); (function() { + var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + angular.module('Tasks').controller('TasksController', [ '$scope', '$window', '$routeParams', 'TasksModel', 'ListsModel', 'CollectionsModel', 'TasksBusinessLayer', '$location', 'SettingsBusinessLayer', 'SearchBusinessLayer', function($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location, SettingsBusinessLayer, SearchBusinessLayer) { var TasksController; @@ -1039,6 +1041,17 @@ this._$scope.showSubtaskInput = function(uid) { return _$scope.status.addSubtaskTo = uid; }; + this._$scope.hideSubtasks = function(task) { + var descendants, _ref; + descendants = _$tasksmodel.getDescendantID(task.id); + if (task.id === _$scope.route.taskID) { + return false; + } else if (_ref = _$scope.route.taskID, __indexOf.call(descendants, _ref) >= 0) { + return false; + } else { + return task.hidesubtasks; + } + }; this._$scope.showInput = function() { var _ref; if ((_ref = _$scope.route.listID) === 'completed' || _ref === 'week') { @@ -2626,6 +2639,18 @@ return childrenID; }; + TasksModel.prototype.getDescendantID = function(taskID) { + var childID, childrenID, descendantID, _i, _len; + childrenID = this.getChildrenID(taskID); + descendantID = []; + descendantID = descendantID.concat(childrenID); + for (_i = 0, _len = childrenID.length; _i < _len; _i++) { + childID = childrenID[_i]; + descendantID = descendantID.concat(this.getDescendantID(childID)); + } + return descendantID; + }; + TasksModel.prototype.filterTasks = function(task, filter) { switch (filter) { case 'completed': diff --git a/templates/part.taskbody.php b/templates/part.taskbody.php index 4e2ab985..cb1c9357 100644 --- a/templates/part.taskbody.php +++ b/templates/part.taskbody.php @@ -31,7 +31,7 @@