-
-
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
Started on the CRUD actions for delivery_area
.
- #1136 TODO: finish building create, edit, destroy flows. Co-authored-by: Zee Spencer <[email protected]> Co-authored-by: Ana <[email protected]> Co-authored-by: Dalton Pruitt <[email protected]>
- Loading branch information
1 parent
e8a68ce
commit 7ed72a4
Showing
10 changed files
with
79 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Marketplace | ||
class DeliveryArea < Record | ||
self.table_name = "marketplace_delivery_areas" | ||
self.location_parent = :marketplace | ||
|
||
belongs_to :marketplace, inverse_of: :delivery_areas | ||
|
||
monetize :price_cents | ||
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,15 @@ | ||
class Marketplace | ||
class DeliveryAreaPolicy < ApplicationPolicy | ||
alias_method :delivery_area, :object | ||
|
||
def create? | ||
person.operator? || person.member_of?(delivery_area.marketplace.space) | ||
end | ||
|
||
class Scope < ApplicationScope | ||
def resolve | ||
scope.all | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= form_with(model: delivery_area.location) do |delivery_area_form| %> | ||
<%= render "text_field", attribute: :label, form: delivery_area_form %> | ||
<%= render "money_field", attribute: :price, form: delivery_area_form, required: true, step: 0.01, min: 0 %> | ||
|
||
<%= delivery_area_form.submit %> | ||
<%- 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,12 @@ | ||
<%- breadcrumb(:marketplace_delivery_areas, marketplace) %> | ||
|
||
<section class="max-w-2xl self-stretch mx-auto"> | ||
<main> | ||
<div class="mt-3 grid grid-cols-1 gap-5 sm:gap-6 sm:grid-cols-2 lg:grid-cols-4"> | ||
<%= render delivery_areas %> | ||
</div> | ||
</main> | ||
<footer class="text-center"> | ||
<%= link_to(t("marketplace.delivery_areas.new.link_to"), marketplace.location(:new, child: :delivery_area)) %> | ||
</footer> | ||
</section> |
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 :new_delivery_area, delivery_area %> | ||
<%= render "form", delivery_area: delivery_area %> |
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,18 @@ | ||
class Marketplace | ||
class DeliveryAreasController < Controller | ||
def index | ||
end | ||
|
||
def new | ||
delivery_area | ||
end | ||
|
||
helper_method def delivery_area | ||
@delivery_area ||= authorize(delivery_areas.new) | ||
end | ||
|
||
helper_method def delivery_areas | ||
@delivery_areas ||= policy_scope(marketplace.delivery_areas) | ||
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