Skip to content

Commit

Permalink
Merge branch 'MDL-80192-402' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_402_STABLE
  • Loading branch information
junpataleta committed Jan 12, 2024
2 parents 32d33c7 + 3aac83e commit af8d6ce
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 13 deletions.
1 change: 1 addition & 0 deletions lang/en/form.php
Expand Up @@ -50,6 +50,7 @@
$string['filetypesnotallowed'] = 'These file types are not allowed here: {$a}';
$string['filetypesothers'] = 'Other files';
$string['filetypesunknown'] = 'Unknown file types: {$a}';
$string['formactions'] = 'Form actions';
$string['general'] = 'General';
$string['hideadvanced'] = 'Hide advanced';
$string['hour'] = 'Hour';
Expand Down
12 changes: 12 additions & 0 deletions lib/form/group.php
Expand Up @@ -46,6 +46,9 @@ class MoodleQuickForm_group extends HTML_QuickForm_group implements templatable
/** @var string html for help button, if empty then no help */
var $_helpbutton='';

/** @var bool if true label will be hidden. */
protected $_hiddenLabel = false;

/** @var MoodleQuickForm */
protected $_mform = null;

Expand Down Expand Up @@ -104,6 +107,15 @@ function getElementTemplateType(){
}
}

/**
* Sets label to be hidden
*
* @param bool $hiddenLabel sets if label should be hidden
*/
public function setHiddenLabel($hiddenLabel) {
$this->_hiddenLabel = $hiddenLabel;
}

/**
* Sets the grouped elements and hides label
*
Expand Down
4 changes: 4 additions & 0 deletions lib/form/upgrade.txt
@@ -1,6 +1,10 @@
This files describes API changes in core_form libraries and APIs,
information provided here is intended especially for developers.

=== 4.2.6 ===

* New method `setHiddenLabel` added to the group form element type

=== 4.2.4 ===

* The group element has a new method `getAttributesForFormElement` which should be used in conjunction
Expand Down
5 changes: 3 additions & 2 deletions reportbuilder/classes/form/condition.php
Expand Up @@ -146,9 +146,10 @@ protected function definition() {
$buttons = [];
$buttons[] = $mform->createElement('submit', 'submitbutton', get_string('apply', 'core_reportbuilder'));
$buttons[] = $mform->createElement('submit', 'resetconditions', get_string('resetall', 'core_reportbuilder'),
null, null, ['customclassoverride' => 'btn-link']);
null, null, ['customclassoverride' => 'btn-link ml-1']);

$mform->addGroup($buttons, 'buttonar', '', [' '], false);
$mform->addGroup($buttons, 'buttonar', get_string('formactions', 'core_form'), '', false)
->setHiddenLabel(true);
$mform->closeHeaderBefore('buttonar');

$mform->disable_form_change_checker();
Expand Down
5 changes: 3 additions & 2 deletions reportbuilder/classes/form/filter.php
Expand Up @@ -149,9 +149,10 @@ protected function definition() {
$buttons = [];
$buttons[] = $mform->createElement('submit', 'submitbutton', get_string('apply', 'core_reportbuilder'));
$buttons[] = $mform->createElement('submit', 'resetfilters', get_string('resetall', 'core_reportbuilder'),
null, null, ['customclassoverride' => 'btn-link']);
null, null, ['customclassoverride' => 'btn-link ml-1']);

$mform->addGroup($buttons, 'buttonar', '', [' '], false);
$mform->addGroup($buttons, 'buttonar', get_string('formactions', 'core_form'), '', false)
->setHiddenLabel(true);
$mform->closeHeaderBefore('buttonar');

$mform->disable_form_change_checker();
Expand Down
3 changes: 2 additions & 1 deletion reportbuilder/classes/local/filters/date.php
Expand Up @@ -143,7 +143,8 @@ public function setup_form(MoodleQuickForm $mform): void {
$mform->hideIf("{$this->name}_unit", "{$this->name}_operator", 'in', $typesnounit);

// Add operator/value/unit group.
$mform->addGroup($elements, "{$this->name}_group", '', '', false);
$mform->addGroup($elements, "{$this->name}_group", $this->get_header(), '', false)
->setHiddenLabel(true);

// Date selectors for range operator.
$mform->addElement('date_selector', "{$this->name}_from", get_string('filterdatefrom', 'core_reportbuilder'),
Expand Down
3 changes: 2 additions & 1 deletion reportbuilder/classes/local/filters/duration.php
Expand Up @@ -95,7 +95,8 @@ public function setup_form(MoodleQuickForm $mform): void {
$mform->setDefault("{$this->name}_unit", 1);
$mform->hideIf("{$this->name}_unit", "{$this->name}_operator", 'eq', self::DURATION_ANY);

$mform->addGroup($elements, "{$this->name}_group", '', '', false);
$mform->addGroup($elements, "{$this->name}_group", $this->get_header(), '', false)
->setHiddenLabel(true);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions reportbuilder/classes/local/filters/number.php
Expand Up @@ -93,16 +93,16 @@ public function setup_form(\MoodleQuickForm $mform): void {
get_string('filterfieldvalue', 'core_reportbuilder', $this->get_header()), ['size' => 3]);
$mform->setType($this->name . '_value1', PARAM_INT);
$mform->setDefault($this->name . '_value1', 0);
$mform->hideIf($this->name . '_value1', $this->name . '_operator', 'in',
[self::ANY_VALUE, self::IS_NOT_EMPTY, self::IS_EMPTY]);

$objs['text2'] = $mform->createElement('text', $this->name . '_value2', get_string('to'), ['size' => 3]);
$mform->setType($this->name . '_value2', PARAM_INT);
$mform->setDefault($this->name . '_value2', 0);

$mform->addElement('group', $this->name . '_grp', '', $objs, '', false);

$mform->hideIf($this->name . '_value1', $this->name . '_operator', 'in',
[self::ANY_VALUE, self::IS_NOT_EMPTY, self::IS_EMPTY]);
$mform->hideIf($this->name . '_value2', $this->name . '_operator', 'noteq', self::RANGE);

$mform->addGroup($objs, $this->name . '_grp', $this->get_header(), '', false)
->setHiddenLabel(true);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion reportbuilder/classes/local/filters/select.php
Expand Up @@ -84,7 +84,8 @@ public function setup_form(MoodleQuickForm $mform): void {
$elements['value'] = $mform->createElement($element, $this->name . '_value',
get_string('filterfieldvalue', 'core_reportbuilder', $this->get_header()), $options);

$mform->addElement('group', $this->name . '_group', '', $elements, '', false);
$mform->addGroup($elements, $this->name . '_group', $this->get_header(), '', false)
->setHiddenLabel(true);

$mform->hideIf($this->name . '_value', $this->name . '_operator', 'eq', self::ANY_VALUE);
}
Expand Down
3 changes: 2 additions & 1 deletion reportbuilder/classes/local/filters/text.php
Expand Up @@ -92,7 +92,8 @@ public function setup_form(\MoodleQuickForm $mform): void {
$elements['value'] = $mform->createElement('text', $this->name . '_value',
get_string('filterfieldvalue', 'core_reportbuilder', $this->get_header()));

$mform->addElement('group', $this->name . '_group', '', $elements, '', false);
$mform->addGroup($elements, $this->name . '_group', $this->get_header(), '', false)
->setHiddenLabel(true);

$mform->setType($this->name . '_value', PARAM_RAW);
$mform->hideIf($this->name . '_value', $this->name . '_operator', 'eq', self::ANY_VALUE);
Expand Down

0 comments on commit af8d6ce

Please sign in to comment.