-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Marketplace
: Shopper
chooses DeliveryArea
independently
- #1672 So, in reviewing a bunch of the delivery app workflows, most of them have: - Choose Pickup or Delivery - Enter Address - Browse Menu - Tap Item - Add Item to Order This lends me to believe we want to switch to gathering the `DeliveryArea` *then* `DeliveryAddress` *then* showing the `Products` that are available. This uses TurboFrames to replace pieces of the page, rather than relying on TurboStreams. On the one hand, it's lot easier (just respond with html with matching `turbo_frame_tag`s`). Blerg; anyway, I'm checking this in now; but not sure if I like it enough. Thoughts? In particular: - Copy-editing - Design tweaks? - Name Collisions: How Undo?
- Loading branch information
Showing
12 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Marketplace | ||
class Cart::DeliveryArea < Model | ||
attr_accessor :cart, :delivery_area | ||
extend StripsNamespaceFromModelName | ||
location parent: :cart, routed_as: :resource | ||
|
||
delegate :label, to: :delivery_area | ||
delegate :marketplace, :update, :persisted?, to: :cart | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class Marketplace | ||
class Cart::DeliveryAreaPolicy < Policy | ||
alias_method :delivery_area, :object | ||
|
||
def permitted_attributes(_params) | ||
%(delivery_area_id) | ||
end | ||
|
||
class Scope < ApplicationScope | ||
def resolve | ||
scope.all | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
app/furniture/marketplace/cart/delivery_areas/_delivery_area.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%= turbo_frame_tag(dom_id(delivery_area.cart, :delivery_area)) do %> | ||
<%- if delivery_area.delivery_area.present? %> | ||
<%= render CardComponent.new(classes: "text-left") do %> | ||
<%= delivery_area.label %> | ||
<%= link_to(t('marketplace.cart.delivery_areas.edit.link_to'), delivery_area.location(:edit)) %> | ||
<%- end %> | ||
<%- else %> | ||
<%= render "marketplace/cart/delivery_areas/form", delivery_area: delivery_area %> | ||
<%- end %> | ||
<%- end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= render CardComponent.new(dom_id: dom_id(delivery_area), classes: "text-left") do %> | ||
<%= form_with model: delivery_area.location do |form| %> | ||
<%= render "select", options: delivery_area.marketplace.delivery_areas.pluck(:label, :id), include_blank: true, attribute: :delivery_area_id, form: form %> | ||
<%= form.submit %> | ||
<%- end %> | ||
<%- end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<%- breadcrumb :edit_marketplace_cart_delivery_area, delivery_area %> | ||
<%= turbo_frame_tag(dom_id(cart, :delivery_area)) do %> | ||
<%= render "form", cart: cart %> | ||
<%- end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%- breadcrumb :marketplace_cart_delivery_area, :delivery_area %> | ||
<%= render delivery_area %> |
25 changes: 25 additions & 0 deletions
25
app/furniture/marketplace/cart/delivery_areas_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Marketplace | ||
class Cart::DeliveryAreasController < Controller | ||
expose :delivery_area, -> { cart.cart_delivery_area } | ||
expose :cart, scope: -> { carts }, model: Cart | ||
expose :carts, -> { policy_scope(marketplace.carts) } | ||
|
||
def show | ||
authorize(delivery_area) | ||
end | ||
|
||
def edit | ||
authorize(delivery_area) | ||
end | ||
|
||
def update | ||
authorize(delivery_area) | ||
delivery_area.update(delivery_area_params) | ||
redirect_to delivery_area.location | ||
end | ||
|
||
def delivery_area_params | ||
params.require(:delivery_area).permit(:delivery_area_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters