From 728e6a6bf9540b845073c4c8fb96dd7eb1dffa3a Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 23 Apr 2012 18:03:19 +0200 Subject: [PATCH] Tasks: Simple categories input --- apps/tasks/ajax/update_property.php | 4 ++++ apps/tasks/css/style.css | 5 +++-- apps/tasks/js/tasks.js | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/tasks/ajax/update_property.php b/apps/tasks/ajax/update_property.php index 7128aee8d3..a14816be12 100644 --- a/apps/tasks/ajax/update_property.php +++ b/apps/tasks/ajax/update_property.php @@ -25,6 +25,10 @@ switch($property) { $description = $_POST['description']; $vtodo->setString('DESCRIPTION', $description); break; + case 'categories': + $categories = $_POST['categories']; + $vtodo->setString('CATEGORIES', $categories); + break; case 'due': $due = $_POST['due']; $due_date_only = $_POST['date']; diff --git a/apps/tasks/css/style.css b/apps/tasks/css/style.css index 084085d6b7..e619be6785 100644 --- a/apps/tasks/css/style.css +++ b/apps/tasks/css/style.css @@ -46,11 +46,12 @@ .task .categories{position:absolute;right:6em;text-align:right;top:0.4em} .task .categories a{background-color:#1d2d44;color:white;} -.task .categories .tag.active{display:none} +.task .categories .tag.active{display:none;} +.task input.categories{display:none;top:0;text-align:left;} .task .location{background-color:#442d44;color:white;position:absolute;right:0.6em;width:4.2em;text-align:left;top:0.4em} -.task .more{display:none;} +.task .more{display:none;margin-top:0.5em;} .task .description{position:relative;left:4em;} .task .due{position:absolute;right:0.3em;} diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js index 3647107eab..bf28626d09 100644 --- a/apps/tasks/js/tasks.js +++ b/apps/tasks/js/tasks.js @@ -103,6 +103,20 @@ OC.Tasks = { .append(description) .append(due) .appendTo(task_container); + $('') + .addClass('categories') + .multiple_autocomplete({source: categories}) + .val(task.categories) + .blur(function(){ + var task = $(this).closest('.task').data('task'); + var categories = $(this).val(); + $.post('ajax/update_property.php', {id:task.id, type:'categories', categories:categories}, function(jsondata){ + if(jsondata.status == 'success') { + task.categories = categories.split(','); + } + }); + }) + .appendTo(task_container); return task_container; }, filter:function(tag, find_filter) { @@ -221,6 +235,8 @@ OC.Tasks = { var $task = $(this).closest('.task'), task = $task.data('task'); $task.find('.more').show(); + $task.find('div.categories').hide(); + $task.find('input.categories').show(); }, complete_task:function() { var $task = $(this).closest('.task'), @@ -242,6 +258,11 @@ OC.Tasks = { } }, 'json'); }, + categoriesChanged:function(newcategories){ + categories = $.map(newcategories, function(v) {return v;}); + console.log('Task categories changed to: ' + categories); + $('input.categories').multiple_autocomplete('option', 'source', categories); + }, List: { create_list_div:function(category){ return $('
').text(category) @@ -283,6 +304,8 @@ $(document).ready(function(){ }); $(this).toggleClass('active'); }); + OCCategories.changed = OC.Tasks.categoriesChanged; + OCCategories.app = 'calendar'; }); /*-------------------------------------------------------------------------