TACC / Core-CMS-Custom

Customized Core CMS code and builds
5 stars 0 forks source link

hotfix/WP-232-234-...--fix-checkForBlankInputs-not-loaded #202

Closed wesleyboar closed 1 year ago

wesleyboar commented 1 year ago

Overview

Ensure checkForBlankInputs.js script loads.

Related

Changes

  1. Rename checkforBlankInputs to checkForBlankInputs.js.
  2. Move this file to the same path it has in main branch.[^1]
  3. Add __init__.py into the utils/ folder.[^1][^2]
  4. Add , 'apps.utils' to CUSTOM_APPS.

[^1]: Django static files are confusing. TL;DR Given the utils folder is recognized as an app, Django copies /…/apps/utils/static/utils/js/checkForBlankInputs.js to /…/static/utils/js/checkForBlankInputs.js (see inside container; it is not synced to your local machine). OMG;MORE: Python treats folders with an __init__.py (like the apcd-cms/src/apps/utils in main) as an "app". Then Django reads /static folder (by default) of any "app" as where to find static files, but only if they are within a folder of the same name as the "app" folder e.g. utils/static/utils/. Anything after that confusing-and-required hierarchy is then recognized as a static file, and copied to /static (root folder).

[^2]: At utils/__init__.py not utils/static/utils/__init__.py. Change 4—registering apps.utils as an app—may make this moot, but I am just being consistent with main for now.

Testing

  1. In browser, open DevTools > "Network" tab.
  2. Open http://localhost:8000/register/request-to-submit/.
  3. Confirm script checkForBlankInputs.js loads.
  4. Type <script> into a field.
  5. Focus on another field.
  6. Confirm <script> becomes script.

UI

script loads
script loads

https://github.com/TACC/Core-CMS-Custom/assets/62723358/bccfb9b3-2841-4b5c-804f-1683babb136d