Problem/Motivation
Provide a possibility to create discounts using Inline Entity Form field widget.
Here is a use case from my project. We give a possibility to apply discounts manually, by clicking on the radio button (condition was implemented).

Also we have a Buying Groups (BG) which contain set of discounts. BG was implemented using node entity and couple fields (entity reference to commerce_discount). Initially we added discounts from default screen and attached them on node editing. But, when number of BGs and discounts began to grow, I've thought: would be cool to add discounts on node editing.

Now, when this was implemented, we not need to go to discount creation screen and turn back to attach it on a node.
Proposed resolution
Implement IEF controller and redesign commerce_discount_form().
Remaining tasks
- Some CSS styles could be missed
API changes
- Added
COMMERCE_DISCOUNT_ADMIN_BASE_URLwithadmin/commerce/discountsURI - Added
COMMERCE_DISCOUNT_ENTITIES_PREFIXwithdiscount_prefix. - Completely redesigned admin forms and related functionality.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | Edit__5_off_products___Site-Install.png | 27.73 KB | joelpittet |
| #17 | inline_entity_form-2631670-17.patch | 47.93 KB | joelpittet |
| #7 | interdiff-4-7.txt | 1.93 KB | br0ken |
| #7 | commerce_discount-ief-support-2631670-7.patch | 62.14 KB | br0ken |
Comments
Comment #2
br0kenComment #4
br0kenHappenes...
Comment #5
br0kenComment #7
br0kenComment #8
joelpittetThere seems to be a bunch of unrelated changes in there: .gitignore, coding standards, permission changes, variable renames, etc. I'd rather be able to review this for what you intend and not be scanning over all the other unrelated changes. Could you please remove them?
Comment #9
joelpittetAlso would be nice to know a little bit more about the use-case or improvement this is providing in the issue summary and/or a screenshot.
Comment #10
joelpittetSome of the minor changes that were unrelated but relevant I've committed and credited to you so that it would be less tempting for you to add them to the patch.
Comment #12
br0kenYeah, here is present some unrelated changes, but some of them are necessary in general.
- File permissions
This is my fault, I'm not configure my Git for ignoring file modes globally and forgot to do this for module repo. But this is not a big problem.
- .gitignore
I'm using Mac OS and it creates .DS_Store files which are not ignored by repo. So, small improvement was created. But, forgot to add
*.map, sorry.All changes from a patch were made not just for fun. Each of them is related to general task anyway (ignoring code clean up, of course).
I'm sure that made code more readable and flexible. Also I want write tests for this, but needs some time and separate issue for this.
P.S. Will be sad if this work won't be committed.
Comment #13
joelpittet@BR0kEN thanks for filling out the issue summary more. The code cleanup makes it really hard to review and also conflicts with possibly other patches in the queue that could be tackling that problem. I know it's hard (because I tend to do it too) but please keep the changes to the scope needed to solve the problem.
FYI most people are on OSX. May be good idea to add .DS_Store to a global .gitignore file on your system. As there is never a need to include that in your repos (AFAIK).
I'll try to commit it but can't make promises as it's not fair to others: if it breaks things for other people or it doesn't help most people, or just over complicates (I don't know these things because it's hard to review as-is).
Comment #14
joelpittetHere's a review of some of the things I noticed on a first take of about half the patch. Maybe you can split this patch up a bit, it seems to be doing a lot and would really help reviewers if the focus was narrower.
I can see you put a lot of work into it and want to help you get this in. Thank you @BR0kEN
Unrelated: Add .DS_Store to global git ignore.
These file mode changes aren't needed:
http://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file...
All the comma ending coding standards fixes were fixed else-where and shouldn't be included in this patch. Will need a re-roll as a result.
Note to self: I changed this and it looked to break some use-cases we had, a bit weary and will look at that bit closer after.
This is better with the argument but I fixed it a different way to keep things similar to what it was.
Constants keep adding to the global namespace, I wonder if there is a better way. I see this done in drupal lots but with lots of modules this becomes a small problem on every request.
Why is this 'file path' needed?
Note to self: This looks like a nice helper, though I wonder if there is a better way than preg_replace for performance.
In what cases will this function not exsit?
I'm not too keen on this helper function. Is there precedent for this in other modules?
Comment #15
torgospizzaLooks like this was already committed, and so now I'm leery of downloading Discounts -dev version. @BR0kEN could you please respond to @joelpittet's comments?
Comment #16
br0kenIt didn't commited, unfortunately. So everything is ok.
Comment #17
joelpittet@torgosPizza I only committed the niggly things to boil them away in hopes we can see the actual code that changes that are being requested here.
@BR0kEN need your response to the items in #14
Here's a reroll of #7 so you don't have to do that. The only things I didn't merge in were the JS changes because there was too much conflicts and I had no idea from the patch what it was trying to do other than renaming variables and the .gitignore changes because they are not needed for this feature.
Comment #19
joelpittetSetting back to needs work for #14
And regarding #14.4 here's a screenshot of what I meant in how that breaks the UI a bit.
Comment #20
joelpittet#17 I think that failed because of the changes to the form tree.
I've removed the need for that weighted div wrapper
commerce-discount-fields-wrapperin another issue.