Commit 7688a676 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

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

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