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

Issue/2630 display grouped products #2731

Merged
merged 20 commits into from
Aug 18, 2020

Conversation

anitaa1990
Copy link
Contributor

@anitaa1990 anitaa1990 commented Aug 17, 2020

Part 1/3 of #2630. This PR adds logic to display products associated with grouped products.

Changes

  • Added logic to display the product count for a grouped product, if the count > 0.
  • Created a new fragment, module and View Model to handle the changes needed to show only the products for a specific grouped product.
  • Split the ProductListViewHolder and ProductListDiffUtil to separate classes so that they can be reused by GroupedProductListAdapter as well as ProductListAdapter

Screenshots

. . .

Testing

  • Click on a grouped product with atleast 2 associated products.
  • Notice the grouped products section in the Product Detail screen.
  • Click on the grouped products section and notice the list of products associated with this product, displayed correctly.
  • Click on the delete icon for one of the items and verify:
    • that the "Done" menu button is displayed correctly.
    • that clicking on the back button displays the discard dialog.
  • Click on the "Done" menu button and notice that
    • the "Update" button is displayed correctly in the Product detail screen.
    • the grouped products section displays the correct count.
  • Click on the "Update" menu button and verify that the product is updated correctly.

Notes

  • This PR is in draft till this FluxC PR can be reviewed and merged.
  • The option to add a grouped product will take place in a subsequent PR.

Update release notes:

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@anitaa1990 anitaa1990 added type: enhancement A request for an enhancement. feature: product details Related to adding or editing products, includes product settings. labels Aug 17, 2020
@anitaa1990 anitaa1990 added this to the 4.9 milestone Aug 17, 2020
@anitaa1990 anitaa1990 requested a review from a team August 17, 2020 06:38
@peril-woocommerce
Copy link

peril-woocommerce bot commented Aug 17, 2020

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@peril-woocommerce
Copy link

peril-woocommerce bot commented Aug 17, 2020

You can test the changes on this Pull Request by downloading the APK here.

@anitaa1990 anitaa1990 marked this pull request as ready for review August 17, 2020 09:34
@AmandaRiu AmandaRiu self-assigned this Aug 17, 2020
Copy link
Contributor

@AmandaRiu AmandaRiu left a comment

Choose a reason for hiding this comment

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

@anitaa1990 Tried to test, but am getting this crash:

2020-08-17 16:57:01.147 30517-30517/com.woocommerce.android.dev E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.woocommerce.android.dev, PID: 30517
    java.lang.IllegalStateException: Gson().fromJson(groupedP… JsonElement::class.java) must not be null
        at org.wordpress.android.fluxc.model.WCProductModel.getGroupedProductIds(WCProductModel.kt:245)
        at com.woocommerce.android.model.ProductKt.toAppModel(Product.kt:548)
        at com.woocommerce.android.ui.products.ProductListRepository.getProductList(ProductListRepository.kt:141)
        at com.woocommerce.android.ui.products.ProductListViewModel$loadProducts$2.invokeSuspend(ProductListViewModel.kt:195)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

@anitaa1990
Copy link
Contributor Author

Hey @AmandaRiu!

Tried to test, but am getting this crash:

I'm not actually able to reproduce the crash. I tested with a branch new grouped product as well as existing product. But looking at the error, it seems to be that groupedProductIds is null (which shouldn't happen) but I added logic in FluxC to verify if the groupedProductIds is empty before parsing it. I opened a PR in FluxC as well.

Ready for another round 👍 Let me know if you are able to reproduce the crash. I would also like to reproduce, if possible so any testing steps would be helpful as well.

@anitaa1990 anitaa1990 requested a review from AmandaRiu August 18, 2020 05:22
fun onProductChanged(event: OnProductChanged) {
if (event.causeOfChange == FETCH_PRODUCTS) {
if (event.isError) {
// TODO: add tracking event
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting there is a TODO here for tracks events. Will that be handled in a separate PR? Same with a couple lines down.

resources.getString(groupedProductResourceId, groupedProductsSize),
R.drawable.ic_widgets
) {
// TODO: add click event
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: tracks event TODO.

Copy link
Contributor

@AmandaRiu AmandaRiu left a comment

Choose a reason for hiding this comment

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

Tested and looks good! 👍 Nice job Anitaa! :shipit:

@AmandaRiu AmandaRiu merged commit 1ae7ef2 into develop Aug 18, 2020
@AmandaRiu AmandaRiu deleted the issue/2630-display-grouped-products branch August 18, 2020 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: product details Related to adding or editing products, includes product settings. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants