diff --git a/classes/view/base.php b/classes/view/base.php index da9f0e10..e0f92b29 100644 --- a/classes/view/base.php +++ b/classes/view/base.php @@ -111,7 +111,7 @@ abstract class base { * when just displaying the view. * @var bool */ - protected bool $entriesprocessedsuccessfully = false; + public bool $entriesprocessedsuccessfully = false; /** * Constructor @@ -164,19 +164,15 @@ public function __construct($df = 0, $view = 0, $filteroptions = true) { // Set editors and patterns. $this->set__editors(); $this->set__patterns(); - $this->set_filter($filteroptions, $this->is_forcing_filter()); // If filter is forced ignore URL parameters. // Base url params. $baseurlparams = array(); $baseurlparams['d'] = $this->_df->id(); $baseurlparams['view'] = $this->id(); - $baseurlparams['filter'] = $this->_filter->id; if (!empty($eids)) { $baseurlparams['eids'] = $eids; } - if ($this->_filter->page) { - $baseurlparams['page'] = $this->_filter->page; - } + if ($this->_df->currentgroup) { $baseurlparams['currentgroup'] = $this->_df->currentgroup; } @@ -191,10 +187,10 @@ public function __construct($df = 0, $view = 0, $filteroptions = true) { $this->_baseurl = new moodle_url("/mod/datalynx/{$this->_df->pagefile()}.php", $baseurlparams); $this->set_filter($filteroptions, $this->is_forcing_filter()); // If filter is forced ignore URL parameters. + $this->_baseurl->param('filter', $this->_filter->id); if ($this->_filter->page) { $this->_baseurl->param('page', $this->_filter->page); } - $this->_baseurl->param('filter', $this->_filter->id); $this->set_groupby_per_page(); require_once("$CFG->dirroot/mod/datalynx/entries_class.php"); @@ -641,7 +637,7 @@ public function display(array $options = []): string { } else if ($this->_entries->get_count()) { // Entries have been updated or added. if ($this->entriesprocessedsuccessfully) { - $redirectid = $this->_redirect ? $this->_redirect : $this->id(); + $redirectid = $this->_redirect ?: $this->id(); $url = new moodle_url($this->_baseurl, array('view' => $redirectid)); $output = $notifications . $OUTPUT->continue_button($url); } else { @@ -1594,8 +1590,8 @@ public function process_entries_data() { $this->_entries->set_content(); } - // Set the display definition for the form. - $this->_editentries = explode(',', $update); + // Set the display definition for the form. Cast $update to string because PHP has a problem exploding -1 integer. + $this->_editentries = explode(',', (string) $update); $this->set__display_definition(); $entriesform = $this->get_entries_form(); diff --git a/filter/filter_class.php b/filter/filter_class.php index cc9b2d14..48ba694f 100644 --- a/filter/filter_class.php +++ b/filter/filter_class.php @@ -21,6 +21,9 @@ * @copyright based on the work by 2011 Itamar Tzadok * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +use mod_datalynx\view\base; + defined('MOODLE_INTERNAL') || die(); /** @@ -1367,7 +1370,7 @@ public function get_advanced_filter_form($filter, $view) { /** */ - public function get_customfilter_frontend_form($filter, $view, $customfilter = false) { + public function get_customfilter_frontend_form($filter, base $view, $customfilter = false) { global $CFG; require_once("$CFG->dirroot/mod/datalynx/filter/filter_form.php"); @@ -1396,7 +1399,7 @@ public function get_user_filters_menu($viewid) { /** */ - public function set_user_filter($filterid, $view, $advanced = false, $customfilter = false) { + public function set_user_filter($filterid, base $view, $advanced = false, $customfilter = false) { $df = $this->_df; $dfid = $df->id(); $viewid = $view->id(); diff --git a/tests/behat/customfilter_multiselect.feature b/tests/behat/customfilter_multiselect.feature index c81a60a8..471a6ac4 100644 --- a/tests/behat/customfilter_multiselect.feature +++ b/tests/behat/customfilter_multiselect.feature @@ -45,8 +45,7 @@ Feature: Create entry, add multiselect and use customfilter # Make customfilter visible in view. When I follow "Views" - And I click on "//table/tbody/tr[1]/td[9]/a" "xpath_element" - Then I should see "Gridview" + And I click on "Edit Gridview" "link" And I click on "View template" "link" Then I add to "id_esection_editor" editor the text ". ##addnewentry## ##customfilter:mycustomfilter## ##entries## ." And I press "Save changes" @@ -61,6 +60,7 @@ Feature: Create entry, add multiselect and use customfilter And I click on "Opt4" item in the autocomplete list And I click on "Opt5" item in the autocomplete list And I press "Save changes" + And I wait until the page is ready And I should see "1 entry(s) updated" Then I press "Continue" @@ -68,6 +68,7 @@ Feature: Create entry, add multiselect and use customfilter And I fill in the entry form fields | type | name | value | | text | Text | testtext2 | + And I open the autocomplete suggestions list And I click on "Opt2" item in the autocomplete list And I press "Save changes" And I press "Continue" @@ -76,6 +77,7 @@ Feature: Create entry, add multiselect and use customfilter And I fill in the entry form fields | type | name | value | | text | Text | testtext3 | + And I open the autocomplete suggestions list And I click on "Opt3" item in the autocomplete list And I press "Save changes" And I press "Continue" @@ -84,6 +86,7 @@ Feature: Create entry, add multiselect and use customfilter And I fill in the entry form fields | type | name | value | | text | Text | testtext4 | + And I open the autocomplete suggestions list And I click on "Opt4" item in the autocomplete list And I press "Save changes" And I press "Continue" @@ -98,7 +101,8 @@ Feature: Create entry, add multiselect and use customfilter Then "Opt2" "autocomplete_suggestions" should exist And I click on "Opt2" item in the autocomplete list And I close the autocomplete suggestions list - And I click on "//input[@value = 'Search']" "xpath_element" + And I press the escape key + And I press "id_customsearch" And I should see "Opt2" And I should not see "Opt3" And I should not see "Opt5" @@ -107,7 +111,7 @@ Feature: Create entry, add multiselect and use customfilter And I open the autocomplete suggestions list And I click on "Opt1" item in the autocomplete list And I close the autocomplete suggestions list - And I click on "//input[@value = 'Search']" "xpath_element" + And I press "id_customsearch" And I should see "Opt1" And I should see "Opt2" And I should see "Opt4" @@ -120,7 +124,7 @@ Feature: Create entry, add multiselect and use customfilter And I click on "Opt5" item in the autocomplete list And I close the autocomplete suggestions list And I click on "All selected options have to be part of the entry" "checkbox" - And I click on "//input[@value = 'Search']" "xpath_element" + And I press "id_customsearch" And I should not see "Opt2" And I should not see "testtext2" @@ -139,7 +143,7 @@ Feature: Create entry, add multiselect and use customfilter And I open the autocomplete suggestions list And I click on "Opt1" item in the autocomplete list And I close the autocomplete suggestions list - And I click on "//input[@value = 'Search']" "xpath_element" + And I press "id_customsearch" And I should see "Opt1" And I should see "testtext1" And I should see "Opt4" diff --git a/view/index.php b/view/index.php index 3ea45b12..1ecc6645 100644 --- a/view/index.php +++ b/view/index.php @@ -220,7 +220,8 @@ $viewdescription = shorten_text($view->view->description, 30); $viewedit = html_writer::link( new moodle_url($editbaseurl, $linkparams + array('vedit' => $viewid)), - $OUTPUT->pix_icon('t/edit', $stredit)); + $OUTPUT->pix_icon('t/edit', $stredit . " " . $view->name()), + array('title' => $stredit . " " . $view->name())); $viewduplicate = html_writer::link( new moodle_url($actionbaseurl, $linkparams + array('duplicate' => $viewid)), $OUTPUT->pix_icon('t/copy', $strduplicate)); diff --git a/view/view_patterns.php b/view/view_patterns.php index 96181ed0..eeab9268 100644 --- a/view/view_patterns.php +++ b/view/view_patterns.php @@ -348,6 +348,10 @@ protected function get_userpref_replacements($tag, array $options = null) { case '##advancedfilter##': return $this->print_advanced_filter($filter, true); } + // When we just updated an entry, only a continue button is shown, so do not display the form. + if ($this->_view->entriesprocessedsuccessfully) { + return ''; + } if (strpos($tag, '##customfilter') !== false && empty($view->user_is_editing())) { return $this->print_custom_filter($tag, true); }