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

Bug 1501052: Plan block option to restrict tasks via config form



Instead of only allowing pagination by 10 item we can specify how many
tasks to display/paginate by

Change-Id: Id3532bffce8912eb017069cc34f5e7ed1c3b924f
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 1f06f998
......@@ -18,3 +18,4 @@ $string['newerplans'] = 'Newer plans';
$string['noplansaddone'] = 'No plans yet. %sAdd one%s!';
$string['olderplans'] = 'Older plans';
$string['planstoshow'] = 'Plan to show';
$string['taskstodisplay'] = 'Tasks to display';
\ No newline at end of file
......@@ -55,11 +55,12 @@ class PluginBlocktypePlans extends PluginBlocktype {
safe_require('artefact','plans');
$configdata = $instance->get('configdata');
$limit = (!empty($configdata['count'])) ? $configdata['count'] : 10;
$smarty = smarty_core();
if (isset($configdata['artefactid'])) {
$plan = artefact_instance_from_id($configdata['artefactid']);
$tasks = ArtefactTypeTask::get_tasks($configdata['artefactid']);
$tasks = ArtefactTypeTask::get_tasks($configdata['artefactid'], 0, $limit);
$template = 'artefact:plans:taskrows.tpl';
$blockid = $instance->get('id');
if ($exporter) {
......@@ -107,6 +108,12 @@ class PluginBlocktypePlans extends PluginBlocktype {
// Which resume field does the user want
$form[] = self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null);
$form['count'] = array(
'type' => 'text',
'title' => get_string('taskstodisplay', 'blocktype.plans/plans'),
'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 10,
'size' => 3,
);
return $form;
}
......
......@@ -26,7 +26,8 @@ if ($blockid = param_integer('block', null)) {
json_reply(true, get_string('accessdenied', 'error'));
}
$options = $configdata = $bi->get('configdata');
// If block sets limit use that instead
$limit = !empty($configdata['count']) ? $configdata['count'] : $limit;
$tasks = ArtefactTypeTask::get_tasks($configdata['artefactid'], $offset, $limit);
$template = 'artefact:plans:taskrows.tpl';
......
......@@ -97,7 +97,10 @@ Scenario: Creating a plan with 11 tasks
And I press "Add"
And I set the following fields to these values:
| Plan 9 from outer space | 1 |
| Tasks to display | 5 |
And I press "Save"
And I follow "Display page"
And I follow "Next page"
Then I should see "Build utopia"
And I follow "Next page"
Then I should see "Social collapse"
\ No newline at end of file
Markdown is supported
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