MDL-82329 course: consistent section permalink on view/section pages.

This commit is contained in:
Paul Holden
2024-06-28 08:59:54 +01:00
parent 87d7ac1f81
commit 044e924d8a
5 changed files with 16 additions and 6 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -4
View File
@@ -85,6 +85,7 @@ define(
TOGGLE: '.toggle-display,.dropdown-toggle',
SECTIONLI: 'li.section',
SECTIONACTIONMENU: '.section_action_menu',
SECTIONACTIONMENUTRIGGER: '.section-actions',
SECTIONITEM: '[data-for="section_title"]',
ADDSECTIONS: '.changenumsections [data-add-sections]',
SECTIONBADGES: '[data-region="sectionbadges"]',
@@ -957,16 +958,16 @@ define(
}
});
// Add a handler for section show/hide actions.
$('body').on('click keypress', SELECTOR.SECTIONLI + ' ' +
SELECTOR.SECTIONACTIONMENU + '[data-sectionid] ' +
// Add a handler for section action menu.
$('body').on('click keypress',
SELECTOR.SECTIONACTIONMENUTRIGGER + '[data-sectionid] ' +
'a[data-action]', function(e) {
if (e.type === 'keypress' && e.keyCode !== 13) {
return;
}
var actionItem = $(this),
sectionElement = actionItem.closest(SELECTOR.SECTIONLI),
sectionId = actionItem.closest(SELECTOR.SECTIONACTIONMENU).attr('data-sectionid');
sectionId = actionItem.closest(SELECTOR.SECTIONACTIONMENUTRIGGER).attr('data-sectionid');
if (actionItem.attr('data-action') === 'permalink') {
e.preventDefault();
@@ -119,6 +119,7 @@ class controlmenu implements named_templatable, renderable {
$menu = new action_menu();
$menu->set_kebab_trigger(get_string('edit'));
$menu->attributes['class'] .= ' section-actions';
$menu->attributes['data-sectionid'] = $this->section->id;
foreach ($controls as $value) {
$url = empty($value['url']) ? '' : $value['url'];
$icon = empty($value['icon']) ? '' : $value['icon'];
@@ -101,6 +101,14 @@ Feature: Single section course page
When I set the field "Edit section name" in the "page-header" "region" to "Custom section name"
Then "Custom section name" "text" should exist in the ".breadcrumb" "css_element"
@javascript
Scenario: Copy section page permalink URL to clipboard
Given I am on the "Course 1 > Section 1" "course > section" page
And I turn editing mode on
When I choose the "Permalink" item in the "Edit" action menu of the "page-header" "region"
And I click on "Copy to clipboard" "link" in the "Permalink" "dialogue"
Then I should see "Text copied to clipboard"
Scenario: Blocks are displayed in section page too
Given I log out
And the following "blocks" exist: