diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-04-20 18:16:39 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-04-20 18:16:39 +0200 |
commit | c75bbb59a9c065ff7e76558ba7d2e0fab33df0b8 (patch) | |
tree | 3390d6622f3b71b3191cfb9caa4c501537bd6d4e /apps/tasks | |
parent | 921fc59d8fb6f11b377531d60d3f956e90a5e617 (diff) | |
download | nextcloud-server-c75bbb59a9c065ff7e76558ba7d2e0fab33df0b8.tar.gz nextcloud-server-c75bbb59a9c065ff7e76558ba7d2e0fab33df0b8.zip |
Tasks: Add due property handling
Diffstat (limited to 'apps/tasks')
-rw-r--r-- | apps/tasks/ajax/update_property.php | 15 | ||||
-rw-r--r-- | apps/tasks/css/style.css | 3 | ||||
-rw-r--r-- | apps/tasks/index.php | 2 | ||||
-rw-r--r-- | apps/tasks/js/tasks.js | 44 | ||||
-rw-r--r-- | apps/tasks/lib/app.php | 2 |
5 files changed, 65 insertions, 1 deletions
diff --git a/apps/tasks/ajax/update_property.php b/apps/tasks/ajax/update_property.php index 1916a2eb7b1..66ff34f8482 100644 --- a/apps/tasks/ajax/update_property.php +++ b/apps/tasks/ajax/update_property.php @@ -21,6 +21,21 @@ switch($property) { $summary = $_POST['summary']; $vtodo->setString('SUMMARY', $summary); break; + case 'due': + $due = $_POST['due']; + if ($due != 'false') { + try { + $timezone = OC_Preferences::getValue(OC_User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $timezone = new DateTimeZone($timezone); + $due = new DateTime('@'.$due); + $due->setTimezone($timezone); + } catch (Exception $e) { + OC_JSON::error(array('data'=>array('message'=>OC_Task_App::$l10n->t('Invalid date/time')))); + exit(); + } + } + $vtodo->setDateTime('DUE', $due); + break; case 'complete': $checked = $_POST['checked']; OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null); diff --git a/apps/tasks/css/style.css b/apps/tasks/css/style.css index 9185c52f779..084085d6b76 100644 --- a/apps/tasks/css/style.css +++ b/apps/tasks/css/style.css @@ -53,3 +53,6 @@ .task .more{display:none;} .task .description{position:relative;left:4em;} +.task .due{position:absolute;right:0.3em;} +.task .due .date{width:6em;} +.task .due .time{width:6em;} diff --git a/apps/tasks/index.php b/apps/tasks/index.php index 95bb10a77c3..1ec91feb17a 100644 --- a/apps/tasks/index.php +++ b/apps/tasks/index.php @@ -18,6 +18,8 @@ if( count($calendars) == 0 ) { exit; } +OC_Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker'); +OC_Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker'); OC_UTIL::addScript('tasks', 'tasks'); OC_UTIL::addStyle('tasks', 'style'); OC_Util::addScript('contacts','jquery.multi-autocomplete'); diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js index 1381a356fb8..8d2714941d3 100644 --- a/apps/tasks/js/tasks.js +++ b/apps/tasks/js/tasks.js @@ -65,9 +65,32 @@ OC.Tasks = { var description = $('<textarea>') .addClass('description') .text(task.description); + var due = $('<span>') + .addClass('due') + .append(t('tasks', 'Due')); + due + .append($('<input type="date">') + .addClass('date') + .datepicker({ + dateFormat: 'dd-mm-yy', + onClose: OC.Tasks.dueUpdateHandler + }), + $('<input type="time">') + .addClass('time') + .timepicker({ + showPeriodLabels:false, + onClose: OC.Tasks.dueUpdateHandler + }) + ); + if (task.due){ + var date = new Date(parseInt(task.due)*1000); + due.find('.date').datepicker('setDate', date); + due.find('.time').timepicker('setTime', date.getHours()+':'+date.getMinutes()); + } $('<div>') .addClass('more') .append(description) + .append(due) .appendTo(task_container); return task_container; }, @@ -156,6 +179,27 @@ OC.Tasks = { input.focus(); return false; }, + dueUpdateHandler:function(){ + var task = $(this).closest('.task').data('task'); + var old_due = task.due; + var $date = $(this).parent().children('.date'); + var $time = $(this).parent().children('.time'); + var date = $date.datepicker('getDate'); + var time = $time.timepicker('getTime').split(':'); + var due; + if (!date || time.length<2){ + due = false; + } else { + date.setHours(time[0]); + date.setMinutes(time[1]); + due = date.getTime()/1000; + } + $.post('ajax/update_property.php', {id:task.id, type:'due', due:due}, function(jsondata){ + if(jsondata.status != 'success') { + task.due = old_due; + } + }); + }, moreClickHandler:function(event){ var $task = $(this).closest('.task'), task = $task.data('task'); diff --git a/apps/tasks/lib/app.php b/apps/tasks/lib/app.php index b564866b805..ae7efc37889 100644 --- a/apps/tasks/lib/app.php +++ b/apps/tasks/lib/app.php @@ -54,7 +54,7 @@ class OC_Task_App { if ($due) { $due = $due->getDateTime(); $due->setTimezone(new DateTimeZone($user_timezone)); - $task['due'] = $due->format('Y-m-d H:i:s'); + $task['due'] = $due->format('U'); } else { $task['due'] = false; |