diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-04-14 14:55:37 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-04-14 14:55:37 +0200 |
commit | 029e1aced7fc39fa5673b69927a24aa18b159a19 (patch) | |
tree | 73a5643a52991c502ae2a945692a7822b2eba1d2 | |
parent | 7d1880078c36eb51f7cd591b113a951064df4a65 (diff) | |
download | nextcloud-server-029e1aced7fc39fa5673b69927a24aa18b159a19.tar.gz nextcloud-server-029e1aced7fc39fa5673b69927a24aa18b159a19.zip |
Tasks: Update to use new categories interface
-rw-r--r-- | apps/calendar/lib/app.php | 13 | ||||
-rw-r--r-- | apps/tasks/ajax/addtaskform.php | 4 | ||||
-rw-r--r-- | apps/tasks/ajax/edittaskform.php | 8 | ||||
-rw-r--r-- | apps/tasks/index.php | 4 | ||||
-rw-r--r-- | apps/tasks/js/tasks.js | 3 | ||||
-rw-r--r-- | apps/tasks/lib/app.php | 8 | ||||
-rw-r--r-- | apps/tasks/templates/part.taskform.php | 10 | ||||
-rw-r--r-- | apps/tasks/templates/tasks.php | 3 |
8 files changed, 29 insertions, 24 deletions
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 22c1133e006..660aa928a76 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -110,7 +110,7 @@ class OC_Calendar_App{ foreach($events as $event) { $vobject = OC_VObject::parse($event['calendardata']); if(!is_null($vobject)) { - $vcategories->loadFromVObject($vobject->VEVENT, true); + self::loadCategoriesFromVCalendar($vobject); } } } @@ -121,7 +121,16 @@ class OC_Calendar_App{ * @see OC_VCategories::loadFromVObject */ public static function loadCategoriesFromVCalendar(OC_VObject $calendar) { - self::getVCategories()->loadFromVObject($calendar->VEVENT, true); + $object = null; + if (isset($calendar->VEVENT)) { + $object = $calendar->VEVENT; + } else + if (isset($calendar->VTODO)) { + $object = $calendar->VTODO; + } + if ($object) { + self::getVCategories()->loadFromVObject($object, true); + } } public static function getRepeatOptions(){ 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 @@ <input type="text" id="location" name="location" placeholder="<?php echo $l->t('Location of the task');?>" value="<?php echo isset($_['details']->LOCATION) ? $_['details']->LOCATION[0]->value : '' ?>"> <br> <label for="categories"><?php echo $l->t('Categories'); ?></label> - <select name="categories[]" multiple="multiple"> - <?php -var_dump($_['categories']); - foreach($_['category_options'] as $category){ - echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>'; - } - ?> - </select> + <input id="categories" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? htmlspecialchars($_['categories']) : '' ?>"> + <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a> <br> <label for="due"><?php echo $l->t('Due'); ?></label> <input type="text" id="due" name="due" placeholder="<?php echo $l->t('Due date') ?>" value="<?php echo isset($_['details']->DUE) ? $l->l('datetime', $_['details']->DUE[0]->getDateTime()) : '' ?>"> 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 @@ <img title="Edit" src="<?php echo image_path('core', 'actions/rename.svg') ?>" class="svg"> </span> </p> +<script type='text/javascript'> +var categories = <?php echo json_encode($_['categories']); ?>; +</script> |