Bug 21520: QA Follow-up: do not build html tags with TT conditions
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / oai_set_mappings.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Administration &rsaquo; OAI sets &rsaquo; OAI set mappings</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="admin_oai_set_mappings" class="admin">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'prefs-admin-search.inc' %]
12
13 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <a href="/cgi-bin/koha/admin/oai_sets.pl">OAI sets configuration</a> &rsaquo; <a href="/cgi-bin/koha/admin/oai_set_mappings.pl?id=[% id | html %]">OAI set mappings</a></div>
14
15 <div class="main container-fluid">
16     <div class="row">
17         <div class="col-sm-10 col-sm-push-2">
18             <main>
19
20       [% IF ( mappings_saved ) %]
21         <div class="dialog message">
22           <h4>Mappings have been saved</h4>
23           <p><a href="/cgi-bin/koha/admin/oai_sets.pl">Return to sets management</a></p>
24         </div>
25       [% END %]
26       <h1>Mappings for set '[% setName | html %]' ([% setSpec | html %])</h1>
27       [% UNLESS ( mappings ) %]
28         <div class="dialog alert"><p><strong>Warning:</strong> No mappings have been defined for this set</p></div>
29       [% END %]
30       <form action="/cgi-bin/koha/admin/oai_set_mappings.pl" method="post" id="mappingform">
31         <table id="mappings">
32           <thead>
33             <tr>
34               <th>Rule operator</th>
35               <th>Field</th>
36               <th>Subfield</th>
37               <th>Operator</th>
38               <th>Value</th>
39               <th>&nbsp;</th>
40               <th>&nbsp;</th>
41             </tr>
42           </thead>
43           <tbody>
44             [% IF ( mappings ) %]
45               [% FOREACH mapping IN mappings %]
46                 <tr>
47                   <td>
48                   <select name="rule_operator">
49                     [% IF (mapping.rule_operator == 'and') %]
50                     <option value="and" selected="selected">and</option>
51                     [% ELSE %]
52                     <option value="and">and</option>
53                     [% END %]
54                     [% IF (mapping.rule_operator == 'or') %]
55                     <option value="or" selected="selected">or</option>
56                     [% ELSE %]
57                     <option value="or">or</option>
58                     [% END %]
59                   </select>
60                   </td>
61                   <td><input type="text" name="marcfield" size="3" value="[% mapping.marcfield | html %]" /></td>
62                   <td style="text-align:center"><input type="text" name="marcsubfield" size="1" value="[% mapping.marcsubfield | html %]" /></td>
63                   <td><select name=operator>
64                       [% IF mapping.operator == 'equal' %]
65                         <option value="equal" selected="selected">is equal to</option>
66                         <option value="notequal">not equal to</option>
67                       [% ELSE %]
68                         <option value="equal">is equal to</option>
69                         <option value="notequal" selected="selected">not equal to</option>
70                       [% END %]
71                       </select></td>
72                   <td><input type="text" name="marcvalue" value="[% mapping.marcvalue | html %]" /></td>
73                   <td style="text-align:center">
74                     [% IF ( loop.last ) %]
75                       <input type="button" id="new_rule_button" value="add" title="Add another condition" />
76                     [% END %]
77                   </td>
78                   <td><button class="btn btn-default btn-xs clear-field" type="button"><i class="fa fa-trash"></i> Delete</button></td>
79                 </tr>
80               [% END %]
81             [% ELSE %]
82               <tr>
83                 <td>
84                   <select name="rule_operator">
85                     [% IF (mapping.rule_operator == 'and') %]
86                     <option value="and" selected="selected">and</option>
87                     [% ELSE %]
88                     <option value="and">and</option>
89                     [% END %]
90                     [% IF (mapping.rule_operator == 'or') %]
91                     <option value="or" selected="selected">or</option>
92                     [% ELSE %]
93                     <option value="or">or</option>
94                     [% END %]
95                   </select>
96                 </td>
97                 <td><input type="text" name="marcfield" size="3" /></td>
98                 <td style="text-align:center"><input type="text" name="marcsubfield" size="1" /></td>
99                 <td><select name=operator>
100                     <option value="equal">is equal to</option>
101                     <option value="notequal">not equal to</option>
102                     </select></td>
103                 <td><input type="text" name="marcvalue" /></td>
104                 <td><input type="button" id="new_rule_button" value="Add" /></td>
105                 <td><button class="btn btn-default btn-xs clear-field" type="button"><i class="fa fa-trash"></i> Delete</button></td>
106               </tr>
107             [% END %]
108           </tbody>
109         </table>
110         <input type="hidden" name="id" value="[% id | html %]" />
111         <input type="hidden" name="op" value="save" />
112         <fieldset class="action">
113             <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/oai_sets.pl">Cancel</a>
114         </fieldset>
115       </form>
116
117             </main>
118         </div> <!-- /.col-sm-10.col-sm-push-2 -->
119
120         <div class="col-sm-2 col-sm-pull-10">
121             <aside>
122                 [% INCLUDE 'admin-menu.inc' %]
123             </aside>
124         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
125      </div> <!-- /.row -->
126
127 [% MACRO jsinclude BLOCK %]
128     [% Asset.js("js/admin-menu.js") | $raw %]
129     <script>
130         $(document).ready(function() {
131             $("#mappingform").submit(function(){
132               hideDialogBox();
133             });
134             $("body").on("click","#new_rule_button", function(e){
135                 e.preventDefault();
136                 newCondition();
137             });
138             $("body").on("click",".clear-field",function(e){
139                 e.preventDefault();
140                 clearRow(e.target);
141             });
142             $("#mappings tbody tr:first-child td:first-child select").hide();
143         });
144
145         function newCondition() {
146             var tr = $('#new_rule_button').parents('tr');
147             var clone = $(tr).clone();
148             $("#new_rule_button").parent('td').find("#new_rule_button").remove();
149             $(clone).find("select").show();
150             $(tr).parent('tbody').append(clone);
151         }
152         function clearRow(link){
153             var tr = $(link).parent().parent();
154             var found = tr.find('#new_rule_button');
155             if( found.length ){
156               tr.find('input[type="text"]').attr("value","");
157             } else {
158               tr.remove();
159             }
160             $("#mappings tbody tr:first-child td:first-child select").hide();
161         }
162         function hideDialogBox() {
163             $('div.dialog').remove();
164         }
165     </script>
166 [% END %]
167 [% INCLUDE 'intranet-bottom.inc' %]