Bug 21520: More complex OAI sets mappings
[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                     <option value="and" [% IF (mapping.rule_operator == 'and') %] selected="selected" [% END %]>and</option>
50                     <option value="or" [% IF (mapping.rule_operator == 'or') %] selected="selected" [% END %]>or</option>
51                   </select>
52                   </td>
53                   <td><input type="text" name="marcfield" size="3" value="[% mapping.marcfield | html %]" /></td>
54                   <td style="text-align:center"><input type="text" name="marcsubfield" size="1" value="[% mapping.marcsubfield | html %]" /></td>
55                   <td><select name=operator>
56                       [% IF mapping.operator == 'equal' %]
57                         <option value="equal" selected="selected">is equal to</option>
58                         <option value="notequal">not equal to</option>
59                       [% ELSE %]
60                         <option value="equal">is equal to</option>
61                         <option value="notequal" selected="selected">not equal to</option>
62                       [% END %]
63                       </select></td>
64                   <td><input type="text" name="marcvalue" value="[% mapping.marcvalue | html %]" /></td>
65                   <td style="text-align:center">
66                     [% IF ( loop.last ) %]
67                       <input type="button" id="new_rule_button" value="add" title="Add another condition" />
68                     [% END %]
69                   </td>
70                   <td><button class="btn btn-default btn-xs clear-field" type="button"><i class="fa fa-trash"></i> Delete</button></td>
71                 </tr>
72               [% END %]
73             [% ELSE %]
74               <tr>
75                 <td>
76                   <select name="rule_operator">
77                     <option value="and" [% IF (mapping.rule_operator == 'and') %] selected="selected" [% END %]>and</option>
78                     <option value="or" [% IF (mapping.rule_operator == 'or') %] selected="selected" [% END %]>or</option>
79                   </select>
80                 </td>
81                 <td><input type="text" name="marcfield" size="3" /></td>
82                 <td style="text-align:center"><input type="text" name="marcsubfield" size="1" /></td>
83                 <td><select name=operator>
84                     <option value="equal">is equal to</option>
85                     <option value="notequal">not equal to</option>
86                     </select></td>
87                 <td><input type="text" name="marcvalue" /></td>
88                 <td><input type="button" id="new_rule_button" value="Add" /></td>
89                 <td><button class="btn btn-default btn-xs clear-field" type="button"><i class="fa fa-trash"></i> Delete</button></td>
90               </tr>
91             [% END %]
92           </tbody>
93         </table>
94         <input type="hidden" name="id" value="[% id | html %]" />
95         <input type="hidden" name="op" value="save" />
96         <fieldset class="action">
97             <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/oai_sets.pl">Cancel</a>
98         </fieldset>
99       </form>
100
101             </main>
102         </div> <!-- /.col-sm-10.col-sm-push-2 -->
103
104         <div class="col-sm-2 col-sm-pull-10">
105             <aside>
106                 [% INCLUDE 'admin-menu.inc' %]
107             </aside>
108         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
109      </div> <!-- /.row -->
110
111 [% MACRO jsinclude BLOCK %]
112     [% Asset.js("js/admin-menu.js") | $raw %]
113     <script>
114         $(document).ready(function() {
115             $("#mappingform").submit(function(){
116               hideDialogBox();
117             });
118             $("body").on("click","#new_rule_button", function(e){
119                 e.preventDefault();
120                 newCondition();
121             });
122             $("body").on("click",".clear-field",function(e){
123                 e.preventDefault();
124                 clearRow(e.target);
125             });
126             $("#mappings tbody tr:first-child td:first-child select").hide();
127         });
128
129         function newCondition() {
130             var tr = $('#new_rule_button').parents('tr');
131             var clone = $(tr).clone();
132             $("#new_rule_button").parent('td').find("#new_rule_button").remove();
133             $(clone).find("select").show();
134             $(tr).parent('tbody').append(clone);
135         }
136         function clearRow(link){
137             var tr = $(link).parent().parent();
138             var found = tr.find('#new_rule_button');
139             if( found.length ){
140               tr.find('input[type="text"]').attr("value","");
141             } else {
142               tr.remove();
143             }
144             $("#mappings tbody tr:first-child td:first-child select").hide();
145         }
146         function hideDialogBox() {
147             $('div.dialog').remove();
148         }
149     </script>
150 [% END %]
151 [% INCLUDE 'intranet-bottom.inc' %]