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

Form customization front end fixes/improvements #15836

Closed
wants to merge 4 commits into from

Conversation

smg6511
Copy link
Collaborator

@smg6511 smg6511 commented Oct 14, 2021

What does it do?

Reworks the methods responsible for moving and changing field/tab visibility and labelling. Code optimizations were made and method documentation was added.

Why is it needed?

Most of these methods were written to receive/process serialized/array data, but there appears to be no reason (any longer at least) to keep them that way—especially given that problems have arisen such as the one referenced by this PR. The changes allow for the use of commas in labels and provides simplification and clarification of the relevant code.

How to test

Clear your caches and remember to run grunt build within the _build/templates/default directory to compile the changes into the main js file. Create one or two test TVs, then create a Form Customization profile with at least one rule. Within your rule(s), experiment with re-labelling and hiding various resource fields along with your test TVs. Also create a new tab in Regions tab and verify that assigning your TVs to that tab (or the standard regions) works as expected.

Related issue(s)/PR(s)

Resolves #15357.

@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Oct 14, 2021
@smg6511
Copy link
Collaborator Author

smg6511 commented Oct 14, 2021

REVIEWERS: Note that the unit test for this (modActionDomTest.php) will need to be changed for this PR to pass. I'm just not sure who should do that. Basically, the parameters given that are formatted as an array need to be changed to a string. Please advise.

@Ibochkarev Ibochkarev added the pr/review-needed Pull request requires review and testing. label Oct 14, 2021
@Ibochkarev Ibochkarev added this to the v2.8.4 milestone Oct 14, 2021
@Ibochkarev
Copy link
Collaborator

@smg6511 Please correct errors for passing tests

@Ruslan-Aleev Ruslan-Aleev added the pr/port-to-3 Pull request has to be ported to 3.x. label Oct 14, 2021
@smg6511
Copy link
Collaborator Author

smg6511 commented Oct 14, 2021

@Ibochkarev OK, the unit test is fixed.

@Ibochkarev Ibochkarev requested a review from alroniks October 15, 2021 03:58
Copy link
Member

@theboxer theboxer left a comment

Choose a reason for hiding this comment

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

Hey, thank you for your contribution. This is just a quick code review, I'll be testing this PR later on.

manager/assets/modext/core/modx.js Show resolved Hide resolved
manager/assets/modext/core/modx.js Show resolved Hide resolved
manager/assets/modext/core/modx.js Show resolved Hide resolved
@smg6511
Copy link
Collaborator Author

smg6511 commented Oct 15, 2021

@theboxer - Just a general note as I work on your feedback: The methods I updated were primarily done so with the main purpose in mind (changing the unnecessary array-formatted params to string params), as well as renaming params so they're immediately understandable and providing doc blocks for the methods I worked with. I did not really alter them too much otherwise. As you're pointing out, maybe some re-writing could be done, but that's not what I was looking to address with this PR.

I've found that a lot of reworking needs to be done overall with the element creation and form customization UIs that may not be immediately apparent. See my PR #15773 ... it'll give you a pretty good idea of what I'm referring to. These type of changes are too big to be worthwhile for 2.x and are targeted for 3.x.

@theboxer
Copy link
Member

@smg6511 Sorry, I kind of missed that this is not a PR for 3.x, priorly knowing that this is for 2.x I wouldn't care about the complexity :))

Feel free to ignore them all.

I'd love to see the overall code quality to improve for 3.x, that's why I was trying to make these suggestions - as it makes the code more readable and easier to follow.

@smg6511
Copy link
Collaborator Author

smg6511 commented Oct 15, 2021

@theboxer - No problem. I'm totally with you on upping the code quality! As I was playing with this I discovered how fragile the form customization is; once you have a conflicting rule (whether in one profile or across multiple ones) unexpected behavior creeps in. That'll be a bigger task for a different day ;-)

@smg6511 smg6511 requested a review from theboxer October 16, 2021 02:16
@smg6511
Copy link
Collaborator Author

smg6511 commented Oct 17, 2021

@theboxer - There's still a change requested flagged, but I can't see where it is. Not sure if I dismiss that (and if so, how) or you do...

Copy link
Member

@theboxer theboxer left a comment

Choose a reason for hiding this comment

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

Unfortunately the signature changes are not possible for 2.x as they would break a backwards compatibility.

* @param {String} targetId - Text id of the TV's destination (region/tab)
* @return {void}
*/
,moveTV: function(tvId, targetId) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid that this change can't go to 2.x as it technically breaks backwards compatibility (changing the array arg to string).

Copy link
Collaborator Author

@smg6511 smg6511 Oct 18, 2021

Choose a reason for hiding this comment

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

Can you tell me how and at what version this would break it? Same with the others. I'd like to try to fix this issue for 2.x if possible, but it'll likely be unfixable if the FC rules were somehow saved in a serialized way at some point. Thx ;-)

Copy link
Member

Choose a reason for hiding this comment

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

Well you changed the signature of the function from accepting array/string and string, to accept string and string. I know you changed all the usages within modx, but if there's an extra out there that's using the array & string signature it'll break. Which is not allowed when following semver.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me ask you this: Would there be any reason for an extra to interact directly with the FC rules/logic? I might be short-sited on this, but I can't imagine an extra utilizing these methods in any way.

On the breaking change/semver point, I get that and am wholeheartedly for following common and strict protocols. For the sake of debate, is it worth not fixing a bug to maintain protocol when a change technically breaks the protocol but has a slim-to-none practical chance of actually breaking functionality? Arguably, the particular issue this PR addresses is low priority as far as bugs go, but addressing it did lead to discovering some seemingly unnecessarily complicated code.

Anyway, regardless of whether we drop this PR for 2.x, should I assume that the BC we're debating will not be an issue if submitted for 3.x?

Copy link
Member

Choose a reason for hiding this comment

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

Is there a specific reason this bug could not be resolved without changing the function signatures?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the issue is that right now FC can't handle a comma in a field label because the current code reads that as a separator. I'm not sure there's a way around it without changing the signature.

} else {
cto.label.update(vals[0]);
container.label.update(newLabel);
Copy link
Member

Choose a reason for hiding this comment

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

Same as the previous, breaks backwards compatibility by changing array to string.

* @param {String} fieldId - Text id or name of field whose label is being hidden
* @return {void}
*/
,hideField: function(fieldId) {
Copy link
Member

Choose a reason for hiding this comment

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

BC break as well

* @param {String} newLabel - The replacement label text
* @return {void}
*/
,setLabel: function(fieldId, newLabel){
Copy link
Member

Choose a reason for hiding this comment

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

BC break

@Ibochkarev Ibochkarev removed the pr/review-needed Pull request requires review and testing. label Oct 26, 2021
smg6511 pushed a commit to smg6511/revolution that referenced this pull request Nov 5, 2021
@smg6511
Copy link
Collaborator Author

smg6511 commented Nov 5, 2021

Closing this for 2.x. A port to 3.x has been merged.

@smg6511 smg6511 closed this Nov 5, 2021
opengeek pushed a commit to smg6511/revolution that referenced this pull request Jan 10, 2022
opengeek added a commit that referenced this pull request Jan 10, 2022
* Port changes from PR #15836

* Update modActionDom.php

* Remove commented code

* grunt build

Co-authored-by: Jason Coward <jason@opengeek.com>
@smg6511 smg6511 deleted the 2.x-issue-15357 branch June 4, 2022 04:43
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A label is cut off after applying form customization rule
5 participants