mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
MDL-82541 core_courseformat: fix orphan sections sorting
This commit is contained in:
parent
9f9f5f6821
commit
393d4f6043
2
course/format/amd/build/local/content.min.js
vendored
2
course/format/amd/build/local/content.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -746,22 +746,22 @@ export default class Component extends BaseComponent {
|
||||
}
|
||||
});
|
||||
|
||||
// Dndupload add a fake element we need to keep.
|
||||
let dndFakeActivity;
|
||||
|
||||
// Remove the remaining elements.
|
||||
const orphanElements = [];
|
||||
while (container.children.length > neworder.length) {
|
||||
const lastchild = container.lastChild;
|
||||
if (lastchild?.classList?.contains('dndupload-preview')) {
|
||||
dndFakeActivity = lastchild;
|
||||
// Any orphan element is always displayed after the listed elements.
|
||||
// Also, some third-party plugins can use a fake dndupload-preview indicator.
|
||||
if (lastchild?.classList?.contains('dndupload-preview') || lastchild.dataset?.orphan) {
|
||||
orphanElements.push(lastchild);
|
||||
} else {
|
||||
dettachedelements[lastchild?.dataset?.id ?? 0] = lastchild;
|
||||
}
|
||||
container.removeChild(lastchild);
|
||||
}
|
||||
// Restore dndupload fake element.
|
||||
if (dndFakeActivity) {
|
||||
container.append(dndFakeActivity);
|
||||
}
|
||||
// Restore orphan elements.
|
||||
orphanElements.forEach((element) => {
|
||||
container.append(element);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,7 @@
|
||||
data-id="{{id}}"
|
||||
data-number="{{num}}"
|
||||
data-sectionname="{{sectionname}}"
|
||||
{{#isstealth}} data-orphan="true" {{/isstealth}}
|
||||
>
|
||||
<div class="section-item">
|
||||
{{$ core_courseformat/local/content/section/content }}
|
||||
|
@ -129,3 +129,12 @@ Feature: Courses should not lose subsection contents when mod_subsection is disa
|
||||
And I enable "subsection" "mod" plugin
|
||||
Then I am on "Course 1" course homepage
|
||||
And I should see "Hidden from students"
|
||||
|
||||
@javascript
|
||||
Scenario: Orphaned sections should appear after any other section
|
||||
Given I log in as "teacher1"
|
||||
When I am on "Course 1" course homepage with editing mode on
|
||||
And I click on "Add section" "link" in the "course-addsection" "region"
|
||||
Then I should see "New section"
|
||||
And "Section 2" "section" should appear before "New section" "section"
|
||||
And "New section" "section" should appear before "Subsection1" "section"
|
||||
|
Loading…
x
Reference in New Issue
Block a user