Lines 5-10
Link Here
|
5 |
<title>Koha › Cataloging › [% IF ( biblionumber ) %]Editing [% title | html %] (Record number [% biblionumber | html %])[% ELSE %]Add MARC record[% END %]</title> |
5 |
<title>Koha › Cataloging › [% IF ( biblionumber ) %]Editing [% title | html %] (Record number [% biblionumber | html %])[% ELSE %]Add MARC record[% END %]</title> |
6 |
[% INCLUDE 'doc-head-close.inc' %] |
6 |
[% INCLUDE 'doc-head-close.inc' %] |
7 |
[% Asset.js("lib/hc-sticky.js") | $raw %] |
7 |
[% Asset.js("lib/hc-sticky.js") | $raw %] |
|
|
8 |
<script> |
9 |
var CAN_user_parameters_manage_auth_values = "[% CAN_user_parameters_manage_auth_values | html %]"; |
10 |
</script> |
8 |
[% Asset.js("js/cataloging.js") | $raw %] |
11 |
[% Asset.js("js/cataloging.js") | $raw %] |
9 |
[% INCLUDE 'strings.inc' %] |
12 |
[% INCLUDE 'strings.inc' %] |
10 |
[% Asset.js("js/browser.js") | $raw %] |
13 |
[% Asset.js("js/browser.js") | $raw %] |
Lines 477-551
Link Here
|
477 |
[% Asset.css("css/addbiblio.css") | $raw %] |
480 |
[% Asset.css("css/addbiblio.css") | $raw %] |
478 |
|
481 |
|
479 |
[% INCLUDE 'select2.inc' %] |
482 |
[% INCLUDE 'select2.inc' %] |
480 |
<script> |
|
|
481 |
$(document).ready(function() { |
482 |
$('.subfield_line select[data-category=""]').select2(); // branches, itemtypes and cn_source |
483 |
|
484 |
[% UNLESS CAN_user_parameters_manage_auth_values %] |
485 |
$('.subfield_line select[data-category!=""]').select2(); |
486 |
[% ELSE %] |
487 |
var current_select2; |
488 |
$('.subfield_line select[data-category!=""]').select2({ |
489 |
tags: true, |
490 |
createTag: function (tag) { |
491 |
return { |
492 |
id: tag.term, |
493 |
text: tag.term, |
494 |
newTag: true |
495 |
}; |
496 |
}, |
497 |
templateResult: function(state) { |
498 |
if (state.newTag) { |
499 |
return state.text + " " + "(select to create)"; |
500 |
} |
501 |
return state.text; |
502 |
} |
503 |
}).on("select2:select", function(e) { |
504 |
if(e.params.data.newTag){ |
505 |
|
506 |
var category = $(this).data("category"); |
507 |
$("#avCreate #new_av_category").html(category); |
508 |
$("#avCreate input[name='category']").val(category); |
509 |
$("#avCreate input[name='value']").val(e.params.data.text); |
510 |
$("#avCreate input[name='description']").val(e.params.data.text); |
511 |
$('#avCreate').modal({show:true}); |
512 |
|
513 |
$(current_select2).val($(current_select2).find("option:first").val()).trigger('change'); |
514 |
|
515 |
current_select2 = this; |
516 |
|
517 |
} |
518 |
}); |
519 |
|
520 |
$("#avCreate").on('hide.bs.modal', function(e){ |
521 |
}); |
522 |
|
523 |
$("#add_new_av").on("submit", function(){ |
524 |
var data = { |
525 |
category: $(this).find('input[name="category"]').val(), |
526 |
value: $(this).find('input[name="value"]').val(), |
527 |
description: $(this).find('input[name="description"]').val(), |
528 |
opac_description: $(this).find('input[name="opac_description"]').val(), |
529 |
}; |
530 |
$.ajax({ |
531 |
type: "POST", |
532 |
url: "/api/v1/authorised_values", |
533 |
data:JSON.stringify(data), |
534 |
success: function(response) { |
535 |
$('#avCreate').modal('hide'); |
536 |
|
537 |
$(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>'); |
538 |
}, |
539 |
error: function(err) { |
540 |
$("#avCreate .error").html(_("Something went wrong, maybe the value already exists?")) |
541 |
} |
542 |
}); |
543 |
return false; |
544 |
}); |
545 |
[% END %] |
546 |
}); |
547 |
</script> |
548 |
|
549 |
</head> |
483 |
</head> |
550 |
<body id="cat_addbiblio" class="cat"> |
484 |
<body id="cat_addbiblio" class="cat"> |
551 |
|
485 |
|
Lines 955-1001
Link Here
|
955 |
[%# End of fields for fast cataloging %] |
889 |
[%# End of fields for fast cataloging %] |
956 |
</form> <!-- /name=f --> |
890 |
</form> <!-- /name=f --> |
957 |
|
891 |
|
958 |
<div id="avCreate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="avCreateLabel" aria-hidden="true"> |
892 |
[% INCLUDE 'modals/cataloguing_create_av.inc' %] |
959 |
<div class="modal-dialog"> |
|
|
960 |
<div class="modal-content"> |
961 |
<div class="modal-header"> |
962 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
963 |
<h3 id="avCreateLabel">Create a new authorised value</h3> |
964 |
</div> |
965 |
<form id="add_new_av" method="post"> |
966 |
<div class="modal-body"> |
967 |
<div class="error"></div> |
968 |
<fieldset class="rows"> |
969 |
<ol> |
970 |
<li> |
971 |
<span class="label">Category:</span> |
972 |
<input type="hidden" name="category" value="" /> |
973 |
<span id="new_av_category"></span> |
974 |
</li> |
975 |
<li> |
976 |
<span class="label" for="value">Authorised value:</span> |
977 |
<input type="text" id="value" name="value" /> |
978 |
</li> |
979 |
<li> |
980 |
<span class="label" for="description">Description:</span> |
981 |
<input type="text" id="description" name="description" /> |
982 |
</li> |
983 |
<li> |
984 |
<span class="label" for="opac_description">Description (OPAC):</span> |
985 |
<input type="text" id="opac_description" name="opac_description" /> |
986 |
</li> |
987 |
</ol> |
988 |
</fieldset> |
989 |
</div> |
990 |
<div class="modal-footer"> |
991 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
992 |
<input type="hidden" name="select2" value="" /> |
993 |
<input type="submit" class="btn btn-primary" value="Save"> |
994 |
</div> |
995 |
</form> |
996 |
</div> <!-- /.modal-content --> |
997 |
</div> <!-- /.modal-dialog --> |
998 |
</div> <!-- /#avCreate --> |
999 |
|
893 |
|
1000 |
</div> <!-- /.col-md-10.col-md-offset-1 --> |
894 |
</div> <!-- /.col-md-10.col-md-offset-1 --> |
1001 |
</div> <!-- /.row --> |
895 |
</div> <!-- /.row --> |