Merge branch 'MDL-77291-master' of https://github.com/sarjona/moodle
This commit is contained in:
+1
-1
@@ -8,6 +8,6 @@ define("core_courseformat/local/courseindex/cm",["exports","core_courseformat/lo
|
||||
* @class core_courseformat/local/courseindex/cm
|
||||
* @copyright 2021 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_dndcmitem=_interopRequireDefault(_dndcmitem),_templates=_interopRequireDefault(_templates),_prefetch=_interopRequireDefault(_prefetch),_config=_interopRequireDefault(_config);_prefetch.default.prefetchTemplate("core_courseformat/local/courseindex/cmcompletion");class Component extends _dndcmitem.default{create(){this.name="courseindex_cm",this.selectors={CM_NAME:"[data-for='cm_name']",CM_COMPLETION:"[data-for='cm_completion']"},this.classes={CMHIDDEN:"dimmed",LOCKED:"editinprogress",RESTRICTIONS:"restrictions",PAGEITEM:"pageitem",INDENTED:"indented"},this.id=this.element.dataset.id}static init(target,selectors){return new this({element:document.getElementById(target),selectors:selectors})}stateReady(state){this.configDragDrop(this.id);const cm=state.cm.get(this.id),course=state.course;this._refreshCompletion({state:state,element:cm}),window.location.href!=cm.url&&window.location.href!="".concat(course.baseurl,"#").concat(cm.anchor)||(this.reactive.dispatch("setPageItem","cm",this.id),this.element.scrollIntoView({block:"center"})),_config.default.contextid!=_config.default.courseContextId&&_config.default.contextInstanceId==this.id&&(this.reactive.dispatch("setPageItem","cm",this.id,!0),this.element.scrollIntoView({block:"center"})),cm.uservisible||this.addEventListener(this.getElement(this.selectors.CM_NAME),"click",this._activityAnchor)}getWatchers(){return[{watch:"cm[".concat(this.id,"]:deleted"),handler:this.remove},{watch:"cm[".concat(this.id,"]:updated"),handler:this._refreshCm},{watch:"cm[".concat(this.id,"].completionstate:updated"),handler:this._refreshCompletion},{watch:"course.pageItem:updated",handler:this._refreshPageItem}]}_refreshCm(_ref){var _element$dragging,_element$locked,_element$hascmrestric;let{element:element}=_ref;this.element.classList.toggle(this.classes.CMHIDDEN,!element.visible),this.getElement(this.selectors.CM_NAME).innerHTML=element.name,this.element.classList.toggle(this.classes.DRAGGING,null!==(_element$dragging=element.dragging)&&void 0!==_element$dragging&&_element$dragging),this.element.classList.toggle(this.classes.LOCKED,null!==(_element$locked=element.locked)&&void 0!==_element$locked&&_element$locked),this.element.classList.toggle(this.classes.RESTRICTIONS,null!==(_element$hascmrestric=element.hascmrestrictions)&&void 0!==_element$hascmrestric&&_element$hascmrestric),this.element.classList.toggle(this.classes.INDENTED,element.indent),this.locked=element.locked}_refreshPageItem(_ref2){let{element:element}=_ref2;if(!element.pageItem)return;const isPageId="cm"==element.pageItem.type&&element.pageItem.id==this.id;this.element.classList.toggle(this.classes.PAGEITEM,isPageId),isPageId&&!this.reactive.isEditing&&this.element.scrollIntoView({block:"nearest"})}async _refreshCompletion(_ref3){let{state:state,element:element}=_ref3;if(this.reactive.isEditing||!element.istrackeduser)return;const completionElement=this.getElement(this.selectors.CM_COMPLETION);if(completionElement.dataset.value==element.completionstate)return;const data=this.reactive.getExporter().cmCompletion(state,element);try{const{html:html,js:js}=await _templates.default.renderForPromise("core_courseformat/local/courseindex/cmcompletion",data);_templates.default.replaceNode(completionElement,html,js)}catch(error){throw error}}_activityAnchor(event){const cm=this.reactive.get("cm",this.id);if(document.getElementById(cm.anchor))return void setTimeout((()=>{this.reactive.dispatch("setPageItem","cm",cm.id)}),50);const course=this.reactive.get("course"),section=this.reactive.get("section",cm.sectionid);if(!section)return;const url="".concat(course.baseurl,"§ion=").concat(section.number,"#").concat(cm.anchor);event.preventDefault(),window.location=url}}return _exports.default=Component,_exports.default}));
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_dndcmitem=_interopRequireDefault(_dndcmitem),_templates=_interopRequireDefault(_templates),_prefetch=_interopRequireDefault(_prefetch),_config=_interopRequireDefault(_config);_prefetch.default.prefetchTemplate("core_courseformat/local/courseindex/cmcompletion");class Component extends _dndcmitem.default{create(){this.name="courseindex_cm",this.selectors={CM_NAME:"[data-for='cm_name']",CM_COMPLETION:"[data-for='cm_completion']"},this.classes={CMHIDDEN:"dimmed",LOCKED:"editinprogress",RESTRICTIONS:"restrictions",PAGEITEM:"pageitem",INDENTED:"indented"},this.id=this.element.dataset.id}static init(target,selectors){return new this({element:document.getElementById(target),selectors:selectors})}stateReady(state){this.configDragDrop(this.id);const cm=state.cm.get(this.id),course=state.course;this._refreshCompletion({state:state,element:cm}),window.location.href!=cm.url&&window.location.href!="".concat(course.baseurl,"#").concat(cm.anchor)||(this.reactive.dispatch("setPageItem","cm",this.id),this.element.scrollIntoView({block:"center"})),_config.default.contextid!=_config.default.courseContextId&&_config.default.contextInstanceId==this.id&&(this.reactive.dispatch("setPageItem","cm",this.id,!0),this.element.scrollIntoView({block:"center"})),cm.uservisible&&cm.url||this.addEventListener(this.getElement(this.selectors.CM_NAME),"click",this._activityAnchor)}getWatchers(){return[{watch:"cm[".concat(this.id,"]:deleted"),handler:this.remove},{watch:"cm[".concat(this.id,"]:updated"),handler:this._refreshCm},{watch:"cm[".concat(this.id,"].completionstate:updated"),handler:this._refreshCompletion},{watch:"course.pageItem:updated",handler:this._refreshPageItem}]}_refreshCm(_ref){var _element$dragging,_element$locked,_element$hascmrestric;let{element:element}=_ref;this.element.classList.toggle(this.classes.CMHIDDEN,!element.visible),this.getElement(this.selectors.CM_NAME).innerHTML=element.name,this.element.classList.toggle(this.classes.DRAGGING,null!==(_element$dragging=element.dragging)&&void 0!==_element$dragging&&_element$dragging),this.element.classList.toggle(this.classes.LOCKED,null!==(_element$locked=element.locked)&&void 0!==_element$locked&&_element$locked),this.element.classList.toggle(this.classes.RESTRICTIONS,null!==(_element$hascmrestric=element.hascmrestrictions)&&void 0!==_element$hascmrestric&&_element$hascmrestric),this.element.classList.toggle(this.classes.INDENTED,element.indent),this.locked=element.locked}_refreshPageItem(_ref2){let{element:element}=_ref2;if(!element.pageItem)return;const isPageId="cm"==element.pageItem.type&&element.pageItem.id==this.id;this.element.classList.toggle(this.classes.PAGEITEM,isPageId),isPageId&&!this.reactive.isEditing&&this.element.scrollIntoView({block:"nearest"})}async _refreshCompletion(_ref3){let{state:state,element:element}=_ref3;if(this.reactive.isEditing||!element.istrackeduser)return;const completionElement=this.getElement(this.selectors.CM_COMPLETION);if(completionElement.dataset.value==element.completionstate)return;const data=this.reactive.getExporter().cmCompletion(state,element);try{const{html:html,js:js}=await _templates.default.renderForPromise("core_courseformat/local/courseindex/cmcompletion",data);_templates.default.replaceNode(completionElement,html,js)}catch(error){throw error}}_activityAnchor(event){const cm=this.reactive.get("cm",this.id);if(document.getElementById(cm.anchor))return void setTimeout((()=>{this.reactive.dispatch("setPageItem","cm",cm.id)}),50);const course=this.reactive.get("course"),section=this.reactive.get("section",cm.sectionid);if(!section)return;const url="".concat(course.baseurl,"§ion=").concat(section.number,"#").concat(cm.anchor);event.preventDefault(),window.location=url}}return _exports.default=Component,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=cm.min.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -96,8 +96,8 @@ export default class Component extends DndCmItem {
|
||||
this.reactive.dispatch('setPageItem', 'cm', this.id, true);
|
||||
this.element.scrollIntoView({block: "center"});
|
||||
}
|
||||
// Add anchor logic if the element is not user visible.
|
||||
if (!cm.uservisible) {
|
||||
// Add anchor logic if the element is not user visible or the element hasn't URL.
|
||||
if (!cm.uservisible || !cm.url) {
|
||||
this.addEventListener(
|
||||
this.getElement(this.selectors.CM_NAME),
|
||||
'click',
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
{{#isactive}}active{{/isactive}}
|
||||
{{#hascmrestrictions}}restrictions{{/hascmrestrictions}}
|
||||
{{^accessvisible}}dimmed{{/accessvisible}}
|
||||
{{#url}} d-flex {{/url}} {{^url}} d-flex-noedit {{/url}}
|
||||
d-flex
|
||||
{{#indent}} indented {{/indent}}"
|
||||
id="{{uniqid}}-course-index-cm-{{id}}"
|
||||
data-for="cm"
|
||||
@@ -44,23 +44,21 @@
|
||||
role="treeitem"
|
||||
>
|
||||
<span class="completioninfo" data-for="cm_completion" data-value="NaN"></span>
|
||||
{{#url}}
|
||||
{{#uservisible}}
|
||||
<a class="courseindex-link text-truncate" href="{{{url}}}" data-for="cm_name" tabindex="-1">
|
||||
{{{name}}}
|
||||
</a>
|
||||
{{/uservisible}}
|
||||
{{^uservisible}}
|
||||
<a class="courseindex-link text-truncate" href="#{{{anchor}}}" data-for="cm_name" tabindex="-1" data-anchor="true">
|
||||
{{{name}}}
|
||||
</a>
|
||||
{{/uservisible}}
|
||||
{{/url}}
|
||||
{{^url}}
|
||||
<span class="courseindex-name text-truncate" data-for="cm_name">
|
||||
{{#uservisible}}
|
||||
<a
|
||||
class="courseindex-link text-truncate"
|
||||
{{#url}} href="{{{url}}}" {{/url}}{{^url}} href="#{{{anchor}}}" data-anchor="true" {{/url}}
|
||||
data-for="cm_name"
|
||||
tabindex="-1"
|
||||
>
|
||||
{{{name}}}
|
||||
</span>
|
||||
{{/url}}
|
||||
</a>
|
||||
{{/uservisible}}
|
||||
{{^uservisible}}
|
||||
<a class="courseindex-link text-truncate" href="#{{{anchor}}}" data-for="cm_name" tabindex="-1" data-anchor="true">
|
||||
{{{name}}}
|
||||
</a>
|
||||
{{/uservisible}}
|
||||
<span class="courseindex-locked ml-1" data-for="cm_name">
|
||||
{{#pix}} t/locked, core {{/pix}}
|
||||
</span>
|
||||
|
||||
@@ -308,3 +308,24 @@ Feature: Course index depending on role
|
||||
And I follow "Switch role to..." in the user menu
|
||||
And I press "Student"
|
||||
Then I should not see "Topic 1" in the "courseindex-content" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Course index behaviour for activities without url
|
||||
# Add a label to the course (labels doesn't have URL, because they can't be displayed in a separate page).
|
||||
Given the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber | section |
|
||||
| label | Activity sample 4 | Test label | C1 | sample4 | 2 |
|
||||
# Check resources without URL, as labels, are displayed in the CI and the link goes to the main page when it is clicked.
|
||||
When I am on the "sample1" "Activity" page logged in as "student1"
|
||||
Then I should see "Test label" in the "#courseindex" "css_element"
|
||||
And I click on "Test label" "link" in the "#courseindex" "css_element"
|
||||
And I should see "Test label" in the "region-main" "region"
|
||||
And I should see "Activity sample 2" in the "region-main" "region"
|
||||
# Check resources without URL, as labels, are displayed for teachers too, and the link is working even when edit mode is on.
|
||||
And I am on the "sample1" "Activity" page logged in as "teacher1"
|
||||
And I should see "Test label" in the "#courseindex" "css_element"
|
||||
And I turn editing mode on
|
||||
And I should see "Test label" in the "#courseindex" "css_element"
|
||||
And I click on "Test label" "link" in the "#courseindex" "css_element"
|
||||
And I should see "Test label" in the "region-main" "region"
|
||||
And I should see "Activity sample 2" in the "region-main" "region"
|
||||
|
||||
@@ -14,7 +14,7 @@ Feature: Atto editor with customised toolbar
|
||||
| label | L1 | <a href="../lib/editor/atto/tests/fixtures/custom_toolbar_example.php">FixtureLink</a> | C1 | label1 |
|
||||
When I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "FixtureLink"
|
||||
And I click on "FixtureLink" "link" in the "region-main" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Confirm that both editors have different toolbars but still function
|
||||
|
||||
@@ -14,7 +14,7 @@ Feature: Atto with enable/disable function.
|
||||
| label | L1 | <a href="../lib/editor/tests/fixtures/disable_control_example.php">Control Enable/Disable Atto</a> | C1 | label1 |
|
||||
And I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Control Enable/Disable Atto"
|
||||
And I click on "Control Enable/Disable Atto" "link" in the "region-main" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Check disable Atto editor.
|
||||
|
||||
@@ -18,7 +18,7 @@ Feature: Text area with enable/disable function.
|
||||
And I set the field "Text editor" to "Plain text area"
|
||||
And I press "Save changes"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Control Enable/Disable Text area"
|
||||
And I click on "Control Enable/Disable Text area" "link" in the "region-main" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Check disable Text area editor.
|
||||
|
||||
@@ -13,7 +13,7 @@ Feature: Forms with a large number of fields
|
||||
| activity | name | intro | course | idnumber |
|
||||
| label | L1 | <a href="../lib/tests/fixtures/max_input_vars.php">FixtureLink</a> | C1 | label1 |
|
||||
When I am on the "C1" "Course" page logged in as "admin"
|
||||
And I follow "FixtureLink"
|
||||
And I click on "FixtureLink" "link" in the "region-main" "region"
|
||||
|
||||
# Note: These tests do not actually use JavaScript but they don't work with
|
||||
# the headless 'browser'.
|
||||
|
||||
@@ -13,7 +13,7 @@ Feature: Read-only forms should work
|
||||
| activity | name | intro | course | idnumber |
|
||||
| label | L1 | <a href="../lib/tests/fixtures/readonlyform.php?sections=1">Fixture link</a> | C1 | label1 |
|
||||
Given I am on the "C1" "Course" page logged in as "admin"
|
||||
And I follow "Fixture link"
|
||||
And I click on "Fixture link" "link" in the "region-main" "region"
|
||||
When I expand all fieldsets
|
||||
Then the field "Name" matches value "Important information"
|
||||
|
||||
@@ -26,7 +26,7 @@ Feature: Read-only forms should work
|
||||
| activity | name | intro | course | idnumber |
|
||||
| label | L1 | <a href="../lib/tests/fixtures/readonlyform.php?sections=2">Fixture link</a> | C1 | label1 |
|
||||
Given I am on the "C1" "Course" page logged in as "admin"
|
||||
And I follow "Fixture link"
|
||||
And I click on "Fixture link" "link" in the "region-main" "region"
|
||||
When I expand all fieldsets
|
||||
Then the field "Name" matches value "Important information"
|
||||
Then the field "Other" matches value "Other information"
|
||||
|
||||
Reference in New Issue
Block a user