Skip to content

Conversation

@cjelger
Copy link
Contributor

@cjelger cjelger commented Mar 10, 2020

  • make it possible to configure the property type to be saved when drag'n'dropping a product

How Has This Been Tested?

TO BE DONE: extend unit tests

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

- make it possible to configure the property type to be saved when drag'n'dropping a product
@codecov
Copy link

codecov bot commented Mar 10, 2020

Codecov Report

Merging #221 into master will decrease coverage by 0.32%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #221      +/-   ##
============================================
- Coverage     60.14%   59.82%   -0.33%     
+ Complexity      541      531      -10     
============================================
  Files           148      147       -1     
  Lines          4393     4348      -45     
  Branches        746      736      -10     
============================================
- Hits           2642     2601      -41     
+ Misses         1660     1659       -1     
+ Partials         91       88       -3     
Flag Coverage Δ Complexity Δ
#jest 38.47% <ø> (ø) 0.00 <ø> (ø)
#karma 94.97% <ø> (ø) 0.00 <ø> (ø)
#unittests 84.71% <ø> (-0.19%) 531.00 <ø> (-10.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 546160e...44a5142. Read the comment docs.

accept="[.*]"
groups="[product]"
propertyName="./selection"/>
propertyName="./multiDropTarget->@selection">
Copy link
Contributor

Choose a reason for hiding this comment

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

Why needs the product teaser the "multiDropTarget"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we implement that DnD "save" feature in the MultiFieldDropTargetPostProcessor so we don't have to introduce another post-processor. I added the multiple parameter to control the ADD or REPLACE behaviour, so the teaser uses false so DnD'ing another product replaces the selection.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for keeping everything in on post-processor. But this looks cumbersome somehow because it is not "AEM standard".

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can find a way to get both property flavors: propertyName="./selection" and propertyName="./multiDropTarget->@product" working?

The first format is the AEM "standard" and ideal for components which do only accept d&d of one product this should be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well if we want to allow the "standard" DnD AND the choice of selectionId (sku, path, slug), we must have a way to "detect" that special DnD feature. A possible alternative to what is being done here could be:

propertyName = "./selection"
<parameters
  selectionId="multiDropTargetValue->sku@selection">

We need 2 things:

  • we must "indicate" that this POST must be processed by the MultiFieldDropTargetPostProcessor (so we need a special String somewhere to "activate" the post processor)
  • we have to indicate which property will hold the value. This is required because the DnD POST sets all properties in the same HTTP form, so we have to make sure we know which property must be modified before saving.

So I think it's possible, but would add more complexity to the post-processor, and anyway requires a special configuration in cq:editConfig ... so I don't really see a big benefit. If someone only needs the standard existing DnD, they can just continue to use this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I think I can agree, let's keep the current approach then.

if (SKU.equals(selectionType) || COMBINED_SKU.equals(selectionType)) {
propertyValue = StringUtils.substringAfterLast(propertyValue, "/");
} else if (SLUG.equals(selectionType)) {
Resource product = resourceResolver.getResource(propertyValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

The SLUG resolving part must be changed, this only works because of the virtual product bundles are installed by the connector. We must not have any dependency on virtual products within the components project. This is will also very likely break with the new authoring tools.

So maybe two simple reasons to move the entire post-processor to the connector project. That is IMHO the better place since it does something which is related to the authoring tools. Then this code part would also be ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's something more related to authoring so we can move it in the connector project. But strictly speaking, this doesn't really remove the dependency, because for example the carousel DnD target would still be defined with ./multiDropTarget->@product, so it wouldn't work without the connector.

Note that we could also simply remove the "slug" option: both the carousel and the teaser anyway do not support having product(s) configured by slug, so I only added it to demonstrate it's possible to support that, but we don't have any use case for this.

@cjelger
Copy link
Contributor Author

cjelger commented Mar 12, 2020

As agreed with the team, the post-processor was moved from this repository to the connector repo, see adobe/commerce-cif-connector#105

@cjelger cjelger requested review from LSantha, dplaton and mhaack March 12, 2020 13:11
@mhaack mhaack added the enhancement New feature or request label Mar 16, 2020
- renamed property to 'selectionId' to align with product picker
@mhaack mhaack merged commit 166435d into master Mar 20, 2020
@mhaack mhaack deleted the CIF-1182 branch March 20, 2020 15:11
@mhaack
Copy link
Contributor

mhaack commented Mar 20, 2020

Verified

@mhaack mhaack added verified and removed To Verify labels Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request verified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants