diff --git a/mod/data/classes/output/view_action_bar.php b/mod/data/classes/output/view_action_bar.php index 351e3e337e2..24c21c451cc 100644 --- a/mod/data/classes/output/view_action_bar.php +++ b/mod/data/classes/output/view_action_bar.php @@ -58,15 +58,12 @@ class view_action_bar implements templatable, renderable { * @return array */ public function export_for_template(\renderer_base $output): array { - global $PAGE, $DB; + global $PAGE; $data = [ 'urlselect' => $this->urlselect->export_for_template($output), ]; - $addentrybutton = new add_entries_action($this->id); - $data['addentrybutton'] = $addentrybutton->export_for_template($output); - if (has_capability('mod/data:manageentries', $PAGE->context)) { $importentrieslink = new moodle_url('/mod/data/import.php', ['d' => $this->id, 'backto' => $PAGE->url->out(false)]); diff --git a/mod/data/classes/output/view_footer.php b/mod/data/classes/output/view_footer.php new file mode 100644 index 00000000000..fe358116810 --- /dev/null +++ b/mod/data/classes/output/view_footer.php @@ -0,0 +1,156 @@ +. + +namespace mod_data\output; + +use action_link; +use core\output\sticky_footer; +use html_writer; +use mod_data\manager; +use mod_data\template; +use moodle_url; +use renderer_base; + +/** + * Renderable class for sticky footer in the view pages of the database activity. + * + * @package mod_data + * @copyright 2022 Ferran Recio + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class view_footer extends sticky_footer { + + /** @var int $totalcount the total records count. */ + private $totalcount; + + /** @var int $currentpage the current page */ + private $currentpage; + + /** @var int $nowperpage the number of elements per page */ + private $nowperpage; + + /** @var moodle_url $baseurl the page base url */ + private $baseurl; + + /** @var template $parser the template name */ + private $parser; + + /** @var manager $manager if the user can manage capabilities or not */ + private $manager; + + /** + * The class constructor. + * + * @param manager $manager the activity manager + * @param int $totalcount the total records count + * @param int $currentpage the current page + * @param int $nowperpage the number of elements per page + * @param moodle_url $baseurl the page base url + * @param template $parser the current template name + */ + public function __construct( + manager $manager, + int $totalcount, + int $currentpage, + int $nowperpage, + moodle_url $baseurl, + template $parser + ) { + $this->manager = $manager; + $this->totalcount = $totalcount; + $this->currentpage = $currentpage; + $this->nowperpage = $nowperpage; + $this->baseurl = $baseurl; + $this->parser = $parser; + } + + /** + * Export this data so it can be used as the context for a mustache template (core/inplace_editable). + * + * @param renderer_base $output typically, the renderer that's calling this function + * @return array data context for a mustache template + */ + public function export_for_template(renderer_base $output) { + $this->set_content( + $this->get_footer_output($output) + ); + return parent::export_for_template($output); + } + + /** + * Generate the pre-rendered footer content. + * + * @param \renderer_base $output The renderer to be used to render the action bar elements. + * @return string the rendered content + */ + public function get_footer_output(renderer_base $output): string { + $data = []; + + $cm = $this->manager->get_coursemodule(); + $instance = $this->manager->get_instance(); + $currentgroup = groups_get_activity_group($cm); + $groupmode = groups_get_activity_groupmode($cm); + $context = $this->manager->get_context(); + $canmanageentries = has_capability('mod/data:manageentries', $context); + $parser = $this->parser; + + // Sticky footer content. + $data['pagination'] = $output->paging_bar( + $this->totalcount, + $this->currentpage, + $this->nowperpage, + $this->baseurl + ); + + if ($parser->get_template_name() != 'singletemplate' && $canmanageentries) { + // Build the select/deselect all control. + $selectallid = 'selectall-listview-entries'; + $togglegroup = 'listview-entries'; + $mastercheckbox = new \core\output\checkbox_toggleall($togglegroup, true, [ + 'id' => $selectallid, + 'name' => $selectallid, + 'value' => 1, + 'label' => get_string('selectall'), + 'classes' => 'btn-secondary mr-1', + ], true); + $data['selectall'] = $output->render($mastercheckbox); + + $data['deleteselected'] = html_writer::empty_tag('input', [ + 'class' => 'btn btn-secondary', + 'type' => 'submit', + 'value' => get_string('deleteselected'), + 'disabled' => true, + 'data-action' => 'toggle', + 'data-togglegroup' => $togglegroup, + 'data-toggle' => 'action', + ]); + } + if (data_user_can_add_entry($instance, $currentgroup, $groupmode, $context)) { + $addentrylink = new moodle_url( + '/mod/data/edit.php', + ['id' => $cm->id, 'backto' => $this->baseurl] + ); + $addentrybutton = new action_link( + $addentrylink, + get_string('add', 'mod_data'), + null, + ['class' => 'btn btn-primary', 'role' => 'button'] + ); + $data['addentrybutton'] = $addentrybutton->export_for_template($output); + } + return $output->render_from_template('mod_data/view_footer', $data); + } +} diff --git a/mod/data/classes/template.php b/mod/data/classes/template.php index fec7402f261..bc5c8a4e618 100644 --- a/mod/data/classes/template.php +++ b/mod/data/classes/template.php @@ -215,6 +215,15 @@ class template { $this->tags = $matches['tags']; } + /** + * Return the current template name. + * + * @return string the template name + */ + public function get_template_name(): string { + return $this->templatename; + } + /** * Generate the list of action icons. * diff --git a/mod/data/edit.php b/mod/data/edit.php index c6adcfe73fa..12b462732b8 100644 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -217,7 +217,9 @@ if (!$rid && ((!$data->maxentries) || ]); } -echo html_writer::div($actionbuttons, 'mdl-align mt-2'); +$stickyfooter = new core\output\sticky_footer($actionbuttons); +echo $OUTPUT->render($stickyfooter); + echo $OUTPUT->box_end(); echo ''; diff --git a/mod/data/field.php b/mod/data/field.php index 156c753d7a2..aebf790d36d 100644 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -70,36 +70,22 @@ if ($action !== '') { } if ($id) { - $url->param('id', $id); - $PAGE->set_url($url); - if (! $cm = get_coursemodule_from_id('data', $id)) { - throw new \moodle_exception('invalidcoursemodule'); - } - if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { - throw new \moodle_exception('coursemisconf'); - } - if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { - throw new \moodle_exception('invalidcoursemodule'); - } - -} else { + list($course, $cm) = get_course_and_cm_from_cmid($id, manager::MODULE); + $manager = manager::create_from_coursemodule($cm); + $url->param('id', $cm->id); +} else { // We must have $d. + $instance = $DB->get_record('data', ['id' => $d], '*', MUST_EXIST); + $manager = manager::create_from_instance($instance); + $cm = $manager->get_coursemodule(); + $course = get_course($cm->course); $url->param('d', $d); - $PAGE->set_url($url); - if (! $data = $DB->get_record('data', array('id'=>$d))) { - throw new \moodle_exception('invalidid', 'data'); - } - if (! $course = $DB->get_record('course', array('id'=>$data->course))) { - throw new \moodle_exception('invalidcoursemodule'); - } - if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - throw new \moodle_exception('invalidcoursemodule'); - } } -require_login($course, true, $cm); - -$manager = manager::create_from_coursemodule($cm); +$PAGE->set_url($url); +$data = $manager->get_instance(); $context = $manager->get_context(); + +require_login($course, true, $cm); require_capability('mod/data:managetemplates', $context); $formimportzip = new data_import_preset_zip_form(); @@ -438,8 +424,11 @@ if (($mode == 'new') && (!empty($newtype))) { // Adding a new field. echo ''; echo ''; echo ''; - echo ''; + // Add a sticky footer. + echo $renderer->render_fields_footer($manager); + + echo ''; } /// Finish the page diff --git a/mod/data/lang/en/data.php b/mod/data/lang/en/data.php index 9ceef0f8d69..7f5a3157da4 100644 --- a/mod/data/lang/en/data.php +++ b/mod/data/lang/en/data.php @@ -388,7 +388,6 @@ $string['savedataaspreset'] = 'Save all fields and templates as preset'; $string['saveaspresetmissingcapability'] = 'The user does not have permission to save the database as a preset.'; $string['savesettings'] = 'Save settings'; $string['savesuccess'] = 'Preset saved. Preview preset'; -$string['savetemplate'] = 'Save template'; $string['search'] = 'Search'; $string['search:activity'] = 'Database - activity information'; $string['search:entry'] = 'Database - entries'; @@ -441,6 +440,7 @@ $string['usestandard'] = 'Use a preset'; $string['usestandard_help'] = 'To use a preset available to the whole site, select it from the list. (If you have added a preset to the list using the save as preset feature then you have the option of deleting it.)'; $string['viewfromdate'] = 'Read only from'; $string['viewnavigation'] = 'View mode tertiary navigation'; +$string['viewtemplates'] = 'View templates'; $string['viewtodate'] = 'Read only to'; $string['viewtodatevalidation'] = 'The read only to date cannot be before the read only from date.'; $string['wrongdataid'] = 'Wrong data id provided'; @@ -453,3 +453,4 @@ $string['buttons'] = 'Actions'; $string['nolisttemplate'] = 'List template is not yet defined'; $string['nosingletemplate'] = 'Single template is not yet defined'; $string['blank'] = 'Blank'; +$string['savetemplate'] = 'Save template'; diff --git a/mod/data/lang/en/deprecated.txt b/mod/data/lang/en/deprecated.txt index 97fed034dc5..1963b0c3b2b 100644 --- a/mod/data/lang/en/deprecated.txt +++ b/mod/data/lang/en/deprecated.txt @@ -3,3 +3,4 @@ buttons,mod_data nosingletemplate,mod_data nolisttemplate,mod_data blank,mod_data +savetemplate,mod_data diff --git a/mod/data/lib.php b/mod/data/lib.php index 9643740463f..38bded24798 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -406,25 +406,36 @@ class data_field_base { // Base class for Database Field Types (see field/*/ echo ''."\n"; if (empty($this->field->id)) { echo ''."\n"; - $savebutton = get_string('add'); } else { echo ''."\n"; echo ''."\n"; - $savebutton = get_string('savechanges'); } echo ''."\n"; echo ''."\n"; echo $OUTPUT->heading($this->name(), 3); - require_once($CFG->dirroot.'/mod/data/field/'.$this->type.'/mod.html'); + $modpath = $CFG->dirroot . '/mod/data/field/' . $this->type . '/mod.html'; + if (file_exists($modpath)) { + require_once($modpath); + } - echo html_writer::start_div('mt-3'); - echo html_writer::tag('input', null, array('type' => 'submit', 'value' => $savebutton, - 'class' => 'btn btn-primary')); - echo html_writer::tag('input', null, array('type' => 'submit', 'name' => 'cancel', - 'value' => get_string('cancel'), 'class' => 'btn btn-secondary ml-2')); - echo html_writer::end_div(); + $actionbuttons = html_writer::start_div(); + $actionbuttons .= html_writer::tag('input', null, [ + 'type' => 'submit', + 'name' => 'cancel', + 'value' => get_string('cancel'), + 'class' => 'btn btn-secondary mr-2' + ]); + $actionbuttons .= html_writer::tag('input', null, [ + 'type' => 'submit', + 'value' => get_string('save'), + 'class' => 'btn btn-primary' + ]); + $actionbuttons .= html_writer::end_div(); + + $stickyfooter = new core\output\sticky_footer($actionbuttons); + echo $OUTPUT->render($stickyfooter); echo ''; diff --git a/mod/data/renderer.php b/mod/data/renderer.php index 70dbbbcf631..42340dda612 100644 --- a/mod/data/renderer.php +++ b/mod/data/renderer.php @@ -1,6 +1,29 @@ . + +/** + * Database activity renderer. + * + * @copyright 2010 Sam Hemelryk + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod_data + */ use mod_data\local\importer\preset_existing_importer; +use mod_data\manager; defined('MOODLE_INTERNAL') || die(); @@ -33,7 +56,6 @@ class mod_data_renderer extends plugin_renderer_base { */ public function importing_preset(stdClass $datamodule, \mod_data\local\importer\preset_importer $importer): string { - $strcontinue = get_string('continue'); $strwarning = get_string('mappingwarning', 'data'); $strfieldmappings = get_string('fieldmappings', 'data'); @@ -99,7 +121,23 @@ class mod_data_renderer extends plugin_renderer_base { $attrs = array('type' => 'checkbox', 'name' => 'overwritesettings', 'id' => 'overwritesettings', 'class' => 'ml-1'); $html .= html_writer::empty_tag('input', $attrs); $html .= html_writer::end_tag('div'); - $html .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-primary', 'value' => $strcontinue)); + + $actionbuttons = html_writer::start_div(); + $cancelurl = new moodle_url('/mod/data/preset.php', ['d' => $datamodule->id]); + $actionbuttons .= html_writer::tag('a', get_string('cancel') , [ + 'href' => $cancelurl->out(false), + 'class' => 'btn btn-secondary mr-2', + 'role' => 'button', + ]); + $actionbuttons .= html_writer::empty_tag('input', [ + 'type' => 'submit', + 'class' => 'btn btn-primary', + 'value' => get_string('continue'), + ]); + $actionbuttons .= html_writer::end_div(); + + $stickyfooter = new core\output\sticky_footer($actionbuttons); + $html .= $this->render($stickyfooter); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); @@ -119,6 +157,20 @@ class mod_data_renderer extends plugin_renderer_base { return $this->render_from_template('mod_data/fields_action_bar', $data); } + /** + * Renders the fields page footer. + * + * @param manager $manager the instance manager + * @return string The HTML output + */ + public function render_fields_footer(manager $manager): string { + $cm = $manager->get_coursemodule(); + $pageurl = new moodle_url('/mod/data/templates.php', ['id' => $cm->id]); + return $this->render_from_template('mod_data/fields_footer', [ + 'pageurl' => $pageurl->out(false), + ]); + } + /** * Renders the action bar for the view page. * diff --git a/mod/data/templates/action_bar.mustache b/mod/data/templates/action_bar.mustache index 70f94b45f33..54e2f09fb0b 100644 --- a/mod/data/templates/action_bar.mustache +++ b/mod/data/templates/action_bar.mustache @@ -50,9 +50,9 @@ "title": null }, "extraurlselect": { - "id": "url_select_test", + "id": "extra_url_select_test", "action": "https://example.com/post", - "formid": "url_select_form", + "formid": "extra_url_select_form", "sesskey": "sesskey", "classes": "urlselect", "label": "", diff --git a/mod/data/templates/fields_footer.mustache b/mod/data/templates/fields_footer.mustache new file mode 100644 index 00000000000..c0ad4ae2f14 --- /dev/null +++ b/mod/data/templates/fields_footer.mustache @@ -0,0 +1,31 @@ +{{! + This file is part of Moodle - http://moodle.org/ + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template mod_data/fields_footer + + The mod_data fields sticky footer content. + + Example context (json): + { + "pageurl": "http://yoursite/mod/data/field.php" + } +}} +{{< core/sticky_footer }} + {{$ stickyclasses }} justify-content-start{{/ stickyclasses }} + {{$ stickycontent }} + + {{/ stickycontent }} +{{/ core/sticky_footer }} diff --git a/mod/data/templates/preset_preview.mustache b/mod/data/templates/preset_preview.mustache index 1ef948d6c29..8b4a0dda2d4 100644 --- a/mod/data/templates/preset_preview.mustache +++ b/mod/data/templates/preset_preview.mustache @@ -34,10 +34,14 @@ {{{preview}}} -
- - - - - -
+{{< core/sticky_footer }} + {{$ stickycontent }} +
+ + + + + +
+ {{/ stickycontent }} +{{/ core/sticky_footer }} diff --git a/mod/data/templates/presets.mustache b/mod/data/templates/presets.mustache index ccc9f5fcdd5..0df8adc93b6 100644 --- a/mod/data/templates/presets.mustache +++ b/mod/data/templates/presets.mustache @@ -86,7 +86,17 @@ - + {{< core/sticky_footer }} + {{$ stickycontent }} + + {{/ stickycontent }} + {{/ core/sticky_footer }} {{#js}} diff --git a/mod/data/templates/template_editor.mustache b/mod/data/templates/template_editor.mustache index 3272e54a69e..e272a08ec1a 100644 --- a/mod/data/templates/template_editor.mustache +++ b/mod/data/templates/template_editor.mustache @@ -93,22 +93,9 @@ {{/editors}} + {{#disableeditor}}
-
- - -
- {{#disableeditor}}
- {{/disableeditor}}
+ {{/disableeditor}} + {{< core/sticky_footer }} + {{$ stickycontent }} +
+ + +
+ {{/ stickycontent }} + {{/ core/sticky_footer }} diff --git a/mod/data/templates/view_footer.mustache b/mod/data/templates/view_footer.mustache new file mode 100644 index 00000000000..755cc569cf3 --- /dev/null +++ b/mod/data/templates/view_footer.mustache @@ -0,0 +1,52 @@ +{{! + This file is part of Moodle - http://moodle.org/ + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template mod_data/view_footer + + The mod_data sticky footer content. + + Example context (json): + { + "selectall": "", + "deleteselected": "", + "pagination": "1, 2, 3...", + "addentrybutton": { + "disabled": false, + "url": "#", + "id": "test-id", + "classes": "btn btn-link", + "attributes": [ + { + "name": "title", + "value": "Add entry" + } + ], + "text": "Add" + } + } +}} +{{#selectall}} + +{{/selectall}} + +{{#addentrybutton}} + +{{/addentrybutton}} diff --git a/mod/data/tests/behat/actionsmenu_replacement.feature b/mod/data/tests/behat/actionsmenu_replacement.feature index 0f13e265b5a..62596ea2b9c 100644 --- a/mod/data/tests/behat/actionsmenu_replacement.feature +++ b/mod/data/tests/behat/actionsmenu_replacement.feature @@ -40,11 +40,11 @@ Feature: Users can add the ##actionsmenu## replacement to the database templates | Header | | | Repeated entry | | | Footer |
[[field1]]##actionsmenu##
| - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" And I set the field "Templates tertiary navigation" to "Single template" And I set the following fields to these values: | Single template |
[[field1]][[field2]]##actionsmenu##
| - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" @javascript Scenario: The ##actionsmenu## replacement displays the expected actions with default settings depending on the user permissions diff --git a/mod/data/tests/behat/behat_mod_data.php b/mod/data/tests/behat/behat_mod_data.php index 0a935d08d9d..98b65434223 100644 --- a/mod/data/tests/behat/behat_mod_data.php +++ b/mod/data/tests/behat/behat_mod_data.php @@ -62,7 +62,7 @@ class behat_mod_data extends behat_base { } $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $fielddata); - $this->execute('behat_forms::press_button', get_string('add')); + $this->execute('behat_forms::press_button', get_string('save')); } /** diff --git a/mod/data/tests/behat/default_templates.feature b/mod/data/tests/behat/default_templates.feature index ec63a4bd083..bec93cb6857 100644 --- a/mod/data/tests/behat/default_templates.feature +++ b/mod/data/tests/behat/default_templates.feature @@ -131,7 +131,7 @@ Feature: Users can use mod_data without editing the templates | Header | New header! | | Repeated entry | This is the template content | | Footer | New footer! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" And I navigate to "Database" in current page administration And I should see "New header!" And I should see "This is the template content" @@ -139,7 +139,7 @@ Feature: Users can use mod_data without editing the templates And I should not see "Student entry 1" And I should not see "Some content 1" When I navigate to "Templates" in current page administration - And I click on "Reset template" "button" + And I click on "Reset" "button" in the "sticky-footer" "region" And I click on "Reset template" "button" in the "Reset template?" "dialogue" And I should see "Template reset" And I navigate to "Database" in current page administration diff --git a/mod/data/tests/behat/edit_templates.feature b/mod/data/tests/behat/edit_templates.feature index bf263616583..ae5a76d3a18 100644 --- a/mod/data/tests/behat/edit_templates.feature +++ b/mod/data/tests/behat/edit_templates.feature @@ -33,7 +33,7 @@ Feature: Users can edit the database templates | Header | New header! | | Repeated entry | [[field1]] and [[field2]]! | | Footer | New footer! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" When I navigate to "Database" in current page administration Then I should see "New header!" And I should see "Student entry 1 and Some content 1!" @@ -44,7 +44,7 @@ Feature: Users can edit the database templates Given I set the field "Templates tertiary navigation" to "Single template" And I set the following fields to these values: | Single template | [[field1]] and [[field2]] details! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" When I navigate to "Database" in current page administration And I set the field "View mode tertiary navigation" to "Single view" Then I should see "Student entry 1 and Some content 1 details!" @@ -54,7 +54,7 @@ Feature: Users can edit the database templates Given I set the field "Templates tertiary navigation" to "Add entry template" And I set the following fields to these values: | Add entry template | [[field1]] [[field2]] Form extra! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" When I navigate to "Database" in current page administration And I click on "Add entry" "button" Then I should see "Form extra!" @@ -64,7 +64,7 @@ Feature: Users can edit the database templates Given I set the field "Templates tertiary navigation" to "Advanced search template" And I set the following fields to these values: | Advanced search template | New advanced search template! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" When I navigate to "Database" in current page administration And I click on "Advanced search" "checkbox" Then I should see "New advanced search template!" @@ -74,7 +74,7 @@ Feature: Users can edit the database templates Given I click on "Enable editor" "checkbox" And I set the following fields to these values: | Repeated entry | NopeYep! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" When I navigate to "Database" in current page administration Then I should not see "Nope" And I should see "Yep!" @@ -84,11 +84,11 @@ Feature: Users can edit the database templates Given I click on "Enable editor" "checkbox" And I set the following fields to these values: | Repeated entry | NopeYep! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" And I set the field "Templates tertiary navigation" to "CSS template" And I set the following fields to these values: | CSS template | .hideme {display: none;} | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" When I navigate to "Database" in current page administration Then I should not see "Nope" And I should see "Yep!" @@ -98,11 +98,11 @@ Feature: Users can edit the database templates Given I click on "Enable editor" "checkbox" And I set the following fields to these values: | Repeated entry | NopeYep! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" And I set the field "Templates tertiary navigation" to "Javascript template" And I set the following fields to these values: | Javascript template | window.onload = () => document.querySelector('#hideme').style.display = 'none'; | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" When I navigate to "Database" in current page administration Then I should not see "Nope" And I should see "Yep!" @@ -113,7 +113,7 @@ Feature: Users can edit the database templates | Header | New header! | | Repeated entry | This is the template content | | Footer | New footer! | - And I click on "Save template" "button" + And I click on "Save" "button" in the "sticky-footer" "region" And I navigate to "Database" in current page administration And I should see "New header!" And I should see "This is the template content" @@ -121,7 +121,7 @@ Feature: Users can edit the database templates And I should not see "Student entry 1" And I should not see "Some content 1" When I navigate to "Templates" in current page administration - And I click on "Reset template" "button" + And I click on "Reset" "button" in the "sticky-footer" "region" And I click on "Reset template" "button" in the "Reset template?" "dialogue" Then I should see "Template reset" And I navigate to "Database" in current page administration diff --git a/mod/data/view.php b/mod/data/view.php index 88ef0fd6e90..f4caf7355fc 100644 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -217,8 +217,8 @@ if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) { $urlediting = 'on'; $strediting = get_string('blocksediton'); } - $url = new moodle_url($CFG->wwwroot.'/mod/data/view.php', array('id' => $cm->id, 'edit' => $urlediting)); - $PAGE->set_button($OUTPUT->single_button($url, $strediting)); + $editurl = new moodle_url($CFG->wwwroot.'/mod/data/view.php', ['id' => $cm->id, 'edit' => $urlediting]); + $PAGE->set_button($OUTPUT->single_button($editurl, $strediting)); } if ($mode == 'asearch') { @@ -426,8 +426,8 @@ if ($showactivity) { } else { // We have some records to print. - $url = new moodle_url('/mod/data/view.php', array('d' => $data->id, 'sesskey' => sesskey())); - echo html_writer::start_tag('form', array('action' => $url, 'method' => 'post')); + $formurl = new moodle_url('/mod/data/view.php', ['d' => $data->id, 'sesskey' => sesskey()]); + echo html_writer::start_tag('form', ['action' => $formurl, 'method' => 'post']); if ($maxcount != $totalcount) { $a = new stdClass(); @@ -447,7 +447,6 @@ if ($showactivity) { $baseurlparams['page'] = $page; } $baseurl = new moodle_url($baseurl, $baseurlparams); - echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl); require_once($CFG->dirroot.'/rating/lib.php'); if ($data->assessed != RATING_AGGREGATE_NONE) { @@ -474,10 +473,8 @@ if ($showactivity) { ]; $parser = $manager->get_template('singletemplate', $options); echo $parser->parse_entries($records); - - echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl); - - } else { // List template + } else { + // List template. $baseurl = '/mod/data/view.php'; $baseurlparams = ['d' => $data->id, 'advanced' => $advanced, 'paging' => $paging]; if (!empty($search)) { @@ -485,8 +482,6 @@ if ($showactivity) { } $baseurl = new moodle_url($baseurl, $baseurlparams); - echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl); - echo $data->listtemplateheader; $options = [ 'search' => $search, @@ -497,34 +492,17 @@ if ($showactivity) { echo $parser->parse_entries($records); echo $data->listtemplatefooter; - - echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl->out()); } - if ($mode != 'single' && $canmanageentries) { - // Build the select/deselect all control. - $selectallid = 'selectall-listview-entries'; - $togglegroup = 'listview-entries'; - $mastercheckbox = new \core\output\checkbox_toggleall($togglegroup, true, [ - 'id' => $selectallid, - 'name' => $selectallid, - 'value' => 1, - 'label' => get_string('selectall'), - 'classes' => 'btn-secondary mr-1', - ], true); - echo $OUTPUT->render($mastercheckbox); - - $deleteselected = html_writer::empty_tag('input', array( - 'class' => 'btn btn-secondary', - 'type' => 'submit', - 'value' => get_string('deleteselected'), - 'disabled' => true, - 'data-action' => 'toggle', - 'data-togglegroup' => $togglegroup, - 'data-toggle' => 'action', - )); - echo $deleteselected; - } + $stickyfooter = new mod_data\output\view_footer( + $manager, + $totalcount, + $page, + $nowperpage, + $baseurl, + $parser + ); + echo $OUTPUT->render($stickyfooter); echo html_writer::end_tag('form'); }