Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
What do we think of vertical tabs on the discount form? As I add fields for compatibility settings, it strikes me that we could use vertical tabs for everything beneath the inline conditions: date settings, usage settings, compatibility settings, etc. These are all things that determine general availability of a discount that aren't directly related to the offer type - would make sense for them to be tied together in a single vertical tabs interface.
Comment | File | Size | Author |
---|---|---|---|
#22 | 2557247-21-commerce_discount-vertical-tabs.patch | 4.63 KB | daggerhart |
Comments
Comment #2
joelpittet+1 to this idea, it would make the UI a bit less "custom" which would make it easier to keep to the style of the themes that are styling it.
Comment #3
torgosPizzaThis idea also gets a +1 from me, it'd make that entire user interface so much.. usable. Tagging for commerce-sprint.
Comment #4
joelpittet@rszrama if you could post even a broken patch that kickstarts this, I'll take this an run with it.
Comment #5
daggerhart CreditAttribution: daggerhart as a volunteer commented@joelpittet - Attempting to get this started with a patch.
One issue with this patch: I needed to modify the css to prevent some floating problems, but did not find a scss config file within the repo, so I only modified the css files, not the related scss.
Any feedback is appreciated. I'm happy to re-roll with another approach and with proper scss usage.
Comment #6
torgosPizzaThere's a patch so I'm setting to Needs Review.
Comment #7
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedhey @daggerhart
I'm not sure what you mean by scss config file, but the scss file is just in scss/. I updated the patch with the code moved into the scss file and also changed the $k variable to something clearer, drupal standard isn't big on naming stuff like that unless maybe it is just a counter.
Do you think this should be moved into a config or a define or is there somewhere else we can pull this from? Seems like a bad place to have the additional setting types defined.
Comment #8
daggerhart CreditAttribution: daggerhart as a volunteer commentedHi @smccabe,
Thanks for the feedback on the patch.
I found the scss files, and the note in the README with compiling instructions, but didn't like the results of my compile. It replaced every single line in the file. Not sure if the scss file is out of date or if it was an OS line ending issue, so I haven't messed with it further. I'd like for someone more familiar with the scss file than I am to verify that it is up to date and safe to use for css compilation.
You're right about it not being good to use a hard-coded list of fields for the vertical tabs, so I've attached a patch that takes a more flexible approach. It loops through all visible child fields of
commerce_discount_fields
and ignores a hard-coded list of fields we don't want in the vertical tabs.This patch fixed one of the css float issue by adding the clearfix class to the commerce_discount_offer field, but does not attempt to change any css.
Let me know what you think.
Comment #9
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedhey @daggerhart
I like the dynamic setup better, I just added a small comment to explain why we were skipping those options. I also put the CSS in the patch since I got the SCSS stuff working correctly. The below worked for me and produced only the relevant changes to the CSS.
Comment #10
daggerhart CreditAttribution: daggerhart as a volunteer commentedHi @smccabe,
That css build looks much better, and the patch works well. I think we're almost done.
Two things remaining that I see:
commerce_discount_usage.css
file. (see screenshot). Since the only css in that file is causing the float problem, I believe the whole file can be removed.Comment #11
rszrama CreditAttribution: rszrama commentedYeah, go ahead and remove the CSS file - this stuff has long needed a clean-up. : D
Re: the automatic creation of vertical tabs, I think we may need to manually set it b/c we can't trust each field to need to go in its own tab. For example, "Selected discounts" is really an optional field that only appears when the appropriate option is selected in "Compatibility with other discounts." So those two should be in the same tab.
I'd group the current fields like so:
And leave it up to modules adding other fields to alter this form themselves.
Comment #12
rszrama CreditAttribution: rszrama commentedComment #13
rszrama CreditAttribution: rszrama at Centarro commentedOh! Let's test this with Commerce Coupon 2.x as well, as it would need to be in a vertical tab as well. Probably just needs a follow-up issue in the Commerce Coupon queue once this is committed.
Comment #14
daggerhart CreditAttribution: daggerhart as a volunteer commentedHere is my first attempt at the new (non-automated) approach. Having to move & unset fields, then move them back during validation seems a bit sloppy, but I didn't see another obvious approach without significantly altering the original form.
@smccabe - I've removed the commerce_discount_usage.css file as @rszrama recommended, but I'm still having issues with sass compilation replacing the whole line, so I didn't make changes to the remaining css. It must have something to do with my setup. I suspect in the end, you will have to roll the final patch along with css changes.
@rszrama - I started working on commerce_coupon 2.x, but it has a much more complicated form situation, so I'd like to hear thoughts on this patch before going much further.
Any feedback is appreciated.
Comment #15
torgosPizzaComment #17
rszrama CreditAttribution: rszrama at Centarro commentedGuessing the tests are failing because they were dependent on the current form structure or HTML.
@daggerhart Is the additional complexity owing to trying to group multiple fields in one vertical tab?
Comment #18
rszrama CreditAttribution: rszrama at Centarro commentedOn visual review, I also can't figure out why the discount date fields are pushed down inside the tab. Anyone have any ideas?
Additionally, we should look at what it'll take to get summaries into the tab gutter. This requires a bit of JavaScript if I'm not mistaken. Been a while since I wrote them for Commerce.
Comment #19
daggerhart CreditAttribution: daggerhart as a volunteer commented@rszrama - Yes, the difficulty is in putting multiple fields that already exist in the form structure into a single vertical tab. I couldn't find a way to make the fields appear within the vertical tab without actually moving them. Is there something obvious I've missed?
The javascript for vertical tab gutters shouldn't be too difficult. I can dig into it once I get the fields moved in a reasonable way.
Comment #20
joelpittetThis fixes nothing other than the nitpicks/coding standards, I've gotta catch up on what's been done. There were some errant whitespace at the end of lines and 80chars, etc stuffs.
Thanks for giving this a go, keep going @daggerhart;)
Comment #22
daggerhart CreditAttribution: daggerhart as a volunteer commentedThanks for @bojanz in IRC this patch takes a much more clean approach. It creates the tab fieldsets in hook_form_alter so that vertical tab weights are respected, but doesn't move the field to those tabs until #pre_render so that we don't have to move the fields back during validation.
I didn't touched the css this time because everything is looking good without doing so. Any feedback is appreciated.
Comment #23
mglamanPatch #22 looks great! Marking review to see if test bot is still upset.
Comment #24
mglaman#22 accomplishes the tasks and keeps the tests a passin'!
Comment #25
joelpittet@daggerhart this looks great thanks for the clean-up. Interesting approach, and just curious if you played with the
#parents
Some references if you wanted to play with it at all:
https://www.drupal.org/node/48643
https://www.drupal.org/node/279246#comment-2292322
Comment #26
joelpittetThanks all, I've committed this to the latest dev branch. Any further changes can be done in a follow-up if you see fit.
Comment #27
rszrama CreditAttribution: rszrama at Centarro commentedSpawned a follow-up for my comment in #18 above re: tab summaries:
#2616356: Add setting summaries to vertical tabs
Comment #28
torgosPizzaIt's so clean and so pretty! The new config form is soooo much friendlier now, between the vertical tabs and the CSS cleanup. Nice work!