c13aa7d5661823da63321eed38b3559387bac9a9
[moodle.git] / admin / tool / analytics / templates / models_list.mustache
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/>.
16 }}
17 {{!
18     @template tool_analytics/models_list
20     Template for models list.
22     Classes required for JS:
23     * none
25     Data attributes required for JS:
26     * none
28     Context variables required for this template:
29     * models: array - list of models to display
30         - name: object - data for the inplace editable element template
31         - target: string - name of the target associated with the model
32         - targetclass: string - fully qualified name of the target class
33         - targethelp: object - data for the help tooltip template
34         - enabled: bool - is the model enabled
35         - indicators: array - list of indicators used by the model
36             + name: string - name of the indicator
37             + help: object - data for the help tooltip template
38         - insights: object - data for the single select template
39         - noinsights: string - text to display instead of insights
40     * warnings: array - list of data for notification warning template
41     * infos: array - list of data for notification info template
42     * createmodelurl: string - URL to create a new model
43     * importmodelurl: string - URL to import a model
45     Example context (json):
46     {
47         "models": [
48             {
49                 "name": {
50                     "component": "local_analyticsdemo",
51                     "itemtype": "modelname",
52                     "itemid": 42,
53                     "displayvalue": "Prevent devs at risk",
54                     "value": ""
55                 },
56                 "target": "Prevent devs at risk",
57                 "targetclass": "\\local_analyticsdemo\\analytics\\target\\dev_risk",
58                 "targethelp": {
59                     "title": "Help with Prevent devs at risk",
60                     "text": "This target blah blah ...",
61                     "url": "http://example.org/help",
62                     "linktext": "",
63                     "icon": {
64                         "extraclasses": "iconhelp",
65                         "attributes": [
66                             {"name": "src", "value": "../../../pix/help.svg"},
67                             {"name": "alt", "value": "Help icon"}
68                         ]
69                     }
70                 },
71                 "enabled": 1,
72                 "indicators": [
73                     {
74                         "name": "Indicator 1",
75                         "help": {
76                             "text": "This indicator blah blah ...",
77                             "title": "Help with Indicator 1",
78                             "url": "http://example.org/help",
79                             "linktext": "",
80                             "icon": {
81                                 "extraclasses": "iconhelp",
82                                 "attributes": [
83                                     {"name": "src", "value": "../../../pix/help.svg"},
84                                     {"name": "alt", "value": "Help icon"}
85                                 ]
86                             }
87                         }
88                     },
89                     {
90                         "name": "Indicator 2",
91                         "help": {
92                             "text": "This indicator blah blah ...",
93                             "title": "Help with Indicator 2",
94                             "url": "http://example.org/help",
95                             "linktext": "",
96                             "icon": {
97                                 "extraclasses": "iconhelp",
98                                 "attributes": [
99                                     {"name": "src", "value": "../../../pix/help.svg"},
100                                     {"name": "alt", "value": "Help icon"}
101                                 ]
102                             }
103                         }
104                     }
105                 ],
106                 "timesplitting": "Quarters",
107                 "timesplittinghelp": {
108                     "text": "This time splitting methof blah blah ...",
109                     "title": "Help with Quarters",
110                     "url": "http://example.org/help",
111                     "linktext": "",
112                     "icon": {
113                         "extraclasses": "iconhelp",
114                         "attributes": [
115                             {"name": "src", "value": "../../../pix/help.svg"},
116                             {"name": "alt", "value": "Help icon"}
117                         ]
118                     }
119                 },
120                 "noinsights": "No insights available yet"
121             }
122         ],
123         "warnings": [
124             {
125                 "message": "Be ware, this is just an example!"
126             }
127         ],
128         "createmodelurl": "#",
129         "importmodelurl": "#"
130     }
131 }}
133 {{#warnings}}
134     {{> core/notification_warning}}
135 {{/warnings}}
136 {{#infos}}
137     {{> core/notification_info}}
138 {{/infos}}
140 <div class="box">
141     <div class="top-nav d-flex">
142         <a href="{{createmodelurl}}" class="btn btn-secondary mr-2">{{#str}}createmodel, tool_analytics{{/str}}</a>
143         <a href="{{importmodelurl}}" class="btn btn-secondary">{{#str}}importmodel, tool_analytics{{/str}}</a>
144     </div>
145     <table class="generaltable fullwidth">
146         <caption>{{#str}}analyticmodels, tool_analytics{{/str}}</caption>
147         <thead>
148             <tr>
149                 <th scope="col">{{#str}}modelname, tool_analytics{{/str}}</th>
150                 <th scope="col">{{#str}}enabled, tool_analytics{{/str}}</th>
151                 <th scope="col">{{#str}}indicators, tool_analytics{{/str}}</th>
152                 <th scope="col">{{#str}}modeltimesplitting, tool_analytics{{/str}}</th>
153                 <th scope="col">{{#str}}insights, tool_analytics{{/str}}</th>
154                 <th scope="col">{{#str}}actions{{/str}}</th>
155             </tr>
156         </thead>
157         <tbody>
158         {{#models}}
159             <tr>
160                 <td>
161                     {{#name}}
162                         <span class="model-name">{{>core/inplace_editable}}</span>
163                     {{/name}}
164                     <div>
165                         <small class="target-class">{{targetclass}}</small>
166                         {{#targethelp}}
167                             {{>core/help_icon}}
168                         {{/targethelp}}
169                     </div>
170                 </td>
171                 <td>
172                     {{#enabled}}
173                         {{#pix}}i/checked, core, {{#str}}yes{{/str}}{{/pix}}
174                     {{/enabled}}
175                     {{^enabled}}
176                         {{#str}}no{{/str}}
177                     {{/enabled}}
178                 </td>
179                 <td>
180                     <ul>
181                     {{#indicators}}
182                         <li>
183                             {{name}}
184                             {{#help}}
185                                 {{>core/help_icon}}
186                             {{/help}}
187                         </li>
188                     {{/indicators}}
189                     </ul>
190                 </td>
191                 <td>
192                     {{#timesplitting}}
193                         {{timesplitting}}
194                         {{#timesplittinghelp}}
195                             {{>core/help_icon}}
196                         {{/timesplittinghelp}}
197                     {{/timesplitting}}
198                     {{^timesplitting}}
199                         {{#str}}notdefined, tool_analytics{{/str}}
200                         {{#timesplittinghelp}}
201                             {{>core/help_icon}}
202                         {{/timesplittinghelp}}
203                     {{/timesplitting}}
204                 </td>
205                 <td>
206                     {{! models_list renderer is responsible of sending one or the other}}
207                     {{#insights}}
208                         {{> core/single_select }}
209                     {{/insights}}
210                     {{#noinsights}}
211                         {{.}}
212                     {{/noinsights}}
213                 </td>
214                 <td>
215                     {{#actions}}
216                         {{> core/action_menu}}
217                     {{/actions}}
218                 </td>
219             </tr>
220         {{/models}}
221         </tbody>
222     </table>
223 </div>