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