This commit is contained in:
Shamim Rezaie 2024-07-03 04:06:19 +10:00
commit b174c16d4d
5 changed files with 17 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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();

View File

@ -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'];

View File

@ -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:
@ -115,8 +123,7 @@ Feature: Single section course page
Scenario: Delete a section from the section page redirects to the main course page
Given I am on the "C1 > Section 1" "course > section" page
And I turn editing mode on
And I open the action menu in "page-header" "region"
When I choose "Delete" in the open action menu
When I choose the "Delete" item in the "Edit" action menu of the "page-header" "region"
And I click on "Delete" "button" in the "Delete section?" "dialogue"
# Section 1 should be removed.
Then I should not see "Section 1"