This commit is contained in:
Andrew Nicols
2024-08-14 22:31:16 +08:00
7 changed files with 62 additions and 11 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -327,7 +327,11 @@ export default class extends BaseComponent {
data.cmid = cmInfo.id;
data.cmname = cmInfo.name;
data.information = await this.reactive.getFormatString('cmmove_info', data.cmname);
titleText = this.reactive.getFormatString('cmmove_title');
if (cmInfo.hasdelegatedsection) {
titleText = this.reactive.getFormatString('cmmove_subsectiontitle');
} else {
titleText = this.reactive.getFormatString('cmmove_title');
}
} else {
data.information = await this.reactive.getFormatString('cmsmove_info', cmIds.length);
titleText = this.reactive.getFormatString('cmsmove_title');
@@ -167,8 +167,24 @@ class delegatedcontrolmenu extends basecontrolmenu {
}
}
// Only show the move link if we are not already in the section view page.
// Move (only for component compatible formats).
if (!$isheadersection && $hasmanageactivities && $usecomponents) {
$controls['move'] = [
'url' => new moodle_url('/course/mod.php', ['copy' => $cm->id]),
'icon' => 'i/dragdrop',
'name' => get_string('move'),
'pixattr' => ['class' => ''],
'attr' => [
'class' => 'editing_movecm ',
'data-action' => 'moveCm',
'data-id' => $cm->id,
],
];
}
// Delete deletes the module.
// Only show the view link if we are not already in the section view page.
// Only show the delete link if we are not already in the section view page.
if (!$isheadersection && $hasmanageactivities) {
$url = clone($cmbaseurl);
$url->param('delete', $cm->id);
+3 -2
View File
@@ -52,13 +52,14 @@ $string['cm_visiblegroups_feedback'] = '{$a->name} group mode changed to Visible
$string['cmavailability'] = 'Activity availability';
$string['cmdelete_info'] = 'This will delete {$a->name} and any user data it contains.';
$string['cmdelete_title'] = 'Delete activity?';
$string['cmmove_info'] = 'Move {$a} after';
$string['cmmove_subsectiontitle'] = 'Move subsection';
$string['cmmove_title'] = 'Move activity';
$string['cmsdelete'] = 'Delete activities';
$string['cmsdelete_info'] = 'This will delete {$a->count} activities and any user data they contain.';
$string['cmsdelete_title'] = 'Delete selected activities?';
$string['cmsduplicate'] = 'Duplicate activities';
$string['cmsmove'] = 'Move activities';
$string['cmmove_title'] = 'Move activity';
$string['cmmove_info'] = 'Move {$a} after';
$string['cmsmove_title'] = 'Move selected activities';
$string['cmsmove_info'] = 'Move {$a} activities after';
$string['courseindex'] = 'Course index';
@@ -33,8 +33,8 @@ Feature: The module menu replaces the delegated section menu
And I should not see "Assign roles"
And I should not see "Highlight"
And I should see "Edit settings"
# Duplicate and Move are not implemented yet.
And I should not see "Move"
# Duplicate is not implemented yet.
And I should not see "Duplicate"
And I should see "Hide"
# Delete option for subsection page is not implemented yet.
@@ -50,8 +50,8 @@ Feature: The module menu replaces the delegated section menu
And I should not see "Highlight"
And I should see "View"
And I should see "Edit settings"
# Duplicate and Move are not implemented yet.
And I should not see "Move"
And I should see "Move"
# Duplicate is not implemented yet.
And I should not see "Duplicate"
And I should see "Hide"
And I should see "Delete"
@@ -66,8 +66,8 @@ Feature: The module menu replaces the delegated section menu
And I should not see "Highlight"
And I should see "View"
And I should see "Edit settings"
# Duplicate and Move are not implemented yet.
And I should not see "Move"
And I should see "Move"
# Duplicate is not implemented yet.
And I should not see "Duplicate"
And I should see "Hide"
And I should see "Delete"
@@ -207,3 +207,32 @@ Feature: The module menu replaces the delegated section menu
And I open section "Subsection1" edit menu
And I should not see "Hide"
And I should not see "Show"
@javascript
Scenario: Move option in subsection action menu
Given the following "activities" exist:
| activity | course | idnumber | name | intro | section |
| subsection | C1 | subsection2 | Subsection2 | Test Subsection2 | 1 |
And I turn editing mode on
And I open "Subsection1" actions menu
When I choose "Move" in the open action menu
And I should see "Move Subsection1 after" in the "Move subsection" "dialogue"
# Can't be moved inside same subsection.
And I click on "Subsection1" "link" in the "Move subsection" "dialogue"
And I should see "Move Subsection1 after" in the "Move subsection" "dialogue"
# Can't be moved inside other subsection.
And I click on "Subsection2" "link" in the "Move subsection" "dialogue"
And I should see "Move Subsection1 after" in the "Move subsection" "dialogue"
# Can be moved to other position.
And I click on "General" "link" in the "Move subsection" "dialogue"
Then I should not see "Move Subsection1 after"
And I should see "Subsection1" in the "General" "section"
And I should not see "Subsection1" in the "Section 1" "section"
# Section page. Subsection is still content, so Move option should exist.
And I am on the "C1 > Section 1" "course > section" page
And I open "Subsection2" actions menu
And I should see "Move"
# Subsection page. Move option should not exist.
And I am on the "C1 > Subsection1" "course > section" page
And I click on "Edit" "icon" in the "[data-region='header-actions-container']" "css_element"
And "Move" "link" should not exist in the "[data-region='header-actions-container']" "css_element"
@@ -77,6 +77,7 @@ final class sectiondelegate_test extends \advanced_testcase {
$streditsection,
get_string('hidefromothers', 'format_' . $course->format),
get_string('showfromothers', 'format_' . $course->format),
get_string('move'),
get_string('delete'),
get_string('sectionlink', 'course'),
];