|
Lines 1-303
Link Here
|
| 1 |
[% INCLUDE 'doc-head-open.inc' %] |
1 |
[% INCLUDE 'doc-head-open.inc' %] |
| 2 |
<title>Koha › Tools › MARC modification templates</title> |
2 |
<title>Koha › Tools › MARC modification templates</title> |
| 3 |
[% INCLUDE 'doc-head-close.inc' %] |
3 |
[% INCLUDE 'doc-head-close.inc' %] |
| 4 |
|
|
|
| 5 |
<script type="text/javascript"> |
4 |
<script type="text/javascript"> |
| 6 |
//<![CDATA[ |
5 |
//<![CDATA[ |
| 7 |
$(document).ready(function() { |
6 |
var MSG_MMT_SUBFIELDS_MATCH = _("Both subfield values should be filled or empty."); |
| 8 |
$('#select_template').find("input:submit").hide(); |
7 |
var MSG_MMT_DESTINATION_REQUIRED = _("The destination should be filled."); |
| 9 |
$('#select_template').change(function() { |
8 |
var MSG_MMT_CONTROL_FIELD_EMPTY = _("If the field is a control field, the subfield should be empty"); |
| 10 |
$('#select_template').submit(); |
9 |
var MSG_MMT_CONTROL_FIELD = _("A control field cannot be used with a regular field."); |
| 11 |
}); |
10 |
var MSG_MMT_SOURCE_SUBFIELD = _("The source subfield should be filled for update."); |
| 12 |
$("span.match_regex_prefix" ).hide(); |
11 |
var MSG_MMT_SOURCE_FIELD = _("The source field should be filled."); |
| 13 |
$("span.match_regex_suffix" ).hide(); |
12 |
var MSG_MMT_EVERY = _("Every"); |
| 14 |
|
13 |
var MSG_MMT_ALL = _("All"); |
| 15 |
$("#add_action").submit(function(){ |
14 |
var MSG_MMT_CONFIRM_DEL_TEMPLATE= _("Are you sure you wish to delete this template?"); |
| 16 |
var action = $("#action").val(); |
15 |
var MSG_MMT_EDIT_ACTION = _("Edit action %s"); |
| 17 |
if ( action == 'move_field' || action == 'copy_field' || action == 'copy_and_replace_field') { |
16 |
var MSG_MMT_UPDATE_ACTION = _("Update action"); |
| 18 |
if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) { |
17 |
//]]> |
| 19 |
alert(_("Both subfield values should be filled or empty.")); |
|
|
| 20 |
return false; |
| 21 |
} |
| 22 |
if ( $("#to_field").val().length <= 0 ) { |
| 23 |
alert(_("The destination should be filled.")); |
| 24 |
return false; |
| 25 |
} |
| 26 |
if ( ( $("#to_field").val() < 10 && $("#to_subfield").val().length > 0 ) || |
| 27 |
( $("#from_field").val() < 10 && $("#from_subfield").val().length > 0 ) ) { |
| 28 |
alert(_("If the field is a control field, the subfield should be empty")); |
| 29 |
return false; |
| 30 |
} |
| 31 |
if ( ( $("#from_field").val() < 10 && $("#to_subfield").val().length == 0 ) || |
| 32 |
( $("#to_field").val() < 10 && $("#from_subfield").val().length == 0 ) ) { |
| 33 |
alert(_("A control field cannot be used with a regular field.")); |
| 34 |
return false; |
| 35 |
} |
| 36 |
} |
| 37 |
if ( action == 'update_field' ) { |
| 38 |
if ( $("#from_subfield").val().length <= 0 ) { |
| 39 |
alert(_("The source subfield should be filled for update.")); |
| 40 |
return false; |
| 41 |
} |
| 42 |
} |
| 43 |
if ( $("#from_field").val().length <= 0 ) { |
| 44 |
alert(_("The source field should be filled.")); |
| 45 |
return false; |
| 46 |
} |
| 47 |
}); |
| 48 |
|
| 49 |
$("#conditional_field,#from_field").change(function(){ |
| 50 |
updateAllEvery(); |
| 51 |
}); |
| 52 |
}); |
| 53 |
//]]> |
| 54 |
</script> |
18 |
</script> |
| 55 |
|
19 |
<script type="text/javascript" src="[% themelang %]/js/marc_modification_templates.js"></script> |
| 56 |
<script> |
|
|
| 57 |
function updateAllEvery(){ |
| 58 |
if ( $("#conditional_field").is(":visible") ) { |
| 59 |
if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) { |
| 60 |
$("#field_number option[value='0']").html(_("Every")); |
| 61 |
} else { |
| 62 |
$("#field_number option[value='0']").html(_("All")); |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
function onActionChange(selectObj) { |
| 68 |
// get the index of the selected option |
| 69 |
var idx = selectObj.selectedIndex; |
| 70 |
|
| 71 |
// get the value of the selected option |
| 72 |
var action = selectObj.options[idx].value; |
| 73 |
|
| 74 |
switch( action ) { |
| 75 |
case 'delete_field': |
| 76 |
show('field_number_block'); |
| 77 |
hide('with_value_block'); |
| 78 |
hide('to_field_block'); |
| 79 |
break; |
| 80 |
|
| 81 |
case 'update_field': |
| 82 |
hide('field_number_block'); |
| 83 |
show('with_value_block'); |
| 84 |
hide('to_field_block'); |
| 85 |
break; |
| 86 |
|
| 87 |
case 'move_field': |
| 88 |
show('field_number_block'); |
| 89 |
hide('with_value_block'); |
| 90 |
show('to_field_block'); |
| 91 |
break; |
| 92 |
|
| 93 |
case 'copy_field': |
| 94 |
show('field_number_block'); |
| 95 |
hide('with_value_block'); |
| 96 |
show('to_field_block'); |
| 97 |
break; |
| 98 |
|
| 99 |
case 'copy_and_replace_field': |
| 100 |
show('field_number_block'); |
| 101 |
hide('with_value_block'); |
| 102 |
show('to_field_block'); |
| 103 |
break; |
| 104 |
|
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
function onConditionalChange(selectObj) { |
| 109 |
// get the index of the selected option |
| 110 |
var idx = selectObj.selectedIndex; |
| 111 |
|
| 112 |
// get the value of the selected option |
| 113 |
var action = selectObj.options[idx].value; |
| 114 |
|
| 115 |
switch( action ) { |
| 116 |
case '': |
| 117 |
hide('conditional_block'); |
| 118 |
break; |
| 119 |
|
| 120 |
case 'if': |
| 121 |
case 'unless': |
| 122 |
show('conditional_block'); |
| 123 |
break; |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
function onConditionalComparisonChange(selectObj) { |
| 128 |
// get the index of the selected option |
| 129 |
var idx = selectObj.selectedIndex; |
| 130 |
|
| 131 |
// get the value of the selected option |
| 132 |
var action = selectObj.options[idx].value; |
| 133 |
|
| 134 |
switch( action ) { |
| 135 |
case 'equals': |
| 136 |
case 'not_equals': |
| 137 |
show('conditional_comparison_block'); |
| 138 |
break; |
| 139 |
|
| 140 |
default: |
| 141 |
hide('conditional_comparison_block'); |
| 142 |
break; |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
function onToFieldRegexChange( checkboxObj ) { |
| 147 |
if ( checkboxObj.checked ) { |
| 148 |
show('to_field_regex_value_block'); |
| 149 |
} else { |
| 150 |
hide('to_field_regex_value_block'); |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
function onConditionalRegexChange( checkboxObj ) { |
| 155 |
if ( checkboxObj.checked ) { |
| 156 |
$("span.match_regex_prefix" ).show(); |
| 157 |
$("span.match_regex_suffix" ).show(); |
| 158 |
} else { |
| 159 |
$("span.match_regex_prefix" ).hide(); |
| 160 |
$("span.match_regex_suffix" ).hide(); |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
function show(eltId) { |
| 165 |
elt = document.getElementById( eltId ); |
| 166 |
elt.style.display='inline'; |
| 167 |
} |
| 168 |
|
| 169 |
function hide(eltId) { |
| 170 |
clearFormElements( eltId ); |
| 171 |
elt = document.getElementById( eltId ); |
| 172 |
elt.style.display='none'; |
| 173 |
} |
| 174 |
|
| 175 |
function clearFormElements(divId) { |
| 176 |
myBlock = document.getElementById( divId ); |
| 177 |
|
| 178 |
var inputElements = myBlock.getElementsByTagName( "input" ); |
| 179 |
for (var i = 0; i < inputElements.length; i++) { |
| 180 |
switch( inputElements[i].type ) { |
| 181 |
case "text": |
| 182 |
inputElements[i].value = ''; |
| 183 |
break; |
| 184 |
case "checkbox": |
| 185 |
inputElements[i].checked = false; |
| 186 |
break; |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
var selectElements = myBlock.getElementsByTagName( "select" ); |
| 191 |
for (var i = 0; i < selectElements.length; i++) { |
| 192 |
selectElements[i].selectedIndex = 0; |
| 193 |
} |
| 194 |
|
| 195 |
} |
| 196 |
|
| 197 |
function confirmDelete() { |
| 198 |
var agree = confirm(_("Are you sure you wish to delete this template?")); |
| 199 |
return agree; |
| 200 |
} |
| 201 |
|
| 202 |
var modaction_legend_innerhtml; |
| 203 |
var action_submit_value; |
| 204 |
|
| 205 |
function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field, |
| 206 |
to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield, |
| 207 |
conditional_comparison, conditional_value, conditional_regex, description |
| 208 |
) { |
| 209 |
document.getElementById('mmta_id').value = mmta_id; |
| 210 |
|
| 211 |
setSelectByValue( 'action', action ); |
| 212 |
document.getElementById('action').onchange(); |
| 213 |
|
| 214 |
setSelectByValue( 'field_number', field_number ); |
| 215 |
|
| 216 |
document.getElementById('from_field').value = from_field; |
| 217 |
document.getElementById('from_subfield').value = from_subfield; |
| 218 |
document.getElementById('field_value').value = field_value; |
| 219 |
document.getElementById('to_field').value = to_field; |
| 220 |
document.getElementById('to_subfield').value = to_subfield; |
| 221 |
$("#to_regex_search").val(to_regex_search); |
| 222 |
$("#to_regex_replace").val(to_regex_replace); |
| 223 |
$("#to_regex_modifiers").val(to_regex_modifiers); |
| 224 |
|
| 225 |
document.getElementById('to_field_regex').checked = conditional_regex.length; |
| 226 |
document.getElementById('to_field_regex').onchange(); |
| 227 |
|
| 228 |
setSelectByValue( 'conditional', conditional ); |
| 229 |
document.getElementById('conditional').onchange(); |
| 230 |
|
| 231 |
document.getElementById('conditional_field').value = conditional_field; |
| 232 |
document.getElementById('conditional_subfield').value = conditional_subfield; |
| 233 |
|
| 234 |
setSelectByValue( 'conditional_comparison', conditional_comparison ); |
| 235 |
document.getElementById('conditional_comparison').onchange(); |
| 236 |
|
| 237 |
document.getElementById('conditional_value').value = conditional_value; |
| 238 |
|
| 239 |
document.getElementById('conditional_regex').checked = parseInt( conditional_regex ); |
| 240 |
|
| 241 |
document.getElementById('description').value = description; |
| 242 |
|
| 243 |
window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML; |
| 244 |
document.getElementById('modaction_legend').innerHTML = _("Edit action %s").format(ordering); |
| 245 |
|
| 246 |
window.action_submit_value = document.getElementById('action_submit').value; |
| 247 |
document.getElementById('action_submit').value = _("Update action"); |
| 248 |
|
| 249 |
show('cancel_edit'); |
| 250 |
} |
| 251 |
|
| 252 |
function cancelEditAction() { |
| 253 |
document.getElementById('mmta_id').value = ''; |
| 254 |
|
| 255 |
setSelectByValue( 'action', 'delete_field' ); |
| 256 |
document.getElementById('action').onchange(); |
| 257 |
|
| 258 |
document.getElementById('from_field').value = ''; |
| 259 |
document.getElementById('from_subfield').value = ''; |
| 260 |
document.getElementById('field_value').value = ''; |
| 261 |
document.getElementById('to_field').value = ''; |
| 262 |
document.getElementById('to_subfield').value = ''; |
| 263 |
$("#to_regex_search").val(""); |
| 264 |
$("#to_regex_replace").val(""); |
| 265 |
$("#to_regex_modifiers").val(""); |
| 266 |
|
| 267 |
document.getElementById('to_field_regex').checked = false; |
| 268 |
document.getElementById('to_field_regex').onchange(); |
| 269 |
|
| 270 |
setSelectByValue( 'conditional', '' ); |
| 271 |
document.getElementById('conditional').onchange(); |
| 272 |
|
| 273 |
document.getElementById('conditional_field').value = ''; |
| 274 |
document.getElementById('conditional_subfield').value = ''; |
| 275 |
|
| 276 |
setSelectByValue( 'conditional_comparison', '' ); |
| 277 |
document.getElementById('conditional_comparison').onchange(); |
| 278 |
|
| 279 |
document.getElementById('conditional_value').value = ''; |
| 280 |
|
| 281 |
document.getElementById('conditional_regex').checked = false; |
| 282 |
|
| 283 |
document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml; |
| 284 |
document.getElementById('action_submit').value = window.action_submit_value; |
| 285 |
|
| 286 |
hide('cancel_edit'); |
| 287 |
} |
| 288 |
|
| 289 |
function setSelectByValue( selectId, value ) { |
| 290 |
s = document.getElementById( selectId ); |
| 291 |
|
| 292 |
for ( i = 0; i < s.options.length; i++ ) { |
| 293 |
if ( s.options[i].value == value ) { |
| 294 |
s.selectedIndex = i; |
| 295 |
} |
| 296 |
} |
| 297 |
} |
| 298 |
|
| 299 |
</script> |
| 300 |
|
| 301 |
</head> |
20 |
</head> |
| 302 |
|
21 |
|
| 303 |
<body id="tools_marc_modification_templates" class="tools"> |
22 |
<body id="tools_marc_modification_templates" class="tools"> |
|
Lines 311-317
function setSelectByValue( selectId, value ) {
Link Here
|
| 311 |
<div id="yui-main"> |
30 |
<div id="yui-main"> |
| 312 |
<div class="yui-b"> |
31 |
<div class="yui-b"> |
| 313 |
<h2>MARC modification templates</h2> |
32 |
<h2>MARC modification templates</h2> |
| 314 |
|
33 |
|
| 315 |
[% IF error %] |
34 |
[% IF error %] |
| 316 |
[% IF error == 'no_from_field' %] |
35 |
[% IF error == 'no_from_field' %] |
| 317 |
<div class="dialog message">Error: no field value specified.</div> |
36 |
<div class="dialog message">Error: no field value specified.</div> |
|
Lines 351-358
function setSelectByValue( selectId, value ) {
Link Here
|
| 351 |
<th>Order</th> |
70 |
<th>Order</th> |
| 352 |
<th>Action</th> |
71 |
<th>Action</th> |
| 353 |
<th>Description</th> |
72 |
<th>Description</th> |
| 354 |
<th> </th> |
73 |
<th> </th> |
| 355 |
<th> </th> |
74 |
<th> </th> |
| 356 |
</tr> |
75 |
</tr> |
| 357 |
|
76 |
|
| 358 |
[% FOREACH ActionsLoo IN ActionsLoop %] |
77 |
[% FOREACH ActionsLoo IN ActionsLoop %] |
| 359 |
- |
|
|