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