Skip to content

MAGETWO-75743: Fix for #9783 Multiple <depends> parameters in widget.… #11495

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

Merged
merged 1 commit into from
Oct 19, 2017
Merged

MAGETWO-75743: Fix for #9783 Multiple <depends> parameters in widget.… #11495

merged 1 commit into from
Oct 19, 2017

Conversation

diazwatson
Copy link
Contributor

@diazwatson diazwatson commented Oct 16, 2017

Description

Allow multiple depends parameters to be allowed in widget.xml.

Fixed Issues (if relevant)

  1. Multiple <depends> parameters in widget.xml not allowed #9783: Multiple parameters in widget.xml not allowed

Manual testing scenarios

  1. Create a custom module.
  2. Create a widget.xml in your custom module and add a widget,
  3. Create a parameter (field) inside parent tag widgets>widget>parameters with a <depends> tag, making it depend on the value of two other parameters as follows:
<parameter name="myfield" xsi:type="text" required="true" visible="true">
      <label translate="true">Example</label>
      <depends>
          <parameter name="dependency_one" value="1"/>
          <parameter name="dependency_two" value="1"/>
      </depends>
</parameter>

Expected result

The field should be shown only when both dependencies are met

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@vrann vrann self-assigned this Oct 16, 2017
@vrann vrann added this to the October 2017 milestone Oct 16, 2017
@vrann vrann added Release Line: 2.2 2.2.x Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 16, 2017
@vrann
Copy link
Contributor

vrann commented Oct 16, 2017

@diazwatson Now there are no fatal errors, but multiple depends node does not work as expected.

  1. Edit app/code/Magento/Catalog/etc/widget.xml and add <parameter name="display_type" value="new_products" /> under products_per_page depends section:
 <parameter name="products_per_page" xsi:type="text" required="true" visible="true">
                ...
                <depends>
                    <parameter name="show_pager" value="1" />
                    <parameter name="display_type" value="new_products" />
                </depends>
                ...
            </parameter>
  1. clear cache
  2. Go to Content -> Widgets -> Add Widget
  3. Add Catalog New Products List, with Magento Blank theme
  4. Press Continue and go to Widget Options tab
  5. select Display Type => New Products and Display Page Controls => YES

Expected Result:

  • Number of Products per Page shows up

Actual Result:

  • Number of Products per Page does not shows up

Notes

The script is generated correctly, but does not seem to work as this PR expects:

<script>
require(["mage/adminhtml/form"], function(){
  new FormElementDependenceController({
"options_fieldsetff03440769cc879b7eb3d75cfbce1da9_products_per_page":

{"options_fieldsetff03440769cc879b7eb3d75cfbce1da9_show_pager":{"values":["1"],"negative":false},

"options_fieldsetff03440769cc879b7eb3d75cfbce1da9_display_type":{"values":["new_products"],"negative":false}}}); 

});</script></div>
   </li>
   </ul>
   </div>  
<script>

@diazwatson
Copy link
Contributor Author

I'll check

@milansimek
Copy link

milansimek commented Oct 16, 2017

Are you sure you have to modify the Javascript for this? I have been using just the XML fix I've proposed in my initial bug report, which seems to do the trick.

    <xs:complexType name="dependsType">
        <xs:annotation>
            <xs:documentation>List of parameters this parameter depends on.</xs:documentation>
        </xs:annotation>
        <xs:sequence maxOccurs="unbounded" minOccurs="1">
            <xs:element name="parameter" type="dependsParameterType" />
        </xs:sequence>
    </xs:complexType>

The main difference I see here compared to your pull request is the minOccurs="1". Not sure if that matters though

@vrann
Copy link
Contributor

vrann commented Oct 16, 2017

@milansimek the PR does not change the javascript; just point out that javascript generates correctly, but it does not work as expected. Try to follow my steps, you'll see that it's not enough to change the xml.

@milansimek
Copy link

@vrann Ah yes, sorry about that. I'm a bit tired. I'll check to see how I did it in our custom extension and will report back here

@milansimek
Copy link

milansimek commented Oct 16, 2017

@vrann I just tested in Magento 2.1.6: Works fine when just using the XML fix I proposed. Should work also in 2.2 I guess but if you want I can double check for you.

Please note that I did not apply the changes from the pull request to the following file when testing: app/code/Magento/Widget/Model/Config/Converter.php

@milansimek
Copy link

2017-10-16_23-03-26

@vrann
Copy link
Contributor

vrann commented Oct 19, 2017

@milansimek thanks, re-tested again and it works as expected

@diazwatson
Copy link
Contributor Author

@vrann should I revert changes in app/code/Magento/Widget/Model/Config/Converter.php as pointed out by @milansimek?

magento-team pushed a commit that referenced this pull request Oct 19, 2017
@magento-team magento-team merged commit 84b0872 into magento:2.2-develop Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Progress: accept Release Line: 2.2 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants