Tasks: Update to use new categories interface

This commit is contained in:
Bart Visscher 2012-04-14 14:55:37 +02:00
parent 7d1880078c
commit 029e1aced7
8 changed files with 29 additions and 24 deletions

View file

@ -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(){

View file

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

View file

@ -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();

View file

@ -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();

View file

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

View file

@ -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) {

View file

@ -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()) : '' ?>">

View file

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