Lines 521-585
$(document).ready(function() {
Link Here
|
521 |
$("input.input_marceditor, input.indicator").addClass('noEnterSubmit'); |
521 |
$("input.input_marceditor, input.indicator").addClass('noEnterSubmit'); |
522 |
}); |
522 |
}); |
523 |
|
523 |
|
524 |
$('.subfield_line select[data-category=""]').select2(); // branches, itemtypes and cn_source |
524 |
if ( window.editor === undefined ) { // TODO This does not work with the advanced editor |
525 |
|
525 |
$('.subfield_line select[data-category=""]').select2(); // branches, itemtypes and cn_source |
526 |
if ( ! CAN_user_parameters_manage_auth_values ) { |
526 |
|
527 |
$('.subfield_line select[data-category!=""]').select2(); |
527 |
if ( ! CAN_user_parameters_manage_auth_values ) { |
528 |
} else { |
528 |
$('.subfield_line select[data-category!=""]').select2(); |
529 |
var current_select2; |
529 |
} else { |
530 |
$('.subfield_line select[data-category!=""]').select2({ |
530 |
var current_select2; |
531 |
tags: true, |
531 |
$('.subfield_line select[data-category!=""]').select2({ |
532 |
createTag: function (tag) { |
532 |
tags: true, |
533 |
return { |
533 |
createTag: function (tag) { |
534 |
id: tag.term, |
534 |
return { |
535 |
text: tag.term, |
535 |
id: tag.term, |
536 |
newTag: true |
536 |
text: tag.term, |
537 |
}; |
537 |
newTag: true |
538 |
}, |
538 |
}; |
539 |
templateResult: function(state) { |
539 |
}, |
540 |
if (state.newTag) { |
540 |
templateResult: function(state) { |
541 |
return state.text + " " + "(select to create)"; |
541 |
if (state.newTag) { |
|
|
542 |
return state.text + " " + "(select to create)"; |
543 |
} |
544 |
return state.text; |
542 |
} |
545 |
} |
543 |
return state.text; |
546 |
}).on("select2:select", function(e) { |
544 |
} |
547 |
if(e.params.data.newTag){ |
545 |
}).on("select2:select", function(e) { |
|
|
546 |
if(e.params.data.newTag){ |
547 |
|
548 |
|
548 |
var category = $(this).data("category"); |
549 |
var category = $(this).data("category"); |
549 |
$("#avCreate #new_av_category").html(category); |
550 |
$("#avCreate #new_av_category").html(category); |
550 |
$("#avCreate input[name='category']").val(category); |
551 |
$("#avCreate input[name='category']").val(category); |
551 |
$("#avCreate input[name='value']").val(e.params.data.text); |
552 |
$("#avCreate input[name='value']").val(e.params.data.text); |
552 |
$("#avCreate input[name='description']").val(e.params.data.text); |
553 |
$("#avCreate input[name='description']").val(e.params.data.text); |
553 |
$('#avCreate').modal({show:true}); |
554 |
$('#avCreate').modal({show:true}); |
554 |
|
555 |
|
555 |
$(current_select2).val($(current_select2).find("option:first").val()).trigger('change'); |
556 |
$(current_select2).val($(current_select2).find("option:first").val()).trigger('change'); |
556 |
|
557 |
|
557 |
current_select2 = this; |
558 |
current_select2 = this; |
558 |
|
|
|
559 |
} |
560 |
}); |
561 |
|
559 |
|
562 |
$("#add_new_av").on("submit", function(){ |
|
|
563 |
var data = { |
564 |
category: $(this).find('input[name="category"]').val(), |
565 |
value: $(this).find('input[name="value"]').val(), |
566 |
description: $(this).find('input[name="description"]').val(), |
567 |
opac_description: $(this).find('input[name="opac_description"]').val(), |
568 |
}; |
569 |
$.ajax({ |
570 |
type: "POST", |
571 |
url: "/api/v1/authorised_values", |
572 |
data:JSON.stringify(data), |
573 |
success: function(response) { |
574 |
$('#avCreate').modal('hide'); |
575 |
|
576 |
$(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>'); |
577 |
}, |
578 |
error: function(err) { |
579 |
$("#avCreate .error").html(_("Something went wrong, maybe the value already exists?")) |
580 |
} |
560 |
} |
581 |
}); |
561 |
}); |
582 |
return false; |
562 |
|
583 |
}); |
563 |
$("#add_new_av").on("submit", function(){ |
|
|
564 |
var data = { |
565 |
category: $(this).find('input[name="category"]').val(), |
566 |
value: $(this).find('input[name="value"]').val(), |
567 |
description: $(this).find('input[name="description"]').val(), |
568 |
opac_description: $(this).find('input[name="opac_description"]').val(), |
569 |
}; |
570 |
$.ajax({ |
571 |
type: "POST", |
572 |
url: "/api/v1/authorised_values", |
573 |
data:JSON.stringify(data), |
574 |
success: function(response) { |
575 |
$('#avCreate').modal('hide'); |
576 |
|
577 |
$(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>'); |
578 |
}, |
579 |
error: function(err) { |
580 |
$("#avCreate .error").html(_("Something went wrong, maybe the value already exists?")) |
581 |
} |
582 |
}); |
583 |
return false; |
584 |
}); |
585 |
} |
584 |
} |
586 |
} |
585 |
}); |
587 |
}); |
586 |
- |
|
|