Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
{{!
2
    This file is part of Moodle - http://moodle.org/
3
 
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.
8
 
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.
13
 
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
19
 
20
    Template for models list.
21
 
22
    Classes required for JS:
23
    * The list od models wrapped within a id="predictionmodelslist" element.
24
 
25
    Data attributes required for JS:
26
    * [data-widget="toggle"] indicates the clickable element for expanding/collapsing
27
      the list of indicators used by the given model.
28
    * [data-model-name="..."] should be provided by an element wrapping the model's actions menu
29
      and contain the plain text name of the model.
30
 
31
    Context variables required for this template:
32
    * models: array - list of models to display
33
        - id: int - model unique identifier
34
        - modelname: string - name of the model
35
        - name: object - data for the inplace editable element template
36
        - target: string - name of the target associated with the model
37
        - targetclass: string - fully qualified name of the target class
38
        - targethelp: object - data for the help tooltip template
39
        - enabled: bool - is the model enabled
40
        - indicatorsnum: int - number of indicators
41
        - indicators: array - list of indicators used by the model
42
            + name: string - name of the indicator
43
            + help: object - data for the help tooltip template
44
        - insights: object - data for the single select template
45
        - noinsights: string - text to display instead of insights
46
    * warnings: array - list of data for notification warning template
47
    * infos: array - list of data for notification info template
48
    * createmodelurl: string - URL to create a new model
49
    * importmodelurl: string - URL to import a model
50
 
51
    Example context (json):
52
    {
53
        "models": [
54
            {
55
                "id": 11,
56
                "modelname": "Prevent devs at risk",
57
                "name": {
58
                    "component": "local_analyticsdemo",
59
                    "itemtype": "modelname",
60
                    "itemid": 42,
61
                    "displayvalue": "Prevent devs at risk",
62
                    "value": ""
63
                },
64
                "target": "Prevent devs at risk",
65
                "targetclass": "\\local_analyticsdemo\\analytics\\target\\dev_risk",
66
                "targethelp": {
67
                    "title": "Help with Prevent devs at risk",
68
                    "text": "This target blah blah ...",
69
                    "url": "http://example.org/help",
70
                    "linktext": "",
71
                    "icon": {
72
                        "extraclasses": "iconhelp",
73
                        "attributes": [
74
                            {"name": "src", "value": "../../../pix/help.svg"},
75
                            {"name": "alt", "value": "Help icon"}
76
                        ]
77
                    }
78
                },
79
                "enabled": 1,
80
                "indicatorsnum": 2,
81
                "indicators": [
82
                    {
83
                        "name": "Indicator 1",
84
                        "help": {
85
                            "text": "This indicator blah blah ...",
86
                            "title": "Help with Indicator 1",
87
                            "url": "http://example.org/help",
88
                            "linktext": "",
89
                            "icon": {
90
                                "extraclasses": "iconhelp",
91
                                "attributes": [
92
                                    {"name": "src", "value": "../../../pix/help.svg"},
93
                                    {"name": "alt", "value": "Help icon"}
94
                                ]
95
                            }
96
                        }
97
                    },
98
                    {
99
                        "name": "Indicator 2",
100
                        "help": {
101
                            "text": "This indicator blah blah ...",
102
                            "title": "Help with Indicator 2",
103
                            "url": "http://example.org/help",
104
                            "linktext": "",
105
                            "icon": {
106
                                "extraclasses": "iconhelp",
107
                                "attributes": [
108
                                    {"name": "src", "value": "../../../pix/help.svg"},
109
                                    {"name": "alt", "value": "Help icon"}
110
                                ]
111
                            }
112
                        }
113
                    }
114
                ],
115
                "timesplitting": "Quarters",
116
                "timesplittinghelp": {
117
                    "text": "This time splitting methof blah blah ...",
118
                    "title": "Help with Quarters",
119
                    "url": "http://example.org/help",
120
                    "linktext": "",
121
                    "icon": {
122
                        "extraclasses": "iconhelp",
123
                        "attributes": [
124
                            {"name": "src", "value": "../../../pix/help.svg"},
125
                            {"name": "alt", "value": "Help icon"}
126
                        ]
127
                    }
128
                },
129
                "noinsights": "No insights available yet"
130
            }
131
        ],
132
        "warnings": [
133
            {
134
                "message": "Be ware, this is just an example!"
135
            }
136
        ],
137
        "createmodelurl": "#",
138
        "importmodelurl": "#"
139
    }
140
}}
141
 
