MDL-61899 tool_dataprivacy: Addition of plugin compliance registry.
[moodle.git] / admin / tool / dataprivacy / templates / data_registry_compliance.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 comments.
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_dataprivacy/data_registry_compliance
20     Data registry main page.
22     Classes required for JS:
23     * none
25     Data attributes required for JS:
26     * none
28     Context variables required for this template:
29     * none
31     Example context (json):
32     {
33         "types" : {
34             "plugin_type_raw" : "mod",
35             "plugin_type" : "Activities and Modules"
36         }
37     }
38 }}
39 <div>
40     <h2>{{#str}}pluginregistrytitle, tool_dataprivacy{{/str}}</h2>
41     <hr />
42     <p><strong>{{#str}}explanationtitle, tool_dataprivacy{{/str}}</strong></p>
43     <dl>
44         <dt>{{#pix}}i/risk_xss, moodle, {{#str}}requiresattention, tool_dataprivacy{{/str}}{{/pix}}</dt>
45         <dd>{{#str}}requiresattentionexplanation, tool_dataprivacy{{/str}}</dd>
46         <dt><span class="badge badge-pill badge-notice">{{#str}}external, tool_dataprivacy{{/str}}</span></dt>
47         <dd>{{#str}}externalexplanation, tool_dataprivacy{{/str}}</dd>
48     </dl>
49     <hr />
50     <div><a class="tool_dataprivacy-expand-all pull-right" href="#" data-visibility-state='visible'>{{#str}}visible, tool_dataprivacy{{/str}}</a></div>
51     {{#types}}
52         <div class="container-fluid">
53             <div class="row">
54                 <div class="col">
55                     <a class="other-expand" href='#' data-plugin="{{plugin_type_raw}}">
56                     <h3 id="{{plugin_type_raw}}">{{#pix}}t/collapsed, moodle, {{#str}}expandplugintype, tool_dataprivacy{{/str}}{{/pix}}{{plugin_type}}</h3>
57                     </a>
58                 </div>
59             </div>
60             <div class="hide" data-plugintarget="{{plugin_type_raw}}" aria-expanded="false">
61                 {{#plugins}}
62                     {{> tool_dataprivacy/component_status}}
63                 {{/plugins}}
64             </div>
65         </div>
66     {{/types}}
67 </div>
68 {{#js}}
69 require(['jquery', 'core/url', 'core/str'], function($, url, str) {
71     var expandedImage = $('<img alt="" src="' + url.imageUrl('t/expanded') + '"/>');
72     var collapsedImage = $('<img alt="" src="' + url.imageUrl('t/collapsed') + '"/>');
74     $('.other-expand').click(function(e) {
75         e.preventDefault();
76         e.stopPropagation();
77         e.stopImmediatePropagation();
78         window.console.log(this);
79         var plugin = $(this).data('plugin');
80         var metadata = $('[data-plugintarget=\'' + plugin + '\']');
81         if (metadata.attr('class') === 'hide') {
82             metadata.attr('class', 'visible');
83             $(this).children('img').attr('src', expandedImage.attr('src'));
84             metadata.attr('aria-expanded', true);
85         } else {
86             metadata.attr('class', 'hide');
87             $(this).children('img').attr('src', collapsedImage.attr('src'));
88             metadata.attr('aria-expanded', false);
89         }
90     });
92     $('.tool_dataprivacy-expand-all').click(function(e) {
93         e.preventDefault();
94         e.stopPropagation();
95         var nextstate = $(this).data('visibilityState');
96         var currentstate = (nextstate == 'visible') ? 'hide' : 'visible';
97         var ariaexpandedstate = (nextstate == 'visible') ? true : false;
98         $('.' + currentstate).each(function() {
99             $(this).attr('class', nextstate);
100             $(this).attr('aria-expanded', ariaexpandedstate);
101         });
102         $(this).data('visibilityState', currentstate);
104         str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) {
105             var visibilitynode = $('.tool_dataprivacy-expand-all');
106             visibilitynode.html(langString);
107         }).catch(Notification.exception);
108     });
109 });
110 {{/js}}