Commit f94180b4 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1723961: Allow update status of plan task via normal page display



If the viewer is the owner of the page.
This hooks into the functionality used on the edit screen

Also added some padding to 'tags' div within a panel

Also changed the javascript call from being an inline html onclick to
being done via jQuery - allowing us to capture the event and stop the
expander event from being triggered

behatnotneeded

Change-Id: I866486493dacb5c48878c539dbbbde3e841d8b91
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c788dcc0
......@@ -30,7 +30,7 @@ function changeCheckBox(taskid, state) {
}
}
function saveCheckBoxChange(el, taskid) {
function saveCheckBoxChange(taskid) {
var params = {};
params.taskid = taskid;
sendjsonrequest(config.wwwroot + 'artefact/plans/checktask.json.php', params, 'POST', function(data) {
......@@ -39,3 +39,24 @@ function saveCheckBoxChange(el, taskid) {
}
});
}
function enableCheckBoxes() {
jQuery('.plan-task-icon').off('click');
jQuery('.plan-task-icon').on('click', function(e) {
e.stopPropagation();
e.preventDefault();
var taskid = jQuery(e.target).data('task');
saveCheckBoxChange(taskid);
});
}
// Wire up the checkboxes
jQuery(document).on('pageupdated', function(e, data) {
// When using pagination
enableCheckBoxes();
});
jQuery(function() {
// On page load
enableCheckBoxes();
});
......@@ -64,7 +64,7 @@ $smarty->display('artefact:plans:delete.tpl');
// calls this function first so that we can get the artefact and call delete on it
function deleteplanform_submit(Pieform $form, $values) {
global $SESSION, $todelete, $view;
global $SESSION, $USER, $todelete, $view;
$todelete->delete();
$SESSION->add_ok_msg(get_string('plandeletedsuccessfully', 'artefact.plans'));
......
......@@ -31,6 +31,13 @@ else {
$view = null;
}
if ($view && $USER->can_edit_view($view)) {
$returnurl = get_config('wwwroot') . 'view/blocks.php?id=' . $view->get('id');
}
else {
$returnurl = get_config('wwwroot') . '/artefact/plans/plan.php?id=' . $todelete->get('parent');
}
$deleteform = array(
'name' => 'deletetaskform',
'class' => 'form-delete',
......@@ -42,7 +49,7 @@ $deleteform = array(
'type' => 'submitcancel',
'class' => 'btn-default',
'value' => array(get_string('deletetask','artefact.plans'), get_string('cancel')),
'goto' => get_config('wwwroot') . '/artefact/plans/plan.php?id='.$todelete->get('parent'),
'goto' => $returnurl,
),
)
);
......
......@@ -690,6 +690,7 @@ class ArtefactTypeTask extends ArtefactType {
* @return array $tasks The tasks array updated with rendered table html
*/
public function render_tasks(&$tasks, $template, $options, $pagination, $editing=false) {
global $USER;
$smarty = smarty_core();
$smarty->assign('tasks', $tasks);
......@@ -697,6 +698,15 @@ class ArtefactTypeTask extends ArtefactType {
$smarty->assign('view', (!empty($options['view']) ? $options['view'] : null));
$smarty->assign('block', (!empty($options['block']) ? $options['block'] : null));
$smarty->assign('editing', $editing);
if (!empty($options['view'])) {
require_once('view.php');
$view = new View($options['view']);
$owner = $view->get('owner');
if ($owner && $owner == $USER->get('id')) {
$smarty->assign('canedit', true);
}
}
$tasks['tablerows'] = $smarty->fetch($template);
if ($tasks['limit'] && $pagination) {
......
......@@ -10,6 +10,7 @@
*/
define('INTERNAL', 1);
define('PUBLIC', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
......@@ -29,6 +30,7 @@ if ($blockid && !$artefactid) {
json_reply(true, get_string('accessdenied', 'error'));
}
$options = $configdata = $bi->get('configdata');
$options['view'] = $bi->get('view');
// If block sets limit use that instead
$limit = !empty($configdata['count']) ? $configdata['count'] : $limit;
......
......@@ -7,10 +7,10 @@
</div>
<div id="planswrap" class="plan-wrapper view-container">
{if $tags}
<p class="tags">
<div class="tags">
<strong>{str tag=tags}:</strong>
{list_tags owner=$owner tags=$tags}
</p>
</div>
{/if}
{if !$tasks.data}
<div class="no-results">
......
......@@ -9,7 +9,7 @@
{/if}
{if $task->description || $task->tags}<a class="link-block collapsed" href="#expand-task-{$task->id}{if $block}-{$block}{/if}" data-toggle="collapse" aria-expanded="false" aria-controls="expand-task-{$task->id}{if $block}-{$block}{/if}">{/if}
<span class="overdue-task">
<span class="icon icon-times text-danger icon-lg left task{$task->id}" role="presentation" aria-hidden="true" {if $editing}onclick="saveCheckBoxChange(this, '{$task->id}')"{/if}></span>
<span class="icon icon-times text-danger icon-lg left task{$task->id}{if $editing || $canedit} plan-task-icon{/if}" role="presentation" aria-hidden="true" data-task="{$task->id}"></span>
<span class="text-danger">{$task->title}</span> -
<span class="text-small text-midtone">
{str tag='completiondate' section='artefact.plans'}: {$task->completiondate}
......@@ -46,10 +46,10 @@
{if $task->description || $task->tags}<a class="link-block collapsed" href="#expand-task-{$task->id}{if $block}-{$block}{/if}" data-toggle="collapse" aria-expanded="false" aria-controls="expand-task-{$task->id}{if $block}-{$block}{/if}">{/if}
<span class="complete-task">
{if $task->completed == 1}
<span class="icon icon-check-square-o icon-lg text-success left task{$task->id}" role="presentation" aria-hidden="true" {if $editing}onclick="saveCheckBoxChange(this, '{$task->id}')"{/if}></span>
<span class="icon icon-check-square-o icon-lg text-success left task{$task->id}{if $editing || $canedit} plan-task-icon{/if}" role="presentation" aria-hidden="true" data-task="{$task->id}"></span>
<span class="sr-only">{str tag=completed section=artefact.plans}</span>
{else}
<span class="icon-square-o icon icon-lg text-midtone left task{$task->id}" role="presentation" aria-hidden="true" {if $editing}onclick="saveCheckBoxChange(this, '{$task->id}')"{/if}></span>
<span class="icon-square-o icon icon-lg text-midtone left task{$task->id}{if $editing || $canedit} plan-task-icon{/if}" role="presentation" aria-hidden="true" data-task="{$task->id}"></span>
<span class="sr-only">{str tag=incomplete section=artefact.plans}</span>
{/if}
......
{if $tags}<p class="tags"><strong>{str tag=tags}:</strong> {list_tags owner=$owner tags=$tags view=$view}</p>{/if}
<div class="">
{if $tags}<div class="tags"><strong>{str tag=tags}:</strong> {list_tags owner=$owner tags=$tags view=$view}</div>{/if}
<div>
<ul id="tasklist" class="list-group list-unstyled">
{$tasks.tablerows|safe}
</ul>
......
......@@ -19,6 +19,10 @@
.task-item .btn-group {
margin-right: -8px; // correct alignment
a {
font-size: 10px;
padding: 2px 8px;
}
}
.no-results {
......
......@@ -7,6 +7,11 @@
}
}
.panel-body, .panel-secondary {
.tags {
margin-bottom: 10px;
}
}
// Tag result page
.mytags {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment