Lines 483-488
Link Here
|
483 |
[% Asset.css("css/addbiblio.css") | $raw %] |
483 |
[% Asset.css("css/addbiblio.css") | $raw %] |
484 |
|
484 |
|
485 |
[% INCLUDE 'select2.inc' %] |
485 |
[% INCLUDE 'select2.inc' %] |
|
|
486 |
<script> |
487 |
$(document).ready(function() { |
488 |
[% IF CAN_user_parameters_manage_auth_values %] |
489 |
var current_select2; |
490 |
$('.subfield_line select[data-category!=""]').select2({ |
491 |
tags: true, |
492 |
createTag: function (tag) { |
493 |
return { |
494 |
id: tag.term, |
495 |
text: tag.term, |
496 |
newTag: true |
497 |
}; |
498 |
}, |
499 |
templateResult: function(state) { |
500 |
if (state.newTag) { |
501 |
return state.text + " " + "(select to create)"; |
502 |
} |
503 |
return state.text; |
504 |
} |
505 |
}).on("select2:select", function(e) { |
506 |
if(e.params.data.newTag){ |
507 |
|
508 |
var category = $(this).data("category"); |
509 |
$("#avCreate #new_av_category").html(category); |
510 |
$("#avCreate input[name='category']").val(category); |
511 |
$("#avCreate input[name='value']").val(e.params.data.text); |
512 |
$("#avCreate input[name='description']").val(e.params.data.text); |
513 |
$('#avCreate').modal({show:true}); |
514 |
|
515 |
$(current_select2).val($(current_select2).find("option:first").val()).trigger('change'); |
516 |
|
517 |
current_select2 = this; |
518 |
|
519 |
} |
520 |
}).on("select2:clear", function () { |
521 |
$(this).on("select2:opening.cancelOpen", function (evt) { |
522 |
evt.preventDefault(); |
523 |
|
524 |
$(this).off("select2:opening.cancelOpen"); |
525 |
}); |
526 |
}); |
527 |
|
528 |
$("#add_new_av").on("submit", function(){ |
529 |
var data = { |
530 |
category: $(this).find('input[name="category"]').val(), |
531 |
value: $(this).find('input[name="value"]').val(), |
532 |
description: $(this).find('input[name="description"]').val(), |
533 |
opac_description: $(this).find('input[name="opac_description"]').val(), |
534 |
}; |
535 |
$.ajax({ |
536 |
type: "POST", |
537 |
url: "/api/v1/authorised_values", |
538 |
data:JSON.stringify(data), |
539 |
success: function(response) { |
540 |
$('#avCreate').modal('hide'); |
541 |
|
542 |
$(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>'); |
543 |
}, |
544 |
error: function(err) { |
545 |
$("#avCreate .error").html(_("Something went wrong, maybe the value already exists?")) |
546 |
} |
547 |
}); |
548 |
return false; |
549 |
}); |
550 |
[% END %] |
551 |
}); |
552 |
</script> |
486 |
|
553 |
|
487 |
</head> |
554 |
</head> |
488 |
<body id="cat_addbiblio" class="cat"> |
555 |
<body id="cat_addbiblio" class="cat"> |
Lines 847-853
Link Here
|
847 |
[% ELSIF ( mv.type == 'textarea' ) %] |
914 |
[% ELSIF ( mv.type == 'textarea' ) %] |
848 |
<textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea> |
915 |
<textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea> |
849 |
[% ELSIF ( mv.type == 'select' ) %] |
916 |
[% ELSIF ( mv.type == 'select' ) %] |
850 |
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]"> |
917 |
[% IF mv.category AND CAN_user_parameters_manage_auth_values %] |
|
|
918 |
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]"> |
919 |
[% ELSE %] |
920 |
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]"> |
921 |
[% END %] |
851 |
[% FOREACH aval IN mv.values %] |
922 |
[% FOREACH aval IN mv.values %] |
852 |
[% IF aval == mv.default %] |
923 |
[% IF aval == mv.default %] |
853 |
<option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> |
924 |
<option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> |
Lines 892-897
Link Here
|
892 |
<input type="hidden" name="duedatespec" value="[% duedatespec | html %]" /> |
963 |
<input type="hidden" name="duedatespec" value="[% duedatespec | html %]" /> |
893 |
[%# End of fields for fast cataloging %] |
964 |
[%# End of fields for fast cataloging %] |
894 |
</form> <!-- /name=f --> |
965 |
</form> <!-- /name=f --> |
|
|
966 |
|
967 |
<div id="avCreate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="avCreateLabel" aria-hidden="true"> |
968 |
<div class="modal-dialog"> |
969 |
<div class="modal-content"> |
970 |
<div class="modal-header"> |
971 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
972 |
<h3 id="avCreateLabel">Create a new authorised value</h3> |
973 |
</div> |
974 |
<form id="add_new_av" method="post"> |
975 |
<div class="modal-body"> |
976 |
<div class="error"></div> |
977 |
<fieldset class="rows"> |
978 |
<ol> |
979 |
<li> |
980 |
<span class="label">Category:</span> |
981 |
<input type="hidden" name="category" value="" /> |
982 |
<span id="new_av_category"></span> |
983 |
</li> |
984 |
<li> |
985 |
<span class="label" for="value">Authorised value:</span> |
986 |
<input type="text" id="value" name="value" /> |
987 |
</li> |
988 |
<li> |
989 |
<span class="label" for="description">Description:</span> |
990 |
<input type="text" id="description" name="description" /> |
991 |
</li> |
992 |
<li> |
993 |
<span class="label" for="opac_description">Description (OPAC):</span> |
994 |
<input type="text" id="opac_description" name="opac_description" /> |
995 |
</li> |
996 |
</ol> |
997 |
</fieldset> |
998 |
</div> |
999 |
<div class="modal-footer"> |
1000 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
1001 |
<input type="hidden" name="select2" value="" /> |
1002 |
<input type="submit" class="btn btn-primary" value="Save"> |
1003 |
</div> |
1004 |
</form> |
1005 |
</div> <!-- /.modal-content --> |
1006 |
</div> <!-- /.modal-dialog --> |
1007 |
</div> <!-- /#avCreate --> |
1008 |
|
895 |
</div> <!-- /.col-md-10.col-md-offset-1 --> |
1009 |
</div> <!-- /.col-md-10.col-md-offset-1 --> |
896 |
</div> <!-- /.row --> |
1010 |
</div> <!-- /.row --> |
897 |
|
1011 |
|
898 |
- |
|
|