3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>MARC overlay rules › Koha › Administration</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 [% Asset.css("css/datatables.css") | $raw %]
7 [% INCLUDE 'datatables.inc' %]
11 background-color: #C00;
16 function doSubmit(op, id) {
17 $('<input type="hidden"/>')
20 .appendTo('#marc-overlay-rules-form');
23 $('<input type="hidden"/>')
26 .appendTo('#marc-overlay-rules-form');
30 if (op == 'add' || op == 'edit') {
32 $('#marc-overlay-rules-form input[name="filter"]'),
33 $('#marc-overlay-rules-form input[name="tag"]')
35 for(var i = 0; i < validate.length; i++) {
36 if (validate[i].length) {
37 if(validate[i].val().length == 0) {
38 validate[i].addClass('required');
41 validate[i].removeClass('required');
48 $('#marc-overlay-rules-form').submit();
54 $(document).ready(function(){
55 $('#doremove').on('click', function(){
58 $('#doedit').on('click', function(){
59 doSubmit('doedit', $("#doedit").attr('value'));
61 $('#add').on('click', function(){
65 $('#btn_batchremove').on('click', function(){
69 /* Disable batch remove unless one or more checkboxes are checked */
70 $('input[name="batchremove"]').change(function() {
71 if($('input[name="batchremove"]:checked').length > 0) {
72 $('#btn_batchremove').removeAttr('disabled');
74 $('#btn_batchremove').attr('disabled', 'disabled');
78 $.fn.dataTable.ext.order['dom-input'] = function (settings, col) {
79 return this.api().column(col, { order: 'index' }).nodes()
80 .map(function (td, i) {
81 if($('input', td).val() != undefined) {
82 return $('input', td).val();
83 } else if($('select', td).val() != undefined) {
84 return $('option[selected="selected"]', td).val();
91 $('#marc-overlay-rules').dataTable($.extend(true, {}, dataTablesDefaults, {
93 {"bSearchable": false, "bSortable": false},
94 {"sSortDataType": "dom-input"},
95 {"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, "sSortDataType": "dom-input"},
102 {"bSearchable": false, "bSortable": false},
103 {"bSearchable": false, "bSortable": false}
105 "pagingType": "simple"
108 var overlay_rules_presets = {};
109 overlay_rules_presets[_("Protect")] = {
115 overlay_rules_presets[_("Overwrite")] = {
121 overlay_rules_presets[_("Add new")] = {
127 overlay_rules_presets[_("Add and append")] = {
133 overlay_rules_presets[_("Protect from deletion")] = {
140 var overlay_rules_label_to_value = {};
141 overlay_rules_label_to_value[_("Add")] = 1;
142 overlay_rules_label_to_value[_("Append")] = 1;
143 overlay_rules_label_to_value[_("Remove")] = 1;
144 overlay_rules_label_to_value[_("Delete")] = 1;
145 overlay_rules_label_to_value[_("Skip")] = 0;
147 function hash_config(config) {
148 return JSON.stringify(config, Object.keys(config).sort());
151 var overlay_rules_preset_map = {};
152 $.each(overlay_rules_presets, function(preset, config) {
153 overlay_rules_preset_map[hash_config(config)] = preset;
156 function operations_config_overlay_rule_preset(config) {
157 return overlay_rules_preset_map[hash_config(config)] || '';
160 /* Set preset values according to operation config */
161 $('.rule').each(function() {
163 var operations_config = {};
164 $('.rule-operation-action', $this).each(function() {
165 var $operation = $(this);
166 operations_config[$operation.data('operation')] = overlay_rules_label_to_value[$operation.text()];
168 $('.rule-preset', $this).text(
169 operations_config_overlay_rule_preset(operations_config) || _("Custom")
173 /* Listen to operations config changes and set presets accordingly */
174 $('.rule-operation-action-edit select').change(function() {
175 var operations_config = {};
176 var $parent_row = $(this).closest('tr');
177 $('.rule-operation-action-edit select', $parent_row).each(function() {
179 operations_config[$this.attr('name')] = parseInt($this.val());
181 $('select[name="preset"]', $parent_row).val(
182 operations_config_overlay_rule_preset(operations_config)
186 /* Listen to preset changes and set operations config accordingly */
187 $('select[name="preset"]').change(function() {
189 var $parent_row = $this.closest('tr');
190 var preset = $this.val();
192 $.each(overlay_rules_presets[preset], function(operation, action) {
193 $('select[name="' + operation + '"]', $parent_row).val(action);
198 var module_filter_options = {
201 batchmod: _("Batch record modification"),
202 intranet: _("Staff client MARC editor"),
203 batchimport: _("Staged MARC import"),
205 /* bulkmarcimport: _("bulkmarcimport.pl"), */
206 import_lexile: _("import_lexile.pl")
210 [% FOREACH categorycode IN categorycodes %]
211 [% categorycode.categorycode | html %]: "[% categorycode.description | html %]",
216 //Kind of hack: Replace filter value with label when one exist
217 $('.rule-module').each(function() {
219 var module = $this.text();
220 if (module in module_filter_options) {
221 let $filter = $this.siblings('.rule-filter');
222 if ($filter.text() in module_filter_options[module]) {
223 $filter.text(module_filter_options[module][$filter.text()]);
228 var $filter_container = $('#filter-container');
230 /* Listen to module changes and set filter input accordingly */
231 $('select[name="module"]').change(function() {
233 var module_name = $this.val();
235 /* Remove current element if any */
236 $filter_container.empty();
238 var filter_elem = null;
239 if (module_name in module_filter_options) {
240 // Create select element
241 filter_elem = document.createElement('select');
242 for (var filter_value in module_filter_options[module_name]) {
243 var option = document.createElement('option');
244 option.value = filter_value;
245 option.text = module_filter_options[module_name][filter_value];
246 filter_elem.appendChild(option);
250 // Create text input element
251 filter_elem = document.createElement('input');
252 filter_elem.type = 'text';
253 filter_elem.setAttribute('size', 5);
255 filter_elem.name = 'filter';
256 filter_elem.id = 'filter';
257 $filter_container.append(filter_elem);
258 }).change(); // Trigger change
260 // Hack: set value if editing rule
261 if ($filter_container.data('filter')) {
262 $('#filter').val($filter_container.data('filter'));
268 <body id="admin_marc-overlay-rules" class="admin">
269 [% INCLUDE 'header.inc' %]
270 [% INCLUDE 'cat-search.inc' %]
272 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
273 › MARC overlay rules
276 <div class="main container-fluid">
278 <div class="col-sm-10 col-sm-push-2">
280 <h1>Manage MARC overlay rules</h1>
282 [% FOR m IN messages %]
283 <div class="dialog [% m.type | html %]">
285 [% CASE 'invalid_tag_regexp' %]
286 Invalid regular expression "[% m.tag | html %]".
287 [% CASE 'invalid_control_field_actions' %]
288 Invalid combination of actions for tag [% m.tag | html %]. Control field rules do not allow "Appended: Append" and "Removed: Skip".
295 [% UNLESS Koha.Preference( 'MARCOverlayRules' ) %]
296 <div class="dialog message">
297 The <b>MARCOverlayRules</b> preference is not set, don't forget to enable it for rules to take effect.
300 [% IF removeConfirm %]
301 <div class="dialog alert">
302 <h3>Remove rule?</h3>
303 <p>Are you sure you want to remove the selected rule(s)?</p>
305 <form action="[% script_name | uri %]" method="GET">
306 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not remove</button>
308 <button type="button" class="approve" id="doremove"><i class="fa fa-fw fa-check"></i> Yes, remove</button>
312 <form action="[% script_name | uri %]" method="POST" id="marc-overlay-rules-form">
313 <table id="marc-overlay-rules">
320 <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>
321 <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>
322 <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>
323 <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>
329 <tr class="rule-new">
332 <select name="module">
333 <option value="source">Source</option>
334 <option value="categorycode">User category</option>
335 <option value="userid">Username</option>
338 <th id="filter-container"></th>
339 <th><input type="text" size="5" name="tag"/></th>
341 <select name="preset">
342 <option value="" selected>Custom</option>
343 <option value="Protect">Protect</option>
344 <option value="Overwrite">Overwrite</option>
345 <option value="Add new">Add new</option>
346 <option value="Add and append">Add and append</option>
347 <option value="Protect from deletion">Protect from deletion</option>
350 <th class="rule-operation-action-edit">
352 <option value="0">Skip</option>
353 <option value="1">Add</option>
356 <th class="rule-operation-action-edit">
357 <select name="append">
358 <option value="0">Skip</option>
359 <option value="1">Append</option>
362 <th class="rule-operation-action-edit">
363 <select name="remove">
364 <option value="0">Skip</option>
365 <option value="1">Remove</option>
368 <th class="rule-operation-action-edit">
369 <select name="delete">
370 <option value="0">Skip</option>
371 <option value="1">Delete</option>
374 <th><button class="btn btn-default btn-xs" title="Add" id="add"><i class="fa fa-plus"></i> Add rule</button></th>
375 <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>
380 [% FOREACH rule IN rules %]
381 <tr id="[% rule.id | html %]" class="rule[% IF rule.edit %]-edit[% END %]">
383 <td>[% rule.id | html %]</td>
385 <select name="module">
386 [% IF rule.module == "source" %]
387 <option value="source" selected="selected">Source</option>
389 <option value="source">Source</option>
391 [% IF rule.module == "categorycode" %]
392 <option value="categorycode" selected="selected">User category</option>
394 <option value="categorycode">User category</option>
396 [% IF rule.module == "userid" %]
397 <option value="userid" selected="selected">Username</option>
399 <option value="userid">Username</option>
403 <td id="filter-container" data-filter="[% rule.filter | html %]"></td>
404 <td><input type="text" size="3" name="tag" value="[% rule.tag | html %]"/></td>
406 <select name="preset">
407 <option value="" selected>Custom</option>
408 <option value="Protect">Protect</option>
409 <option value="Overwrite">Overwrite</option>
410 <option value="Add new">Add new</option>
411 <option value="Add and append">Add and append</option>
412 <option value="Protect from deletion">Protect from deletion</option>
415 <td class="rule-operation-action-edit">
418 <option value="0">Skip</option>
419 <option value="1" selected="selected">Add</option>
421 <option value="0" selected="selected">Skip</option>
422 <option value="1">Add</option>
426 <td class="rule-operation-action-edit">
427 <select name="append">
429 <option value="0">Skip</option>
430 <option value="1" selected="selected">Append</option>
432 <option value="0" selected="selected">Skip</option>
433 <option value="1">Append</option>
437 <td class="rule-operation-action-edit">
438 <select name="remove">
440 <option value="0">Skip</option>
441 <option value="1" selected="selected">Remove</option>
443 <option value="0" selected="selected">Skip</option>
444 <option value="1">Remove</option>
448 <td class="rule-operation-action-edit">
449 <select name="delete">
451 <option value="0">Skip</option>
452 <option value="1" selected="selected">Delete</option>
454 <option value="0" selected="selected">Skip</option>
455 <option value="1">Delete</option>
460 <button class="btn btn-default btn-xs" title="Save" id="doedit" value="[% rule.id | html %]"><i class="fa fa-check"></i> Save</button>
461 <button type="submit" class="btn btn-default btn-xs" title="Cancel" ><i class="fa fa-times"></i> Cancel</button>
465 <td>[% rule.id | html %]</td>
466 <td class="rule-module">[% rule.module | html %]</td>
467 <td class="rule-filter">[% rule.filter | html %]</td>
468 <td>[% rule.tag | html %]</td>
469 <td class="rule-preset"></td>
470 <td class="rule-operation-action" data-operation="add">[% IF rule.add %]Add[% ELSE %]Skip[% END %]</td>
471 <td class="rule-operation-action" data-operation="append">[% IF rule.append %]Append[% ELSE %]Skip[% END %]</td>
472 <td class="rule-operation-action" data-operation="remove">[% IF rule.remove %]Remove[% ELSE %]Skip[% END %]</td>
473 <td class="rule-operation-action" data-operation="delete">[% IF rule.delete %]Delete[% ELSE %]Skip[% END %]</td>
475 <a href="?op=remove&id=[% rule.id | uri %]" title="Delete" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
476 <a href="?op=edit&id=[% rule.id | uri %]" title="Edit" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
479 [% IF rule.removemarked %]
480 <input type="checkbox" name="batchremove" value="[% rule.id | html %]" checked="checked"/>
482 <input type="checkbox" name="batchremove" value="[% rule.id | html %]"/>
492 <form action="[% script_name | uri %]" method="post">
493 <input type="hidden" name="op" value="redo-matching" />
497 <!-- /.col-sm-10.col-sm-push-2 -->
499 <div class="col-sm-2 col-sm-pull-10">
501 [% INCLUDE 'admin-menu.inc' %]
508 <!-- /main container-fluid -->
510 [% INCLUDE 'intranet-bottom.inc' %]