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

Allow Re-creating Shipping Label #3961

Merged
merged 16 commits into from
May 6, 2021

Conversation

hafizrahman
Copy link
Contributor

@hafizrahman hafizrahman commented May 4, 2021

To fix #3856

What this PR does

Allow user to re-purchase Shipping Label on the same Order, and modify the Order Details screen's design to accommodate it.

Testing Instructions

Prepare two Orders: one with no Shipping Labels created yet (but eligible for creation), and one with Shipping Labels already created.

1. Order with no Shipping Label

  1. Open Order Details screen
  2. Make sure the "Create shipping label" button is shown.
  3. Make sure that the "Product" panel at the top does not display triple-dot menu button on the upper right side.
Screenshot Screenshot with notes
Screenshot_20210505_160252 Screenshot_20210505_160230

2. Order with One Shipping Label

  1. Open Order Details screen
  2. Make sure the "Create shipping label" button is not shown
  3. Make sure that the "Product" panel at the to displays triple-dot menu button on the upper right side.
  4. Tap the triple-dot menu button and make sure "Create new shipping label" menu item shows up.
  5. Tap the "Create new shipping label" menu item and make sure the Shipping Label creation screen is shown and working.
  6. Come back to Order Details screen, scroll down to the "Package 1" section.
  7. Make sure it shows "X item(s)" under the "Package 1" heading, with an arrow to the right side.
  8. Make sure the list of products is not yet shown on the "Package 1" section
  9. Tap the "X items(s)" label or its arrow, and make sure it shows the list of products below it.
  10. Tap it again and make sure it hides the list of products below it.
Order details Order details product menu item
Screenshot_20210505_160230 Screenshot_20210505_161326



Package panel toggle: off Package panel toggle: on
Screenshot_20210505_161426 Screenshot_20210505_162140

Update release notes:

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

@hafizrahman hafizrahman added the feature: shipping labels Related to creating, ordering, or printing shipping labels. label May 4, 2021
@hafizrahman hafizrahman added this to the 6.7 milestone May 4, 2021
@peril-woocommerce
Copy link

peril-woocommerce bot commented May 4, 2021

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

Also refactor viewmodel to make the code more testable.
isShipmentTrackingAvailable = shipmentTracking.isVisible,
isProductListVisible = orderProducts.isVisible,
areShippingLabelsVisible = shippingLabels.isVisible
areShippingLabelsVisible = shippingLabels.isVisible,
isProductListMenuVisible = shippingLabels.isVisible
Copy link
Contributor Author

@hafizrahman hafizrahman May 5, 2021

Choose a reason for hiding this comment

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

Previously I used areShippingLabelsVisible as checker for displaying/hiding the Products list menu button. However, I found that it made it not super obvious for unit testing it. So while this is a bit redundant (i.e.: isProductListMenuVisible will always have the same value as areShippingLabelsVisible), it helps make it be more obvious during unit testing, like so:

            assertThat(shippingLabels).isNotEmpty
            assertThat(isCreateShippingLabelButtonVisible).isFalse()
            assertThat(isProductListMenuVisible).isTrue()

@hafizrahman hafizrahman modified the milestones: 6.7, 6.6 ❄️ May 5, 2021
@hafizrahman hafizrahman modified the milestones: 6.6 ❄️, 6.7 May 5, 2021
@hafizrahman hafizrahman marked this pull request as ready for review May 5, 2021 09:24
@hafizrahman hafizrahman requested a review from a team May 5, 2021 09:25
@hichamboushaba hichamboushaba self-assigned this May 5, 2021
Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

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

Really great job @hafizrahman 👏
I left some comments about the usage of the Woo.Card.ExpanderButton style, as it's not matching the mockups, and some other small tips.

@@ -545,7 +538,8 @@ class OrderDetailViewModel @AssistedInject constructor(
val refreshedProductId: Long? = null,
val isCreateShippingLabelButtonVisible: Boolean? = null,
val isProductListVisible: Boolean? = null,
val areShippingLabelsVisible: Boolean? = null
val areShippingLabelsVisible: Boolean? = null,
val isProductListMenuVisible: Boolean? = null
Copy link
Member

Choose a reason for hiding this comment

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

It's nice to have a an explicit variable about this as you said in https://github.com/woocommerce/woocommerce-android/pull/3961/files#r626326768, I like it.
But as its value is always same as areShippingLabelsVisible, we can simplify the logic a bit, and avoid any unwanted bugs (for example changing isProductListMenuVisible in some other areas of the viewmodel) by making it a property without a backing field, similar to the below property isMarkOrderCompleteButtonVisible, we can do this like this:

val isProductListMenuVisible: Boolean?
      get() = areShippingLabelsVisible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, that's a great tips!

Comment on lines 130 to 133
if (isChecked)
WooAnimUtils.fadeIn(viewBinding.shippingLabelListProducts)
else
WooAnimUtils.fadeOut(viewBinding.shippingLabelListProducts)
Copy link
Member

Choose a reason for hiding this comment

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

Normally we should avoid using single-line statement if blocks without braces, so either move the statement to the same line:

if (isChecked) WooAnimUtils.fadeIn(viewBinding.shippingLabelListProducts)
else WooAnimUtils.fadeOut(viewBinding.shippingLabelListProducts)

or add curly braces to those statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome, learned something new here. Thanks.

@@ -300,6 +300,7 @@
<string name="orderdetail_shipping_notice">This order is using extensions to calculate shipping. The shipping methods shown might be incomplete.</string>
<string name="orderdetail_issue_refund_button">Issue refund</string>
<string name="orderdetail_collect_payment_button">Collect Payment</string>
<string name="orderdetail_products_more_button">Create new shipping label</string>
Copy link
Member

Choose a reason for hiding this comment

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

np, I think in our last session we were planning to rename this string resource to something more meaningful, and that this was temporary 🤔, can you please rename it to something like orderdetail_products_recreate_label_button

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reminding me! I missed this part.

Comment on lines 45 to 51
<ToggleButton
android:id="@+id/shippingLabelList_countExpander"
style="@style/Woo.Card.ExpanderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/major_85"
android:paddingBottom="@dimen/major_85" />
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we can use the style Woo.Card.ExpanderButton here, as the arrow image there uses a smaller size 12dp, while in the designs we have 24dp, and also the color is different.
I think you can achieve similar effect using the same technique as the button shippingLabelItem_viewMoreButtonTitle below, and with more customizability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice attention to details, I didn't realize the button size and behavior are different. I've refactored this to be something similar to shippingLabelItem_viewMoreButtonTitle instead.

@hafizrahman
Copy link
Contributor Author

Thanks for your feedbacks @hichamboushaba . This is now ready for another review.

Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

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

Really good job @hafizrahman, looks good to me :shipit:

@hichamboushaba hichamboushaba merged commit 24a1834 into develop May 6, 2021
@hichamboushaba hichamboushaba deleted the issue/3856-allow-recreating-shipping-label branch May 6, 2021 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: shipping labels Related to creating, ordering, or printing shipping labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shipping Labels: allow re-creating shipping labels
2 participants