From 029e1aced7fc39fa5673b69927a24aa18b159a19 Mon Sep 17 00:00:00 2001
From: Bart Visscher
Date: Sat, 14 Apr 2012 14:55:37 +0200
Subject: Tasks: Update to use new categories interface
---
apps/tasks/ajax/addtaskform.php | 4 ++--
apps/tasks/ajax/edittaskform.php | 8 ++------
apps/tasks/index.php | 4 ++++
apps/tasks/js/tasks.js | 3 +++
apps/tasks/lib/app.php | 8 ++------
apps/tasks/templates/part.taskform.php | 10 ++--------
apps/tasks/templates/tasks.php | 3 +++
7 files changed, 18 insertions(+), 22 deletions(-)
(limited to 'apps/tasks')
diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php
index d4a0bb03107..f56549cd747 100644
--- a/apps/tasks/ajax/addtaskform.php
+++ b/apps/tasks/ajax/addtaskform.php
@@ -8,7 +8,7 @@ OC_JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true);
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
+$category_options = OC_Calendar_App::getCategoryOptions($l10n);
$percent_options = range(0, 100, 10);
$priority_options = OC_Task_App::getPriorityOptions();
$tmpl = new OC_Template('tasks','part.addtaskform');
@@ -17,7 +17,7 @@ $tmpl->assign('category_options', $category_options);
$tmpl->assign('percent_options', $percent_options);
$tmpl->assign('priority_options', $priority_options);
$tmpl->assign('details', new OC_VObject('VTODO'));
-$tmpl->assign('categories', array());
+$tmpl->assign('categories', '');
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/tasks/ajax/edittaskform.php b/apps/tasks/ajax/edittaskform.php
index 651c26c4986..e23eb218244 100644
--- a/apps/tasks/ajax/edittaskform.php
+++ b/apps/tasks/ajax/edittaskform.php
@@ -9,13 +9,9 @@ $l10n = new OC_L10N('tasks');
$id = $_GET['id'];
$details = OC_Calendar_App::getVCalendar($id)->VTODO;
-$categories = array();
-if (isset($details->CATEGORIES)){
- $categories = explode(',', $details->CATEGORIES->value);
- $categories = array_map('trim', $categories);
-}
+$categories = $details->getAsString('CATEGORIES');
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
+$category_options = OC_Calendar_App::getCategoryOptions($l10n);
$percent_options = range(0, 100, 10);
$priority_options = OC_Task_App::getPriorityOptions();
diff --git a/apps/tasks/index.php b/apps/tasks/index.php
index 3e324e797f8..95bb10a77c3 100644
--- a/apps/tasks/index.php
+++ b/apps/tasks/index.php
@@ -20,10 +20,14 @@ if( count($calendars) == 0 ) {
OC_UTIL::addScript('tasks', 'tasks');
OC_UTIL::addStyle('tasks', 'style');
+OC_Util::addScript('contacts','jquery.multi-autocomplete');
+OC_Util::addScript('','oc-vcategories');
OC_APP::setActiveNavigationEntry('tasks_index');
+$categories = OC_Calendar_App::getCategoryOptions();
$l10n = new OC_L10N('tasks');
$priority_options = OC_Task_App::getPriorityOptions();
$output = new OC_Template('tasks', 'tasks', 'user');
$output->assign('priority_options', $priority_options);
+$output->assign('categories', $categories);
$output -> printPage();
diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js
index 4a9a0b69c4a..25a2e3f2687 100644
--- a/apps/tasks/js/tasks.js
+++ b/apps/tasks/js/tasks.js
@@ -291,6 +291,7 @@ $(document).ready(function(){
$.getJSON('ajax/edittaskform.php',{'id':id},function(jsondata){
if(jsondata.status == 'success'){
$('#task_details').html(jsondata.data.page);
+ $('#task_details #categories').multiple_autocomplete({source: categories});
}
else{
alert(jsondata.data.message);
@@ -332,4 +333,6 @@ $(document).ready(function(){
}, 'json');
return false;
});
+
+ OCCategories.app = 'calendar';
});
diff --git a/apps/tasks/lib/app.php b/apps/tasks/lib/app.php
index a5f4ff6cdc5..01294b132b3 100644
--- a/apps/tasks/lib/app.php
+++ b/apps/tasks/lib/app.php
@@ -80,10 +80,6 @@ class OC_Task_App {
$errors['summary'] = self::$l10n->t('Empty Summary');
}
- if(isset($request['categories']) && !is_array($request['categories'])){
- $errors['categories'] = self::$l10n->t('Not an array');
- }
-
try {
$timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
$timezone = new DateTimeZone($timezone);
@@ -130,7 +126,7 @@ class OC_Task_App {
public static function updateVCalendarFromRequest($request, $vcalendar)
{
$summary = $request['summary'];
- $categories = isset($request["categories"]) ? $request["categories"] : array();
+ $categories = $request["categories"];
$priority = $request['priority'];
$percent_complete = $request['percent_complete'];
$completed = $request['completed'];
@@ -146,7 +142,7 @@ class OC_Task_App {
$vtodo->setString('LOCATION', $location);
$vtodo->setString('DESCRIPTION', $description);
- $vtodo->setString('CATEGORIES', join(',', $categories));
+ $vtodo->setString('CATEGORIES', $categories);
$vtodo->setString('PRIORITY', $priority);
if ($due) {
diff --git a/apps/tasks/templates/part.taskform.php b/apps/tasks/templates/part.taskform.php
index 139693c0e96..da984d830bd 100644
--- a/apps/tasks/templates/part.taskform.php
+++ b/apps/tasks/templates/part.taskform.php
@@ -5,14 +5,8 @@
-
+
+
diff --git a/apps/tasks/templates/tasks.php b/apps/tasks/templates/tasks.php
index 8d34a40683b..8df2a100b69 100644
--- a/apps/tasks/templates/tasks.php
+++ b/apps/tasks/templates/tasks.php
@@ -20,3 +20,6 @@
+
--
cgit v1.2.3