Merge branch 'MDL-78435' of https://github.com/paulholden/moodle
[moodle.git] / availability / templates / availability_info.mustache
blob32215a83a6b630b885475738503a4294363fa4b3
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_availability/availability_info
20     Renders the availability tree for course activties
22     Example context (json):
23     {
24         "id" : "123456",
25         "header": "Not available unless:",
26         "items" : [
27             {
28                 "showmorelink": 0,
29                 "abbreviate" : 0,
30                 "hidden" : 0,
31                 "hasitems": 0,
32                 "header": "You belong to Green Group"
33             },
34             {
35                 "showmorelink": 0,
36                 "abbreviate" : 0,
37                 "hidden" : 0,
38                 "hasitems": 0,
39                 "header": "You belong to Red Group"
40             },
41             {
42                 "showmorelink": 0,
43                 "abbreviate" : 1,
44                 "hidden" : 0,
45                 "hasitems": 0,
46                 "header": "You belong to Orange Group"
47             },
48             {
49                 "showmorelink": 0,
50                 "abbreviate" : 0,
51                 "hidden" : 1,
52                 "hasitems": 0,
53                 "header": "You belong to Pink Group"
54             },
55             {
56                 "showmorelink": 0,
57                 "abbreviate" : 0,
58                 "hidden" : 1,
59                 "hasitems": 0,
60                 "header": "You belong to Red Group"
61             }
62         ],
63         "hasitems": 1,
64         "showmorelink": 1
65     }
67 {{{header}}}
68 {{#hasitems}}
69 <ul {{#id}} id="availability-tree-{{id}}" {{/id}} data-region="availability-multiple">
70     {{#items}}
71         <li class="{{#hidden}}d-none{{/hidden}}">
72             {{#abbreviate}}
73                 <span class="d-none">
74                     {{> core_availability/availability_info }}
75                 </span><span class="d-block">...</span>
76             {{/abbreviate}}
77             {{^abbreviate}}
78                 {{> core_availability/availability_info }}
79             {{/abbreviate}}
80         </li>
81     {{/items}}
82     {{#showmorelink}}
83         <li data-action="showmore" class="d-block showmore">
84             <a role="button" aria-expanded="false" aria-controls="availability-tree-{{id}}" href="#" >
85                 {{#str}}showmore, availability{{/str}}
86             </a>
87         </li>
88     {{/showmorelink}}
89 </ul>
90 {{/hasitems}}
92 {{#showmorelink}}
93 {{#js}}
94 require(['core_availability/availability_more'], function(availabilityMore) {
95         availabilityMore.init();
96 });
97 {{/js}}
98 {{/showmorelink}}