summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-04-15 15:39:49 +0200
committerBart Visscher <bartv@thisnet.nl>2012-04-15 15:39:49 +0200
commit947d2e5705ed606469d99ec4115b60f4eae3a0c4 (patch)
tree4831e391aa10feb4a6020b566e1a05130abc43ba /apps
parent19d81068f62cf38f03422a0f7bc50b309351dc5f (diff)
downloadnextcloud-server-947d2e5705ed606469d99ec4115b60f4eae3a0c4.tar.gz
nextcloud-server-947d2e5705ed606469d99ec4115b60f4eae3a0c4.zip
Tasks: Mark task as complete when checking the checkbox
Diffstat (limited to 'apps')
-rw-r--r--apps/tasks/ajax/complete.php24
-rw-r--r--apps/tasks/css/style.css1
-rw-r--r--apps/tasks/js/tasks.js24
-rw-r--r--apps/tasks/lib/app.php10
4 files changed, 55 insertions, 4 deletions
diff --git a/apps/tasks/ajax/complete.php b/apps/tasks/ajax/complete.php
new file mode 100644
index 00000000000..22c65c0bc83
--- /dev/null
+++ b/apps/tasks/ajax/complete.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+// Init owncloud
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('tasks');
+
+$id = $_POST['id'];
+$checked = $_POST['checked'];
+$vcalendar = OC_Calendar_App::getVCalendar( $id );
+
+$vtodo = $vcalendar->VTODO;
+OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null);
+OC_Calendar_Object::edit($id, $vcalendar->serialize());
+
+$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone);
+OC_JSON::success(array('data' => $task_info));
diff --git a/apps/tasks/css/style.css b/apps/tasks/css/style.css
index cedb21b1374..52c7178e973 100644
--- a/apps/tasks/css/style.css
+++ b/apps/tasks/css/style.css
@@ -24,6 +24,7 @@
.task .completed {position:absolute;left:3em;top:0.3em;}
.task .summary{padding-left:4em;}
+.task.done .summary{text-decoration:line-through;}
.task .tag{border-radius:0.4em;display:inline-block;opacity:0.2;margin:0 0.2em;border:1px solid transparent;padding:0 0.4em;}
.task .tag:hover{opacity:0.5;}
diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js
index 25a2e3f2687..719c49f7891 100644
--- a/apps/tasks/js/tasks.js
+++ b/apps/tasks/js/tasks.js
@@ -24,9 +24,11 @@ OC.Tasks = {
)
//.append(actions.clone().removeAttr('id'))
;
- var checkbox = $('<input type="checkbox">');
+ var checkbox = $('<input type="checkbox">')
+ .click(OC.Tasks.complete_task);
if (task.completed) {
checkbox.attr('checked', 'checked');
+ task_container.addClass('done');
}
$('<div>')
.addClass('completed')
@@ -112,6 +114,26 @@ OC.Tasks = {
}
container.append(this);
});
+ },
+ complete_task:function() {
+ var $task = $(this).closest('.task'),
+ task = $task.data('task'),
+ checked = $(this).is(':checked');
+ $.post('ajax/complete.php', {id:task.id, checked:checked?1:0}, function(jsondata){
+ if(jsondata.status == 'success') {
+ task = jsondata.data;
+ $task.data('task', task)
+ if (task.completed) {
+ $task.addClass('done');
+ }
+ else {
+ $task.removeClass('done');
+ }
+ }
+ else{
+ alert(jsondata.data.message);
+ }
+ }, 'json');
}
};
diff --git a/apps/tasks/lib/app.php b/apps/tasks/lib/app.php
index 01294b132b3..b564866b805 100644
--- a/apps/tasks/lib/app.php
+++ b/apps/tasks/lib/app.php
@@ -154,6 +154,13 @@ class OC_Task_App {
unset($vtodo->DUE);
}
+ self::setComplete($vtodo, $percent_complete, $completed);
+
+ return $vcalendar;
+ }
+
+ public static function setComplete($vtodo, $percent_complete, $completed)
+ {
if (!empty($percent_complete)) {
$vtodo->setString('PERCENT-COMPLETE', $percent_complete);
}else{
@@ -175,8 +182,5 @@ class OC_Task_App {
} else {
unset($vtodo->COMPLETED);
}
-
- return $vcalendar;
}
}
-