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

Fix Various Issues with Resource/Element Validation and Field Display #15146

Merged
merged 5 commits into from
Oct 4, 2020

Conversation

smg6511
Copy link
Collaborator

@smg6511 smg6511 commented Jul 2, 2020

#Made several changes to gain expected validation behavior when editing resources, templates, tvs, snippets, chunks, and plugins. Now, the first tab with an invalid field is activated when not currently visible. Also small fixes to validation regex rules as well as message display were made. Lastly, some inconsistencies with field description labelling is addressed (i.e., when inline help is specified in system settings, all element editing fields now show their descriptions below instead of in tooltips). This labelling inconsistency should IMO be fixed in resource editing pages as well, but is not addressed here. (Please forgive all the minute space diffs; most of them are not intentional.)

What does it do?

  • Fixed regex in modx schema and class maps for element names (end of rules incorrectly had a negative lookahead for space rather than negative lookbehind).
  • Removed failureSubmit and traverseNode methods in MODx.panel.Resource. The showErroredTab and detectErrors methods in the parent MODx.FormPanel class, with adjustments, serve the same purpose. The failureSubmit listener of each element panel subclass now calls the showErroredTab method to evaluate field errors.
  • Added helper method in MODx.FormPanel to convert an array of component itemIds into their associated component ids. This to ensure a proper value to pass to getCmp when a component's id is created on the fly.
  • Added failure listener to element panels. Without it, the failureSubmit event never gets triggered.
  • Fixed element create and update processors to handle the name field for templates correctly. Without this fix, it was possible to save templates with duplicate names.
  • Some general streamlining of defaults in element panel configs.
  • The first-found (and now navigated to) field error, when being returned from the server side, would disappear as soon as the alert message appeared. This was due to the default behavior of native (Ext) validation triggering on blur. If the field in question is valid as far as the front end config rules go, its invalid state gets cleared once focus is lost even though the back end validation may still not be passing. Thus the default validation event was set to 'change' instead.

Why is it needed?

To ensure better evaluation and display of, as well as dynamic navigation to, found field errors. At present, it can be confusing when encountering an error that is not in the currently active tab.

Related issue(s)/PR(s)

Addresses issues #14743 , #15116 , and #15088

Jim Graham added 2 commits June 29, 2020 12:28
Now, first tab with an invalid field is activated when not currently visible. Also small fixes to validation regex rules as well as message display were made. Lastly, inconsistencies with field description labels are addressed.
Various small changes to resource and element panel widgets, including making the validation event change instead of blur. Major changes to error handling methods in the main MODx.FormPanel class to fix/enhance ux.
@smg6511 smg6511 requested review from Mark-H and opengeek as code owners July 2, 2020 04:18
@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Jul 2, 2020
Removed stray console.log line
Copy link
Collaborator

@Ruslan-Aleev Ruslan-Aleev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR, thanks a lot!
Solves a lot of problems in UX :)

The active sub-category of the TV tabs opens, and the screen "scrolls" to the error (when the TV position is below the content or in a separate tab):
tv_req_1

Messages are displayed and the tab is activated:
tv_req_2

@JoshuaLuckers JoshuaLuckers added the pr/review-needed Pull request requires review and testing. label Jul 4, 2020
@Ruslan-Aleev
Copy link
Collaborator

Guys, please test this PR, it significantly improves the current behavior for validation in forms.
It would be great to have this in the 2.8 branch :)

@Mark-H
Copy link
Collaborator

Mark-H commented Oct 4, 2020

It looks our current js build workflow fails when using let and const constructs (in the uglifyjs bit) so I'm reverting those back to plain ol' var. Probably a good idea to sort out that workflow at some point, but for now I'm doing it this way to get your improvements into 2.8. Thanks @smg6511 for the great work.

@Ruslan-Aleev
Copy link
Collaborator

@Mark-H what about the 3.x branch? The 3.x branch also contains these bugs.

@Mark-H
Copy link
Collaborator

Mark-H commented Oct 6, 2020

I'll try to cherry pick this (and the other things I merged the other day) into 3.x later. Couldn't get that to do what I wanted last sunday around midnight so figured that was a good one for another day. ;)

@smg6511
Copy link
Collaborator Author

smg6511 commented Oct 6, 2020

Mark - If you want I can integrate the changes into a new PR for 3.x. Also, regarding your comment on the workflow you may want to take a look at Terser in place of Uglifyjs. I think ES6 has been out long enough and support is broad enough for us to be integrating its features into our coding.

@JoshuaLuckers JoshuaLuckers added the pr/port-to-3 Pull request has to be ported to 3.x. label Nov 6, 2020
smg6511 pushed a commit to smg6511/revolution that referenced this pull request Jul 26, 2021
A continuation of the work initiated in draft PR modxcms#15164, ported to 3.x. Many of the validation UX features (and more) that were originally in the referenced draft (and have since been implemented into 2.x via PR modxcms#15146) have been removed from this commit and pending PR for clarity.
opengeek pushed a commit to smg6511/revolution that referenced this pull request Oct 19, 2021
A continuation of the work initiated in draft PR modxcms#15164, ported to 3.x. Many of the validation UX features (and more) that were originally in the referenced draft (and have since been implemented into 2.x via PR modxcms#15146) have been removed from this commit and pending PR for clarity.
opengeek added a commit that referenced this pull request Oct 19, 2021
* Refactor of TV Configuration and Management

A continuation of the work initiated in draft PR #15164, ported to 3.x. Many of the validation UX features (and more) that were originally in the referenced draft (and have since been implemented into 2.x via PR #15146) have been removed from this commit and pending PR for clarity.

* GIT ignore

Ignore this file, had to commit to reapply stashed changes.

* Updates to Pass Linter

Also a couple minor tweaks were made.

* Requested changes from PR conversation, batch 1

* A couple more minor changes

* Update resourcelist.tpl

* Changes in Response to PR Feedback

Addresses comments and requests to-date, with the exception of documentation.

* PSR-12 Fixes

* Revert gitignore changes

* Changes in Response to PR Feedback, Batch 2

* Updates to Enable Multiple Overrides

A few additions to allow non-native tvs to switch to the new loader method and add their own named validators and listeners.

Note that I originally thought it would be possible for each custom TV to provide its own Ext.override(MODx.panel.TV,{}), and that overrides would build on top of one another. That's not the case however, as the last-loaded Ext.override takes precedence over all others.

* grunt build

Co-authored-by: Jason Coward <[email protected]>
@rthrash
Copy link
Member

rthrash commented Nov 1, 2021

This pull request has been mentioned on MODX Community. There might be relevant details there:

https://community.modx.com/t/proposal-to-move-element-code-into-its-own-tab/4562/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed CLA confirmed for contributors to this PR. pr/port-to-3 Pull request has to be ported to 3.x. pr/review-needed Pull request requires review and testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants