aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-08-20 20:40:42 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-08-20 20:40:42 -0700
commit49c4aa1a546264fa39754ae8a7c08243a6896b04 (patch)
treec5dfd1e0a0b6587cefe29d7685eb4f5b96d3659a /include
parentafbbc9cd72e48a9eb4fb035eb01cd6e742d0088e (diff)
downloadvolse-hubzilla-49c4aa1a546264fa39754ae8a7c08243a6896b04.tar.gz
volse-hubzilla-49c4aa1a546264fa39754ae8a7c08243a6896b04.tar.bz2
volse-hubzilla-49c4aa1a546264fa39754ae8a7c08243a6896b04.zip
cleanup of task widget - make jquery workflow a bit smoother
Diffstat (limited to 'include')
-rw-r--r--include/event.php4
-rw-r--r--include/widgets.php20
2 files changed, 12 insertions, 12 deletions
diff --git a/include/event.php b/include/event.php
index fad852dfc..95a165fdc 100644
--- a/include/event.php
+++ b/include/event.php
@@ -927,10 +927,10 @@ function tasks_fetch($arr) {
$ret = array();
$sql_extra = " and event_status != 'COMPLETED' ";
- if(argc() > 1 && argv(1) === 'all')
+ if($arr && $arr['all'] == 1)
$sql_extra = '';
- $r = q("select * from event where type = 'task' and uid = %d $sql_extra ",
+ $r = q("select * from event where type = 'task' and uid = %d $sql_extra order by created desc",
intval(local_channel())
);
diff --git a/include/widgets.php b/include/widgets.php
index 7433a1ec8..5e70730a3 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1047,17 +1047,17 @@ function widget_tasklist($arr) {
require_once('include/event.php');
- $o .= '<script>$("#tasklist-new-summary").keyup(function(e) { if (e.keyCode == 13) { $.post( "tasks/new", $("#tasklist-new").serialize() ); return false; } });</script>';
- $o .= '<script>function taskComplete(id) { $.post("tasks/complete/"+id); }</script>';
- $o .= '<div class="widget">' . '<h3>' . t('Tasks') . '</h3>';
- $x = tasks_fetch(array());
-
- if($x['success']) {
- foreach($x['tasks'] as $y) {
- $o .= '<div class="tasklist-item"><input type="checkbox" onchange="taskComplete(' . $y['id'] . '); return false;" /> ' . $y['summary'] . '</div>';
+ $o .= '<script>var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch(); $("#tasklist-new-summary").val(""); } ); return false; } )});</script>';
+ $o .= '<script>function taskComplete(id) { $.post("tasks/complete/"+id, function(data) { tasksFetch();}); }
+ function tasksFetch() {
+ $.get("tasks/fetch" + ((tasksShowAll) ? "/all" : ""), function(data) {
+ $(".tasklist-tasks").html(data.html);
+ });
}
- }
- $o .= '<form id="tasklist-new" action="tasks/new" method="post"><input id="tasklist-new-summary" type="text" name="summary" value="" /></form>';
+ </script>';
+
+ $o .= '<div class="widget">' . '<h3>' . t('Tasks') . '</h3><div class="tasklist-tasks">';
+ $o .= '</div><form id="tasklist-new-form" action="" ><input id="tasklist-new-summary" type="text" name="summary" value="" /></form>';
$o .= '</div>';
return $o;