-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
🥔✨ Marketplace
: DeliveryAreas
may be Archived
#2024
Conversation
I decided to merge my PRs that were building on this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you!
Some suggestions below, but nothing blocking.
href: delivery_area.location, method: :delete, scheme: :secondary) | ||
end | ||
|
||
def discard_button? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: it feels like this method and the destroy_button?
methods want to instead to be methods on Delivery Area, DeliveryArea#discardable?
and DeliveryArea#destroyable?
. Then those can be unit-tested in the model spec, and this component calls those methods to determine if the buttons can/should be displayed.
It also helps the model self-document its behavior in terms of when it can be discarded or destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it! I've left the policy check but pulled out the state checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same thing @anaulin!
Was thinking about how in React (or similar) -- which supposedly influences ViewComponent -- it wasn't encouraged to pass entities into a component but instead a view over the model1 with strong indirections already prepped so you wouldn't end up coupling your entity layer to your view layer so tightly. In that modality we'd have a view function like:
class MyComponent {
constructor(data) {
this.model = data;
}
showDiscardButton() {
return this.model.canRemoveDeliveryArea;
}
}
1 Presenter, view model, etc... but a simple data bag
<%- if params[:archive] %> | ||
<%= link_to "Active", marketplace.location(child: :delivery_areas) %> | ||
<%- else %> | ||
<%= link_to "Archive", marketplace.location(child: :delivery_areas, query_params: { archive: true }) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the links want to be say "Active areas" and "Archived areas" (or "Active delivery areas", if there is enough space), otherwise I'm not sure it's clear what they are for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I've updated these too!
- #2014 This adds the `discard` gem so that we can archive objects. It also updates the workflow for removing DeliveryArea to have an `Archive` step first. Once a `DeliveryArea` is archived, it can not yet be restored; but it can be removed if there are no `Orders` associated with the `DeliveryArea`
Now that we have a better idea how to use TurboFrames, the Streams seem pretty unnecessary. This also makes it so following links within the `Marketplace::ManagementComponent` update the browser URL.
…nk (#2027) * 🧹 `Marketplace`: `DeliveryArea` Strip TurboStreams Now that we have a better idea how to use TurboFrames, the Streams seem pretty unnecessary. This also makes it so following links within the `Marketplace::ManagementComponent` update the browser URL. * ✨ `Marketplace`: Put Archived DeliveryAreas behind the `Archive` link
Co-authored-by: Ana Ulin <[email protected]>
Co-authored-by: Ana Ulin <[email protected]>
Co-authored-by: Ana Ulin <[email protected]>
2c75567
to
e19398d
Compare
2533a11
to
854d0cf
Compare
854d0cf
to
971df03
Compare
- zinc-collective#2198 When we added [archiving delivery areas], I didn't take into account that `Marketplace#cart_for_shopper` was checking against all the delivery areas. This fixes that and adds a system spec to make sure we can still checkout after! [archiving delivery areas]: zinc-collective#2024
Marketplace
: RemovingDeliveryAreas
#2014This adds the
discard
gem so that we can archive objects. It also updates the workflow for removing DeliveryArea to have anArchive
step first.Once a
DeliveryArea
is archived, it can not yet be restored; but it can be removed if there are noOrders
associated with theDeliveryArea