|
Lines 479-485
Link Here
|
| 479 |
[% INCLUDE 'select2.inc' %] |
479 |
[% INCLUDE 'select2.inc' %] |
| 480 |
<script> |
480 |
<script> |
| 481 |
$(document).ready(function() { |
481 |
$(document).ready(function() { |
| 482 |
$('.subfield_line select').select2(); |
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 %] |
| 483 |
}); |
546 |
}); |
| 484 |
</script> |
547 |
</script> |
| 485 |
|
548 |
|
|
Lines 846-852
Link Here
|
| 846 |
[% ELSIF ( mv.type == 'textarea' ) %] |
909 |
[% ELSIF ( mv.type == 'textarea' ) %] |
| 847 |
<textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea> |
910 |
<textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea> |
| 848 |
[% ELSIF ( mv.type == 'select' ) %] |
911 |
[% ELSIF ( mv.type == 'select' ) %] |
| 849 |
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]"> |
912 |
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]"> |
| 850 |
[% FOREACH aval IN mv.values %] |
913 |
[% FOREACH aval IN mv.values %] |
| 851 |
[% IF aval == mv.default %] |
914 |
[% IF aval == mv.default %] |
| 852 |
<option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> |
915 |
<option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> |
|
Lines 891-896
Link Here
|
| 891 |
<input type="hidden" name="duedatespec" value="[% duedatespec | html %]" /> |
954 |
<input type="hidden" name="duedatespec" value="[% duedatespec | html %]" /> |
| 892 |
[%# End of fields for fast cataloging %] |
955 |
[%# End of fields for fast cataloging %] |
| 893 |
</form> <!-- /name=f --> |
956 |
</form> <!-- /name=f --> |
|
|
957 |
|
| 958 |
<div id="avCreate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="avCreateLabel" aria-hidden="true"> |
| 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 |
|
| 894 |
</div> <!-- /.col-md-10.col-md-offset-1 --> |
1000 |
</div> <!-- /.col-md-10.col-md-offset-1 --> |
| 895 |
</div> <!-- /.row --> |
1001 |
</div> <!-- /.row --> |
| 896 |
|
1002 |
|
| 897 |
- |
|
|