-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CONTRIB-9626 refactor creation of action menus
- Loading branch information
Showing
7 changed files
with
326 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{{! | ||
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 <http://www.gnu.org/licenses/>. | ||
}} | ||
{{! | ||
@template mod_scheduler/action_menu | ||
Action menu. Enhanced to allow confirmation dialogues in action menu items. | ||
Example context (json): | ||
{ | ||
"classes": "", | ||
"instance": "1", | ||
"primary": { | ||
"items": [{"rawhtml": "<p>Item in primary menu</p>"}] | ||
}, | ||
"secondary": { | ||
"attributes": [ | ||
{"name": "id", "value": "action-menu-1-menu"} | ||
], | ||
"items": [ | ||
{ | ||
"rawhtml": "<p>Item in secondary menu</p>" | ||
} | ||
] | ||
} | ||
} | ||
}} | ||
<div class="action-menu {{classes}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}}> | ||
{{#primary}} | ||
|
||
<div class="{{classes}} d-flex "{{#attributes}} {{name}}="{{value}}"{{/attributes}}> | ||
|
||
{{#prioritise}}{{> mod_scheduler/action_menu_trigger }}{{/prioritise}} | ||
|
||
{{#items}} | ||
<div class="action-menu-item"> | ||
{{> mod_scheduler/action_menu_item }} | ||
</div> | ||
{{/items}} | ||
|
||
{{^prioritise}} | ||
<div class="action-menu-trigger"> | ||
{{> mod_scheduler/action_menu_trigger }} | ||
</div> | ||
{{/prioritise}} | ||
|
||
</div> | ||
|
||
{{/primary}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
}} | ||
{{! | ||
@template mod_scheduler/action_menu_item | ||
Action menu item. Enhanced to allow confirmation dialogues in action menu items. | ||
Example context (json): | ||
{ | ||
"rawhtml": "<p>[rawhtml]</p>" | ||
} | ||
}} | ||
{{#actionmenulink}}{{> mod_scheduler/action_menu_link }}{{/actionmenulink}} | ||
{{#actionmenufiller}}<span class="filler"> </span>{{/actionmenufiller}} | ||
{{#actionlink}}{{> core/action_link }}{{/actionlink}} | ||
{{#pixicon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/pixicon}} | ||
{{#rawhtml}}{{{.}}}{{/rawhtml}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{{! | ||
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 <http://www.gnu.org/licenses/>. | ||
}} | ||
{{! | ||
@template mod_scheduler/action_menu_link | ||
Action menu link. Enhanced to allow confirmation dialogues in action menu items. | ||
Example context (json): | ||
{ | ||
"text": "Example link text", | ||
"showtext": true, | ||
"url": "http://example.com/link" | ||
} | ||
}} | ||
{{^disabled}} | ||
<a href="{{url}}" id="{{id}}" class="{{$actionmenulinkclasses}}aabtn {{classes}}{{/actionmenulinkclasses}}" {{#attributes}}{{name}}="{{value}}" {{/attributes}}> | ||
{{#icon}} | ||
{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}} | ||
{{/icon}} | ||
{{#showtext}} | ||
<span class="menu-action-text">{{{text}}}</span> | ||
{{/showtext}} | ||
</a> | ||
{{#hasactions}} | ||
{{> core/actions }} | ||
{{/hasactions}} | ||
{{/disabled}} | ||
{{#disabled}} | ||
<span class="currentlink" role="menuitem">{{#icon}}{{#pix}}{{key}},{{component}},{{title}}{{/pix}}{{/icon}}{{{text}}}</span> | ||
{{/disabled}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
{{! | ||
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 <http://www.gnu.org/licenses/>. | ||
}} | ||
{{! | ||
@template core/action_menu_trigger | ||
Action menu trigger. | ||
Example context (json): | ||
{ | ||
"actiontext": "Example link text", | ||
"title": "Example link title", | ||
"triggerrole": "button", | ||
"triggerattributes": [ | ||
{"name": "data-boundary", "value": "window" } | ||
], | ||
"url": "http://example.com/link", | ||
"classes": "icon menu-action", | ||
"instance": "1", | ||
"triggerextraclasses": "", | ||
"attributes": [ | ||
{"name": "role", "value": "menuitem" }, | ||
{"name": "data-title", "value": "mymoodle,admin" } | ||
], | ||
"secondary": { | ||
"classes": "menu align-tr-br", | ||
"dropdownalignment": "dropdown-menu-right", | ||
"attributes": [ | ||
{"name": "id", "value": "action-menu-0-menu"}, | ||
{"name": "data-rel", "value": "menu-content"}, | ||
{"name": "role", "value": "menu"}, | ||
{"name": "data-align", "value": "tr-br"} | ||
], | ||
"items": [ | ||
{"actionmenulink": | ||
{ | ||
"id": "action_link59ecf8394a68078", | ||
"disabled": false, | ||
"text": "Dashboard", | ||
"url": "http://example.com/link", | ||
"icon": { | ||
"key": "i/dashboard", | ||
"component": null, | ||
"title": "Dashboard" | ||
}, | ||
"classes": "menu-action", | ||
"attributes": [ | ||
{"name": "role", "value": "menuitem"}, | ||
{"name": "data-title", "value": "mymoodle,admin"} | ||
], | ||
"instance": 1, | ||
"showtext": true | ||
} | ||
}, | ||
{"actionmenufiller": | ||
{ | ||
"id": "action_link59ecf8394a68079", | ||
"disabled": false, | ||
"text": "", | ||
"url": "", | ||
"icon": null, | ||
"classes": "", | ||
"attributes": [ | ||
{"name": "role", "value": "menuitem"} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}} | ||
<div class="dropdown{{^secondary.items}} hidden{{/secondary.items}}"> | ||
<a | ||
href="#" | ||
tabindex="0" | ||
class="{{triggerextraclasses}} dropdown-toggle icon-no-margin" | ||
id="action-menu-toggle-{{instance}}" | ||
aria-label="{{title}}" | ||
data-toggle="dropdown" | ||
role="{{triggerrole}}" | ||
aria-haspopup="true" | ||
aria-expanded="false" | ||
aria-controls="action-menu-{{instance}}-menu" | ||
{{#triggerattributes}} | ||
{{name}}="{{value}}" | ||
{{/triggerattributes}} | ||
> | ||
{{{actiontext}}} | ||
{{{menutrigger}}} | ||
{{#icon}} | ||
{{#pix}} | ||
{{key}},{{component}},{{title}} | ||
{{/pix}} | ||
{{/icon}} | ||
{{#rawicon}}{{{.}}}{{/rawicon}} | ||
{{#menutrigger}} | ||
<b class="caret"></b> | ||
{{/menutrigger}} | ||
</a> | ||
{{#secondary}} | ||
<div class="dropdown-menu {{classes}} {{dropdownalignment}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}}> | ||
{{#items}} | ||
{{#actionmenulink}} | ||
{{< mod_scheduler/action_menu_link}} | ||
{{$actionmenulinkclasses}}dropdown-item {{classes}}{{/actionmenulinkclasses}} | ||
{{/ mod_scheduler/action_menu_link}} | ||
{{/actionmenulink}} | ||
{{#actionmenufiller}} | ||
<div class="dropdown-divider" role="presentation"><span class="filler"> </span></div> | ||
{{/actionmenufiller}} | ||
{{#subpanel}} | ||
{{> core/local/action_menu/subpanel}} | ||
{{/subpanel}} | ||
{{#simpleitem}} | ||
<div class="dropdown-item">{{> mod_scheduler/action_menu_item }}</div> | ||
{{/simpleitem}} | ||
{{/items}} | ||
</div> | ||
{{/secondary}} | ||
</div> |