131544806fad9210896ed60e6662525879cab726
[moodle.git] / admin / tool / policy / templates / acceptances.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_policy/acceptances
20     Template for the user acceptances page.
22     Classes required for JS:
23     -
25     Data attributes required for JS:
26     -
28     Context variables required for this template:
29     * policies
31     Example context (json):
32     {
33         "hasonbehalfagreements": true,
34         "canrevoke": true,
35         "policies": [
36             {
37               "versions": [
38                     {
39                         "isfirst": true,
40                         "policyid": 1,
41                         "viewurl": "/",
42                         "name": "Terms &amp; conditions",
43                         "revision": "2.0",
44                         "hasarchived": true,
45                         "timeaccepted": "1 Mar 2018",
46                         "agreement": {
47                             "onbehalf": false,
48                             "status": false,
49                             "canaccept": true,
50                             "acceptlink": "#"
51                         }
52                     },
53                     {
54                         "isfirst": false,
55                         "policyid": 1,
56                         "viewurl": "/",
57                         "name": "Terms &amp; conditions",
58                         "revision": "1.0-beta",
59                         "acceptedby": "<a href=\"#\">Mary Smith</a>",
60                         "note": "Based on parent's agreement via email",
61                         "hasarchived": false,
62                         "timeaccepted": "15 Feb 2018",
63                         "agreement": {
64                             "onbehalf": true,
65                             "status": true,
66                             "canaccept": false
67                         }
68                     }
69                 ]
70             }
71         ]
72     }
73 }}
74 {{^canrevoke}}
75     <div class="alert alert-info">{{#str}} contactdpo, tool_policy {{/str}}</div>
76 {{/canrevoke}}
78 <table class="generaltable fullwidth">
79     <thead>
80     <tr>
81         <th>{{#str}} policydocname, tool_policy {{/str}}</th>
82         <th>{{#str}} policydocrevision, tool_policy {{/str}}</th>
83         <th>{{#str}} agreed, tool_policy {{/str}}</th>
84         <th>{{#str}} agreedon, tool_policy {{/str}}</th>
85         {{#hasonbehalfagreements}}
86         <th>{{#str}} agreedby, tool_policy {{/str}}</th>
87         <th>{{#str}} acceptancenote, tool_policy {{/str}}</th>
88         {{/hasonbehalfagreements}}
89         <th></th>
90     </tr>
91     </thead>
92     <tbody>
93         {{#policies}}
94             {{#versions}}
95                 <tr {{^isfirst}}class="archived{{policyid}}" style="display:none"{{/isfirst}}>
96                     <td>
97                         {{^isfirst}}
98                             <div style="float:left">
99                                 {{#pix}} level, tool_policy {{/pix}}
100                             </div>
101                         {{/isfirst}}
102                         <div {{^isfirst}}style="margin-left: 24px" {{/isfirst}}>
103                             <div><a href="{{viewurl}}">{{{name}}}</a></div>
104                         </div>
105                     </td>
106                     <td>
107                         <a href="{{viewurl}}">{{{revision}}}</a>
108                         {{#iscurrent}}<span class="label label-success">{{#str}} status1, tool_policy {{/str}}{{/iscurrent}}
109                     </td>
110                     <td>
111                         {{#agreement}}
112                             {{>tool_policy/user_agreement}}
113                         {{/agreement}}
115                     </td>
116                     <td>{{timeaccepted}}</td>
117                     {{#hasonbehalfagreements}}
118                     <td>{{{acceptedby}}}</td>
119                     <td>{{{note}}}</td>
120                     {{/hasonbehalfagreements}}
121                     <td>
122                         {{#hasarchived}}<a class="showarchived" data-target=".archived{{policyid}}" data-status="hidden" href="#">
123                             <div class="toggleoff" style="display:none">{{#pix}}t/less, moodle, {{#str}}detailedless, moodle{{/str}}{{/pix}}</div>
124                             <div class="toggleon">{{#pix}}t/more, moodle, {{#str}}detailedmore, moodle{{/str}}{{/pix}}</div>
125                         </a>{{/hasarchived}}
126                     </td>
127                 </tr>
128             {{/versions}}
129         {{/policies}}
130     </tbody>
131 </table>
132 {{#returnurl}}
133     <div><a role="button" href="{{returnurl}}" class="btn btn-primary">{{#str}} back {{/str}}</a></div>
134 {{/returnurl}}
135 {{#js}}
136     require(['jquery'], function($) {
137         $('body').on('click', '.showarchived', function(e) {
138             e.preventDefault();
139             var target = $(this).attr('data-target'),
140                 status = $(this).attr('data-status');
141             if (status === 'hidden') {
142                 $(target).show();
143                 $(this).attr('data-status', 'shown');
144                 $(this).find('.toggleoff').show();
145                 $(this).find('.toggleon').hide();
146             } else {
147                 $(target).hide();
148                 $(this).attr('data-status', 'hidden');
149                 $(this).find('.toggleon').show();
150                 $(this).find('.toggleoff').hide();
151             }
152         });
153     });
154 {{/js}}