Skip to content

Config Form not displaying configuration fields #15

@nxm-bsa

Description

@nxm-bsa

In the current code base, the JS is not displaying the configuration fields selectively based on radio button choice. This JS in PersistentIdentifiers/asset/js/pid-config.js will display correctly and allow a save to happen:

$(document).ready(function () {
const ezidRadio = $('input[type="radio"][value="ezid"]');
const dataciteRadio = $('input[type="radio"][value="datacite"]');
const localArkRadio = $('input[type="radio"][value="localark"]');
const show = selector => $(selector).removeClass('inactive');
const hide = selector => $(selector).addClass('inactive');
const disableSection = selector => {
$(selector).find(':input')
.prop('disabled', true)
.removeAttr('required');
};
const enableSection = selector => {
$(selector).find(':input')
.prop('disabled', false);
};
const hideAll = () => {
hide('#ezid-configuration');
hide('#datacite-configuration');
hide('#datacite-required-metadata');
hide('#local-ark-configuration');
disableSection('#ezid-configuration');
disableSection('#datacite-configuration');
disableSection('#datacite-required-metadata');
disableSection('#local-ark-configuration');
};

const activateEzid = () => {
    hideAll();
    show('#ezid-configuration');
    enableSection('#ezid-configuration');
    $('#ezid-configuration')
        .find('[required-original="true"]')
        .attr('required', 'required');
};
const activateDatacite = () => {
    hideAll();
    show('#datacite-configuration');
    show('#datacite-required-metadata');
    enableSection('#datacite-configuration');
    enableSection('#datacite-required-metadata');
    $('#datacite-required-metadata')
        .find('select')
        .attr('required', 'required');
};
const activateLocalArk = () => {
    hideAll();
    show('#local-ark-configuration');
    enableSection('#local-ark-confiuration');
    $('#local-ark-naan').attr('required', 'required');
};

// Initial page state
if (ezidRadio.prop('checked')) {
    activateEzid();
}
if (dataciteRadio.prop('checked')) {
    activateDatacite();
}
if (localArkRadio.prop('checked')) {
    activateLocalArk();
}

// Radio button changes
ezidRadio.on('change', function () {
    if (this.checked) {
        activateEzid();
    }
});

dataciteRadio.on('change', function () {
    if (this.checked) {
        activateDatacite();
    }
});

localArkRadio.on('change', function () {
    if (this.checked) {
        activateLocalArk();
    }
});

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions