Merge branch 'MDL-72466-master' of https://github.com/bmbrands/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2022-02-02 12:10:18 +01:00
commit 5aa93e3066
27 changed files with 25 additions and 47 deletions

View File

@ -89,7 +89,6 @@ class presets_list implements renderable, templatable {
$actionsmenu = new \action_menu();
$actionsmenu->set_menu_trigger(get_string('actions'));
$actionsmenu->set_owner_selector('preset-actions-' . $preset->id);
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
$loadlink = new \moodle_url('/admin/tool/admin_presets/index.php', ['action' => 'load', 'id' => $preset->id]);
$actionsmenu->add(new \action_menu_link_secondary(

View File

@ -65,7 +65,7 @@ class models_list implements \renderable, \templatable {
$newmodelmenu = new \action_menu();
$newmodelmenu->set_menu_trigger(get_string('newmodel', 'tool_analytics'), 'btn btn-secondary');
$newmodelmenu->set_alignment(\action_menu::TL, \action_menu::BL);
$newmodelmenu->set_menu_left();
$newmodelmenu->add(new \action_menu_link(
new \moodle_url('/admin/tool/analytics/createmodel.php'),
@ -191,7 +191,6 @@ class models_list implements \renderable, \templatable {
$actionsmenu = new \action_menu();
$actionsmenu->set_menu_trigger(get_string('actions'));
$actionsmenu->set_owner_selector('model-actions-' . $model->get_id());
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
$urlparams = ['id' => $model->get_id(), 'sesskey' => sesskey()];

View File

@ -89,7 +89,6 @@ if (get_config('core', 'allowthemechangeonurl')) {
$thememenu = new action_menu($menuthemes);
$thememenu->set_menu_trigger($PAGE->theme->name, 'nav-link');
$thememenu->set_owner_selector('change-moodle-theme');
$thememenu->set_alignment(\action_menu::TL, \action_menu::BL);
$PAGE->set_headingmenu($OUTPUT->render($thememenu));
}

View File

@ -71,7 +71,6 @@ abstract class crud_element {
$actionmenu = new \action_menu();
$actionmenu->set_menu_trigger(get_string('actions'));
$actionmenu->set_owner_selector($elementname . '-' . $exported->id . '-actions');
$actionmenu->set_alignment(\action_menu::TL, \action_menu::BL);
$url = new \moodle_url('/admin/tool/dataprivacy/edit' . $elementname . '.php',
['id' => $exported->id]);

View File

@ -87,7 +87,6 @@ class data_registry_page implements renderable, templatable {
$actionmenu = new \action_menu();
$actionmenu->set_menu_trigger(get_string('edit'), 'btn btn-primary');
$actionmenu->set_owner_selector('dataregistry-actions');
$actionmenu->set_alignment(\action_menu::TL, \action_menu::BL);
$url = new \moodle_url('/admin/tool/dataprivacy/categories.php');
$categories = new \action_menu_link_secondary($url, null, get_string('categories', 'tool_dataprivacy'));

View File

@ -285,7 +285,6 @@ class data_requests_table extends table_sql {
$actionsmenu = new action_menu($actions);
$actionsmenu->set_menu_trigger(get_string('actions'));
$actionsmenu->set_owner_selector('request-actions-' . $requestid);
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
$actionsmenu->set_constraint('[data-region=data-requests-table] > .no-overflow');
return $OUTPUT->render($actionsmenu);

View File

@ -153,7 +153,6 @@ class my_data_requests_page implements renderable, templatable {
$actionsmenu = new action_menu($actions);
$actionsmenu->set_menu_trigger(get_string('actions'));
$actionsmenu->set_owner_selector('request-actions-' . $requestid);
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
$item->actions = $actionsmenu->export_for_template($output);
}

View File

@ -182,7 +182,6 @@ class page_managedocs_list implements renderable, templatable {
$actionmenu = new action_menu();
$actionmenu->set_menu_trigger(get_string('actions', 'tool_policy'));
$actionmenu->set_alignment(action_menu::TL, action_menu::BL);
$actionmenu->prioritise = true;
if ($moveup) {
$actionmenu->add(new action_menu_link(

View File

@ -77,7 +77,6 @@ $PAGE->set_pagelayout('incourse');
// Create the cog menu with all the secondary actions, such as delete, rename...
$actionmenu = new action_menu();
$actionmenu->set_alignment(action_menu::TR, action_menu::BR);
if ($contenttype->can_manage($content)) {
// Add the visibility item to the menu.
switch($content->get_visibility()) {

View File

@ -125,7 +125,6 @@ class controlmenu implements renderable, templatable {
// Convert control array into an action_menu.
$menu = new action_menu();
$menu->set_alignment(action_menu::TR, action_menu::BR);
$icon = $output->pix_icon('i/menu', get_string('edit'));
$menu->set_menu_trigger($icon, 'btn btn-icon d-flex align-items-center justify-content-center');

View File

@ -253,7 +253,6 @@ class core_course_renderer extends plugin_renderer_base {
$menu = new action_menu();
$menu->set_owner_selector($ownerselector);
$menu->set_constraint($constraint);
$menu->set_alignment(action_menu::TR, action_menu::BR);
$menu->set_menu_trigger(get_string('edit'));
foreach ($actions as $action) {

View File

@ -100,7 +100,6 @@ class management implements renderable, templatable {
}
$menu = new \action_menu();
$menu->set_alignment(\action_menu::BL, \action_menu::BL);
$menu->set_menu_trigger(get_string('createnewcustomfield', 'core_customfield'));
foreach ($fieldtypes as $type => $fieldname) {

View File

@ -129,7 +129,6 @@ class grade_edit_tree {
$actionsmenu = new action_menu();
$actionsmenu->set_menu_trigger(get_string('edit'));
$actionsmenu->set_owner_selector('grade-item-' . $eid);
$actionsmenu->set_alignment(action_menu::TL, action_menu::BL);
if (!$is_category_item && ($icon = $this->gtree->get_edit_icon($element, $this->gpr, true))) {
$actionsmenu->add($icon);
@ -1090,4 +1089,4 @@ class grade_edit_tree_column_select extends grade_edit_tree_column {
return $togglegroup;
}
}
}

View File

@ -81,7 +81,6 @@ class libraries implements renderable, templatable {
// Get the action menu options.
$actionmenu = new action_menu();
$actionmenu->set_menu_trigger(get_string('actions', 'core_h5p'));
$actionmenu->set_alignment(action_menu::TL, action_menu::BL);
$actionmenu->prioritise = true;
$actionmenu->add_primary_action(new action_menu_link(
new moodle_url('/h5p/libraries.php', ['deletelibrary' => $version->id]),

View File

@ -4232,6 +4232,12 @@ class action_menu implements renderable, templatable {
*/
public $prioritise = false;
/**
* Dropdown menu alignment class.
* @var string
*/
public $dropdownalignment = '';
/**
* Constructs the action menu with the given items.
*
@ -4258,7 +4264,7 @@ class action_menu implements renderable, templatable {
'aria-labelledby' => 'action-menu-toggle-'.$this->instance,
'role' => 'menu'
);
$this->set_alignment(self::TR, self::BR);
$this->dropdownalignment = 'dropdown-menu-right';
foreach ($actions as $action) {
$this->add($action);
}
@ -4436,10 +4442,13 @@ class action_menu implements renderable, templatable {
/**
* Sets the alignment of the dialogue in relation to button used to toggle it.
*
* @deprecated since Moodle 4.0
*
* @param int $dialogue One of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.
* @param int $button One of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.
*/
public function set_alignment($dialogue, $button) {
debugging('The method action_menu::set_alignment() is deprecated, use action_menu::set_menu_left()', DEBUG_DEVELOPER);
if (isset($this->attributessecondary['data-align'])) {
// We've already got one set, lets remove the old class so as to avoid troubles.
$class = $this->attributessecondary['class'];
@ -4472,6 +4481,14 @@ class action_menu implements renderable, templatable {
}
}
/**
* Aligns the left corner of the dropdown.
*
*/
public function set_menu_left() {
$this->dropdownalignment = 'dropdown-menu-left';
}
/**
* Sets a constraint for the dialogue.
*
@ -4633,6 +4650,7 @@ class action_menu implements renderable, templatable {
$data->primary = $primary;
$data->secondary = $secondary;
$data->dropdownalignment = $this->dropdownalignment;
return $data;
}

View File

@ -3469,7 +3469,6 @@ EOD;
'nav-link'
);
$am->set_action_label(get_string('usermenu'));
$am->set_alignment(action_menu::TR, action_menu::BR);
$am->set_nowrap_on_items();
if ($withlinks) {
$navitemcount = count($opts->navitems);

View File

@ -33,6 +33,7 @@
],
"secondary": {
"classes": "menu align-tr-br",
"dropdownalignment": "dropdown-menu-right",
"attributes": [
{"name": "id", "value": "action-menu-0-menu"},
{"name": "data-rel", "value": "menu-content"},
@ -92,7 +93,7 @@
{{/menutrigger}}
</a>
{{#secondary}}
<div class="dropdown-menu dropdown-menu-right {{classes}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}}>
<div class="dropdown-menu {{classes}} {{dropdownalignment}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}}>
{{#items}}
{{#actionmenulink}}
{{< core/action_menu_link}}

View File

@ -2,6 +2,8 @@ This files describes API changes in core libraries and APIs,
information provided here is intended especially for developers.
=== 4.0 ===
* The method action_menu->set_alignment() has been deprecated, please use action_menu->set_menu_left if you need a dropdown
to align to the left of the dropdown button.
* The $OUTPUT->should_display_main_logo() function has been deprecated and should no longer be used.
* New method flexible_table::set_columnsattributes() has been introduced to add column attributes applied in every cell.
* New method flexible_table::get_row_cells_html() has been introduced, extracted from flexible_table::get_row_html

View File

@ -1419,7 +1419,6 @@ class assign_grading_table extends table_sql implements renderable {
$menu = new action_menu();
$menu->set_owner_selector('.gradingtable-actionmenu');
$menu->set_alignment(action_menu::TL, action_menu::BL);
$menu->set_constraint('.gradingtable > .no-overflow');
$menu->set_menu_trigger(get_string('edit'));
foreach ($actions as $action) {

View File

@ -450,7 +450,6 @@ class mod_feedback_complete_form extends moodleform {
$menu = new action_menu();
$menu->set_owner_selector('#' . $this->guess_element_id($item, $element));
$menu->set_constraint('.feedback_form');
$menu->set_alignment(action_menu::TR, action_menu::BR);
$menu->set_menu_trigger(get_string('edit'));
$menu->prioritise = true;

View File

@ -592,7 +592,6 @@ class edit_renderer extends \plugin_renderer_base {
return '';
}
$menu = new \action_menu();
$menu->set_alignment(\action_menu::TR, \action_menu::TR);
$menu->set_constraint('.mod-quiz-edit-content');
$trigger = html_writer::tag('span', get_string('add', 'quiz'), array('class' => 'add-menu'));
$menu->set_menu_trigger($trigger);

View File

@ -57,7 +57,6 @@ foreach ($accounts as $account) {
}
$menu = new action_menu();
$menu->set_alignment(action_menu::TL, action_menu::BL);
$menu->set_menu_trigger(get_string('edit'));
if ($canmanage) {
$menu->add(new action_menu_link_secondary($account->get_edit_url(), null, get_string('edit')));

View File

@ -77,7 +77,6 @@ class edit_menu_column extends column_base {
$menu = new \action_menu();
$menu->set_menu_trigger(get_string('edit'));
$menu->set_alignment(\action_menu::TL, \action_menu::BL);
foreach ($this->actions as $actioncolumn) {
$action = $actioncolumn->get_action_menu_link($question);
if ($action) {

View File

@ -17,14 +17,6 @@
background-position: 0.75rem center;
}
/*rtl:raw:
.dropdown-menu {
right: auto;
left: 0;
text-align: right;
}
*/
.dir-rtl .custom-switch .custom-control-input:checked ~ .custom-control-label::after {
transform: translateX(-($custom-switch-width - $custom-control-indicator-size));
}

View File

@ -9847,13 +9847,6 @@ a.text-dark:hover, a.text-dark:focus {
.dir-rtl .custom-select {
background-position: 0.75rem center; }
/*rtl:raw:
.dropdown-menu {
right: auto;
left: 0;
text-align: right;
}
*/
.dir-rtl .custom-switch .custom-control-input:checked ~ .custom-control-label::after {
transform: translateX(-0.9375rem); }

View File

@ -9847,13 +9847,6 @@ a.text-dark:hover, a.text-dark:focus {
.dir-rtl .custom-select {
background-position: 0.75rem center; }
/*rtl:raw:
.dropdown-menu {
right: auto;
left: 0;
text-align: right;
}
*/
.dir-rtl .custom-switch .custom-control-input:checked ~ .custom-control-label::after {
transform: translateX(-0.75rem); }

View File

@ -135,7 +135,6 @@ foreach ($categories as $category) {
// Add new field menu.
$menu = new \action_menu();
$menu->set_alignment(\action_menu::BL, \action_menu::BL);
$menu->set_menu_trigger($strcreatefield);
foreach ($options as $type => $fieldname) {
$action = new \action_menu_link_secondary(new \moodle_url('#'), null, $fieldname,