NationalCentreTruthReconciliation / Secure-Record-Transfer

A transfer portal incorporating CAAIS and BagIt Specifications
https://secure-record-transfer.readthedocs.io/en/latest/
4 stars 2 forks source link

Split JS for multi-stage transfer form #235

Open yenaing-oo opened 3 weeks ago

yenaing-oo commented 3 weeks ago

This way, only the relevant JS is loaded for each page, and it will no longer be necessary to avoid running portions of JS where constants are missing, since they are expected to be there.

For e.g. currently, we might have to do something like this in JS to prevent a console error on pages where this constant is not needed:

if (typeof ID_SUBMISSION_GROUP_SELECTION !== 'undefined') {
        const selectField = $('#' + ID_SUBMISSION_GROUP_SELECTION);
        selectField.on('change', updateGroupDescription);
        initializeGroupTransferForm();
    }

This means that if the constant ID_SUBMISSION_GROUP_SELECTION is not being passed to the JS in a situation where we do need it, it would be hard to detect since no error is raised.

danloveg commented 3 weeks ago

Would this require that a separate minified JS file be created per page of the form? Not saying that's a bad thing, just wondering.

yenaing-oo commented 3 weeks ago

Yes it would, if there is JS needed for that page. I think if we plan on doing this, it might be a good idea to consider placing the contents of these includes within the templates themselves, instead of storing them in separate include templates:

{% if DEBUG %}
    {% load static %}
    <script src="{% static 'recordtransfer/js/profile/profile.js' %}"></script>
{% else %}
    {% load pipeline %}
    {% javascript 'recordtransfer_profile_js' %}
{% endif %}

The addition of more named JS packages in base.py would be unavoidable as far as I know.

danloveg commented 2 weeks ago

This may or may not be related, but I'm seeing this error on the Record Description part of the form when I try to open a date picker:

Screenshot 2024-11-14 142345

danloveg commented 2 weeks ago

Also JS related, when you click "More" on the rights form set or other identifiers form set, three more forms get added, but only one should be added.

danloveg commented 2 days ago

Related to #247. I could see there being multiple "entrypoints" in webpack, one for the overarching JS that the whole site needs, and one for each of the special case pages like the pages of the transfer form