Correctly show subtasks, toggle their visibility
This commit is contained in:
parent
cad16a9208
commit
d7116f5f98
6 changed files with 286 additions and 289 deletions
|
@ -49,16 +49,12 @@
|
|||
this._$scope.TasksBusinessLayer = this._tasksbusinesslayer;
|
||||
|
||||
this._$scope.addTask = function(taskName, related, calendar) {
|
||||
var task;
|
||||
var task, _ref,
|
||||
_this = this;
|
||||
var _ref, _this = this;
|
||||
if (calendar == null) {
|
||||
calendar = '';
|
||||
}
|
||||
_$scope.isAddingTask = true;
|
||||
task = {
|
||||
// tmpID: 'newTask' + Date.now(),
|
||||
// id: 'newTask' + Date.now(),
|
||||
var task = {
|
||||
calendar: null,
|
||||
related: related,
|
||||
summary: taskName,
|
||||
|
@ -90,7 +86,6 @@
|
|||
task.calendar = _$listsmodel.getByUri(_$scope.route.calendarID);
|
||||
}
|
||||
task = VTodo.create(task);
|
||||
// console.log(task);
|
||||
_tasksbusinesslayer.add(task).then(function(task) {
|
||||
_$scope.isAddingTask = false;
|
||||
return $scope.$apply();
|
||||
|
@ -103,8 +98,8 @@
|
|||
};
|
||||
|
||||
this._$scope.getAddString = function() {
|
||||
var calendar;
|
||||
if (angular.isDefined(calendar = _$listsmodel.getStandardList())) {
|
||||
var calendar = _$listsmodel.getStandardList();
|
||||
if (angular.isDefined(calendar)) {
|
||||
if (angular.isDefined(_$scope.route.collectionID)) {
|
||||
switch (_$scope.route.collectionID) {
|
||||
case 'starred':
|
||||
|
@ -126,22 +121,25 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
this._$scope.getSubAddString = function(taskname) {
|
||||
return t('tasks', 'Add a subtask to "%s"...').replace('%s', taskname);
|
||||
};
|
||||
|
||||
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;
|
||||
// }
|
||||
var taskID = _$scope.route.taskID;
|
||||
var descendantIDs = _$tasksmodel.getDescendantIDs(task);
|
||||
if (task.uri === taskID) {
|
||||
return false;
|
||||
} else if (__indexOf.call(descendantIDs, taskID) >= 0) {
|
||||
return false;
|
||||
} else {
|
||||
return task.hideSubtasks;
|
||||
}
|
||||
};
|
||||
this._$scope.showInput = function() {
|
||||
var _ref;
|
||||
|
@ -189,11 +187,13 @@
|
|||
this._$scope.toggleHidden = function() {
|
||||
return _settingsbusinesslayer.toggle('various', 'showHidden');
|
||||
};
|
||||
|
||||
this._$scope.filterTasks = function(task, filter) {
|
||||
return function(task) {
|
||||
return _$tasksmodel.filterTasks(task, filter);
|
||||
};
|
||||
};
|
||||
|
||||
this._$scope.getSubTasks = function(tasks, parent) {
|
||||
var ret, task, _i, _len;
|
||||
ret = [];
|
||||
|
@ -215,17 +215,14 @@
|
|||
this._$scope.hasSubtasks = function(task) {
|
||||
return _$tasksmodel.hasSubtasks(task.uid);
|
||||
};
|
||||
this._$scope.toggleSubtasks = function(taskID) {
|
||||
if (_$tasksmodel.hideSubtasks(taskID)) {
|
||||
return _tasksbusinesslayer.unhideSubtasks(taskID);
|
||||
} else {
|
||||
return _tasksbusinesslayer.hideSubtasks(taskID);
|
||||
}
|
||||
|
||||
this._$scope.toggleSubtasks = function(task) {
|
||||
_tasksbusinesslayer.setHideSubtasks(task, !task.hideSubtasks);
|
||||
};
|
||||
|
||||
this._$scope.filterTasksByString = function(task) {
|
||||
return function(task) {
|
||||
var filter;
|
||||
filter = _searchbusinesslayer.getFilter();
|
||||
var filter = _searchbusinesslayer.getFilter();
|
||||
return _$tasksmodel.filterTasksByString(task, filter);
|
||||
};
|
||||
};
|
||||
|
@ -294,9 +291,6 @@
|
|||
return task.due;
|
||||
}
|
||||
};
|
||||
this._$scope.getTaskColor = function(listID) {
|
||||
return _$listsmodel.getColor(listID);
|
||||
};
|
||||
this._$scope.getTaskList = function(listID) {
|
||||
return _$listsmodel.getName(listID);
|
||||
};
|
||||
|
|
|
@ -105,14 +105,10 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
|
|||
}
|
||||
};
|
||||
|
||||
TasksBusinessLayer.prototype.unhideSubtasks = function(taskID) {
|
||||
this._$tasksmodel.setHideSubtasks(taskID, false);
|
||||
return this._persistence.setHideSubtasks(taskID, false);
|
||||
};
|
||||
|
||||
TasksBusinessLayer.prototype.hideSubtasks = function(taskID) {
|
||||
this._$tasksmodel.setHideSubtasks(taskID, true);
|
||||
return this._persistence.setHideSubtasks(taskID, true);
|
||||
TasksBusinessLayer.prototype.setHideSubtasks = function(task, hide) {
|
||||
task.hideSubtasks = hide;
|
||||
this._$vtodoservice.update(task).then(function(task) {
|
||||
});
|
||||
};
|
||||
|
||||
TasksBusinessLayer.prototype.deleteTask = function(taskID) {
|
||||
|
|
|
@ -231,30 +231,29 @@
|
|||
return false;
|
||||
};
|
||||
|
||||
TasksModel.prototype.getChildrenID = function(taskID) {
|
||||
var childrenID, t, task, tasks, _i, _len;
|
||||
task = this.getById(taskID);
|
||||
TasksModel.prototype.getChildren = function(task) {
|
||||
var children, t, tasks, _i, _len;
|
||||
tasks = this.getAll();
|
||||
childrenID = [];
|
||||
children = [];
|
||||
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
|
||||
t = tasks[_i];
|
||||
if (t.related === task.uid) {
|
||||
childrenID.push(t.id);
|
||||
children.push(t);
|
||||
}
|
||||
}
|
||||
return childrenID;
|
||||
return children;
|
||||
};
|
||||
|
||||
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));
|
||||
TasksModel.prototype.getDescendantIDs = function(task) {
|
||||
var child, children, descendantIDs, _i, _len;
|
||||
children = this.getChildren(task);
|
||||
descendantIDs = [];
|
||||
for (_i = 0, _len = children.length; _i < _len; _i++) {
|
||||
child = children[_i];
|
||||
descendantIDs = descendantIDs.concat(child.uri);
|
||||
descendantIDs = descendantIDs.concat(this.getDescendantIDs(child));
|
||||
}
|
||||
return descendantID;
|
||||
return descendantIDs;
|
||||
};
|
||||
|
||||
TasksModel.prototype.filterTasks = function(task, filter) {
|
||||
|
|
|
@ -442,6 +442,15 @@ angular.module('Tasks').factory('VTodo', ['$filter', 'ICalFactory', 'RandomStrin
|
|||
var vtodos = this.components.getAllSubcomponents('vtodo');
|
||||
return vtodos[0].getFirstPropertyValue('related-to') || null;
|
||||
},
|
||||
get hideSubtasks() {
|
||||
var vtodos = this.components.getAllSubcomponents('vtodo');
|
||||
return +vtodos[0].getFirstPropertyValue('x-oc-hidesubtasks') || 0;
|
||||
},
|
||||
set hideSubtasks(hide) {
|
||||
var vtodos = this.components.getAllSubcomponents('vtodo');
|
||||
vtodos[0].updatePropertyWithValue('x-oc-hidesubtasks', +hide);
|
||||
this.data = this.components.toString();
|
||||
},
|
||||
get reminder() {
|
||||
return null;
|
||||
},
|
||||
|
|
102
js/public/app.js
102
js/public/app.js
|
@ -855,16 +855,12 @@ angular.module('Tasks').controller('ListController', [
|
|||
this._$scope.TasksBusinessLayer = this._tasksbusinesslayer;
|
||||
|
||||
this._$scope.addTask = function(taskName, related, calendar) {
|
||||
var task;
|
||||
var task, _ref,
|
||||
_this = this;
|
||||
var _ref, _this = this;
|
||||
if (calendar == null) {
|
||||
calendar = '';
|
||||
}
|
||||
_$scope.isAddingTask = true;
|
||||
task = {
|
||||
// tmpID: 'newTask' + Date.now(),
|
||||
// id: 'newTask' + Date.now(),
|
||||
var task = {
|
||||
calendar: null,
|
||||
related: related,
|
||||
summary: taskName,
|
||||
|
@ -896,7 +892,6 @@ angular.module('Tasks').controller('ListController', [
|
|||
task.calendar = _$listsmodel.getByUri(_$scope.route.calendarID);
|
||||
}
|
||||
task = VTodo.create(task);
|
||||
// console.log(task);
|
||||
_tasksbusinesslayer.add(task).then(function(task) {
|
||||
_$scope.isAddingTask = false;
|
||||
return $scope.$apply();
|
||||
|
@ -909,8 +904,8 @@ angular.module('Tasks').controller('ListController', [
|
|||
};
|
||||
|
||||
this._$scope.getAddString = function() {
|
||||
var calendar;
|
||||
if (angular.isDefined(calendar = _$listsmodel.getStandardList())) {
|
||||
var calendar = _$listsmodel.getStandardList();
|
||||
if (angular.isDefined(calendar)) {
|
||||
if (angular.isDefined(_$scope.route.collectionID)) {
|
||||
switch (_$scope.route.collectionID) {
|
||||
case 'starred':
|
||||
|
@ -932,22 +927,25 @@ angular.module('Tasks').controller('ListController', [
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
this._$scope.getSubAddString = function(taskname) {
|
||||
return t('tasks', 'Add a subtask to "%s"...').replace('%s', taskname);
|
||||
};
|
||||
|
||||
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;
|
||||
// }
|
||||
var taskID = _$scope.route.taskID;
|
||||
var descendantIDs = _$tasksmodel.getDescendantIDs(task);
|
||||
if (task.uri === taskID) {
|
||||
return false;
|
||||
} else if (__indexOf.call(descendantIDs, taskID) >= 0) {
|
||||
return false;
|
||||
} else {
|
||||
return task.hideSubtasks;
|
||||
}
|
||||
};
|
||||
this._$scope.showInput = function() {
|
||||
var _ref;
|
||||
|
@ -995,11 +993,13 @@ angular.module('Tasks').controller('ListController', [
|
|||
this._$scope.toggleHidden = function() {
|
||||
return _settingsbusinesslayer.toggle('various', 'showHidden');
|
||||
};
|
||||
|
||||
this._$scope.filterTasks = function(task, filter) {
|
||||
return function(task) {
|
||||
return _$tasksmodel.filterTasks(task, filter);
|
||||
};
|
||||
};
|
||||
|
||||
this._$scope.getSubTasks = function(tasks, parent) {
|
||||
var ret, task, _i, _len;
|
||||
ret = [];
|
||||
|
@ -1021,17 +1021,14 @@ angular.module('Tasks').controller('ListController', [
|
|||
this._$scope.hasSubtasks = function(task) {
|
||||
return _$tasksmodel.hasSubtasks(task.uid);
|
||||
};
|
||||
this._$scope.toggleSubtasks = function(taskID) {
|
||||
if (_$tasksmodel.hideSubtasks(taskID)) {
|
||||
return _tasksbusinesslayer.unhideSubtasks(taskID);
|
||||
} else {
|
||||
return _tasksbusinesslayer.hideSubtasks(taskID);
|
||||
}
|
||||
|
||||
this._$scope.toggleSubtasks = function(task) {
|
||||
_tasksbusinesslayer.setHideSubtasks(task, !task.hideSubtasks);
|
||||
};
|
||||
|
||||
this._$scope.filterTasksByString = function(task) {
|
||||
return function(task) {
|
||||
var filter;
|
||||
filter = _searchbusinesslayer.getFilter();
|
||||
var filter = _searchbusinesslayer.getFilter();
|
||||
return _$tasksmodel.filterTasksByString(task, filter);
|
||||
};
|
||||
};
|
||||
|
@ -1100,9 +1097,6 @@ angular.module('Tasks').controller('ListController', [
|
|||
return task.due;
|
||||
}
|
||||
};
|
||||
this._$scope.getTaskColor = function(listID) {
|
||||
return _$listsmodel.getColor(listID);
|
||||
};
|
||||
this._$scope.getTaskList = function(listID) {
|
||||
return _$listsmodel.getName(listID);
|
||||
};
|
||||
|
@ -1710,14 +1704,10 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
|
|||
}
|
||||
};
|
||||
|
||||
TasksBusinessLayer.prototype.unhideSubtasks = function(taskID) {
|
||||
this._$tasksmodel.setHideSubtasks(taskID, false);
|
||||
return this._persistence.setHideSubtasks(taskID, false);
|
||||
};
|
||||
|
||||
TasksBusinessLayer.prototype.hideSubtasks = function(taskID) {
|
||||
this._$tasksmodel.setHideSubtasks(taskID, true);
|
||||
return this._persistence.setHideSubtasks(taskID, true);
|
||||
TasksBusinessLayer.prototype.setHideSubtasks = function(task, hide) {
|
||||
task.hideSubtasks = hide;
|
||||
this._$vtodoservice.update(task).then(function(task) {
|
||||
});
|
||||
};
|
||||
|
||||
TasksBusinessLayer.prototype.deleteTask = function(taskID) {
|
||||
|
@ -3483,30 +3473,29 @@ angular.module('Tasks').factory('Calendar', ['$rootScope', '$filter', function($
|
|||
return false;
|
||||
};
|
||||
|
||||
TasksModel.prototype.getChildrenID = function(taskID) {
|
||||
var childrenID, t, task, tasks, _i, _len;
|
||||
task = this.getById(taskID);
|
||||
TasksModel.prototype.getChildren = function(task) {
|
||||
var children, t, tasks, _i, _len;
|
||||
tasks = this.getAll();
|
||||
childrenID = [];
|
||||
children = [];
|
||||
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
|
||||
t = tasks[_i];
|
||||
if (t.related === task.uid) {
|
||||
childrenID.push(t.id);
|
||||
children.push(t);
|
||||
}
|
||||
}
|
||||
return childrenID;
|
||||
return children;
|
||||
};
|
||||
|
||||
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));
|
||||
TasksModel.prototype.getDescendantIDs = function(task) {
|
||||
var child, children, descendantIDs, _i, _len;
|
||||
children = this.getChildren(task);
|
||||
descendantIDs = [];
|
||||
for (_i = 0, _len = children.length; _i < _len; _i++) {
|
||||
child = children[_i];
|
||||
descendantIDs = descendantIDs.concat(child.uri);
|
||||
descendantIDs = descendantIDs.concat(this.getDescendantIDs(child));
|
||||
}
|
||||
return descendantID;
|
||||
return descendantIDs;
|
||||
};
|
||||
|
||||
TasksModel.prototype.filterTasks = function(task, filter) {
|
||||
|
@ -4163,6 +4152,15 @@ angular.module('Tasks').factory('VTodo', ['$filter', 'ICalFactory', 'RandomStrin
|
|||
var vtodos = this.components.getAllSubcomponents('vtodo');
|
||||
return vtodos[0].getFirstPropertyValue('related-to') || null;
|
||||
},
|
||||
get hideSubtasks() {
|
||||
var vtodos = this.components.getAllSubcomponents('vtodo');
|
||||
return +vtodos[0].getFirstPropertyValue('x-oc-hidesubtasks') || 0;
|
||||
},
|
||||
set hideSubtasks(hide) {
|
||||
var vtodos = this.components.getAllSubcomponents('vtodo');
|
||||
vtodos[0].updatePropertyWithValue('x-oc-hidesubtasks', +hide);
|
||||
this.data = this.components.toString();
|
||||
},
|
||||
get reminder() {
|
||||
return null;
|
||||
},
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="task-body"
|
||||
type="task"
|
||||
taskID="{{ task.uri }}"
|
||||
ng-class="{active: route.taskID==task.uri, subtasks: hasSubtasks(task), subtaskshidden: task.hidesubtasks, attachment: task.note!=''}">
|
||||
<div class="percentdone" style="width:{{ task.complete }}%; background-color:{{ getTaskColor(task.calendarid) }};"></div>
|
||||
ng-class="{active: route.taskID==task.uri, subtasks: hasSubtasks(task), subtaskshidden: task.hideSubtasks, attachment: task.note!=''}">
|
||||
<div class="percentdone" style="width:{{ task.complete }}%; background-color:{{ task.calendar.color }};"></div>
|
||||
<a class="task-checkbox handler" name="toggleCompleted" ng-click="toggleCompleted(task)">
|
||||
<span class="icon task-checkbox" ng-class="{'task-checked': task.completed}"></span>
|
||||
</a>
|
||||
|
@ -13,7 +13,7 @@
|
|||
<a class="task-addsubtask handler add-subtask" ng-click="showSubtaskInput(task.uid)" oc-click-focus="{selector: '.add-subtask input', timeout: 0}">
|
||||
<span class="icon large addsubtask" title="<?php p($l->t('add a subtask to')); ?> {{ task.summary }}"></span>
|
||||
</a>
|
||||
<a class="handler" ng-click="toggleSubtasks(task.uri)">
|
||||
<a class="handler" ng-click="toggleSubtasks(task)">
|
||||
<span class="icon large subtasks"></span>
|
||||
</a>
|
||||
<a>
|
||||
|
@ -46,13 +46,14 @@
|
|||
ng-keydown="checkTaskInput($event)"/>
|
||||
</form>
|
||||
</li>
|
||||
<!-- <li taskID="{{ task.uri }}"
|
||||
<li taskID="{{ task.uri }}"
|
||||
class="task-item ui-draggable handler subtask"
|
||||
ng-repeat="task in getSubTasks(filtered,task) | orderBy:'1*id':true | orderBy:'priority':true | orderBy:'completed':false"
|
||||
ng-click="openDetails(task.uri,$event)"
|
||||
ng-class="{done: task.completed}"
|
||||
ng-include="'part.taskbody'"
|
||||
dnd-draggable="task"
|
||||
dnd-effect-allowed="move"></li> -->
|
||||
dnd-effect-allowed="move">
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue