Skip to content

Commit

Permalink
MDL-76358 mod_data: Add options to preset menu
Browse files Browse the repository at this point in the history
* Add "Preview" and "Use this preset" menus to the preset plugin page's
burger menu
* Refactor importmapping dialogue to use the 'data-action' selector
* Add a new set_kebab_trigger action menu method
* Use set_additional_classes method for action menu
* Remove redundant parameter to add_action_menu
  • Loading branch information
Laurent David committed Jan 11, 2023
1 parent b8b905c commit 45317d6
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ public function get_action_menu(\renderer_base $output): ?action_menu {

// Convert control array into an action_menu.
$menu = new action_menu();
$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');

$menu->set_kebab_trigger(get_string('edit'));
$menu->attributes['class'] .= ' section-cm-edit-actions commands';

// Prioritise the menu ahead of all other actions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public function export_for_template(\renderer_base $output): stdClass {

// Convert control array into an action_menu.
$menu = new action_menu();
$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');
$menu->set_kebab_trigger(get_string('edit'));
$menu->attributes['class'] .= ' section-actions';
foreach ($controls as $value) {
$url = empty($value['url']) ? '' : $value['url'];
Expand Down
25 changes: 25 additions & 0 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4304,6 +4304,31 @@ public function set_menu_trigger($trigger, $extraclasses = '') {
$this->triggerextraclasses = $extraclasses;
}

/**
* Classes for the trigger menu
*/
const DEFAULT_KEBAB_TRIGGER_CLASSES = 'btn btn-icon d-flex align-items-center justify-content-center';

/**
* Setup trigger as in the kebab menu.
*
* @param string|null $triggername
* @param core_renderer|null $output
* @param string|null $extraclasses extra classes for the trigger {@see self::set_menu_trigger()}
* @throws coding_exception
*/
public function set_kebab_trigger(?string $triggername = null, ?core_renderer $output = null,
?string $extraclasses = '') {
global $OUTPUT;
if (empty($output)) {
$output = $OUTPUT;
}
$label = $triggername ?? get_string('actions');
$triggerclasses = self::DEFAULT_KEBAB_TRIGGER_CLASSES . ' ' . $extraclasses;
$icon = $output->pix_icon('i/menu', $label);
$this->set_menu_trigger($icon, $triggerclasses);
}

/**
* Return true if there is at least one visible link in the menu.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ information provided here is intended especially for developers.
* New DB parameter 'versionfromdb', only available for MySQL and MariaDB drivers. It allows to force the DB version to be
evaluated through an explicit call to VERSION() to skip the PHP client version which appears to be sometimes fooled by the
underlying infrastructure, e.g. PaaS on Azure.
* The actionmenu component has now a set_kebab_trigger that will setup the action menu for use in kebab menus.
* The useexternalyui configuration setting has been removed as a part of the migration away from YUI.
It only worked with http sites and did not officially support SSL, and is at risk of disappearing should Yahoo! decide
to remove it.
Expand Down Expand Up @@ -715,7 +716,6 @@ filepath because some components, such as mod_page or mod_resource, add the revi
call the above function because the file is sent by a third party library, then you should add
the attribute data-double-submit-protection="off" to your form.


=== 3.7 ===

* Nodes in the navigation api can have labels for each group. See set/get_collectionlabel().
Expand Down
2 changes: 1 addition & 1 deletion mod/data/amd/build/importmappingdialogue.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 45317d6

Please sign in to comment.