-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
Refactor template variable creation #15773
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really huge PR, I left some general feedback on a small part of the changes.
I have not checked whether this PR is technically the best approach.
Re whether this is the best technical approach: I think you'll find it is at least a much better one. I found when diving into the Ext side of this that its implementation in MODX pretty much crippled its excellent ability to track the dirty state of forms because of the way some components get rendered to the DOM, taking them out of the Ext environment. Their likely was never the need to add/use the markDirty methods currently in MODX's implementation (which end up setting the real dirty state inaccurately most of the time) had a different approach been taken. Note that I say this humbly, not sharply -- I'm sure there were reasons at the time and maybe there's something I'm not taking into consideration, but why not improve this if we can? |
Sometimes the reason something is the way it is, is nothing more than "a decade ago it seemed like a good idea". ;) I'm currently trying it out, and I have to say I am impressed with the UI side of it. It's so much more native, and there's a lot of very useful tidbits (like the example values) that greatly improve the user experience setting them up. Obviously with a PR that adds 5k lines, there is going to be discussion about some of the details, but so far I'm impressed! -- For others looking to quickly create all TVs, here's a SQL dump of all core TV types. May need to truncate your TV table as the IDs start with 1:, and afterwards edit your template to enable the TVs.
|
Some feedback from trying this out a little and reviewing the code:
It's obvious you've put a lot of effort into this and you deserve to be credited for that, however it is not standard to put such notices for anyone in any place in the core and I would ask you to remove (=replace with standard one) because: (1) I worry this "ownership statement" has license implications, even though as you've signed the CLA you have agreed that any changes become ownership of the project; (2) if we accept this, it may set a precedent contributors can go ahead and stamp their name in files they add/change if it's big enough -- that could get messy, and we have the git history and contributors listing for that; (3) I'm hoping we can get this merged for the beta and then suddenly this comment becomes factually incorrect as it is no longer a proposal but the actually merged core ;) After we get this merged I'm more than happy to talk about a MODX.today post about this change that very clearly and publicly acknowledges the work you've done on making it happen. In terms of getting you/your company some exposure I think that would be both more appropriate and effective.
|
Mark - thanks for taking a look so quickly. I know it's a lot to look at. Suffice it to say, once I go down the rabbit hole, I can't help myself! Anyway, to respond to your feedback:
|
Note that in this most recent commit, the code quality check is failing due to 2 warnings in one file on line length. The trouble is, breaking those lines up makes them less readable IMO. Should these warnings result in all files failing? Doesn't seem right ... please advise. RE documentation stubs: What would be the most useful way of providing those at this point in time? |
Great job! Visually, everything works as it should, but there are a couple of comments.
Most likely there are also changes in TVs that are missing in this PR.
Although for TV with an image type and a file, I would, on the contrary, reduce the width of the field "Default value", as it is now in the resource (not 50%, but 400px). Firstly, uniformity in the interface, and secondly, it is less to reach the mouse to the upload icon.
In general, in many PRs, I previously tried to standardize the position of TV parameters, it would be great if this work was not in vain :) Thanks for the PR! |
Quick comments re RA's review:
I'll respond to the other items shortly... |
Yes, I ran grunt build, my comments on the updated styles. Check it out for yourself too.
Yes, I agree with that. |
On the styles, I see from your screen grabs that the updates are not showing for you. I've double-checked here and it's looking as it should. Take a look at this screen grab (note the checkboxes were updated to the switch style used elsewhere): Re you comment on the widths of the file and image default fields, I see what you mean if you're editing on a large screen. I'll adjust these by giving them a max-width or give them a special class so the width can be set according to the breakpoints. Hard-coding this in the config with a pixel value is problematic when viewing on mobile (where all fields should stack and be 100% width). At any rate, we're on the same page on this, I'll cook up something to fix it. |
It's strange that the styles haven't been updated, I'll double-check. |
One other quick note for all: Please review this with compress_js off, as there's a fair amount of ES6 in the js code that won't compile correctly with the current build workflow. I have another PR (#15793) to update the workflow that looks like it has a good chance of adoption very soon, probably well before this PR is fully approved. If not, I'll adjust as needed. |
Circling back to the Allow Blank placement, I did a bit of playing around with what would need to be done to place it next to the input type as a switch and reversing the logic so it's labelled as "Required?" instead of "Allow Blank." It turned out to not be as tricky as I thought it'd be. Here's a mock up of how that placement would actually look: If this is preferred by the reviewers, I can commit the necessary changes. |
I really love what you did with this PR, thanks a lot for all the effort you put into this! A console error is thrown when selecting "Resource List" as Input Type if you try to create a new Template Variable. I guess this is caused by the response from the connector:
|
OK, I think I've covered most of the issues/requests thus far: Re @JoshuaLuckers' comments above:
Re @Ruslan-Aleev's comments:
I also made a minor change to a few of the processors to quiet the error about loading smarty the old way (the rest of the changes in those files are just PSR-12 style fixes). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given it another test with the latest changes, and all seems well!
@smg6511 Sorry about my earlier "two weeks" estimate turning out too be too positive. It hadn't fallen off my radar - the radar just started overflowing with other things. I'm also notoriously bad at timeframes, especially when giving them on a good day before other things start happening ;) |
@Mark-H - No problem, thanks for making the time to look at this again! @Ruslan-Aleev @Jako @Ibochkarev - If there's any way one or more of you guys can give this a review in the near future I'd really appreciate it. As you all may have seen, @opengeek would like at least 3 approvals to merge this. The sooner this is (hopefully) incorporated, the more time to work out any issues. I'd also love to be able to build upon this by reworking the render functionality (to the resource editing form) well before we get too far into the beta stages, especially since that will be a major reworking as well. Thanks - I know there's a lot going on here trying to move 2.x and 3.x forward, and everyone's got regular jobs and lives and other things going on! |
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.
Ignore this file, had to commit to reapply stashed changes.
Also a couple minor tweaks were made.
Addresses comments and requests to-date, with the exception of documentation.
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.
a76697b
to
af3aa5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange lexicon entries.
$_lang['tv_elements_listbox-multiple_desc'] = $_lang['tv_elements_listbox_desc']; | ||
$_lang['tv_elements_radio_desc'] = $_lang['tv_elements_option_desc'] = $_lang['tv_elements_desc']; | ||
$_lang['tv_elements_tag_desc'] = $_lang['tv_elements_desc']; | ||
$_lang['tv_daterange_elements_desc'] = 'Test options desc for daterange with example ph: [[+ex1]]'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like some test description. Is this text used somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been merged. Can we create an issue for this instead?
$_lang['tv_elements_radio_desc'] = $_lang['tv_elements_option_desc'] = $_lang['tv_elements_desc']; | ||
$_lang['tv_elements_tag_desc'] = $_lang['tv_elements_desc']; | ||
$_lang['tv_daterange_elements_desc'] = 'Test options desc for daterange with example ph: [[+ex1]]'; | ||
$_lang['tv_daterange_default_text_desc'] = 'Test default text desc for daterange with example ph: [[+ex1]]'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like some test description. Is this text used somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been merged. Can we create an issue for this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only one who can quick answer this, created the pull request. So it is IMHO better placed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, good catch ... looks like I missed removing those. Yes, I used your daterange TV in one of my tests for ensuring backward compatibility and for override testing.
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 |
What does it do?
This proposed enhancement changes the way that TV input and output properties are incorporated into the TV editing form, generating these dynamically-loaded fields as Ext components (as the rest of the form does) instead of a rendered DOM element. This allows a level of manipulation of those fields (and native Ext tracking of their dirty states) that's not currently possible, as well as fully-functional validation.
To preserve compatibility with community-developed custom TVs, the original renders and templates were left untouched and a new directory "configs" was created alongside the original "renders" one. The structure within is essentially the same, though the field configs are set up directly in the php files instead of loading a Smarty-parsed tpl file. These configs are subsequently iterated in javascript and inserted as items into a new fieldset component.
Other changes and enhancements include:
Why is it needed?
To lay the groundwork to solve problems with validation (the dirty state of fields and forms, currently implemented in a very non-ideal way) and refine the control over/display of element form fields (particularly that of TVs). Assuming eventual approval of these changes, applicable ones will then be created along the same guidelines for other elements (chunks, snippets, etc.). The advantages will become even more apparent when my validation fixes for 2.x (from PR #15146) are introduced into 3.x (which I'll turn to once this is hopefully merged).
How to test
Related issue(s)/PR(s)
Related to #15164, the original draft version of these changes for 2.x.