Jonathan Druart
b387502eaf
This new enhancement adds the ability to change the default order the subfields. Both bibliographic and authority MARC subfield structure are taken into account. And so the item edition as well (in the different screens when item can be added/edited). This will answer the following needs that have been listed in the comments of the bug report: - $i in 7xx fields should be the first subfield in the sequence - 300 fields are sorted number first when cataloguers enter the letter fields first - 100 field, it's commonly $a, $q, $d. Test plan: 1. Edit a MARC frameworks, field 300 2. Resort the subfield (drag and drop the tab of the subfield) as you like 3. Save => Notice that the list of fields are displayed following the order you chose 4. Edit it again => The order is correctly kept! 5. Create a new bibliographic record 6. Notice that the subfields are order in the same sequence 7. Fill different subfields, not all 8. Save, edit again 9. Note that the subfields that have been filled are listed first, then the empty ones. But the sequence defined at the framework level is kept. 10. Do the same for an authority framework and create/edit an authority record 11. Modify item (952) subfields order 12. Create an item and confirm that the order is correct 13. Modify the ACQ framework, 952, modify the order of the subfield 14. Create a new order and confirm that the item form has the subfield ordered following the sequence defined at the framework level QA: Note that this patch is about bibliographic records only, next patches deal with authotiries and items. Sponsored-by: Orex Digital Signed-off-by: Michal Denar <black23@gmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
181 lines
7.1 KiB
JavaScript
181 lines
7.1 KiB
JavaScript
/* global dataTablesDefaults */
|
|
$(document).ready(function() {
|
|
var tabs = $('#subfieldtabs').tabs();
|
|
var current_index;
|
|
tabs.find( ".ui-tabs-nav" ).sortable({
|
|
axis: "x",
|
|
start: function (e, ui) {
|
|
current_index = $(ui.item[0]).index();
|
|
},
|
|
stop: function (e, ui) {
|
|
var new_index = $(ui.item[0]).index();
|
|
if (current_index < new_index) new_index++;
|
|
var subfield_code = $(ui.item[0]).attr('id').replace( /^tab_subfield_/, '');
|
|
var content = $('#sub' + subfield_code + 'field');
|
|
var panels = $("#subfieldtabs > div");
|
|
if ( new_index < $(panels).size() ){
|
|
$(content).insertBefore($("#subfieldtabs > div")[new_index]);
|
|
} else {
|
|
$(content).insertAfter($("#subfieldtabs > div")[new_index-1]);
|
|
}
|
|
tabs.tabs("refresh");
|
|
}
|
|
});
|
|
$("input[id^='hidden_']").click(setHiddenValue);
|
|
$("input[id^='hidden-']").each(function() {
|
|
populateHiddenCheckboxes($(this).attr('id').split('-')[1]);
|
|
});
|
|
$("#table_marcsubfieldstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
|
|
"columnDefs": [
|
|
{ 'sortable': false, 'targets': [ 'NoSort' ] }
|
|
],
|
|
aaSorting: [],
|
|
paginate: false
|
|
}));
|
|
});
|
|
|
|
/* Function to enable/disable hidden values checkboxes when Flag is (de)selected */
|
|
function enable_cb(tab) {
|
|
if ($("#hidden_flagged_" + tab).is(':checked')) {
|
|
$('.inclusive_' + tab).prop('disabled', true).prop('checked', false);
|
|
}
|
|
else {
|
|
$('.inclusive_' + tab).prop('disabled', false);
|
|
}
|
|
}
|
|
|
|
/* Function to serialize and set the 'hidden' field */
|
|
function setHiddenValue() {
|
|
|
|
var tab = $(this).attr('id').split('_')[2];
|
|
var flagged_checked = $("#hidden_flagged_" + tab).is(':checked');
|
|
var opac_checked = $("#hidden_opac_" + tab).is(':checked');
|
|
var intranet_checked = $("#hidden_intranet_" + tab).is(':checked');
|
|
var editor_checked = $("#hidden_editor_" + tab).is(':checked');
|
|
var collapsed_checked = $("#hidden_collapsed_" + tab).is(':checked');
|
|
var hidden_value = "";
|
|
|
|
if ( flagged_checked ) {
|
|
hidden_value='-8';
|
|
} else if ( opac_checked && ! intranet_checked && ! editor_checked && collapsed_checked ) {
|
|
hidden_value='-7';
|
|
} else if ( opac_checked && intranet_checked && ! editor_checked && ! collapsed_checked) {
|
|
hidden_value='-6';
|
|
} else if ( opac_checked && intranet_checked && ! editor_checked && collapsed_checked) {
|
|
hidden_value='-5';
|
|
} else if ( opac_checked && ! intranet_checked && ! editor_checked && ! collapsed_checked) {
|
|
hidden_value='-4';
|
|
} else if ( opac_checked && ! intranet_checked && editor_checked && collapsed_checked) {
|
|
hidden_value='-3';
|
|
} else if ( opac_checked && ! intranet_checked && editor_checked && ! collapsed_checked) {
|
|
hidden_value='-2';
|
|
} else if ( opac_checked && intranet_checked && editor_checked && collapsed_checked) {
|
|
hidden_value='-1';
|
|
} else if ( opac_checked && intranet_checked && editor_checked && ! collapsed_checked) {
|
|
hidden_value='0';
|
|
} else if ( ! opac_checked && intranet_checked && editor_checked && collapsed_checked) {
|
|
hidden_value='1';
|
|
} else if ( ! opac_checked && ! intranet_checked && editor_checked && ! collapsed_checked) {
|
|
hidden_value='2';
|
|
} else if ( ! opac_checked && ! intranet_checked && editor_checked && collapsed_checked) {
|
|
hidden_value='3';
|
|
} else if ( ! opac_checked && intranet_checked && editor_checked && ! collapsed_checked) {
|
|
hidden_value='4';
|
|
} else if ( ! opac_checked && ! intranet_checked && ! editor_checked && collapsed_checked) {
|
|
hidden_value='5';
|
|
} else if ( ! opac_checked && intranet_checked && ! editor_checked && ! collapsed_checked) {
|
|
hidden_value='6';
|
|
} else if ( ! opac_checked && intranet_checked && ! editor_checked && collapsed_checked) {
|
|
hidden_value='7';
|
|
} else if ( ! opac_checked && ! intranet_checked && ! editor_checked && ! collapsed_checked) {
|
|
hidden_value='8';
|
|
}
|
|
|
|
var hidden_protected = $('#hidden-'+ tab).attr('data-koha-protected');
|
|
if ( hidden_protected != 1 ) {
|
|
enable_cb(tab);
|
|
}
|
|
|
|
$('#hidden-' + tab).val(hidden_value);
|
|
|
|
}
|
|
|
|
function populateHiddenCheckboxes(tab) {
|
|
// read the serialized value
|
|
var hidden_value = $('#hidden-' + tab).val();
|
|
var hidden_protected = $('#hidden-'+ tab).attr('data-koha-protected');
|
|
// deafult to false
|
|
var opac_checked = false;
|
|
var intranet_checked = false;
|
|
var editor_checked = false;
|
|
var collapsed_checked = false;
|
|
var flagged_checked = false;
|
|
|
|
if ( hidden_value == '-8' ) {
|
|
flagged_checked = true;
|
|
} else if ( hidden_value == '-7') {
|
|
opac_checked = true;
|
|
collapsed_checked = true;
|
|
} else if ( hidden_value == '-6' ) {
|
|
opac_checked = true;
|
|
intranet_checked = true;
|
|
} else if ( hidden_value == '-5') {
|
|
opac_checked = true;
|
|
intranet_checked = true;
|
|
collapsed_checked = true;
|
|
} else if ( hidden_value == '-4' ) {
|
|
opac_checked = true;
|
|
} else if ( hidden_value == '-3') {
|
|
opac_checked = true;
|
|
editor_checked = true;
|
|
collapsed_checked = true;
|
|
} else if ( hidden_value == '-2' ) {
|
|
opac_checked = true;
|
|
editor_checked = true;
|
|
} else if ( hidden_value == '-1' ) {
|
|
opac_checked = true;
|
|
intranet_checked = true;
|
|
editor_checked = true;
|
|
collapsed_checked = true;
|
|
} else if ( hidden_value == '0' ) {
|
|
opac_checked = true;
|
|
intranet_checked = true;
|
|
editor_checked = true;
|
|
} else if ( hidden_value == '1' ) {
|
|
intranet_checked = true;
|
|
editor_checked = true;
|
|
collapsed_checked = true;
|
|
} else if ( hidden_value == '2' ) {
|
|
editor_checked = true;
|
|
} else if ( hidden_value == '3' ) {
|
|
editor_checked = true;
|
|
collapsed_checked = true;
|
|
} else if ( hidden_value == '4' ) {
|
|
intranet_checked = true;
|
|
editor_checked = true;
|
|
} else if ( hidden_value == '5' ) {
|
|
collapsed_checked = true;
|
|
} else if ( hidden_value == '6' ) {
|
|
intranet_checked = true;
|
|
} else if ( hidden_value == '7' ) {
|
|
intranet_checked = true;
|
|
collapsed_checked = true;
|
|
} // else if ( hidden_value == '8') { skip }
|
|
|
|
$("#hidden_opac_" + tab).prop('checked',opac_checked);
|
|
$("#hidden_intranet_" + tab).prop('checked',intranet_checked);
|
|
$("#hidden_editor_" + tab).prop('checked',editor_checked);
|
|
$("#hidden_collapsed_" + tab).prop('checked',collapsed_checked);
|
|
$("#hidden_flagged_" + tab).prop('checked',flagged_checked);
|
|
|
|
if ( hidden_protected == 1 ) {
|
|
$("#hidden_opac_" + tab).prop('disabled','disabled');
|
|
$("#hidden_intranet_" + tab).prop('disabled','disabled');
|
|
$("#hidden_editor_" + tab).prop('disabled','disabled');
|
|
$("#hidden_collapsed_" + tab).prop('disabled','disabled');
|
|
$("#hidden_flagged_" + tab).prop('disabled','disabled');
|
|
}
|
|
else {
|
|
enable_cb(tab);
|
|
}
|
|
}
|