mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
Merge branch 'MDL-76850-master' of https://github.com/ferranrecio/moodle
This commit is contained in:
commit
9fcb71d5ff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -472,13 +472,13 @@ export default class extends BaseComponent {
|
||||
* @param {Event} event the triggered event
|
||||
*/
|
||||
async _requestCmDuplicate(target, event) {
|
||||
const cmId = target.dataset.id;
|
||||
if (!cmId) {
|
||||
const cmIds = this._getTargetIds(target);
|
||||
if (cmIds.length == 0) {
|
||||
return;
|
||||
}
|
||||
const sectionId = target.dataset.sectionid ?? null;
|
||||
event.preventDefault();
|
||||
this.reactive.dispatch('cmDuplicate', [cmId], sectionId);
|
||||
this.reactive.dispatch('cmDuplicate', cmIds, sectionId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,6 +199,7 @@ export default class {
|
||||
this.sectionLock(stateManager, Array.from(sectionIds), true);
|
||||
|
||||
const updates = await this._callEditWebservice('cm_duplicate', course.id, cmIds, targetSectionId, targetCmId);
|
||||
this.bulkReset(stateManager);
|
||||
stateManager.processUpdates(updates);
|
||||
|
||||
this.sectionLock(stateManager, Array.from(sectionIds), false);
|
||||
|
@ -328,7 +328,7 @@ export default class Component extends BaseComponent {
|
||||
container.append(item);
|
||||
return;
|
||||
}
|
||||
if (currentitem !== item) {
|
||||
if (currentitem !== item && item) {
|
||||
container.insertBefore(item, currentitem);
|
||||
}
|
||||
});
|
||||
|
@ -99,6 +99,17 @@ class bulkedittools implements named_templatable, renderable {
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$duplicatecapabilities = ['moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport'];
|
||||
if (has_all_capabilities($duplicatecapabilities, $context, $user)) {
|
||||
$controls['duplicate'] = [
|
||||
'icon' => 't/copy',
|
||||
'action' => 'cmDuplicate',
|
||||
'name' => get_string('duplicate'),
|
||||
'bulk' => 'cm',
|
||||
];
|
||||
}
|
||||
|
||||
return $controls;
|
||||
}
|
||||
|
||||
|
@ -97,3 +97,16 @@ Feature: Bulk course activity actions.
|
||||
And I click on "Apply" "button" in the "Availability" "dialogue"
|
||||
Then I should see "Available but not shown on course page" in the "Activity sample 1" "activity"
|
||||
And I should see "Available but not shown on course page" in the "Activity sample 3" "activity"
|
||||
|
||||
Scenario: Bulk duplicate activities
|
||||
Given I click on "Select activity Activity sample 1" "checkbox"
|
||||
And I click on "Select activity Activity sample 3" "checkbox"
|
||||
And I should see "2 selected" in the "sticky-footer" "region"
|
||||
When I click on "Duplicate" "button" in the "sticky-footer" "region"
|
||||
Then I should see "Activity sample 1" in the "Topic 1" "section"
|
||||
And I should see "Activity sample 1 (copy)" in the "Topic 1" "section"
|
||||
And "Activity sample 1 (copy)" "activity" should appear after "Activity sample 1" "activity"
|
||||
And I should see "Activity sample 3" in the "Topic 2" "section"
|
||||
And I should see "Activity sample 3 (copy)" in the "Topic 2" "section"
|
||||
And "Activity sample 3 (copy)" "activity" should appear after "Activity sample 3" "activity"
|
||||
And I should see "0 selected" in the "sticky-footer" "region"
|
||||
|
Loading…
x
Reference in New Issue
Block a user