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

[Promotion] Fix js errors associated with actions/rules/scopes #13547

Merged
merged 1 commit into from Jan 27, 2022

Conversation

GSadee
Copy link
Member

@GSadee GSadee commented Jan 26, 2022

Q A
Branch? 1.11
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #13447
License MIT

@GSadee GSadee added Admin AdminBundle related issues and PRs. Bug Confirmed bugs or bugfixes. labels Jan 26, 2022
@GSadee GSadee requested a review from a team as a code owner January 26, 2022 08:53
$('#sylius_catalog_promotion_scopes > a[data-form-collection="add"]').on('click', () => {
setTimeout(() => {
$(`select[name^="sylius_catalog_promotion[scopes]"][name$="[type]"]`).last().change();
$('select[name^="sylius_promotion[rules]"][name$="[type]"]').last().change();
Copy link
Contributor

Choose a reason for hiding this comment

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

This change from three different cases to one certainly doesn't look right.
Also, please use the direct ancestor selector (>), because this will allow adding collections in child forms without having to hack JS.

Copy link
Member Author

@GSadee GSadee Jan 26, 2022

Choose a reason for hiding this comment

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

Here, I've only removed the lines that do nothing in my opinion, they are needed for cart promotions, not catalog ones. But of course, I might have missed sth. However, the tests are green and I've checked both cart and catalog promotions manually also

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't catalog promotions use same JS?
And yeah, disregard that second part of my previous comment. It's irrelevant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Those lines allow to use nested collections inside the promotion rules and actions.
Unfortunately there's no test for that, because there's no such use case in Sylius by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vvasiloi no, it's just the > in the selector that allows nested collections. It doesn't mean that these lines were actually used.

And remember, we added behat scenarios for both catalog promotions and cart promotions. If all of them still succeed even without these lines, that means that either the tests are bad, or the lines aren't really used after all.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I was referring to the > in the selector.
We tested that the form is displayed when a new action or rule is added and if it works with a single selector then it's even better.

Copy link
Member

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

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

If I understood correctly, we are fine to have it merge. Thanks for your activity @rimas-kudelis and @vvasiloi ?

@lchrusciel lchrusciel merged commit 2f876d2 into Sylius:1.11 Jan 27, 2022
@lchrusciel
Copy link
Member

Thank you, Grzegorz! 🥇

@GSadee GSadee deleted the cart-promotion-rule-form-fix branch January 27, 2022 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin AdminBundle related issues and PRs. Bug Confirmed bugs or bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants