Open
Description
Feature
# for a resource called product
# variants can be an association on the model product
# We should figure it out fom the reflections
# and do what we need to do to make it work
# variants can be a json field on the product table
# We should figure it out fom the db schema
# and "just pass it"
# variants can be some plain object/method that creates something else through a gem (like acts_as_taggalble_on (an assocition))
# Maybe
# variants can be a json field on the product table
field :variants,
as: :repeater,
limit: 10,
can_add: true, # callable too
can_update: -> { curren_user.admin? ? true : false },
can_order: true, # maybe
update_using: -> {
record # is the actual product
item # is the variant; which is a hash?
_id # maybe
_position # is the position of the item in the list. something we expose "privately"
# do something with the item
item.position = _position
}
can_delete: true do
field :id, as: :id # this should not show up as it's an "edit view"
field :color, as: :select
field :description, as: :textarea
field :price, as: :money
end
# pseudo code being run
product.variants = [
{ id: 1, color: "red", description: "A red variant", price: 10 }, # this will be updated
{ id: 2, color: "blue", description: "A blue variant", price: 20 }, # this will be updated
{ color: "green", description: "A blue variant", price: 20 }, # this will be created
]