Tasks: Simple categories input

This commit is contained in:
Bart Visscher 2012-04-23 18:03:19 +02:00
parent acea156a3d
commit 728e6a6bf9
3 changed files with 30 additions and 2 deletions

View file

@ -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'];

View file

@ -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;}

View file

@ -103,6 +103,20 @@ OC.Tasks = {
.append(description)
.append(due)
.appendTo(task_container);
$('<input placeholder="'+t('tasks', 'List')+'">')
.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 $('<div>').text(category)
@ -283,6 +304,8 @@ $(document).ready(function(){
});
$(this).toggleClass('active');
});
OCCategories.changed = OC.Tasks.categoriesChanged;
OCCategories.app = 'calendar';
});
/*-------------------------------------------------------------------------