2 commits - plugins/tasklist
Thomas Brüderli
bruederli at kolabsys.com
Thu Oct 3 17:18:41 CEST 2013
plugins/tasklist/tasklist.js | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
New commits:
commit f1a6254bc217cccc0923f17fe5838c4ae8f7fb53
Merge: 59bae43 65239fb
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Thu Oct 3 17:17:10 2013 +0200
Merge branch 'master' of ssh://git.kolab.org/git/roundcubemail-plugins-kolab
commit 59bae43b0166df41434d86ab73c1ea40e2f52c0e
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Thu Oct 3 17:13:22 2013 +0200
Consider task hierarchy when matching current filter and tags selection (#2290):
- Show children of matching tasks
- Show ancestors if a child task matches
diff --git a/plugins/tasklist/tasklist.js b/plugins/tasklist/tasklist.js
index 7b4ef81..9ad67d0 100644
--- a/plugins/tasklist/tasklist.js
+++ b/plugins/tasklist/tasklist.js
@@ -467,13 +467,14 @@ function rcube_tasklist_ui(settings)
// clear display
var id, rec,
count = 0,
+ cache = {},
msgbox = $('#listmessagebox').hide(),
list = $(rcmail.gui_objects.resultlist).html('');
for (var i=0; i < listindex.length; i++) {
id = listindex[i];
rec = listdata[id];
- if (match_filter(rec)) {
+ if (match_filter(rec, cache)) {
render_task(rec);
count++;
}
@@ -1333,9 +1334,14 @@ function rcube_tasklist_ui(settings)
/**
* Check if the given task matches the current filtermask and tag selection
*/
- function match_filter(rec)
+ function match_filter(rec, cache, recursive)
{
- var match = !filtermask || (filtermask & rec.mask) > 0;
+ // return cached result
+ if (typeof cache[rec.id] != 'undefined') {
+ return cache[rec.id];
+ }
+
+ var match = !filtermask || (filtermask & rec.mask) > 0
if (match && tagsfilter.length) {
match = rec.tags && rec.tags.length;
@@ -1345,6 +1351,23 @@ function rcube_tasklist_ui(settings)
}
}
+ // check if a child task matches the tags
+ if (!match && (recursive||0) < 2 && rec.children && rec.children.length) {
+ for (var j=0; !match && j < rec.children.length; j++) {
+ match = match_filter(listdata[rec.children[j]], cache, 1);
+ }
+ }
+
+ // walk up the task tree and check if a parent task matches
+ var parent_id;
+ if (!match && !recursive && (parent_id = rec.parent_id)) {
+ while (!match && parent_id && listdata[parent_id]) {
+ match = match_filter(listdata[parent_id], cache, 2);
+ parent_id = listdata[parent_id].parent_id;
+ }
+ }
+
+ cache[rec.id] = match;
return match;
}
More information about the commits
mailing list