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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama created an issue. See original summary.

joelpittet’s picture

+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.

torgosPizza’s picture

Issue tags: +commerce-sprint

This idea also gets a +1 from me, it'd make that entire user interface so much.. usable. Tagging for commerce-sprint.

joelpittet’s picture

@rszrama if you could post even a broken patch that kickstarts this, I'll take this an run with it.

daggerhart’s picture

Status: Active » Needs work
FileSize
2.63 KB

@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.

torgosPizza’s picture

Status: Needs work » Needs review

There's a patch so I'm setting to Needs Review.

smccabe’s picture

FileSize
32.24 KB

hey @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.

+++ b/commerce_discount.module
@@ -322,6 +322,27 @@ function commerce_discount_form_commerce_discount_form_alter(&$form, $form_state
+  $additional_settings = array(
+    'commerce_compatibility_strategy',
+    'commerce_compatibility_selection',
+    'discount_usage_per_person',
+    'discount_usage_limit',
+    'commerce_discount_date'
+  );

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.

daggerhart’s picture

Hi @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.

smccabe’s picture

hey @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.

sass scss/commerce_discount.scss:css/commerce_discount.css --style expanded
daggerhart’s picture

FileSize
38.81 KB

Hi @smccabe,

That css build looks much better, and the patch works well. I think we're almost done.

Two things remaining that I see:

  1. We need feedback on whether the approach of dynamically building the vertical tabs is desired.
  2. There is still a css float issue caused by the 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.

discount usage css float problem

rszrama’s picture

Yeah, 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:

  • Discount dates
  • Compatibility with other discounts
  • Maximum usage (including both maximum usage fields)

And leave it up to modules adding other fields to alter this form themselves.

rszrama’s picture

Status: Needs review » Needs work
rszrama’s picture

Oh! 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.

daggerhart’s picture

FileSize
8.48 KB

Here 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.

torgosPizza’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: 2557247-14-commerce_discount-vertical-tabs.patch, failed testing.

rszrama’s picture

Guessing 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?

rszrama’s picture

On 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.

daggerhart’s picture

@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.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
8.47 KB
5.23 KB

This 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;)

Status: Needs review » Needs work

The last submitted patch, 20: add_vertical_tabs_to-2557247-20.patch, failed testing.

daggerhart’s picture

Thanks 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.

mglaman’s picture

Status: Needs work » Needs review

Patch #22 looks great! Marking review to see if test bot is still upset.

mglaman’s picture

Status: Needs review » Reviewed & tested by the community

#22 accomplishes the tasks and keeps the tests a passin'!

joelpittet’s picture

@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

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all, I've committed this to the latest dev branch. Any further changes can be done in a follow-up if you see fit.

rszrama’s picture

Spawned a follow-up for my comment in #18 above re: tab summaries:

#2616356: Add setting summaries to vertical tabs

torgosPizza’s picture

It'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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.