2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha › Administration › MARC overlay rules</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 [% Asset.css("css/datatables.css") %]
6 [% INCLUDE 'datatables.inc' %]
8 <style type="text/css">
10 background-color: #C00;
14 <script type="text/javascript">
15 function doSubmit(op, id) {
16 $('<input type="hidden"/>')
19 .appendTo('#marc-overlay-rules-form');
22 $('<input type="hidden"/>')
25 .appendTo('#marc-overlay-rules-form');
29 if (op == 'add' || op == 'edit') {
31 $('#marc-overlay-rules-form input[name="filter"]'),
32 $('#marc-overlay-rules-form input[name="tag"]')
34 for(var i = 0; i < validate.length; i++) {
35 if (validate[i].length) {
36 if(validate[i].val().length == 0) {
37 validate[i].addClass('required');
40 validate[i].removeClass('required');
47 $('#marc-overlay-rules-form').submit();
53 $(document).ready(function(){
54 $('#doremove').on('click', function(){
57 $('#doedit').on('click', function(){
58 doSubmit('doedit', $("#doedit").attr('value'));
60 $('#add').on('click', function(){
64 $('#btn_batchremove').on('click', function(){
68 /* Disable batch remove unless one or more checkboxes are checked */
69 $('input[name="batchremove"]').change(function() {
70 if($('input[name="batchremove"]:checked').length > 0) {
71 $('#btn_batchremove').removeAttr('disabled');
73 $('#btn_batchremove').attr('disabled', 'disabled');
77 $.fn.dataTable.ext.order['dom-input'] = function (settings, col) {
78 return this.api().column(col, { order: 'index' }).nodes()
79 .map(function (td, i) {
80 if($('input', td).val() != undefined) {
81 return $('input', td).val();
82 } else if($('select', td).val() != undefined) {
83 return $('option[selected="selected"]', td).val();
90 $('#marc-overlay-rules').dataTable($.extend(true, {}, dataTablesDefaults, {
92 {"bSearchable": false, "bSortable": false},
93 {"sSortDataType": "dom-input"},
94 {"sSortDataType": "dom-input"},
95 {"bSearchable": false, "sSortDataType": "dom-input"},
96 {"bSearchable": false, "sSortDataType": "dom-input"},
97 {"bSearchable": false, "sSortDataType": "dom-input"},
98 {"bSearchable": false, "sSortDataType": "dom-input"},
99 {"bSearchable": false, "sSortDataType": "dom-input"},
100 {"bSearchable": false, "sSortDataType": "dom-input"},
101 {"bSearchable": false, "bSortable": false},
102 {"bSearchable": false, "bSortable": false}
104 "pagingType": "simple"
107 var overlay_rules_presets = {};
108 overlay_rules_presets[_("Protect")] = {
114 overlay_rules_presets[_("Overwrite")] = {
120 overlay_rules_presets[_("Add new")] = {
126 overlay_rules_presets[_("Add and append")] = {
132 overlay_rules_presets[_("Protect from deletion")] = {
139 var overlay_rules_label_to_value = {};
140 overlay_rules_label_to_value[_("Add")] = 1;
141 overlay_rules_label_to_value[_("Append")] = 1;
142 overlay_rules_label_to_value[_("Remove")] = 1;
143 overlay_rules_label_to_value[_("Delete")] = 1;
144 overlay_rules_label_to_value[_("Skip")] = 0;
146 function hash_config(config) {
147 return JSON.stringify(config, Object.keys(config).sort());
150 var overlay_rules_preset_map = {};
151 $.each(overlay_rules_presets, function(preset, config) {
152 overlay_rules_preset_map[hash_config(config)] = preset;
155 function operations_config_overlay_rule_preset(config) {
156 return overlay_rules_preset_map[hash_config(config)] || '';
159 /* Set preset values according to operation config */
160 $('.rule').each(function() {
162 var operations_config = {};
163 $('.rule-operation-action', $this).each(function() {
164 var $operation = $(this);
165 operations_config[$operation.data('operation')] = overlay_rules_label_to_value[$operation.text()];
167 $('.rule-preset', $this).text(
168 operations_config_overlay_rule_preset(operations_config) || _("Custom")
172 /* Listen to operations config changes and set presets accordingly */
173 $('.rule-operation-action-edit select').change(function() {
174 var operations_config = {};
175 var $parent_row = $(this).closest('tr');
176 $('.rule-operation-action-edit select', $parent_row).each(function() {
178 operations_config[$this.attr('name')] = parseInt($this.val());
180 $('select[name="preset"]', $parent_row).val(
181 operations_config_overlay_rule_preset(operations_config)
185 /* Listen to preset changes and set operations config accordingly */
186 $('select[name="preset"]').change(function() {
188 var $parent_row = $this.closest('tr');
189 var preset = $this.val();
191 $.each(overlay_rules_presets[preset], function(operation, action) {
192 $('select[name="' + operation + '"]', $parent_row).val(action);
197 var module_filter_options = {
200 batchmod: _("Batch record modification"),
201 intranet: _("Staff client MARC editor"),
202 batchimport: _("Staged MARC import"),
204 /* bulkmarcimport: _("bulkmarcimport.pl"), */
205 import_lexile: _("import_lexile.pl")
209 [% FOREACH categorycode IN categorycodes %]
210 [% categorycode.categorycode | html %]: "[% categorycode.description | html %]",
215 //Kind of hack: Replace filter value with label when one exist
216 $('.rule-module').each(function() {
218 var module = $this.text();
219 if (module in module_filter_options) {
220 let $filter = $this.siblings('.rule-filter');
221 if ($filter.text() in module_filter_options[module]) {
222 $filter.text(module_filter_options[module][$filter.text()]);
227 var $filter_container = $('#filter-container');
229 /* Listen to module changes and set filter input accordingly */
230 $('select[name="module"]').change(function() {
232 var module_name = $this.val();
234 /* Remove current element if any */
235 $filter_container.empty();
237 var filter_elem = null;
238 if (module_name in module_filter_options) {
239 // Create select element
240 filter_elem = document.createElement('select');
241 for (var filter_value in module_filter_options[module_name]) {
242 var option = document.createElement('option');
243 option.value = filter_value;
244 option.text = module_filter_options[module_name][filter_value];
245 filter_elem.appendChild(option);
249 // Create text input element
250 filter_elem = document.createElement('input');
251 filter_elem.type = 'text';
252 filter_elem.setAttribute('size', 5);
254 filter_elem.name = 'filter';
255 filter_elem.id = 'filter';
256 $filter_container.append(filter_elem);
257 }).change(); // Trigger change
259 // Hack: set value if editing rule
260 if ($filter_container.data('filter')) {
261 $('#filter').val($filter_container.data('filter'));
267 <body id="admin_marc-overlay-rules" class="admin">
268 [% INCLUDE 'header.inc' %]
269 [% INCLUDE 'cat-search.inc' %]
271 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
272 › MARC overlay rules
275 <div class="main container-fluid">
277 <div class="col-sm-10 col-sm-push-2">
279 <h1>Manage MARC overlay rules</h1>
281 [% FOR m IN messages %]
282 <div class="dialog [% m.type | html %]">
284 [% CASE 'invalid_tag_regexp' %]
285 Invalid regular expression "[% m.tag | html %]".
286 [% CASE 'invalid_control_field_actions' %]
287 Invalid combination of actions for tag [% m.tag | html %]. Control field rules do not allow "Appended: Append" and "Removed: Skip".
294 [% UNLESS Koha.Preference( 'MARCOverlayRules' ) %]
295 <div class="dialog message">
296 The <b>MARCOverlayRules</b> preference is not set, don't forget to enable it for rules to take effect.
299 [% IF removeConfirm %]
300 <div class="dialog alert">
301 <h3>Remove rule?</h3>
302 <p>Are you sure you want to remove the selected rule(s)?</p>
304 <form action="[% script_name %]" method="GET">
305 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not remove</button>
307 <button type="button" class="approve" id="doremove"><i class="fa fa-fw fa-check"></i> Yes, remove</button>
311 <form action="[% script_name %]" method="POST" id="marc-overlay-rules-form">
312 <table id="marc-overlay-rules">
319 <th>Added <i id="info_added" data-toggle="tooltip" title="If a field matching the rule tag only exists in the incoming record" data-placement="right" class="fa fa-info-circle"></i></th>
320 <th>Appended <i id="info_appended" data-toggle="tooltip" title="If the original record has one or more fields matching with the rule tag, but one or more fields matching the rule tag differ in the incoming record" data-placement="right" class="fa fa-info-circle"></i></th>
321 <th>Removed <i id="info_removed" data-toggle="tooltip" title="If the original record has a field matching the rule tag, but the matching field is not in the incoming record" data-placement="right" class="fa fa-info-circle"></i></th>
322 <th>Deleted <i id="info_deleted" data-toggle="tooltip" title="If the original record has fields matching the rule tag, but no fields with this are found in the incoming record" data-placement="right" class="fa fa-info-circle"></i></th>
328 <tr class="rule-new">
331 <select name="module">
332 <option value="source">Source</option>
333 <option value="categorycode">User category</option>
334 <option value="userid">Username</option>
337 <th id="filter-container"></th>
338 <th><input type="text" size="5" name="tag"/></th>
340 <select name="preset">
341 <option value="" selected>Custom</option>
342 <option value="Protect">Protect</option>
343 <option value="Overwrite">Overwrite</option>
344 <option value="Add new">Add new</option>
345 <option value="Add and append">Add and append</option>
346 <option value="Protect from deletion">Protect from deletion</option>
349 <th class="rule-operation-action-edit">
351 <option value="0">Skip</option>
352 <option value="1">Add</option>
355 <th class="rule-operation-action-edit">
356 <select name="append">
357 <option value="0">Skip</option>
358 <option value="1">Append</option>
361 <th class="rule-operation-action-edit">
362 <select name="remove">
363 <option value="0">Skip</option>
364 <option value="1">Remove</option>
367 <th class="rule-operation-action-edit">
368 <select name="delete">
369 <option value="0">Skip</option>
370 <option value="1">Delete</option>
373 <th><button class="btn btn-default btn-xs" title="Add" id="add"><i class="fa fa-plus"></i> Add rule</button></th>
374 <th><button id="btn_batchremove" disabled="disabled" class="btn btn-default btn-xs" title="Batch remove"><i class="fa fa-trash"></i> Delete selected</button></th>
379 [% FOREACH rule IN rules %]
380 <tr id="[% rule.id %]" class="rule[% IF rule.edit %]-edit[% END %]">
382 <td>[% rule.id %]</td>
384 <select name="module">
385 [% IF rule.module == "source" %]
386 <option value="source" selected="selected">Source</option>
388 <option value="source">Source</option>
390 [% IF rule.module == "categorycode" %]
391 <option value="categorycode" selected="selected">User category</option>
393 <option value="categorycode">User category</option>
395 [% IF rule.module == "userid" %]
396 <option value="userid" selected="selected">Username</option>
398 <option value="userid">Username</option>
402 <td id="filter-container" data-filter="[% rule.filter | html %]"></td>
403 <td><input type="text" size="3" name="tag" value="[% rule.tag | html %]"/></td>
405 <select name="preset">
406 <option value="" selected>Custom</option>
407 <option value="Protect">Protect</option>
408 <option value="Overwrite">Overwrite</option>
409 <option value="Add new">Add new</option>
410 <option value="Add and append">Add and append</option>
411 <option value="Protect from deletion">Protect from deletion</option>
414 <td class="rule-operation-action-edit">
417 <option value="0">Skip</option>
418 <option value="1" selected="selected">Add</option>
420 <option value="0" selected="selected">Skip</option>
421 <option value="1">Add</option>
425 <td class="rule-operation-action-edit">
426 <select name="append">
428 <option value="0">Skip</option>
429 <option value="1" selected="selected">Append</option>
431 <option value="0" selected="selected">Skip</option>
432 <option value="1">Append</option>
436 <td class="rule-operation-action-edit">
437 <select name="remove">
439 <option value="0">Skip</option>
440 <option value="1" selected="selected">Remove</option>
442 <option value="0" selected="selected">Skip</option>
443 <option value="1">Remove</option>
447 <td class="rule-operation-action-edit">
448 <select name="delete">
450 <option value="0">Skip</option>
451 <option value="1" selected="selected">Delete</option>
453 <option value="0" selected="selected">Skip</option>
454 <option value="1">Delete</option>
459 <button class="btn btn-default btn-xs" title="Save" id="doedit" value="[% rule.id | html %]"><i class="fa fa-check"></i> Save</button>
460 <button type="submit" class="btn btn-default btn-xs" title="Cancel" ><i class="fa fa-times"></i> Cancel</button>
464 <td>[% rule.id | html %]</td>
465 <td class="rule-module">[% rule.module | html %]</td>
466 <td class="rule-filter">[% rule.filter | html %]</td>
467 <td>[% rule.tag | html %]</td>
468 <td class="rule-preset"></td>
469 <td class="rule-operation-action" data-operation="add">[% IF rule.add %]Add[% ELSE %]Skip[% END %]</td>
470 <td class="rule-operation-action" data-operation="append">[% IF rule.append %]Append[% ELSE %]Skip[% END %]</td>
471 <td class="rule-operation-action" data-operation="remove">[% IF rule.remove %]Remove[% ELSE %]Skip[% END %]</td>
472 <td class="rule-operation-action" data-operation="delete">[% IF rule.delete %]Delete[% ELSE %]Skip[% END %]</td>
474 <a href="?op=remove&id=[% rule.id %]" title="Delete" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
475 <a href="?op=edit&id=[% rule.id %]" title="Edit" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
478 [% IF rule.removemarked %]
479 <input type="checkbox" name="batchremove" value="[% rule.id | html %]" checked="checked"/>
481 <input type="checkbox" name="batchremove" value="[% rule.id | html %]"/>
491 <form action="[% script_name %]" method="post">
492 <input type="hidden" name="op" value="redo-matching" />
496 <!-- /.col-sm-10.col-sm-push-2 -->
498 <div class="col-sm-2 col-sm-pull-10">
500 [% INCLUDE 'admin-menu.inc' %]
507 <!-- /main container-fluid -->
509 [% INCLUDE 'intranet-bottom.inc' %]