diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-02-23 21:11:31 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-02-23 21:11:31 +0100 |
commit | 8f9c85232508ffb9bda4f5fdeddb3e3630af0ba1 (patch) | |
tree | 8b7a1431d0f0b6b014e5c49a31e2c55bdebeed66 /apps/tasks | |
parent | c768751c23fe6d5acdcde1124faff6f8dc587509 (diff) | |
download | nextcloud-server-8f9c85232508ffb9bda4f5fdeddb3e3630af0ba1.tar.gz nextcloud-server-8f9c85232508ffb9bda4f5fdeddb3e3630af0ba1.zip |
Add filtering on category, priority and location
Diffstat (limited to 'apps/tasks')
-rw-r--r-- | apps/tasks/css/style.css | 4 | ||||
-rw-r--r-- | apps/tasks/js/tasks.js | 54 |
2 files changed, 54 insertions, 4 deletions
diff --git a/apps/tasks/css/style.css b/apps/tasks/css/style.css index 72254584a5b..cbfb84c6ef1 100644 --- a/apps/tasks/css/style.css +++ b/apps/tasks/css/style.css @@ -23,8 +23,10 @@ .task .summary{padding-left:4em;} -.task .tag{border-radius:0.4em;display:inline-block;opacity:0.2;margin:0 0.2em;padding:0 0.4em;} +.task .tag{border-radius:0.4em;display:inline-block;opacity:0.2;margin:0 0.2em;border:1px solid transparent;padding:0 0.4em;} .task .tag:hover{opacity:0.5;} +.task .tag.active{border-color:black;opacity:0.6;} +.task .tag.active:hover{opacity:0.8;} .task .categories{position:absolute;right:6em;text-align:right;top:0.5em} .task .categories a{background-color:#1d2d44;color:white;} diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js index 6400a8f5120..37ab504a72f 100644 --- a/apps/tasks/js/tasks.js +++ b/apps/tasks/js/tasks.js @@ -1,14 +1,50 @@ +OC.Tasks = { + filter:function(tag, find_filter) { + var tag_text = $(tag).text(); + var filter = !$(tag).hasClass('active'); + var show_count = $('#tasks').data('show_count'); + show_count += filter ? +1 : -1; + $('#tasks').data('show_count', show_count); + $('#tasks .task').each(function(i, task_container){ + task_container = $(task_container); + var task = task_container.data('task'); + var found = 0; + task_container.find(find_filter).each(function(){ + if ($(this).text() == tag_text) { + $(this).toggleClass('active'); + found = 1; + } + }); + var hide_count = task_container.data('show_count'); + if (!filter) { + hide_count-=found; + } + else { + hide_count+=found; + } + if (hide_count == show_count) { + task_container.show(); + } + else { + task_container.hide(); + } + task_container.data('show_count', hide_count); + }); + } +}; + $(document).ready(function(){ /*------------------------------------------------------------------------- * Actions for startup *-----------------------------------------------------------------------*/ $.getJSON(OC.filePath('tasks', 'ajax', 'gettasks.php'), function(jsondata) { - var tasks = $('#tasks').empty(); + var tasks = $('#tasks').empty().data('show_count', 0); var actions = $('#task_actions_template'); $(jsondata).each(function(i, task) { var task_container = $('<div>').appendTo(tasks) .addClass('task') .data('task', task) + .data('show_count', 0) .attr('data-id', task.id) .append($('<p>') .html('<a href="index.php?id='+task.id+'">'+task.summary+'</a>') @@ -62,8 +98,8 @@ $(document).ready(function(){ /*------------------------------------------------------------------------- * Event handlers *-----------------------------------------------------------------------*/ - $('#tasks div').live('click',function(){ - var id = $(this).data('id'); + $('#tasks div.task .summary').live('click',function(){ + var id = $(this).parent('div.task').data('id'); var oldid = $('#task_details').data('id'); if(oldid != 0){ $('#tasks li[data-id="'+oldid+'"]').removeClass('active'); @@ -81,6 +117,18 @@ $(document).ready(function(){ return false; }); + $('#tasks div.categories .tag').live('click',function(){ + OC.Tasks.filter(this, 'div.categories .tag'); + }); + + $('#tasks .priority.tag').live('click',function(){ + OC.Tasks.filter(this, '.priority.tag'); + }); + + $('#tasks .location.tag').live('click',function(){ + OC.Tasks.filter(this, '.location.tag'); + }); + $('#tasks_delete').live('click',function(){ var id = $('#task_details').data('id'); $.getJSON('ajax/delete.php',{'id':id},function(jsondata){ |