Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "use div as legend" config and features value #803

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add "use div as legend" config and features value
Let devs replace visible `legend` elems with `div`. Follows
accessibility guidelines by using `aria-labelledby` and `id`.

Devs can set "use div as legend" in the config file or the same key in
the features block to a boolean. The feature block value takes
precedence. This will change the visible HTML legend elements to divs.
If the dev uses anything other than a boolean, they get an error
message.

Why change only visible legend elements?

It is a smaller change that I thought would be more acceptable.

Why ensure always unique random ids?

Devs should not rely on the selector. Avoids later breaking changes.

Outcome of configuration combinations:

- [x] config: none/feature: none - legend
- [x] config: false/feature: none - legend
- [x] config: true/feature: none - div

- [x] config: none/feature: true - div
- [x] config: false/feature: true - div
- [x] config: true/feature: true - div

- [x] config: none/feature: false - legend
- [x] config: false/feature: false - legend
- [x] config: true/feature: false - legend

- [x] config: chair/feature: none - legend
- [x] config: chair/feature: true - div
- [x] config: chair/feature: false - legend

Error messages:

- [x] config: chair - websockets.log: The Configuration directive "use div as legend" must be True or False.
- [x] feature: chair - webpage: "use div as legend" in "features" must be either True or False.

Edited:

- docassemble_base/docassemble/base/config.py
- docassemble_base/docassemble/base/parse.py
- docassemble_base/docassemble/base/standardformatter.py
- docassemble_webapp/docassemble/webapp/static/app/app.css
- docassemble_webapp/docassemble/webapp/server.py
- tests/features/TestExamples.feature

Ignored:

- docassemble_demo/docassemble/demo/data/static/lumen.min.css:
    Disabling the styles in the DOM didn't have an effect.
- docassemble_webapp/docassemble/webapp/static/bootstrap/css/bootstrap.min.css:
    Same styles as lumen.
- docassemble_webapp/docassemble/webapp/static/app/cm6.js:
    Treats `div` and `legend` the same.
- docassemble_webapp/docassemble/webapp/static/app/jquery.min.js:
    jQuery uses `legend` in checks for disabled fields. Both `div`
    and `legend` cannot be disabled and from what I saw in the code
    I believe jQuery would treat them the same way:
    https://github.com/jquery/jquery/blob/03e183c4ccf22bf4031920c3270c9f113cb72d1d/src/selector.js#L277
    jQuery mentions the spec for disableable elements:
    https://github.com/jquery/jquery/blob/03e183c4ccf22bf4031920c3270c9f113cb72d1d/src/selector.js#L248-L250
- docassemble_webapp/docassemble/webapp/static/app/MaterialIcons-Regular.json:
    MaterialIcons icons are independent of the html that uses them.

Compiled files (ignored):

- docassemble_webapp/docassemble/webapp/static/app/adminbundle.js
- docassemble_webapp/docassemble/webapp/static/app/app.min.css
- docassemble_webapp/docassemble/webapp/static/app/bundle.css
- docassemble_webapp/docassemble/webapp/static/app/bundle.js
- docassemble_webapp/docassemble/webapp/static/app/cm6.min.js
- docassemble_webapp/docassemble/webapp/static/bootstrap/css/bootstrap.min.css.map

I found no a appearances of disabled associated with legends.

Co-authored-by: ttiimm <likarish@gmail.com>
plocket and ttiimm committed Dec 1, 2024
commit d8ebfe538a0f6aa85a32eb1fa3f75d86cd5aea2f
4 changes: 4 additions & 0 deletions docassemble_base/docassemble/base/config.py
Original file line number Diff line number Diff line change
@@ -996,6 +996,10 @@ def load(**kwargs):
daconfig['web server'] = 'nginx'
if 'table css class' not in daconfig or not isinstance(daconfig['table css class'], str):
daconfig['table css class'] = 'table table-striped'
if 'use div as legend' in daconfig:
if not isinstance(daconfig['use div as legend'], bool):
config_error('The Configuration directive "use div as legend" must be True or False.')
del daconfig['use div as legend']
if env_true_false('ENVIRONMENT_TAKES_PRECEDENCE'):
messages = []
for env_var, key in (('DBPREFIX', 'prefix'), ('DBNAME', 'name'), ('DBUSER', 'user'), ('DBPASSWORD', 'password'), ('DBHOST', 'host'), ('DBPORT', 'port'), ('DBTABLEPREFIX', 'table prefix'), ('DBBACKUP', 'backup'), ('DBSSLMODE', 'ssl mode'), ('DBSSLCERT', 'ssl cert'), ('DBSSLKEY', 'ssl key'), ('DBSSLROOTCERT', 'ssl root cert')):
4 changes: 4 additions & 0 deletions docassemble_base/docassemble/base/parse.py
Original file line number Diff line number Diff line change
@@ -2260,6 +2260,10 @@ def __init__(self, orig_data, caller, **kwargs):
self.interview.options['hide standard menu'] = data['features']['hide standard menu']
if 'labels above fields' in data['features'] and isinstance(data['features']['labels above fields'], bool):
self.interview.options['labels above'] = data['features']['labels above fields']
if 'use div as legend' in data['features']:
if not isinstance(data['features']['use div as legend'], bool):
raise DASourceError('"use div as legend" in the "features" block must be either True or False.' + self.idebug(data))
self.interview.options['use div as legend'] = data['features']['use div as legend']
if 'suppress autofill' in data['features'] and isinstance(data['features']['suppress autofill'], bool):
self.interview.options['suppress autofill'] = data['features']['suppress autofill']
if 'floating labels' in data['features'] and isinstance(data['features']['floating labels'], bool):
Loading