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

Marketplace: Products Controller persists Products! #856

Merged

Conversation

zspencer
Copy link
Member

@zspencer zspencer commented Oct 1, 2022

This starts to shift our Furniture and Item system away from an inheritance oriented rails-adjacent structure to a more Rails-forward structure.

Furniture now places it's routes against the room, which allows it to support either Singleton-type Resource routes, or more traditional Resources routes.

Further, it brings the Placeable interface a bit closer to ActiveRecord; which should reduce pain-points as we unwind the current overly-restrictive and complex Furniture/Item design.

@zspencer zspencer requested a review from anaulin October 1, 2022 01:17
This starts to shift our Furniture and Item system away from an
inheritance oriented rails-adjacent structure to a more Rails-forward
structure.

Furniture now places it's routes against the *room*, which allows it to
support either Singleton-type Resource routes, or more traditional
Resources routes.

Further, it brings the `Placeable` interface a bit closer to
ActiveRecord; which should reduce pain-points as we unwind the current
overly-restrictive and complex Furniture/Item design.
@zspencer zspencer force-pushed the zs/ensemble/marketplace-furniture branch from ffe5713 to 714bd48 Compare October 1, 2022 01:18
expect(created_product.price_currency).to eql(Money.default_currency.to_s)
end
end
end
Copy link

Choose a reason for hiding this comment

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

(╯°□°)╯︵ ┻━┻

Copy link
Member Author

Choose a reason for hiding this comment

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

NEEDS MORE TABLE FLIP

@zspencer
Copy link
Member Author

zspencer commented Oct 1, 2022

Ohhhh yea!!!
Screen Shot 2022-09-30 at 6 54 09 PM

Copy link
Member

@anaulin anaulin left a comment

Choose a reason for hiding this comment

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

This is the happiest I've ever been!!!!1!!

Seriously, good work. I like it. 😻

end

factory :marketplace_product, class: 'Marketplace::Product' do
name { Faker::TvShows::DrWho.specie }
Copy link
Member

Choose a reason for hiding this comment

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

Nice Faker choice. 👽

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted one that was more nerdy equipment but I can't always get what I want!

end
end

# Appends each Furnitures CRUD actions within the {Room}
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: On the line below, is the routing_context actually just the router? That seems to be at least the variable name you are using in e.g. Marketplace.append_routes. router seems clearer to me than routing_context -- I don't know what the latter is.

@@ -14,7 +14,15 @@ module Furniture
spotlight: Spotlight,
}.freeze

# Appends each {Furniture}'s CRUD actions
# Appends each {Furniture}'s CRUD actions under a FurniturePlacement
# @deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Nice.

Marketplace::Product.where(space: space)
end

def to_partial_path
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment that this implements https://apidock.com/rails/v6.1.3.1/ActiveModel/Conversion/to_partial_path , for clarity (I had to look up what was this doing, I wasn't familiar with this method, as I've never had the need to implement this myself).

Copy link
Member Author

Choose a reason for hiding this comment

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

I like it!

locals: { furniture: furniture_placement.furniture, space: furniture_placement.space, room: furniture_placement.room,
person: current_person } %>
<%- else %>
<%= render furniture_placement.furniture %>
Copy link
Member

Choose a reason for hiding this comment

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

So much cleaner!

zspencer and others added 3 commits October 2, 2022 10:12
Rails assumes that your parameter names will match the namespace of the
model. For example, a `Marketplace::Product#name` Rails will make HTTP Params
of `marketplace_product[name]`, I had previously assumed it would name
them `product[name]` because I thought it would discard the stuff before
the `::`.

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>
@anaulin had suggested that `routing_context` was confusing; and I
agree. It's just the router! So let's name it that way!

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>
Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>
@zspencer zspencer merged commit f37b5d6 into ensemble/marketplace-furniture Oct 2, 2022
@zspencer zspencer deleted the zs/ensemble/marketplace-furniture branch October 2, 2022 17:28
anaulin added a commit that referenced this pull request Oct 6, 2022
* Add scaffolding for new Marketplace furniture.

Co-authored-by: Sadie Jay <19538219+sadiejay@users.noreply.github.com>
Co-authored-by: Zee <zspencer@users.noreply.github.com>

* Replace money gem with money-rails.

Co-authored-by: Sadie <19538219+sadiejay@users.noreply.github.com>
Co-authored-by: Zee <zspencer@users.noreply.github.com>

* Add Marketplace::Products model, table (not Items!), form and controller.

Co-authored-by: Sadie <19538219+sadiejay@users.noreply.github.com>
Co-authored-by: Zee <zspencer@users.noreply.github.com>

* Marketplace: Products Controller persists Products! (#856)

This starts to shift our Furniture and Item system away from an
inheritance oriented rails-adjacent structure to a more Rails-forward
structure.

Furniture now places it's routes against the *room*, which allows it to
support either Singleton-type Resource routes, or more traditional
Resources routes.

Further, it brings the `Placeable` interface a bit closer to
ActiveRecord; which should reduce pain-points as we unwind the current
overly-restrictive and complex Furniture/Item design.

* Marketplace: Products are shown!

* Use correct parameter name in request spec

Rails assumes that your parameter names will match the namespace of the
model. For example, a `Marketplace::Product#name` Rails will make HTTP Params
of `marketplace_product[name]`, I had previously assumed it would name
them `product[name]` because I thought it would discard the stuff before
the `::`.

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

* Rename from `routing_context` to `router`

@anaulin had suggested that `routing_context` was confusing; and I
agree. It's just the router! So let's name it that way!

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

* All `Placeable` now implement `to_partial_path`

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

Co-authored-by: Zee Spencer <zspencer@users.noreply.github.com>
Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

* Fix method lookup in class ancestry

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

* Marketplace: Present Products in a much cleaner way

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

* Adds Button to add Products to Marketplace

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

* Marketplace: Add Products to Product Table via TurboStreams

This makes the user experience for adding a product even tighter; by
hiding the Product form until the Distributor is adding a new product.

Once they do, we replace the entire marketplace with the New Product
form; and upon successful create, we replace the entire marketplace with
the full Marketplace view!

Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>

* Fixed test by redirecting to room rather than marketplace

Still need to figure out how to redirect to furniture

Co-authored-by:  Kelly <KellyAH@users.noreply.github.com>
Co-authored-by:  Zee <zspencer@users.noreply.github.com>
Co-authored-by:  Ana <anaulin@users.noreply.github.com>

* Marketplace: Validate product names

Validate that `Marketplace::Product` belongs to a space

Co-authored-by:  Kelly <KellyAH@users.noreply.github.com>
Co-authored-by:  Zee <zspencer@users.noreply.github.com>
Co-authored-by:  Ana <anaulin@users.noreply.github.com>

Co-authored-by: Sadie Jay <19538219+sadiejay@users.noreply.github.com>
Co-authored-by: Zee <zspencer@users.noreply.github.com>
Co-authored-by: Zee <50284+zspencer@users.noreply.github.com>
Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>
Co-authored-by: Kelly <KellyAH@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants