Correctly show tasks in collection views
This commit is contained in:
parent
2bff5aa24f
commit
3345319d5a
5 changed files with 21 additions and 74 deletions
|
@ -143,7 +143,10 @@ CollectionsModel, ListsBusinessLayer, $location) ->
|
||||||
return (@getCollectionCount(collectionID) < 1)
|
return (@getCollectionCount(collectionID) < 1)
|
||||||
|
|
||||||
@_$scope.getCollectionString = (collectionID) ->
|
@_$scope.getCollectionString = (collectionID) ->
|
||||||
return _$collectionsmodel.getCountString(collectionID)
|
if collectionID != 'completed'
|
||||||
|
return _$collectionsmodel.getCount(collectionID)
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
|
||||||
@_$scope.getListCount = (listID,type) ->
|
@_$scope.getListCount = (listID,type) ->
|
||||||
return _$listsmodel.getCount(listID,type)
|
return _$listsmodel.getCount(listID,type)
|
||||||
|
|
|
@ -125,7 +125,6 @@ SettingsBusinessLayer) ->
|
||||||
ret.push(task)
|
ret.push(task)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@_$scope.filterTasksByCalendar = (task, listID) ->
|
@_$scope.filterTasksByCalendar = (task, listID) ->
|
||||||
return (task) ->
|
return (task) ->
|
||||||
return ''+task.calendarid == ''+listID
|
return ''+task.calendarid == ''+listID
|
||||||
|
|
|
@ -42,11 +42,5 @@ angular.module('Tasks').factory 'CollectionsModel',
|
||||||
count += @_$tasksmodel.filterTasks(task, collectionID)
|
count += @_$tasksmodel.filterTasks(task, collectionID)
|
||||||
return count
|
return count
|
||||||
|
|
||||||
getCountString: (collectionID) ->
|
|
||||||
if collectionID != 'completed'
|
|
||||||
return @getCount(collectionID)
|
|
||||||
else
|
|
||||||
return ''
|
|
||||||
|
|
||||||
return new CollectionsModel(TasksModel)
|
return new CollectionsModel(TasksModel)
|
||||||
]
|
]
|
|
@ -93,31 +93,13 @@ angular.module('Tasks').factory 'ListsModel',
|
||||||
ret = false
|
ret = false
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
getCount: (listID,type) ->
|
getCount: (listID,collectionID) ->
|
||||||
count = 0
|
count = 0
|
||||||
tasks = @_$tasksmodel.getAll()
|
tasks = @_$tasksmodel.getAll()
|
||||||
switch type
|
|
||||||
when 'all'
|
|
||||||
for task in tasks
|
for task in tasks
|
||||||
count += (task.calendarid==listID && !task.completed)
|
count += (@_$tasksmodel.filterTasks(task, collectionID) &&
|
||||||
return count
|
task.calendarid == listID)
|
||||||
when 'current'
|
|
||||||
for task in tasks
|
|
||||||
count += (task.calendarid==listID && !task.completed &&
|
|
||||||
@_$tasksmodel.current(task.start))
|
|
||||||
return count
|
|
||||||
when 'completed'
|
|
||||||
for task in tasks
|
|
||||||
count += (task.calendarid==listID && task.completed)
|
|
||||||
return count + @notLoaded(listID)
|
|
||||||
when 'starred'
|
|
||||||
for task in tasks
|
|
||||||
count += (task.calendarid==listID && !task.completed && task.starred)
|
|
||||||
return count
|
|
||||||
when 'today'
|
|
||||||
for task in tasks
|
|
||||||
count += (task.calendarid==listID && !task.completed &&
|
|
||||||
@_$tasksmodel.today(task.due))
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
notLoaded: (listID) ->
|
notLoaded: (listID) ->
|
||||||
|
|
|
@ -937,7 +937,11 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this._$scope.getCollectionString = function(collectionID) {
|
this._$scope.getCollectionString = function(collectionID) {
|
||||||
return _$collectionsmodel.getCountString(collectionID);
|
if (collectionID !== 'completed') {
|
||||||
|
return _$collectionsmodel.getCount(collectionID);
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this._$scope.getListCount = function(listID, type) {
|
this._$scope.getListCount = function(listID, type) {
|
||||||
return _$listsmodel.getCount(listID, type);
|
return _$listsmodel.getCount(listID, type);
|
||||||
|
@ -1869,14 +1873,6 @@
|
||||||
return count;
|
return count;
|
||||||
};
|
};
|
||||||
|
|
||||||
CollectionsModel.prototype.getCountString = function(collectionID) {
|
|
||||||
if (collectionID !== 'completed') {
|
|
||||||
return this.getCount(collectionID);
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return CollectionsModel;
|
return CollectionsModel;
|
||||||
|
|
||||||
})(_Model);
|
})(_Model);
|
||||||
|
@ -1997,42 +1993,15 @@
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
ListsModel.prototype.getCount = function(listID, type) {
|
ListsModel.prototype.getCount = function(listID, collectionID) {
|
||||||
var count, task, tasks, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m;
|
var count, task, tasks, _i, _len;
|
||||||
count = 0;
|
count = 0;
|
||||||
tasks = this._$tasksmodel.getAll();
|
tasks = this._$tasksmodel.getAll();
|
||||||
switch (type) {
|
|
||||||
case 'all':
|
|
||||||
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
|
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
|
||||||
task = tasks[_i];
|
task = tasks[_i];
|
||||||
count += task.calendarid === listID && !task.completed;
|
count += this._$tasksmodel.filterTasks(task, collectionID) && task.calendarid === listID;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
case 'current':
|
|
||||||
for (_j = 0, _len1 = tasks.length; _j < _len1; _j++) {
|
|
||||||
task = tasks[_j];
|
|
||||||
count += task.calendarid === listID && !task.completed && this._$tasksmodel.current(task.start);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
case 'completed':
|
|
||||||
for (_k = 0, _len2 = tasks.length; _k < _len2; _k++) {
|
|
||||||
task = tasks[_k];
|
|
||||||
count += task.calendarid === listID && task.completed;
|
|
||||||
}
|
|
||||||
return count + this.notLoaded(listID);
|
|
||||||
case 'starred':
|
|
||||||
for (_l = 0, _len3 = tasks.length; _l < _len3; _l++) {
|
|
||||||
task = tasks[_l];
|
|
||||||
count += task.calendarid === listID && !task.completed && task.starred;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
case 'today':
|
|
||||||
for (_m = 0, _len4 = tasks.length; _m < _len4; _m++) {
|
|
||||||
task = tasks[_m];
|
|
||||||
count += task.calendarid === listID && !task.completed && this._$tasksmodel.today(task.due);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ListsModel.prototype.notLoaded = function(listID) {
|
ListsModel.prototype.notLoaded = function(listID) {
|
||||||
|
|
Loading…
Reference in a new issue