MDL-73683 core_courseformat: match hasRestrictions criteria
[moodle.git] / course / format / templates / local / courseindex / section.mustache
blob1d29a44b9dd7e6f70d3078197844f90713a965fa
1 {{!
2     This file is part of Moodle - http://moodle.org/
4     Moodle is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
9     Moodle is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
14     You should have received a copy of the GNU General Public License
15     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17 {{!
18     @template core_courseformat/local/courseindex/section
20     Displays a course index section entry.
22     Example context (json):
23     {
24         "title": "General",
25         "id": 23,
26         "uniqid": "0",
27         "number": 1,
28         "sectionurl": "#",
29         "indexcollapsed": 0,
30         "current": 1,
31         "visible": 1,
32         "hasrestrictions": 0,
33         "cms": [
34             {
35                 "id": 10,
36                 "name": "Glossary of characters",
37                 "url": "#",
38                 "visible": 1,
39                 "isactive": 0
40             },
41             {
42                 "id": 11,
43                 "name": "World Cinema forum",
44                 "url": "#",
45                 "visible": 1,
46                 "isactive": 0
47             },
48             {
49                 "id": 12,
50                 "name": "Announcements",
51                 "url": "#",
52                 "visible": 0,
53                 "isactive": 1
54             }
55         ]
56     }
58 <div
59     class="courseindex-section {{#current}}current{{/current}}"
60     id="{{uniqid}}-course-index-section-{{id}}"
61     data-for="section"
62     data-id="{{id}}"
63     data-number="{{number}}"
64     role="treeitem"
65     aria-owns="courseindexcollapse{{number}}"
67     <div class="courseindex-item d-flex
68             {{^visible}}dimmed{{/visible}}
69             {{#hasrestrictions}}restrictions{{/hasrestrictions}}
70             courseindex-section-title"
71         id="courseindexsection{{number}}"
72         data-for="section_item"
73     >
74         <a data-toggle="collapse"
75             href="#courseindexcollapse{{number}}"
76             class="courseindex-chevron icons-collapse-expand {{#indexcollapsed}}collapsed{{/indexcollapsed}}"
77             aria-expanded="{{^indexcollapsed}}true{{/indexcollapsed}}{{#indexcollapsed}}false{{/indexcollapsed}}"
78             aria-controls="courseindexcollapse{{number}}"
79             tabindex="-1"
80         >
81             <span class="collapsed-icon icon-no-margin mr-1"
82                 title="{{#str}} expand, core {{/str}}">
83                 {{#pix}} t/collapsedchevron, core {{/pix}}
84                 <span class="sr-only">{{#str}} expand, core {{/str}}</span>
85             </span>
86             <span class="expanded-icon icon-no-margin mr-1"
87                 title="{{#str}} collapse, core {{/str}}">
88                 {{#pix}} t/expandedchevron, core {{/pix}}
89                 <span class="sr-only">{{#str}} collapse, core {{/str}}</span>
90             </span>
91         </a>
92         <a href="{{{sectionurl}}}"
93             class="courseindex-link text-truncate"
94             data-action="togglecourseindexsection"
95             data-for="section_title"
96             tabindex="-1"
97         >
98             {{{title}}}
99         </a>
100         <span class="current-badge badge badge-primary ml-2 px-2 rounded-pill">
101             {{highlighted}}
102         </span>
103         <span class="courseindex-locked ml-1" data-for="cm_name">
104             {{#pix}} t/locked, core {{/pix}}
105         </span>
106         <span class="dragicon ml-auto">{{#pix}}i/dragdrop{{/pix}}</span>
107     </div>
108     <div id="courseindexcollapse{{number}}"
109         class="courseindex-item-content collapse {{^indexcollapsed}}show{{/indexcollapsed}}"
110         aria-labelledby="courseindexsection{{number}}" role="group"
111     >
112         <ul class="courseindex-sectioncontent unlist" data-for="cmlist" data-id="{{id}}" role="group">
113             {{#cms}}
114             {{> core_courseformat/local/courseindex/cm }}
115             {{/cms}}
116         </ul>
117     </div>
118 </div>
119 {{#js}}
120 require(['core_courseformat/local/courseindex/section'], function(component) {
121     component.init('{{uniqid}}-course-index-section-{{id}}');
123 {{/js}}