Tasks: Update to use new categories interface
This commit is contained in:
parent
7d1880078c
commit
029e1aced7
8 changed files with 29 additions and 24 deletions
|
@ -110,7 +110,7 @@ class OC_Calendar_App{
|
||||||
foreach($events as $event) {
|
foreach($events as $event) {
|
||||||
$vobject = OC_VObject::parse($event['calendardata']);
|
$vobject = OC_VObject::parse($event['calendardata']);
|
||||||
if(!is_null($vobject)) {
|
if(!is_null($vobject)) {
|
||||||
$vcategories->loadFromVObject($vobject->VEVENT, true);
|
self::loadCategoriesFromVCalendar($vobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,16 @@ class OC_Calendar_App{
|
||||||
* @see OC_VCategories::loadFromVObject
|
* @see OC_VCategories::loadFromVObject
|
||||||
*/
|
*/
|
||||||
public static function loadCategoriesFromVCalendar(OC_VObject $calendar) {
|
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(){
|
public static function getRepeatOptions(){
|
||||||
|
|
|
@ -8,7 +8,7 @@ OC_JSON::checkAppEnabled('tasks');
|
||||||
$l10n = new OC_L10N('tasks');
|
$l10n = new OC_L10N('tasks');
|
||||||
|
|
||||||
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true);
|
$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);
|
$percent_options = range(0, 100, 10);
|
||||||
$priority_options = OC_Task_App::getPriorityOptions();
|
$priority_options = OC_Task_App::getPriorityOptions();
|
||||||
$tmpl = new OC_Template('tasks','part.addtaskform');
|
$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('percent_options', $percent_options);
|
||||||
$tmpl->assign('priority_options', $priority_options);
|
$tmpl->assign('priority_options', $priority_options);
|
||||||
$tmpl->assign('details', new OC_VObject('VTODO'));
|
$tmpl->assign('details', new OC_VObject('VTODO'));
|
||||||
$tmpl->assign('categories', array());
|
$tmpl->assign('categories', '');
|
||||||
$page = $tmpl->fetchPage();
|
$page = $tmpl->fetchPage();
|
||||||
|
|
||||||
OC_JSON::success(array('data' => array( 'page' => $page )));
|
OC_JSON::success(array('data' => array( 'page' => $page )));
|
||||||
|
|
|
@ -9,13 +9,9 @@ $l10n = new OC_L10N('tasks');
|
||||||
|
|
||||||
$id = $_GET['id'];
|
$id = $_GET['id'];
|
||||||
$details = OC_Calendar_App::getVCalendar($id)->VTODO;
|
$details = OC_Calendar_App::getVCalendar($id)->VTODO;
|
||||||
$categories = array();
|
$categories = $details->getAsString('CATEGORIES');
|
||||||
if (isset($details->CATEGORIES)){
|
|
||||||
$categories = explode(',', $details->CATEGORIES->value);
|
|
||||||
$categories = array_map('trim', $categories);
|
|
||||||
}
|
|
||||||
|
|
||||||
$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
|
$category_options = OC_Calendar_App::getCategoryOptions($l10n);
|
||||||
$percent_options = range(0, 100, 10);
|
$percent_options = range(0, 100, 10);
|
||||||
$priority_options = OC_Task_App::getPriorityOptions();
|
$priority_options = OC_Task_App::getPriorityOptions();
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,14 @@ if( count($calendars) == 0 ) {
|
||||||
|
|
||||||
OC_UTIL::addScript('tasks', 'tasks');
|
OC_UTIL::addScript('tasks', 'tasks');
|
||||||
OC_UTIL::addStyle('tasks', 'style');
|
OC_UTIL::addStyle('tasks', 'style');
|
||||||
|
OC_Util::addScript('contacts','jquery.multi-autocomplete');
|
||||||
|
OC_Util::addScript('','oc-vcategories');
|
||||||
OC_APP::setActiveNavigationEntry('tasks_index');
|
OC_APP::setActiveNavigationEntry('tasks_index');
|
||||||
|
|
||||||
|
$categories = OC_Calendar_App::getCategoryOptions();
|
||||||
$l10n = new OC_L10N('tasks');
|
$l10n = new OC_L10N('tasks');
|
||||||
$priority_options = OC_Task_App::getPriorityOptions();
|
$priority_options = OC_Task_App::getPriorityOptions();
|
||||||
$output = new OC_Template('tasks', 'tasks', 'user');
|
$output = new OC_Template('tasks', 'tasks', 'user');
|
||||||
$output->assign('priority_options', $priority_options);
|
$output->assign('priority_options', $priority_options);
|
||||||
|
$output->assign('categories', $categories);
|
||||||
$output -> printPage();
|
$output -> printPage();
|
||||||
|
|
|
@ -291,6 +291,7 @@ $(document).ready(function(){
|
||||||
$.getJSON('ajax/edittaskform.php',{'id':id},function(jsondata){
|
$.getJSON('ajax/edittaskform.php',{'id':id},function(jsondata){
|
||||||
if(jsondata.status == 'success'){
|
if(jsondata.status == 'success'){
|
||||||
$('#task_details').html(jsondata.data.page);
|
$('#task_details').html(jsondata.data.page);
|
||||||
|
$('#task_details #categories').multiple_autocomplete({source: categories});
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
alert(jsondata.data.message);
|
alert(jsondata.data.message);
|
||||||
|
@ -332,4 +333,6 @@ $(document).ready(function(){
|
||||||
}, 'json');
|
}, 'json');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
OCCategories.app = 'calendar';
|
||||||
});
|
});
|
||||||
|
|
|
@ -80,10 +80,6 @@ class OC_Task_App {
|
||||||
$errors['summary'] = self::$l10n->t('Empty Summary');
|
$errors['summary'] = self::$l10n->t('Empty Summary');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($request['categories']) && !is_array($request['categories'])){
|
|
||||||
$errors['categories'] = self::$l10n->t('Not an array');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
|
$timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
|
||||||
$timezone = new DateTimeZone($timezone);
|
$timezone = new DateTimeZone($timezone);
|
||||||
|
@ -130,7 +126,7 @@ class OC_Task_App {
|
||||||
public static function updateVCalendarFromRequest($request, $vcalendar)
|
public static function updateVCalendarFromRequest($request, $vcalendar)
|
||||||
{
|
{
|
||||||
$summary = $request['summary'];
|
$summary = $request['summary'];
|
||||||
$categories = isset($request["categories"]) ? $request["categories"] : array();
|
$categories = $request["categories"];
|
||||||
$priority = $request['priority'];
|
$priority = $request['priority'];
|
||||||
$percent_complete = $request['percent_complete'];
|
$percent_complete = $request['percent_complete'];
|
||||||
$completed = $request['completed'];
|
$completed = $request['completed'];
|
||||||
|
@ -146,7 +142,7 @@ class OC_Task_App {
|
||||||
|
|
||||||
$vtodo->setString('LOCATION', $location);
|
$vtodo->setString('LOCATION', $location);
|
||||||
$vtodo->setString('DESCRIPTION', $description);
|
$vtodo->setString('DESCRIPTION', $description);
|
||||||
$vtodo->setString('CATEGORIES', join(',', $categories));
|
$vtodo->setString('CATEGORIES', $categories);
|
||||||
$vtodo->setString('PRIORITY', $priority);
|
$vtodo->setString('PRIORITY', $priority);
|
||||||
|
|
||||||
if ($due) {
|
if ($due) {
|
||||||
|
|
|
@ -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 : '' ?>">
|
<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>
|
<br>
|
||||||
<label for="categories"><?php echo $l->t('Categories'); ?></label>
|
<label for="categories"><?php echo $l->t('Categories'); ?></label>
|
||||||
<select name="categories[]" multiple="multiple">
|
<input id="categories" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? htmlspecialchars($_['categories']) : '' ?>">
|
||||||
<?php
|
<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>
|
||||||
var_dump($_['categories']);
|
|
||||||
foreach($_['category_options'] as $category){
|
|
||||||
echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<br>
|
<br>
|
||||||
<label for="due"><?php echo $l->t('Due'); ?></label>
|
<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()) : '' ?>">
|
<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()) : '' ?>">
|
||||||
|
|
|
@ -20,3 +20,6 @@
|
||||||
<img title="Edit" src="<?php echo image_path('core', 'actions/rename.svg') ?>" class="svg">
|
<img title="Edit" src="<?php echo image_path('core', 'actions/rename.svg') ?>" class="svg">
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var categories = <?php echo json_encode($_['categories']); ?>;
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue