Filter tasks by global search
This commit is contained in:
parent
d635283635
commit
6a82d7761f
18 changed files with 247 additions and 274 deletions
|
@ -342,6 +342,7 @@
|
|||
cursor: pointer;
|
||||
padding: 8px;
|
||||
display: block;
|
||||
width: 20px;
|
||||
}
|
||||
#app-navigation div.header #loading span {
|
||||
height: 20px;
|
||||
|
|
|
@ -363,6 +363,7 @@
|
|||
cursor:pointer;
|
||||
padding: 8px;
|
||||
display:block;
|
||||
width: 20px;
|
||||
span{
|
||||
height:20px;
|
||||
width:20px;
|
||||
|
|
|
@ -64,8 +64,9 @@ angular.module('Tasks',['OC','ngRoute','ngAnimate','ui.bootstrap'])
|
|||
]
|
||||
|
||||
angular.module('Tasks').run ['Config', '$timeout',
|
||||
'ListsBusinessLayer', 'TasksBusinessLayer',
|
||||
(Config, $timeout,TasksBusinessLayer, ListsBusinessLayer) ->
|
||||
'ListsBusinessLayer', 'TasksBusinessLayer', 'SearchBusinessLayer'
|
||||
(Config, $timeout,TasksBusinessLayer, ListsBusinessLayer,
|
||||
SearchBusinessLayer) ->
|
||||
|
||||
init = false
|
||||
do update = ->
|
||||
|
@ -78,6 +79,8 @@ angular.module('Tasks').run ['Config', '$timeout',
|
|||
init = true
|
||||
timeOutUpdate()
|
||||
|
||||
OCA.Search.tasks = SearchBusinessLayer
|
||||
|
||||
moment.lang('details', {
|
||||
calendar: {
|
||||
lastDay : '['+t('tasks','Due yesterday')+'], HH:mm'
|
||||
|
|
|
@ -49,10 +49,7 @@ $routeParams, Loading, $modal, SettingsModel) ->
|
|||
@_persistence.init().then(successCallback)
|
||||
|
||||
@_$scope.closeAll = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString)
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID)
|
||||
_$location.path('/lists/'+_$scope.route.listID)
|
||||
|
||||
_$scope.status.addingList = false
|
||||
_$scope.status.focusTaskInput = false
|
||||
|
|
|
@ -123,10 +123,7 @@ $timeout, $routeParams, SettingsModel, Loading) ->
|
|||
return params.slice(2)
|
||||
|
||||
@_$scope.closeDetails = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString)
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID)
|
||||
_$location.path('/lists/'+_$scope.route.listID)
|
||||
|
||||
@_$scope.deleteTask = (taskID) ->
|
||||
_$scope.closeDetails()
|
||||
|
@ -135,62 +132,34 @@ $timeout, $routeParams, SettingsModel, Loading) ->
|
|||
,500)
|
||||
|
||||
@_$scope.editName = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/name')
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/name')
|
||||
|
||||
@_$scope.editDueDate = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/duedate')
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/duedate')
|
||||
_tasksbusinesslayer.initDueDate(_$scope.route.taskID)
|
||||
|
||||
@_$scope.editStart = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/startdate')
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/startdate')
|
||||
_tasksbusinesslayer.initStartDate(_$scope.route.taskID)
|
||||
|
||||
@_$scope.editReminder = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/reminder')
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/reminder')
|
||||
_tasksbusinesslayer.initReminder(_$scope.route.taskID)
|
||||
|
||||
@_$scope.editNote = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/note')
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/note')
|
||||
|
||||
@_$scope.editPercent = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/percent')
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
'/tasks/' + _$scope.route.taskID + '/edit/percent')
|
||||
|
||||
@_$scope.endEdit = () ->
|
||||
if _$scope.status.searchActive
|
||||
_$location.path('/search/'+_$scope.route.searchString +
|
||||
'/tasks/' + _$scope.route.taskID)
|
||||
else
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
_$location.path('/lists/'+_$scope.route.listID +
|
||||
'/tasks/' + _$scope.route.taskID)
|
||||
|
||||
@_$scope.endName = (event) ->
|
||||
|
|
|
@ -1,58 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
###
|
||||
angular.module('Tasks').controller 'SearchController',
|
||||
['$scope', '$window', 'Status', '$location',
|
||||
($scope, $window, Status, $location) ->
|
||||
|
||||
class SearchController
|
||||
|
||||
constructor: (@_$scope, @_$window, @_$status,
|
||||
@_$location) ->
|
||||
@_$scope.searchString = ''
|
||||
@_$scope.searchBuffer = '/lists/all'
|
||||
|
||||
@_$scope.status = @_$status.getStatus()
|
||||
|
||||
@_$scope.$on('$routeChangeSuccess', () ->
|
||||
if _$scope.route.searchString != undefined
|
||||
_$scope.status.searchActive = true
|
||||
)
|
||||
|
||||
@_$scope.openSearch = () =>
|
||||
_$scope.searchBuffer = _$location.path()
|
||||
_$location.path('/search/')
|
||||
_$scope.status.searchActive = true
|
||||
|
||||
@_$scope.closeSearch = () =>
|
||||
_$scope.searchString = ''
|
||||
_$location.path(_$scope.searchBuffer)
|
||||
_$scope.status.searchActive = false
|
||||
|
||||
@_$scope.trySearch = (event) =>
|
||||
if (event.keyCode == 27)
|
||||
_$scope.closeSearch()
|
||||
else
|
||||
_$location.path('/search/'+_$scope.searchString)
|
||||
|
||||
|
||||
return new SearchController($scope, $window, Status, $location)
|
||||
]
|
|
@ -22,16 +22,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
angular.module('Tasks').controller 'TasksController',
|
||||
['$scope', '$window', '$routeParams', 'TasksModel', 'ListsModel',
|
||||
'CollectionsModel', 'TasksBusinessLayer', '$location',
|
||||
'SettingsBusinessLayer',
|
||||
'SettingsBusinessLayer', 'SearchBusinessLayer'
|
||||
($scope, $window, $routeParams, TasksModel, ListsModel,
|
||||
CollectionsModel, TasksBusinessLayer, $location,
|
||||
SettingsBusinessLayer) ->
|
||||
SettingsBusinessLayer, SearchBusinessLayer) ->
|
||||
|
||||
class TasksController
|
||||
|
||||
constructor: (@_$scope,@_$window,@_$routeParams,
|
||||
@_$tasksmodel,@_$listsmodel,@_$collectionsmodel,
|
||||
@_tasksbusinesslayer, @$location, @_settingsbusinesslayer) ->
|
||||
@_tasksbusinesslayer, @$location, @_settingsbusinesslayer,
|
||||
@_searchbusinesslayer) ->
|
||||
|
||||
@_$scope.tasks = @_$tasksmodel.getAll()
|
||||
@_$scope.lists = @_$listsmodel.getAll()
|
||||
|
@ -71,22 +72,36 @@ SettingsBusinessLayer) ->
|
|||
_$listsmodel.getById(_$scope.route.listID).displayname)
|
||||
|
||||
@_$scope.showInput = () ->
|
||||
if _$scope.route.listID in ['completed', 'week'] ||
|
||||
_$scope.status.searchActive
|
||||
if _$scope.route.listID in ['completed', 'week']
|
||||
return false
|
||||
else
|
||||
return true
|
||||
|
||||
@_$scope.filterByString = () =>
|
||||
return (task) ->
|
||||
keys = ['name', 'note', 'location',
|
||||
'categories', 'comments']
|
||||
filter = _searchbusinesslayer.getFilter().toLowerCase()
|
||||
for key,value of task
|
||||
if key in keys
|
||||
if key == 'comments'
|
||||
for comment in task.comments
|
||||
if comment.comment.indexOf(filter) !=-1
|
||||
return true
|
||||
else if key == 'categories'
|
||||
for category in task.categories
|
||||
if category.indexOf(filter) !=-1
|
||||
return true
|
||||
else if value.indexOf(filter) !=-1
|
||||
return true
|
||||
return false
|
||||
|
||||
@_$scope.focusInput = () ->
|
||||
_$scope.status.focusTaskInput = true
|
||||
|
||||
@_$scope.openDetails = (id) ->
|
||||
if _$scope.status.searchActive
|
||||
searchString = _$scope.route.searchString
|
||||
$location.path('/search/'+searchString+'/tasks/'+id)
|
||||
else
|
||||
listID = _$scope.route.listID
|
||||
$location.path('/lists/'+listID+'/tasks/'+id)
|
||||
listID = _$scope.route.listID
|
||||
$location.path('/lists/'+listID+'/tasks/'+id)
|
||||
|
||||
@_$scope.toggleCompleted = (taskID) ->
|
||||
if _$tasksmodel.completed(taskID)
|
||||
|
@ -127,26 +142,17 @@ SettingsBusinessLayer) ->
|
|||
|
||||
@_$scope.filterTasksByCalendar = (task, listID) ->
|
||||
return (task) ->
|
||||
if _$scope.status.searchActive
|
||||
return true
|
||||
else
|
||||
return ''+task.calendarid == ''+listID
|
||||
return ''+task.calendarid == ''+listID
|
||||
|
||||
@_$scope.filterLists = () ->
|
||||
return (list) ->
|
||||
return _$scope.getCount(list.id,_$scope.route.listID)
|
||||
|
||||
@_$scope.getCount = (listID,type) ->
|
||||
if _$scope.status.searchActive
|
||||
return true
|
||||
else
|
||||
return _$listsmodel.getCount(listID,type)
|
||||
return _$listsmodel.getCount(listID,type)
|
||||
|
||||
@_$scope.getCountString = (listID,type) ->
|
||||
if _$scope.status.searchActive
|
||||
return t('tasks', 'Completed Task')
|
||||
else
|
||||
return n('tasks', '%n Completed Task', '%n Completed Tasks',
|
||||
return n('tasks', '%n Completed Task', '%n Completed Tasks',
|
||||
_$listsmodel.getCount(listID,type))
|
||||
|
||||
@_$scope.addTask = (taskName) ->
|
||||
|
@ -212,5 +218,5 @@ SettingsBusinessLayer) ->
|
|||
|
||||
return new TasksController($scope, $window, $routeParams,
|
||||
TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location,
|
||||
SettingsBusinessLayer)
|
||||
SettingsBusinessLayer, SearchBusinessLayer)
|
||||
]
|
|
@ -1,9 +1,9 @@
|
|||
###
|
||||
|
||||
ownCloud - News
|
||||
ownCloud - Tasks
|
||||
|
||||
@author Bernhard Posselt
|
||||
@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
|
||||
@author Raimund Schlüßler
|
||||
@copyright 2015
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
|
72
js/app/services/businesslayer/searchbusinesslayer.coffee
Normal file
72
js/app/services/businesslayer/searchbusinesslayer.coffee
Normal file
|
@ -0,0 +1,72 @@
|
|||
###
|
||||
|
||||
ownCloud - Tasks
|
||||
|
||||
@author Raimund Schlüßler
|
||||
@copyright 2015
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
###
|
||||
|
||||
|
||||
angular.module('Tasks').factory 'SearchBusinessLayer',
|
||||
['ListsModel', 'Persistence', 'TasksModel', '$rootScope',
|
||||
(ListsModel, Persistence, TasksModel, $rootScope) ->
|
||||
|
||||
class SearchBusinessLayer
|
||||
|
||||
constructor: (@_$listsmodel, @_persistence,
|
||||
@_$tasksmodel, @_$rootScope) ->
|
||||
@initialize()
|
||||
@_$searchString = ''
|
||||
|
||||
attach: (search) =>
|
||||
search.setFilter('tasks', (query) =>
|
||||
@_$rootScope.$apply(
|
||||
@setFilter(query)
|
||||
)
|
||||
# if (self.fileAppLoaded())
|
||||
# self.fileList.setFilter(query)
|
||||
# if (query.length > 2)
|
||||
# # //search is not started until 500msec have passed
|
||||
# window.setTimeout(() =>
|
||||
# $('.nofilterresults').addClass('hidden')
|
||||
# , 500)
|
||||
)
|
||||
search.setRenderer('task', @renderTaskResult.bind(@))
|
||||
search.setHandler('task', @handleTaskClick.bind(@))
|
||||
|
||||
setFilter: (query) =>
|
||||
@_$searchString = query
|
||||
|
||||
getFilter: () =>
|
||||
return @_$searchString
|
||||
|
||||
initialize: () ->
|
||||
@handleTaskClick = ($row, result, event) =>
|
||||
console.log('Search result clicked')
|
||||
|
||||
@renderTaskResult = ($row, result) =>
|
||||
# console.log('Render result')
|
||||
# console.log($row)
|
||||
# console.log(result)
|
||||
return $row
|
||||
OC.Plugins.register('OCA.Search', @)
|
||||
|
||||
|
||||
return new SearchBusinessLayer(ListsModel, Persistence,
|
||||
TasksModel, $rootScope)
|
||||
|
||||
]
|
|
@ -1,9 +1,9 @@
|
|||
###
|
||||
|
||||
ownCloud - News
|
||||
ownCloud - Tasks
|
||||
|
||||
@author Bernhard Posselt
|
||||
@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
|
||||
@author Raimund Schlüßler
|
||||
@copyright 2015
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
###
|
||||
|
||||
ownCloud - News
|
||||
ownCloud - Tasks
|
||||
|
||||
@author Bernhard Posselt
|
||||
@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
|
||||
@author Raimund Schlüßler
|
||||
@copyright 2015
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
|
|
@ -192,7 +192,7 @@ angular.module('Tasks').factory 'Persistence',
|
|||
else
|
||||
successCallbackWrapper = () =>
|
||||
onSuccess()
|
||||
failureCallbackWrapper = () =>
|
||||
failureCallbackWrapper = () =>
|
||||
params =
|
||||
onSuccess: successCallbackWrapper
|
||||
onFailure: failureCallbackWrapper
|
||||
|
|
|
@ -26,7 +26,6 @@ angular.module('Tasks').factory 'Status',
|
|||
|
||||
constructor: () ->
|
||||
@_$status = {
|
||||
searchActive: false
|
||||
addingList: false
|
||||
focusTaskInput: false
|
||||
}
|
||||
|
|
234
js/public/app.js
234
js/public/app.js
|
@ -57,7 +57,7 @@
|
|||
]);
|
||||
|
||||
angular.module('Tasks').run([
|
||||
'Config', '$timeout', 'ListsBusinessLayer', 'TasksBusinessLayer', function(Config, $timeout, TasksBusinessLayer, ListsBusinessLayer) {
|
||||
'Config', '$timeout', 'ListsBusinessLayer', 'TasksBusinessLayer', 'SearchBusinessLayer', function(Config, $timeout, TasksBusinessLayer, ListsBusinessLayer, SearchBusinessLayer) {
|
||||
var init, update;
|
||||
init = false;
|
||||
(update = function() {
|
||||
|
@ -72,6 +72,7 @@
|
|||
init = true;
|
||||
return timeOutUpdate();
|
||||
})();
|
||||
OCA.Search.tasks = SearchBusinessLayer;
|
||||
moment.lang('details', {
|
||||
calendar: {
|
||||
lastDay: '[' + t('tasks', 'Due yesterday') + '], HH:mm',
|
||||
|
@ -461,11 +462,7 @@
|
|||
};
|
||||
this._persistence.init().then(successCallback);
|
||||
this._$scope.closeAll = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
_$location.path('/search/' + _$scope.route.searchString);
|
||||
} else {
|
||||
_$location.path('/lists/' + _$scope.route.listID);
|
||||
}
|
||||
_$location.path('/lists/' + _$scope.route.listID);
|
||||
_$scope.status.addingList = false;
|
||||
_$scope.status.focusTaskInput = false;
|
||||
return _$scope.status.newListName = "";
|
||||
|
@ -603,11 +600,7 @@
|
|||
}
|
||||
};
|
||||
this._$scope.closeDetails = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
return _$location.path('/search/' + _$scope.route.searchString);
|
||||
} else {
|
||||
return _$location.path('/lists/' + _$scope.route.listID);
|
||||
}
|
||||
return _$location.path('/lists/' + _$scope.route.listID);
|
||||
};
|
||||
this._$scope.deleteTask = function(taskID) {
|
||||
_$scope.closeDetails();
|
||||
|
@ -616,56 +609,28 @@
|
|||
}, 500);
|
||||
};
|
||||
this._$scope.editName = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
return _$location.path('/search/' + _$scope.route.searchString + '/tasks/' + _$scope.route.taskID + '/edit/name');
|
||||
} else {
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/name');
|
||||
}
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/name');
|
||||
};
|
||||
this._$scope.editDueDate = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
_$location.path('/search/' + _$scope.route.searchString + '/tasks/' + _$scope.route.taskID + '/edit/duedate');
|
||||
} else {
|
||||
_$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/duedate');
|
||||
}
|
||||
_$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/duedate');
|
||||
return _tasksbusinesslayer.initDueDate(_$scope.route.taskID);
|
||||
};
|
||||
this._$scope.editStart = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
_$location.path('/search/' + _$scope.route.searchString + '/tasks/' + _$scope.route.taskID + '/edit/startdate');
|
||||
} else {
|
||||
_$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/startdate');
|
||||
}
|
||||
_$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/startdate');
|
||||
return _tasksbusinesslayer.initStartDate(_$scope.route.taskID);
|
||||
};
|
||||
this._$scope.editReminder = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
_$location.path('/search/' + _$scope.route.searchString + '/tasks/' + _$scope.route.taskID + '/edit/reminder');
|
||||
} else {
|
||||
_$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/reminder');
|
||||
}
|
||||
_$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/reminder');
|
||||
return _tasksbusinesslayer.initReminder(_$scope.route.taskID);
|
||||
};
|
||||
this._$scope.editNote = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
return _$location.path('/search/' + _$scope.route.searchString + '/tasks/' + _$scope.route.taskID + '/edit/note');
|
||||
} else {
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/note');
|
||||
}
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/note');
|
||||
};
|
||||
this._$scope.editPercent = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
return _$location.path('/search/' + _$scope.route.searchString + '/tasks/' + _$scope.route.taskID + '/edit/percent');
|
||||
} else {
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/percent');
|
||||
}
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/percent');
|
||||
};
|
||||
this._$scope.endEdit = function() {
|
||||
if (_$scope.status.searchActive) {
|
||||
return _$location.path('/search/' + _$scope.route.searchString + '/tasks/' + _$scope.route.taskID);
|
||||
} else {
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID);
|
||||
}
|
||||
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID);
|
||||
};
|
||||
this._$scope.endName = function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
|
@ -995,53 +960,6 @@
|
|||
|
||||
}).call(this);
|
||||
|
||||
(function() {
|
||||
angular.module('Tasks').controller('SearchController', [
|
||||
'$scope', '$window', 'Status', '$location', function($scope, $window, Status, $location) {
|
||||
var SearchController;
|
||||
SearchController = (function() {
|
||||
function SearchController(_$scope, _$window, _$status, _$location) {
|
||||
var _this = this;
|
||||
this._$scope = _$scope;
|
||||
this._$window = _$window;
|
||||
this._$status = _$status;
|
||||
this._$location = _$location;
|
||||
this._$scope.searchString = '';
|
||||
this._$scope.searchBuffer = '/lists/all';
|
||||
this._$scope.status = this._$status.getStatus();
|
||||
this._$scope.$on('$routeChangeSuccess', function() {
|
||||
if (_$scope.route.searchString !== void 0) {
|
||||
return _$scope.status.searchActive = true;
|
||||
}
|
||||
});
|
||||
this._$scope.openSearch = function() {
|
||||
_$scope.searchBuffer = _$location.path();
|
||||
_$location.path('/search/');
|
||||
return _$scope.status.searchActive = true;
|
||||
};
|
||||
this._$scope.closeSearch = function() {
|
||||
_$scope.searchString = '';
|
||||
_$location.path(_$scope.searchBuffer);
|
||||
return _$scope.status.searchActive = false;
|
||||
};
|
||||
this._$scope.trySearch = function(event) {
|
||||
if (event.keyCode === 27) {
|
||||
return _$scope.closeSearch();
|
||||
} else {
|
||||
return _$location.path('/search/' + _$scope.searchString);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return SearchController;
|
||||
|
||||
})();
|
||||
return new SearchController($scope, $window, Status, $location);
|
||||
}
|
||||
]);
|
||||
|
||||
}).call(this);
|
||||
|
||||
(function() {
|
||||
angular.module('Tasks').controller('SettingsController', [
|
||||
'$scope', '$window', 'Status', '$location', '$modalInstance', 'CollectionsModel', 'SettingsBusinessLayer', 'SettingsModel', function($scope, $window, Status, $location, $modalInstance, CollectionsModel, SettingsBusinessLayer, SettingsModel) {
|
||||
|
@ -1119,11 +1037,14 @@
|
|||
}).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', function($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location, SettingsBusinessLayer) {
|
||||
'$scope', '$window', '$routeParams', 'TasksModel', 'ListsModel', 'CollectionsModel', 'TasksBusinessLayer', '$location', 'SettingsBusinessLayer', 'SearchBusinessLayer', function($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location, SettingsBusinessLayer, SearchBusinessLayer) {
|
||||
var TasksController;
|
||||
TasksController = (function() {
|
||||
function TasksController(_$scope, _$window, _$routeParams, _$tasksmodel, _$listsmodel, _$collectionsmodel, _tasksbusinesslayer, $location, _settingsbusinesslayer) {
|
||||
function TasksController(_$scope, _$window, _$routeParams, _$tasksmodel, _$listsmodel, _$collectionsmodel, _tasksbusinesslayer, $location, _settingsbusinesslayer, _searchbusinesslayer) {
|
||||
var _this = this;
|
||||
this._$scope = _$scope;
|
||||
this._$window = _$window;
|
||||
this._$routeParams = _$routeParams;
|
||||
|
@ -1133,6 +1054,7 @@
|
|||
this._tasksbusinesslayer = _tasksbusinesslayer;
|
||||
this.$location = $location;
|
||||
this._settingsbusinesslayer = _settingsbusinesslayer;
|
||||
this._searchbusinesslayer = _searchbusinesslayer;
|
||||
this._$scope.tasks = this._$tasksmodel.getAll();
|
||||
this._$scope.lists = this._$listsmodel.getAll();
|
||||
this._$scope.days = [0, 1, 2, 3, 4, 5, 6];
|
||||
|
@ -1164,24 +1086,51 @@
|
|||
};
|
||||
this._$scope.showInput = function() {
|
||||
var _ref;
|
||||
if (((_ref = _$scope.route.listID) === 'completed' || _ref === 'week') || _$scope.status.searchActive) {
|
||||
if ((_ref = _$scope.route.listID) === 'completed' || _ref === 'week') {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
this._$scope.filterByString = function() {
|
||||
return function(task) {
|
||||
var category, comment, filter, key, keys, value, _i, _j, _len, _len1, _ref, _ref1;
|
||||
keys = ['name', 'note', 'location', 'categories', 'comments'];
|
||||
filter = _searchbusinesslayer.getFilter().toLowerCase();
|
||||
for (key in task) {
|
||||
value = task[key];
|
||||
if (__indexOf.call(keys, key) >= 0) {
|
||||
if (key === 'comments') {
|
||||
_ref = task.comments;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
comment = _ref[_i];
|
||||
if (comment.comment.indexOf(filter) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (key === 'categories') {
|
||||
_ref1 = task.categories;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
category = _ref1[_j];
|
||||
if (category.indexOf(filter) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (value.indexOf(filter) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
this._$scope.focusInput = function() {
|
||||
return _$scope.status.focusTaskInput = true;
|
||||
};
|
||||
this._$scope.openDetails = function(id) {
|
||||
var listID, searchString;
|
||||
if (_$scope.status.searchActive) {
|
||||
searchString = _$scope.route.searchString;
|
||||
return $location.path('/search/' + searchString + '/tasks/' + id);
|
||||
} else {
|
||||
listID = _$scope.route.listID;
|
||||
return $location.path('/lists/' + listID + '/tasks/' + id);
|
||||
}
|
||||
var listID;
|
||||
listID = _$scope.route.listID;
|
||||
return $location.path('/lists/' + listID + '/tasks/' + id);
|
||||
};
|
||||
this._$scope.toggleCompleted = function(taskID) {
|
||||
if (_$tasksmodel.completed(taskID)) {
|
||||
|
@ -1235,11 +1184,7 @@
|
|||
};
|
||||
this._$scope.filterTasksByCalendar = function(task, listID) {
|
||||
return function(task) {
|
||||
if (_$scope.status.searchActive) {
|
||||
return true;
|
||||
} else {
|
||||
return '' + task.calendarid === '' + listID;
|
||||
}
|
||||
return '' + task.calendarid === '' + listID;
|
||||
};
|
||||
};
|
||||
this._$scope.filterLists = function() {
|
||||
|
@ -1248,18 +1193,10 @@
|
|||
};
|
||||
};
|
||||
this._$scope.getCount = function(listID, type) {
|
||||
if (_$scope.status.searchActive) {
|
||||
return true;
|
||||
} else {
|
||||
return _$listsmodel.getCount(listID, type);
|
||||
}
|
||||
return _$listsmodel.getCount(listID, type);
|
||||
};
|
||||
this._$scope.getCountString = function(listID, type) {
|
||||
if (_$scope.status.searchActive) {
|
||||
return t('tasks', 'Completed Task');
|
||||
} else {
|
||||
return n('tasks', '%n Completed Task', '%n Completed Tasks', _$listsmodel.getCount(listID, type));
|
||||
}
|
||||
return n('tasks', '%n Completed Task', '%n Completed Tasks', _$listsmodel.getCount(listID, type));
|
||||
};
|
||||
this._$scope.addTask = function(taskName) {
|
||||
var task, _ref,
|
||||
|
@ -1328,7 +1265,7 @@
|
|||
return TasksController;
|
||||
|
||||
})();
|
||||
return new TasksController($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location, SettingsBusinessLayer);
|
||||
return new TasksController($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location, SettingsBusinessLayer, SearchBusinessLayer);
|
||||
}
|
||||
]);
|
||||
|
||||
|
@ -1396,6 +1333,62 @@
|
|||
|
||||
}).call(this);
|
||||
|
||||
(function() {
|
||||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
angular.module('Tasks').factory('SearchBusinessLayer', [
|
||||
'ListsModel', 'Persistence', 'TasksModel', '$rootScope', function(ListsModel, Persistence, TasksModel, $rootScope) {
|
||||
var SearchBusinessLayer;
|
||||
SearchBusinessLayer = (function() {
|
||||
function SearchBusinessLayer(_$listsmodel, _persistence, _$tasksmodel, _$rootScope) {
|
||||
this._$listsmodel = _$listsmodel;
|
||||
this._persistence = _persistence;
|
||||
this._$tasksmodel = _$tasksmodel;
|
||||
this._$rootScope = _$rootScope;
|
||||
this.getFilter = __bind(this.getFilter, this);
|
||||
this.setFilter = __bind(this.setFilter, this);
|
||||
this.attach = __bind(this.attach, this);
|
||||
this.initialize();
|
||||
this._$searchString = '';
|
||||
}
|
||||
|
||||
SearchBusinessLayer.prototype.attach = function(search) {
|
||||
var _this = this;
|
||||
search.setFilter('tasks', function(query) {
|
||||
return _this._$rootScope.$apply(_this.setFilter(query));
|
||||
});
|
||||
search.setRenderer('task', this.renderTaskResult.bind(this));
|
||||
return search.setHandler('task', this.handleTaskClick.bind(this));
|
||||
};
|
||||
|
||||
SearchBusinessLayer.prototype.setFilter = function(query) {
|
||||
return this._$searchString = query;
|
||||
};
|
||||
|
||||
SearchBusinessLayer.prototype.getFilter = function() {
|
||||
return this._$searchString;
|
||||
};
|
||||
|
||||
SearchBusinessLayer.prototype.initialize = function() {
|
||||
var _this = this;
|
||||
this.handleTaskClick = function($row, result, event) {
|
||||
return console.log('Search result clicked');
|
||||
};
|
||||
this.renderTaskResult = function($row, result) {
|
||||
return $row;
|
||||
};
|
||||
return OC.Plugins.register('OCA.Search', this);
|
||||
};
|
||||
|
||||
return SearchBusinessLayer;
|
||||
|
||||
})();
|
||||
return new SearchBusinessLayer(ListsModel, Persistence, TasksModel, $rootScope);
|
||||
}
|
||||
]);
|
||||
|
||||
}).call(this);
|
||||
|
||||
(function() {
|
||||
angular.module('Tasks').factory('SettingsBusinessLayer', [
|
||||
'Persistence', 'SettingsModel', function(Persistence, SettingsModel) {
|
||||
|
@ -2966,7 +2959,6 @@
|
|||
Status = (function() {
|
||||
function Status() {
|
||||
this._$status = {
|
||||
searchActive: false,
|
||||
addingList: false,
|
||||
focusTaskInput: false
|
||||
};
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
<div ng-app="Tasks" ng-cloak ng-controller="AppController" ng-click="closeAll()" id="tasks_wrapper">
|
||||
<div id="app-navigation" ng-controller="ListController">
|
||||
<div id="task_lists_header" class="header" ng-class="{'search': status.searchActive}" ng-controller="SearchController">
|
||||
<div id="task_lists_header" class="header">
|
||||
<div id="main-toolbar">
|
||||
<a id="search" ng-click="openSearch()" oc-click-focus="{selector: '#search-toolbar input', timeout: 0}">
|
||||
<span class="icon search"></span>
|
||||
</a>
|
||||
<a id="loading" ng-click="update()" stop-event="click">
|
||||
<span class="loading" ng-class="{'done':!isLoading()}"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="search-toolbar">
|
||||
<span class="icon menu-search"></span>
|
||||
<input type="text" key-placeholder="placeholder_search" placeholder="<?php p($l->t('Search...')); ?>" ng-model="searchString" ng-keyup="trySearch($event)" >
|
||||
<a id="cancel-search" ng-click="closeSearch()">
|
||||
<span class="icon detail-delete"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="task_lists_scroll" class="scroll">
|
||||
<ul id="collection_filters">
|
||||
|
@ -74,6 +64,7 @@
|
|||
<?php print_unescaped($this->inc('part.tasklist')); ?>
|
||||
<?php print_unescaped($this->inc('part.collectionall')); ?>
|
||||
<?php print_unescaped($this->inc('part.collectionweek')); ?>
|
||||
<!-- <div id="searchresults" stop-event="click"></div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div id="task-details" ng-class="{'details-visible':route.taskID}">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<text>{{ list.displayname }}</text>
|
||||
</h2>
|
||||
<ol class="tasks">
|
||||
<li ng-animate="'animate'" ng-repeat="task in tasks | filter:filterTasksByCalendar(task,list.id) | filter:filterTasks(task) | orderBy:sortDue | orderBy:'starred':true | orderBy:'completed_date':true"
|
||||
<li ng-animate="'animate'" ng-repeat="task in tasks | filter:filterTasksByCalendar(task,list.id) | filter:filterTasks(task) | filter:filterByString(task) | orderBy:sortDue | orderBy:'starred':true | orderBy:'completed_date':true"
|
||||
class="task-item ui-draggable" rel="{{ task.id }}" ng-click="openDetails(task.id)" ng-class="{done: task.completed}" oc-drag-task stop-event="click">
|
||||
<div class="task-body">
|
||||
<div class="percentdone" style="width:{{ task.complete }}%; background-color:{{list.calendarcolor}};"></div>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<text>{{ day | day }}</text>
|
||||
</h2>
|
||||
<ol class="tasks">
|
||||
<li ng-animate="'animate'" ng-repeat="task in getTasksAtDay(tasks, day) | filter:{'completed':'false'} | orderBy:sortDue | orderBy:'starred':true"
|
||||
<li ng-animate="'animate'" ng-repeat="task in getTasksAtDay(tasks, day) | filter:filterByString(task) | filter:{'completed':'false'} | orderBy:sortDue | orderBy:'starred':true"
|
||||
class="task-item ui-draggable" rel="{{ task.id }}" ng-click="openDetails(task.id)" ng-class="{done: task.completed}" oc-drag-task stop-event="click">
|
||||
<div class="task-body">
|
||||
<div class="percentdone" style="width:{{ task.complete }}%; background-color:{{ getTaskColor(task.calendarid) }};"></div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div ng-switch-default>
|
||||
<div class="grouped-tasks">
|
||||
<ol class="tasks" rel="uncompleted" oc-drop-task>
|
||||
<li ng-repeat="(id, task) in tasks | filter:filterTasksByCalendar(task,route.listID) | filter:{'completed':'false'} | filter:route.searchString | orderBy:sortDue | orderBy:'starred':true"
|
||||
<li ng-repeat="(id, task) in tasks | filter:filterTasksByCalendar(task,route.listID) | filter:{'completed':'false'} | filter:filterByString(task) | orderBy:sortDue | orderBy:'starred':true"
|
||||
class="task-item ui-draggable" rel="{{ task.id }}" ng-click="openDetails(task.id)" ng-class="{done: task.completed}" oc-drag-task stop-event="click">
|
||||
<div class="task-body">
|
||||
<div class="percentdone" style="width:{{ task.complete }}%; background-color:{{ getTaskColor(task.calendarid) }};"></div>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<text ng-click="toggleHidden()">{{ getCountString(route.listID,'completed') }}</text>
|
||||
</h2>
|
||||
<ol class="completed-tasks" rel="completed" oc-drop-task>
|
||||
<li ng-repeat="task in tasks | filter:filterTasksByCalendar(task,route.listID) | filter:{'completed':'true'} | filter:route.searchString | orderBy:'completed_date':true"
|
||||
<li ng-repeat="task in tasks | filter:filterTasksByCalendar(task,route.listID) | filter:{'completed':'true'} | filter:filterByString(task) | orderBy:'completed_date':true"
|
||||
class="task-item" rel="{{ task.id }}" ng-click="openDetails(task.id)"
|
||||
ng-class="{done: task.completed}" oc-drag-task stop-event="click">
|
||||
<div class="task-body">
|
||||
|
|
Loading…
Reference in a new issue