Merge branch 'MDL-82478-main' of https://github.com/aanabit/moodle

This commit is contained in:
Jun Pataleta 2024-08-19 11:42:35 +08:00
commit 83a031e39f
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
6 changed files with 41 additions and 18 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

@ -596,17 +596,31 @@ export default class extends BaseComponent {
let bodyText = null;
let titleText = null;
let delegatedsection = null;
if (cmIds.length == 1) {
const cmInfo = this.reactive.get('cm', cmIds[0]);
titleText = getString('cmdelete_title', 'core_courseformat');
bodyText = getString(
'cmdelete_info',
'core_courseformat',
{
type: cmInfo.modname,
name: cmInfo.name,
}
);
if (cmInfo.hasdelegatedsection) {
delegatedsection = cmInfo.delegatesectionid;
titleText = this.reactive.getFormatString('cmdelete_subsectiontitle');
bodyText = getString(
'sectiondelete_info',
'core_courseformat',
{
type: cmInfo.modname,
name: cmInfo.name,
}
);
} else {
titleText = this.reactive.getFormatString('cmdelete_title');
bodyText = getString(
'cmdelete_info',
'core_courseformat',
{
type: cmInfo.modname,
name: cmInfo.name,
}
);
}
} else {
titleText = getString('cmsdelete_title', 'core_courseformat');
bodyText = getString(
@ -628,6 +642,13 @@ export default class extends BaseComponent {
e.preventDefault();
modal.destroy();
this.reactive.dispatch('cmDelete', cmIds);
if (cmIds.length == 1 && delegatedsection && target.baseURI.includes('section.php')) {
// Redirect to the course main page if the subsection is the current page.
let parameters = new URLSearchParams(window.location.search);
if (parameters.has('id') && parameters.get('id') == delegatedsection) {
this._dispatchSectionDelete([delegatedsection], target);
}
}
}
);
}

View File

@ -184,8 +184,7 @@ class delegatedcontrolmenu extends basecontrolmenu {
}
// Delete deletes the module.
// Only show the delete link if we are not already in the section view page.
if (!$isheadersection && $hasmanageactivities) {
if ($hasmanageactivities) {
$url = clone($cmbaseurl);
$url->param('delete', $cm->id);
$url->param('sr', $cm->sectionnum);

View File

@ -51,6 +51,7 @@ $string['cm_stealth_feedback_batch'] = 'The selected {$a->count} activities are
$string['cm_visiblegroups_feedback'] = '{$a->name} group mode changed to Visible groups.';
$string['cmavailability'] = 'Activity availability';
$string['cmdelete_info'] = 'This will delete {$a->name} and any user data it contains.';
$string['cmdelete_subsectiontitle'] = 'Delete subsection?';
$string['cmdelete_title'] = 'Delete activity?';
$string['cmmove_info'] = 'Move {$a} after';
$string['cmmove_subsectiontitle'] = 'Move subsection';

View File

@ -37,8 +37,7 @@ Feature: The module menu replaces the delegated section menu
# 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.
And I should not see "Delete"
And I should see "Delete"
And I should see "Permalink"
@javascript
@ -144,18 +143,21 @@ Feature: The module menu replaces the delegated section menu
And "Subsection3" "link" should exist
And I open "Subsection1" actions menu
When I choose "Delete" in the open action menu
And I click on "Delete" "button" in the "Delete activity?" "dialogue"
And I click on "Delete" "button" in the "Delete subsection?" "dialogue"
And "Subsection1" "link" should not exist in the "#region-main-box" "css_element"
And I am on the "C1 > Section 1" "course > section" page
# Section page. Open Subsection2 module action menu.
And I open "Subsection2" actions menu
And I choose "Delete" in the open action menu
And I click on "Delete" "button" in the "Delete activity?" "dialogue"
And I click on "Delete" "button" in the "Delete subsection?" "dialogue"
And "Subsection2" "link" should not exist in the "#region-main-box" "css_element"
And I am on the "C1 > Subsection3" "course > section" page
# Subsection page. Open the section header action menu.
And I click on "Edit" "icon" in the "[data-region='header-actions-container']" "css_element"
And "Delete" "link" should not exist in the "[data-region='header-actions-container']" "css_element"
And I choose "Delete" in the open action menu
And I click on "Delete" "button" in the "Delete subsection?" "dialogue"
And I should not see "Subsection3"
And I should see "Course 1" in the "h1" "css_element"
@javascript
Scenario: Hide/Show option in subsection action menu