Tasks: Simple add task action
This commit is contained in:
parent
728e6a6bf9
commit
b704ff1bc7
3 changed files with 20 additions and 22 deletions
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'); ?>">
|
||||
|
|
Loading…
Reference in a new issue