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

Rules page shows a textarea when not needed #176

Closed
silic0nalph4 opened this issue Oct 30, 2021 · 0 comments · Fixed by #177
Closed

Rules page shows a textarea when not needed #176

silic0nalph4 opened this issue Oct 30, 2021 · 0 comments · Fixed by #177

Comments

@silic0nalph4
Copy link
Contributor

Server configuration

  • Operating System: Ubuntu 21.04
  • Web Server (+ version): Apache 2.4.48
  • PHP Version: PHP 8
  • Server name and version (for example: TFS 0.3): TFS 1.4 (latest main)
  • MyAAC Version: master

Client configuration (Your Computer)

  • Browser: Brave/Chromium
  • Operating System: Windows 10

Description:

The rules page renders the rules in a readonly textarea when you don't have permission to edit them, and in a single paragraph with no line breaks when you do have the permission to edit them.

Steps To Reproduce:

  1. Log into your MyACC website as an account with any permissions, admin or normal. Navigate to the rules page via the sidebar, e.g. http://nova-secura.local/?rules

Observe that the rules are shown in a small, read-only textarea - we can't read all of the horrific examples without scrolling:

image

  1. Navigate to the admin UI's "Pages" menu, e.g. http://nova-secura.local/admin/?p=pages. Click on the rules_on_the_page item.

Observe that we now have edit controls and a lack of line breaks:

image

  1. Click on the "Edit" button to be navigated back to the admin panel, e.g. http://nova-secura.local/admin/?p=pages&action=edit&id=3

My initial instinct was that the textarea in rules.html.twig was unnecessary.

Changing the env in config.local.php to dev so I could live-edit the Twig templates, I disabled the textarea:

image

The formatting that is clearly visible in both the admin page and the textarea is being lost. Classic HTML not respecting line breaks 😀 The breaks are being written correctly into the page, but the browser won't render them unless they're <br> tags:

image

The good news is that Twig has an nl2br formatting function that we can use to turn those newlines in <br> tags:
image

I'll submit a PR in a couple of minutes 😀 I haven't got a fix for the formatting for rules_on_the_page as show in step 2, but this is only visible to admins so isn't that important. I'm not sure what code is writing the rules out there.

silic0nalph4 added a commit to silic0nalph4/myaac that referenced this issue Oct 30, 2021
The rules page uses a textarea to show lines break.
This commit replaces the textarea and uses the Twig
nl2br function to format the text for web browsers.

Fixes slawkens#176
silic0nalph4 added a commit to silic0nalph4/myaac that referenced this issue Oct 30, 2021
The rules page uses a textarea to show lines break.
This commit replaces the textarea and uses the Twig
nl2br function to format the text for web browsers.

Fixes slawkens#176
slawkens pushed a commit that referenced this issue Oct 30, 2021
The rules page uses a textarea to show lines break.
This commit replaces the textarea and uses the Twig
nl2br function to format the text for web browsers.

Fixes #176
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant