Lines 91-96
Link Here
|
91 |
PopupZ3950(); |
91 |
PopupZ3950(); |
92 |
}); |
92 |
}); |
93 |
|
93 |
|
|
|
94 |
$("#linkerbutton").click(function(){ |
95 |
AutomaticLinker(); |
96 |
}); |
97 |
|
94 |
$("#saverecord").click(function(){ |
98 |
$("#saverecord").click(function(){ |
95 |
$(".btn-group").removeClass("open"); |
99 |
$(".btn-group").removeClass("open"); |
96 |
onOption(); |
100 |
onOption(); |
Lines 177-184
Link Here
|
177 |
var onOption = function () { |
181 |
var onOption = function () { |
178 |
return Check(); |
182 |
return Check(); |
179 |
} |
183 |
} |
180 |
[% END %] |
184 |
[% END %] |
|
|
185 |
|
186 |
function confirmnotdup(redirect){ |
187 |
$("#confirm_not_duplicate").attr("value","1"); |
188 |
$("#redirect").attr("value",redirect); |
189 |
Check(); |
190 |
} |
191 |
|
192 |
function Dopop(link,i) { |
193 |
defaultvalue = document.getElementById(i).value; |
194 |
window.open(link+"&result="+defaultvalue,"valuebuilder",'width=700,height=550,toolbar=false,scrollbars=yes'); |
195 |
} |
196 |
|
197 |
/** |
198 |
* this function open a popup to search on z3950 server. |
199 |
*/ |
200 |
function PopupZ3950() { |
201 |
var strQuery = GetZ3950Terms(); |
202 |
if(strQuery){ |
203 |
window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=[% biblionumber | html %]"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes'); |
204 |
} |
205 |
} |
206 |
|
207 |
/** |
208 |
* this function append button for create new authority if not found |
209 |
*/ |
210 |
|
211 |
function addCreateAuthorityButton(tag_subfield_line, heading, tag_index) { |
212 |
var title = _("Create authority"); |
213 |
var elem = $('<a href="#" title="' + title + '"><i class="fa fa-plus-circle"></i></a>'); |
214 |
tag_subfield_line.append(elem); |
215 |
var tag_subfield_line_a = $('.subfield_line[id^=subfield' + heading.tag + 'a]').eq(tag_index); |
216 |
var subfield_a = tag_subfield_line_a.children('.input_marceditor').eq(0); |
217 |
var index = subfield_a.attr('id'); |
218 |
elem.click(function() { |
219 |
var popup = window.open("", "new_auth_popup",'fullscreen,toolbar=false,scrollbars=yes'); |
220 |
if(popup !== null) { |
221 |
// Create a new form that will be POSTed in the new window |
222 |
var form = $('<form>').attr({ |
223 |
method: 'post', |
224 |
action: "../authorities/authorities.pl", |
225 |
target: "new_auth_popup" |
226 |
}); |
227 |
//add the authtypecode |
228 |
form.append($('<input>').attr({ |
229 |
type: 'hidden', |
230 |
name: 'authtypecode', |
231 |
value: heading.auth_type |
232 |
})); |
233 |
form.append($('<input>').attr({ |
234 |
type: 'hidden', |
235 |
name: 'tagreport', |
236 |
value: heading.tag_to_report |
237 |
})); |
238 |
form.append($('<input>').attr({ |
239 |
type: 'hidden', |
240 |
name: 'tagbiblio', |
241 |
value: heading.tag |
242 |
})); |
243 |
form.append($('<input>').attr({ |
244 |
type: 'hidden', |
245 |
name: 'index', |
246 |
value: index |
247 |
})); |
248 |
$('.tag[id^=tag_' + heading.tag + '_]').eq(tag_index).find(':input').each(function(){ |
249 |
form.append($('<input>').attr({ |
250 |
type: 'hidden', |
251 |
name: this.name.split('_',4).join(''), |
252 |
value: $(this).val() |
253 |
})); |
254 |
}); |
255 |
|
256 |
$('body').append(form); |
257 |
form.submit(); |
258 |
form.remove(); |
259 |
} |
260 |
return false; |
261 |
}); |
262 |
|
263 |
} |
264 |
|
265 |
/** |
266 |
* Updates the authid for every heading field |
267 |
* Adds visual feedback for the changes made on the form. |
268 |
*/ |
269 |
function updateHeadingLinks(links) { |
270 |
var current_tag = ''; |
271 |
var tag_index = 0; |
272 |
|
273 |
// Delete the old message dialog and create a new one |
274 |
$('#autolinker_dialog').remove(); |
275 |
var message_dialog = $('<div id="autolinker_dialog" class="dialog"><strong>' + _("Automatic authority link results:") + '</strong><ul></ul></div>'); |
276 |
var message_dialog_ul = message_dialog.find('ul'); |
277 |
|
278 |
$.each(links, function(index, heading) { |
279 |
if(current_tag == heading.tag) { |
280 |
tag_index++; |
281 |
} |
282 |
else { |
283 |
current_tag = heading.tag; |
284 |
tag_index = 0; |
285 |
} |
286 |
|
287 |
// Find the $9 field to update |
288 |
var tag_subfield_line = $('.subfield_line[id^=subfield' + heading.tag + '9]').eq(tag_index); |
289 |
var subfield = tag_subfield_line.children('.input_marceditor').eq(0); |
290 |
|
291 |
// Delete the old status if one exists |
292 |
tag_subfield_line.children('.subfield_status').remove(); |
293 |
|
294 |
// If the field wasn't modified. Skip it. |
295 |
if(heading.status == 'UNCHANGED') { |
296 |
return; |
297 |
} |
298 |
|
299 |
|
300 |
// Make the subfield line visible and update its value |
301 |
tag_subfield_line.show(); |
302 |
subfield.val(heading.authid); |
303 |
|
304 |
// Add the new status |
305 |
var image = '<i class="fa fa-close no_matching_authority" </i> '; |
306 |
var message = ''; |
307 |
var field_class = 'no_matching_authority_field'; |
308 |
switch(heading.status) { |
309 |
case 'LOCAL_FOUND': |
310 |
image = '<i class="fa fa-check matching_authority"</i> '; |
311 |
message = _("A matching authority was found in the local database."); |
312 |
field_class = 'matching_authority_field'; |
313 |
break; |
314 |
case 'CREATED': |
315 |
image = '<i class="fa fa-check matching_authority"></i> '; |
316 |
message = _("No matching authority found. A new authority was created automatically."); |
317 |
field_class = 'matching_authority_field'; |
318 |
break; |
319 |
case 'MULTIPLE_MATCH': |
320 |
message = _("More than one local match found. Possibly a duplicate authority!"); |
321 |
break; |
322 |
case 'NONE_FOUND': |
323 |
message = _("No matching authority found."); |
324 |
break; |
325 |
default: |
326 |
message = heading.status; |
327 |
break; |
328 |
} |
181 |
|
329 |
|
|
|
330 |
subfield[0].classList.add(field_class); |
331 |
tag_subfield_line.find('i').each(function() { |
332 |
this.remove(); |
333 |
}); |
334 |
tag_subfield_line.append(image); |
335 |
|
336 |
// Add the message to the dialog |
337 |
message_dialog_ul.append('<li><strong>' + heading.tag + '</strong> - ' + message + '</li>'); |
338 |
|
339 |
// Add a link to create a new authority if none was found |
340 |
if(heading.status == 'NONE_FOUND' && tag_subfield_line.find('i').length == 1) { |
341 |
addCreateAuthorityButton(tag_subfield_line, heading , tag_index); |
342 |
} |
343 |
}); |
344 |
|
345 |
if(message_dialog.find('li').length == 0) { |
346 |
message_dialog_ul.append("<li>" + _("No authority link was changed.") + "</li>"); |
347 |
} |
348 |
$('#addbibliotabs').before(message_dialog); |
349 |
} |
350 |
|
351 |
/** |
352 |
* Use an ajax request to automatically find authority links for the current record |
353 |
*/ |
354 |
function AutomaticLinker() { |
355 |
// Show the Loading overlay |
356 |
$("#loading").show(); |
357 |
|
358 |
// Remove fields that are completely empty |
359 |
$('#f').find('.tag').each(function() { |
360 |
var empty = true; |
361 |
$(this).find('.input_marceditor').each(function() { |
362 |
if($(this).val() != '') { |
363 |
empty = false; |
364 |
return false; |
365 |
} |
366 |
}); |
367 |
if(empty) { |
368 |
UnCloneField($(this).attr('id')); |
369 |
} |
370 |
}); |
371 |
|
372 |
// Get all the form values to post via AJAX |
373 |
var form_data = {}; |
374 |
$('#f').find(':input').each(function(){ |
375 |
form_data[this.name] = $(this).val(); |
376 |
}); |
377 |
delete form_data['']; |
378 |
|
379 |
// Send the data to automatic_linker.pl |
380 |
$.ajax({ |
381 |
url:'/cgi-bin/koha/svc/cataloguing/automatic_linker.pl', |
382 |
type:'post', |
383 |
data: form_data, |
384 |
dataType: 'json', |
385 |
error: function(xhr) { |
386 |
alert("Error : \n" + xhr.responseText); |
387 |
}, |
388 |
success: function(json) { |
389 |
switch(json.status) { |
390 |
case 'UNAUTHORIZED': |
391 |
alert(_("Error : You do not have the permissions necessary to use this functionality.")); |
392 |
break; |
393 |
case 'OK': |
394 |
updateHeadingLinks(json.links); |
395 |
break; |
396 |
} |
397 |
}, |
398 |
complete: function() { |
399 |
$("#loading").hide(); |
400 |
} |
401 |
}); |
402 |
} |
403 |
|
404 |
|
405 |
function PopupMARCFieldDoc(field) { |
406 |
[% IF Koha.Preference('marcfielddocurl') %] |
407 |
var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]"; |
408 |
docurl = docurl.replace("{MARC}", "[% marcflavour | html %]"); |
409 |
docurl = docurl.replace("{FIELD}", ""+field); |
410 |
docurl = docurl.replace("{LANG}", "[% lang | html %]"); |
411 |
window.open(docurl); |
412 |
[% ELSIF ( marcflavour == 'MARC21' ) %] |
413 |
_MARC21FieldDoc(field); |
414 |
[% ELSIF ( marcflavour == 'UNIMARC' ) %] |
415 |
_UNIMARCFieldDoc(field); |
416 |
[% END %] |
417 |
} |
182 |
function confirmnotdup(redirect){ |
418 |
function confirmnotdup(redirect){ |
183 |
$("#confirm_not_duplicate").attr("value","1"); |
419 |
$("#confirm_not_duplicate").attr("value","1"); |
184 |
$("#redirect").attr("value",redirect); |
420 |
$("#redirect").attr("value",redirect); |
Lines 587-592
Link Here
|
587 |
[% ELSE %] |
823 |
[% ELSE %] |
588 |
<div class="btn-group"><a class="btn btn-default" href="#" id="z3950search"><i class="fa fa-search"></i> Z39.50/SRU search</a></div> |
824 |
<div class="btn-group"><a class="btn btn-default" href="#" id="z3950search"><i class="fa fa-search"></i> Z39.50/SRU search</a></div> |
589 |
[% END %] |
825 |
[% END %] |
|
|
826 |
[% IF ( CAN_user_editauthorities ) %] |
827 |
<div class="btn-group"><a class="btn btn-default" href="#" id="linkerbutton"><i class="fa fa-refresh"></i> Link authorities automatically</a></div> |
828 |
[% END %] |
590 |
[% END %] |
829 |
[% END %] |
591 |
|
830 |
|
592 |
<div class="btn-group"> |
831 |
<div class="btn-group"> |