mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Convert rep template to rabl
This commit is contained in:
14
app/views/admin/enterprises/index.rabl
Normal file
14
app/views/admin/enterprises/index.rabl
Normal file
@@ -0,0 +1,14 @@
|
||||
collection @collection
|
||||
|
||||
attributes :id, :name
|
||||
|
||||
child supplied_products: :supplied_products do |product|
|
||||
attributes :name
|
||||
node(:supplier_name) { |p| p.supplier.andand.name }
|
||||
node(:image_url) { |p| p.images.present? ? p.images.first.attachment.url(:mini) : nil }
|
||||
node(:master_id) { |p| p.master.id }
|
||||
child variants: :variants do |variant|
|
||||
attributes :id
|
||||
node(:label) { |v| v.options_text }
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
r.list_of :enterprises, @collection do
|
||||
r.element :id
|
||||
r.element :name
|
||||
|
||||
r.list_of :supplied_products do |product|
|
||||
r.element :name
|
||||
r.element :supplier_name, product.supplier.andand.name
|
||||
r.element :image_url, product.images.present? ? product.images.first.attachment.url(:mini) : nil
|
||||
r.element :master_id, product.master.id
|
||||
r.list_of :variants do |variant|
|
||||
r.element :id
|
||||
r.element :label, variant.options_text
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user