Load either all complete or incomplete tasks from the server. Fo further filtering on the client
This commit is contained in:
parent
a9436f3b9e
commit
1809ed09f1
2 changed files with 46 additions and 20 deletions
|
@ -48,6 +48,7 @@ function rcube_tasklist(settings)
|
|||
/* private vars */
|
||||
var selector = 'all';
|
||||
var filtermask = FILTER_MASK_ALL;
|
||||
var loadstate = { filter:-1, lists:'' };
|
||||
var idcount = 0;
|
||||
var saving_lock;
|
||||
var ui_loading;
|
||||
|
@ -274,48 +275,74 @@ function rcube_tasklist(settings)
|
|||
}
|
||||
|
||||
/**
|
||||
* fetch tasks from server
|
||||
* List tasks matching the given selector
|
||||
*/
|
||||
function list_tasks(sel)
|
||||
{
|
||||
if (rcmail.busy)
|
||||
return;
|
||||
|
||||
if (sel && filter_masks[sel] !== undefined) {
|
||||
filtermask = filter_masks[sel];
|
||||
selector = sel;
|
||||
}
|
||||
|
||||
var active = active_lists();
|
||||
if (active.length) {
|
||||
var active = active_lists(),
|
||||
basefilter = filtermask == FILTER_MASK_COMPLETE ? FILTER_MASK_COMPLETE : FILTER_MASK_ALL,
|
||||
reload = active.join(',') != loadstate.lists || basefilter != loadstate.filter;
|
||||
|
||||
if (active.length && reload) {
|
||||
ui_loading = rcmail.set_busy(true, 'loading');
|
||||
rcmail.http_request('fetch', { filter:filtermask, lists:active.join(','), q:search_query }, true);
|
||||
rcmail.http_request('fetch', { filter:basefilter, lists:active.join(','), q:search_query }, true);
|
||||
}
|
||||
else
|
||||
else if (reload)
|
||||
data_ready([]);
|
||||
else
|
||||
render_tasklist();
|
||||
|
||||
$('#taskselector li.selected').removeClass('selected');
|
||||
$('#taskselector li.'+selector).addClass('selected');
|
||||
}
|
||||
|
||||
/**
|
||||
* callback if task data from server is ready
|
||||
* Callback if task data from server is ready
|
||||
*/
|
||||
function data_ready(data)
|
||||
function data_ready(response)
|
||||
{
|
||||
// clear display
|
||||
var msgbox = $('#listmessagebox').hide(),
|
||||
list = $(rcmail.gui_objects.resultlist).html('');
|
||||
listdata = {};
|
||||
|
||||
for (var i=0; i < data.length; i++) {
|
||||
listdata[data[i].id] = data[i];
|
||||
render_task(data[i]);
|
||||
loadstate.lists = response.lists;
|
||||
loadstate.filter = response.filter;
|
||||
for (var i=0; i < response.data.length; i++) {
|
||||
listdata[response.data[i].id] = response.data[i];
|
||||
}
|
||||
|
||||
if (!data.length)
|
||||
msgbox.html(rcmail.gettext('notasksfound','tasklist')).show();
|
||||
|
||||
render_tasklist();
|
||||
rcmail.set_busy(false, 'loading', ui_loading);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function render_tasklist()
|
||||
{
|
||||
// clear display
|
||||
var rec,
|
||||
count = 0,
|
||||
msgbox = $('#listmessagebox').hide(),
|
||||
list = $(rcmail.gui_objects.resultlist).html('');
|
||||
|
||||
for (var id in listdata) {
|
||||
rec = listdata[id];
|
||||
if (match_filter(rec)) {
|
||||
render_task(rec);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!count)
|
||||
msgbox.html(rcmail.gettext('notasksfound','tasklist')).show();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -714,8 +741,7 @@ function rcube_tasklist(settings)
|
|||
*/
|
||||
function match_filter(rec)
|
||||
{
|
||||
// TBD.
|
||||
return true;
|
||||
return !filtermask || (filtermask & rec.mask) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -387,7 +387,7 @@ class tasklist extends rcube_plugin
|
|||
// sort tasks according to their hierarchy level and due date
|
||||
usort($data, array($this, 'task_sort_cmp'));
|
||||
|
||||
$this->rc->output->command('plugin.data_ready', $data);
|
||||
$this->rc->output->command('plugin.data_ready', array('filter' => $f, 'lists' => $lists, 'data' => $data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue