diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tasks/ajax/addtask.php | 31 | ||||
-rw-r--r-- | apps/tasks/js/tasks.js | 8 | ||||
-rw-r--r-- | apps/tasks/templates/tasks.php | 3 |
3 files changed, 20 insertions, 22 deletions
diff --git a/apps/tasks/ajax/addtask.php b/apps/tasks/ajax/addtask.php index 3f129a0eb90..9d62a5fe707 100644 --- a/apps/tasks/ajax/addtask.php +++ b/apps/tasks/ajax/addtask.php @@ -5,26 +5,23 @@ require_once('../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('tasks'); -$cid = $_POST['id']; -$calendar = OC_Calendar_App::getCalendar( $cid ); +$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true); +$cid = reset($calendars)['id']; -$errors = OC_Task_App::validateRequest($_POST); -if (!empty($errors)) { - OC_JSON::error(array('data' => array( 'errors' => $errors ))); - exit(); -} - -$vcalendar = OC_Task_App::createVCalendarFromRequest($_POST); +$input = $_GET['text']; +$request = array(); +$request['summary'] = $input; +$request["categories"] = null; +$request['priority'] = null; +$request['percent_complete'] = null; +$request['completed'] = null; +$request['location'] = null; +$request['due'] = null; +$request['description'] = null; +$vcalendar = OC_Task_App::createVCalendarFromRequest($request); $id = OC_Calendar_Object::add($cid, $vcalendar->serialize()); -$priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OC_Template('tasks','part.details'); -$tmpl->assign('priority_options', $priority_options); -$tmpl->assign('details',$vcalendar->VTODO); -$tmpl->assign('id',$id); -$page = $tmpl->fetchPage(); - $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone); -OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task ))); +OC_JSON::success(array('task' => $task)); diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js index bf28626d09b..40b4f5140a1 100644 --- a/apps/tasks/js/tasks.js +++ b/apps/tasks/js/tasks.js @@ -420,11 +420,11 @@ $(document).ready(function(){ return false; }); - $('#tasks_newtask').click(function(){ - $.getJSON('ajax/addtaskform.php',{},function(jsondata){ + $('#tasks_addtask').click(function(){ + var input = $('#tasks_newtask').val(); + $.getJSON('ajax/addtask.php',{text:input},function(jsondata){ if(jsondata.status == 'success'){ - $('#task_details').data('id',''); - $('#task_details').html(jsondata.data.page); + $('#tasks_list').append(OC.Tasks.create_task_div(jsondata.task)); } else{ alert(jsondata.data.message); diff --git a/apps/tasks/templates/tasks.php b/apps/tasks/templates/tasks.php index 1371d5947a5..07f85b23cef 100644 --- a/apps/tasks/templates/tasks.php +++ b/apps/tasks/templates/tasks.php @@ -1,5 +1,6 @@ <div id="controls"> - <input type="button" id="tasks_newtask" value="<?php echo $l->t('Add Task'); ?>"> + <input type="text" id="tasks_newtask"> + <input type="button" id="tasks_addtask" value="<?php echo $l->t('Add Task'); ?>"> <input type="button" id="tasks_order_due" value="<?php echo $l->t('Order Due'); ?>"> <input type="button" id="tasks_order_category" value="<?php echo $l->t('Order Category'); ?>"> <input type="button" id="tasks_order_complete" value="<?php echo $l->t('Order Complete'); ?>"> |