142
{{#warnings}}
143
    {{> core/notification_warning}}
144
{{/warnings}}
145
{{#infos}}
146
    {{> core/notification_info}}
147
{{/infos}}
148
 
149
<div class="box">
150
    <div class="top-nav d-flex">
151
        {{#newmodelmenu}}
152
        {{>core/action_menu}}
153
        {{/newmodelmenu}}
154
    </div>
155
    <table id="predictionmodelslist" class="generaltable fullwidth">
156
        <caption>{{#str}}analyticmodels, tool_analytics{{/str}}</caption>
157
        <thead>
158
            <tr>
159
                <th scope="col">{{#str}}modelname, tool_analytics{{/str}}</th>
160
                <th scope="col">{{#str}}enabled, tool_analytics{{/str}}</th>
161
                <th scope="col">{{#str}}indicators, tool_analytics{{/str}}</th>
162
                <th scope="col">{{#str}}modeltimesplitting, tool_analytics{{/str}}</th>
163
                <th scope="col">{{#str}}insights, tool_analytics{{/str}}</th>
164
                <th scope="col">{{#str}}actions{{/str}}</th>
165
            </tr>
166
        </thead>
167
        <tbody>
168
        {{#models}}
169
            <tr data-model-name="{{modelname}}">
170
                <td>
171
                    {{#name}}
172
                        <span class="model-name">{{>core/inplace_editable}}</span>
173
                    {{/name}}
174
                    <div>
175
                        <small class="target-class">{{targetclass}}</small>
176
                        {{#targethelp}}
177
                            {{>core/help_icon}}
178
                        {{/targethelp}}
179
                    </div>
180
                </td>
181
                <td>
182
                    {{#enabled}}
183
                        {{#pix}}i/checked, core, {{#str}}yes{{/str}}{{/pix}}
184
                    {{/enabled}}
185
                    {{^enabled}}
186
                        {{#str}}no{{/str}}
187
                    {{/enabled}}
188
                </td>
189
                <td>
190
                    <a data-widget="toggle"
191
                           title="{{#str}} clicktohideshow {{/str}}"
192
                           aria-expanded="false"
193
                           aria-controls="indicators-{{id}}"
194
                           role="button"
195
                           href="">
196
                        {{#str}} indicatorsnum, tool_analytics, {{indicatorsnum}} {{/str}}
197
                    </a>
198
                    <ul class="hidden" id="indicators-{{id}}">
199
                    {{#indicators}}
200
                        <li>
201
                            {{name}}
202
                            {{#help}}
203
                                {{>core/help_icon}}
204
                            {{/help}}
205
                        </li>
206
                    {{/indicators}}
207
                    </ul>
208
                </td>
209
                <td>
210
                    {{#timesplitting}}
211
                        {{timesplitting}}
212
                        {{#timesplittinghelp}}
213
                            {{>core/help_icon}}
214
                        {{/timesplittinghelp}}
215
                    {{/timesplitting}}
216
                    {{^timesplitting}}
217
                        {{#str}}notdefined, tool_analytics{{/str}}
218
                        {{#timesplittinghelp}}
219
                            {{>core/help_icon}}
220
                        {{/timesplittinghelp}}
221
                    {{/timesplitting}}
222
                </td>
223
                <td>
224
                    {{! models_list renderer is responsible of sending one or the other}}
225
                    {{#insights}}
226
                        {{> core/single_select }}
227
                    {{/insights}}
228
                    {{#noinsights}}
229
                        {{.}}
230
                    {{/noinsights}}
231
                </td>
232
                <td>
233
                    {{#actions}}
234
                        {{> core/action_menu}}
235
                    {{/actions}}
236
                </td>
237
            </tr>
238
        {{/models}}
239
        </tbody>
240
    </table>
241
</div>
242
{{#js}}
243
require(['jquery'], function($) {
244
 
245
    // Toggle the visibility of the indicators list.
246
    $('#predictionmodelslist').on('click', '[data-widget="toggle"]', function(e) {
247
        e.preventDefault();
248
        var toggle = $(e.currentTarget);
249
        var listid = toggle.attr('aria-controls');
250
 
251
        $(document.getElementById(listid)).toggle();
252
 
253
        if (toggle.attr('aria-expanded') == 'false') {
254
            toggle.attr('aria-expanded', 'true');
255
        } else {
256
            toggle.attr('aria-expanded', 'false');
257
        }
258
    });
259
});
260
{{/js}}