streams/Code/Widget/Tasklist.php

36 lines
1.2 KiB
PHP
Raw Normal View History

2017-03-16 04:26:28 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Widget;
2017-03-16 04:26:28 +00:00
2022-02-16 04:08:28 +00:00
use Code\Lib\Apps;
2019-06-30 02:23:31 +00:00
2017-03-16 04:26:28 +00:00
require_once('include/event.php');
2022-10-23 21:18:44 +00:00
class Tasklist implements WidgetInterface
2021-12-02 23:02:31 +00:00
{
2017-03-16 04:26:28 +00:00
2022-10-24 03:39:49 +00:00
public function widget(array $arguments): string
2021-12-02 23:02:31 +00:00
{
2017-03-16 04:26:28 +00:00
2021-12-02 23:02:31 +00:00
$o = EMPTY_STR;
2021-03-12 00:03:45 +00:00
2021-12-02 23:02:31 +00:00
if (!(local_channel() && Apps::system_app_installed(local_channel(), 'Tasks'))) {
2021-03-12 00:03:45 +00:00
return $o;
2019-06-30 02:23:31 +00:00
}
2017-03-16 04:26:28 +00:00
2021-12-02 23:02:31 +00:00
$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();}); }
2017-03-16 04:26:28 +00:00
function tasksFetch() {
$.get("tasks/fetch" + ((tasksShowAll) ? "/all" : ""), function(data) {
$(".tasklist-tasks").html(data.html);
});
}
</script>';
2021-12-02 23:02:31 +00:00
$o .= '<div class="widget">' . '<h3>' . t('Tasks') . '</h3><div class="tasklist-tasks">';
$o .= '</div><form id="tasklist-new-form" action="" ><input class="form-control" id="tasklist-new-summary" type="text" name="summary" value="" /></form>';
$o .= '</div>';
return $o;
}
2017-03-16 04:26:28 +00:00
}