diff --git a/api/app/views/.rubocop.yml b/api/app/views/.rubocop.yml new file mode 100644 index 00000000000..d1e622db379 --- /dev/null +++ b/api/app/views/.rubocop.yml @@ -0,0 +1,4 @@ +inherit_from: ../../../.rubocop.yml + +Style/LambdaCall: + EnforcedStyle: braces diff --git a/api/app/views/spree/api/address_books/show.json.jbuilder b/api/app/views/spree/api/address_books/show.json.jbuilder new file mode 100644 index 00000000000..f8d7c57efaf --- /dev/null +++ b/api/app/views/spree/api/address_books/show.json.jbuilder @@ -0,0 +1,11 @@ +json.array! @user_addresses do |user_address| + json.partial!("spree/api/addresses/address", address: user_address.address) + + json.default user_address.default + + # This is a bit of a hack. + # This attribute is only shown on the update action + if @address + json.update_target @address == user_address.address + end +end diff --git a/api/app/views/spree/api/address_books/show.v1.rabl b/api/app/views/spree/api/address_books/show.v1.rabl deleted file mode 100644 index 79fe5bd280f..00000000000 --- a/api/app/views/spree/api/address_books/show.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -collection @user_addresses -node do |user_address| - partial("spree/api/addresses/show", object: user_address.address).merge( - default: user_address.default, - update_target: @address == user_address.address, - ) -end diff --git a/api/app/views/spree/api/addresses/_address.json.jbuilder b/api/app/views/spree/api/addresses/_address.json.jbuilder new file mode 100644 index 00000000000..eddb0e3e69c --- /dev/null +++ b/api/app/views/spree/api/addresses/_address.json.jbuilder @@ -0,0 +1,17 @@ +json.cache! address do + json.(address, *address_attributes) + json.country do + if address.country + json.(address.country, *country_attributes) + else + json.nil! + end + end + json.state do + if address.state + json.(address.state, *state_attributes) + else + json.nil! + end + end +end diff --git a/api/app/views/spree/api/addresses/show.json.jbuilder b/api/app/views/spree/api/addresses/show.json.jbuilder new file mode 100644 index 00000000000..24e5e465fb8 --- /dev/null +++ b/api/app/views/spree/api/addresses/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/addresses/address", address: @address) diff --git a/api/app/views/spree/api/addresses/show.v1.rabl b/api/app/views/spree/api/addresses/show.v1.rabl deleted file mode 100644 index c3416013804..00000000000 --- a/api/app/views/spree/api/addresses/show.v1.rabl +++ /dev/null @@ -1,10 +0,0 @@ -object @address -cache [I18n.locale, root_object] -attributes *address_attributes - -child(:country) do |address| - attributes *country_attributes -end -child(:state) do |address| - attributes *state_attributes -end diff --git a/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder b/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder new file mode 100644 index 00000000000..fd6b1e5e09e --- /dev/null +++ b/api/app/views/spree/api/adjustments/_adjustment.json.jbuilder @@ -0,0 +1,4 @@ +json.cache! [I18n.locale, adjustment] do + json.(adjustment, *adjustment_attributes) + json.display_amount(adjustment.display_amount.to_s) +end diff --git a/api/app/views/spree/api/adjustments/show.v1.rabl b/api/app/views/spree/api/adjustments/show.v1.rabl deleted file mode 100644 index e88c3d801d7..00000000000 --- a/api/app/views/spree/api/adjustments/show.v1.rabl +++ /dev/null @@ -1,4 +0,0 @@ -object @adjustment -cache [I18n.locale, root_object] -attributes *adjustment_attributes -node(:display_amount) { |a| a.display_amount.to_s } diff --git a/api/app/views/spree/api/config/money.json.jbuilder b/api/app/views/spree/api/config/money.json.jbuilder new file mode 100644 index 00000000000..187543c3a81 --- /dev/null +++ b/api/app/views/spree/api/config/money.json.jbuilder @@ -0,0 +1 @@ +json.symbol(::Money.new(1, Spree::Config[:currency]).symbol) diff --git a/api/app/views/spree/api/config/money.v1.rabl b/api/app/views/spree/api/config/money.v1.rabl deleted file mode 100644 index fdc22120ee2..00000000000 --- a/api/app/views/spree/api/config/money.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:symbol) { ::Money.new(1, Spree::Config[:currency]).symbol } diff --git a/api/app/views/spree/api/config/show.json.jbuilder b/api/app/views/spree/api/config/show.json.jbuilder new file mode 100644 index 00000000000..50664974cf1 --- /dev/null +++ b/api/app/views/spree/api/config/show.json.jbuilder @@ -0,0 +1,2 @@ +json.default_country_id(Spree::Country.default.id) +json.default_country_iso(Spree::Config[:default_country_iso]) diff --git a/api/app/views/spree/api/config/show.v1.rabl b/api/app/views/spree/api/config/show.v1.rabl deleted file mode 100644 index 3e7121af74c..00000000000 --- a/api/app/views/spree/api/config/show.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:default_country_id) { Spree::Country.default.id } -node(:default_country_iso) { Spree::Config[:default_country_iso] } diff --git a/api/app/views/spree/api/countries/index.json.jbuilder b/api/app/views/spree/api/countries/index.json.jbuilder new file mode 100644 index 00000000000..6e210c07c6a --- /dev/null +++ b/api/app/views/spree/api/countries/index.json.jbuilder @@ -0,0 +1,4 @@ +json.countries(@countries) { |country| json.(country, *country_attributes) } +json.count(@countries.count) +json.current_page(@countries.current_page) +json.pages(@countries.total_pages) diff --git a/api/app/views/spree/api/countries/index.v1.rabl b/api/app/views/spree/api/countries/index.v1.rabl deleted file mode 100644 index a2c81b5d3d7..00000000000 --- a/api/app/views/spree/api/countries/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@countries => :countries) do - attributes *country_attributes -end -node(:count) { @countries.count } -node(:current_page) { @countries.current_page } -node(:pages) { @countries.total_pages } diff --git a/api/app/views/spree/api/countries/show.json.jbuilder b/api/app/views/spree/api/countries/show.json.jbuilder new file mode 100644 index 00000000000..125bc4b49cd --- /dev/null +++ b/api/app/views/spree/api/countries/show.json.jbuilder @@ -0,0 +1,4 @@ +json.(@country, *country_attributes) +json.states(@country.states) do |state| + json.(state, :id, :name, :abbr, :country_id) +end diff --git a/api/app/views/spree/api/countries/show.v1.rabl b/api/app/views/spree/api/countries/show.v1.rabl deleted file mode 100644 index 19d4322a9c3..00000000000 --- a/api/app/views/spree/api/countries/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @country -attributes *country_attributes -child :states => :states do - attributes :id, :name, :abbr, :country_id -end diff --git a/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder new file mode 100644 index 00000000000..93482cd2ca9 --- /dev/null +++ b/api/app/views/spree/api/credit_cards/_credit_card.json.jbuilder @@ -0,0 +1,10 @@ +json.cache! [I18n.locale, credit_card] do + json.(credit_card, *creditcard_attributes) + json.address do + if credit_card.address + json.partial!("spree/api/addresses/address", address: credit_card.address) + else + json.nil! + end + end +end diff --git a/api/app/views/spree/api/credit_cards/index.json.jbuilder b/api/app/views/spree/api/credit_cards/index.json.jbuilder new file mode 100644 index 00000000000..06cda32d8a4 --- /dev/null +++ b/api/app/views/spree/api/credit_cards/index.json.jbuilder @@ -0,0 +1,6 @@ +json.credit_cards(@credit_cards) do |credit_card| + json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card) +end +json.count(@credit_cards.count) +json.current_page(@credit_cards.current_page) +json.pages(@credit_cards.total_pages) diff --git a/api/app/views/spree/api/credit_cards/index.v1.rabl b/api/app/views/spree/api/credit_cards/index.v1.rabl deleted file mode 100644 index 73d0420be2e..00000000000 --- a/api/app/views/spree/api/credit_cards/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@credit_cards => :credit_cards) do - extends "spree/api/credit_cards/show" -end -node(:count) { @credit_cards.count } -node(:current_page) { @credit_cards.current_page } -node(:pages) { @credit_cards.total_pages } diff --git a/api/app/views/spree/api/credit_cards/show.json.jbuilder b/api/app/views/spree/api/credit_cards/show.json.jbuilder new file mode 100644 index 00000000000..9d9d8613061 --- /dev/null +++ b/api/app/views/spree/api/credit_cards/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/credit_cards/credit_card", credit_card: @credit_card) diff --git a/api/app/views/spree/api/credit_cards/show.v1.rabl b/api/app/views/spree/api/credit_cards/show.v1.rabl deleted file mode 100644 index f0a69b39b8d..00000000000 --- a/api/app/views/spree/api/credit_cards/show.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object @credit_card -cache [I18n.locale, root_object] -attributes *creditcard_attributes - -child :address do - extends "spree/api/addresses/show" -end diff --git a/api/app/views/spree/api/errors/delete_restriction.json.jbuilder b/api/app/views/spree/api/errors/delete_restriction.json.jbuilder new file mode 100644 index 00000000000..7f0a6496bb1 --- /dev/null +++ b/api/app/views/spree/api/errors/delete_restriction.json.jbuilder @@ -0,0 +1 @@ +json.error I18n.t(:delete_restriction_error, scope: "spree.api") diff --git a/api/app/views/spree/api/errors/delete_restriction.v1.rabl b/api/app/views/spree/api/errors/delete_restriction.v1.rabl deleted file mode 100644 index 804d8f49e0f..00000000000 --- a/api/app/views/spree/api/errors/delete_restriction.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:delete_restriction_error, scope: "spree.api") } diff --git a/api/app/views/spree/api/errors/gateway_error.json.jbuilder b/api/app/views/spree/api/errors/gateway_error.json.jbuilder new file mode 100644 index 00000000000..ea722bd58c5 --- /dev/null +++ b/api/app/views/spree/api/errors/gateway_error.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:gateway_error, scope: "spree.api", text: @error)) diff --git a/api/app/views/spree/api/errors/gateway_error.v1.rabl b/api/app/views/spree/api/errors/gateway_error.v1.rabl deleted file mode 100644 index cb79f951a59..00000000000 --- a/api/app/views/spree/api/errors/gateway_error.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:gateway_error, scope: "spree.api", text: @error) } diff --git a/api/app/views/spree/api/errors/invalid_api_key.json.jbuilder b/api/app/views/spree/api/errors/invalid_api_key.json.jbuilder new file mode 100644 index 00000000000..5b4db64cb03 --- /dev/null +++ b/api/app/views/spree/api/errors/invalid_api_key.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:invalid_api_key, key: api_key, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/invalid_api_key.v1.rabl b/api/app/views/spree/api/errors/invalid_api_key.v1.rabl deleted file mode 100644 index 9bd5e8a7e6c..00000000000 --- a/api/app/views/spree/api/errors/invalid_api_key.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:invalid_api_key, :key => api_key, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/invalid_resource.json.jbuilder b/api/app/views/spree/api/errors/invalid_resource.json.jbuilder new file mode 100644 index 00000000000..4522fe816fd --- /dev/null +++ b/api/app/views/spree/api/errors/invalid_resource.json.jbuilder @@ -0,0 +1,2 @@ +json.error(I18n.t(:invalid_resource, scope: "spree.api")) +json.errors(@resource.errors.to_hash) diff --git a/api/app/views/spree/api/errors/invalid_resource.v1.rabl b/api/app/views/spree/api/errors/invalid_resource.v1.rabl deleted file mode 100644 index c7a0a8f92ad..00000000000 --- a/api/app/views/spree/api/errors/invalid_resource.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:error) { I18n.t(:invalid_resource, :scope => "spree.api") } -node(:errors) { @resource.errors.to_hash } diff --git a/api/app/views/spree/api/errors/must_specify_api_key.json.jbuilder b/api/app/views/spree/api/errors/must_specify_api_key.json.jbuilder new file mode 100644 index 00000000000..4f62cea6305 --- /dev/null +++ b/api/app/views/spree/api/errors/must_specify_api_key.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:must_specify_api_key, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/must_specify_api_key.v1.rabl b/api/app/views/spree/api/errors/must_specify_api_key.v1.rabl deleted file mode 100644 index ec85c24be5b..00000000000 --- a/api/app/views/spree/api/errors/must_specify_api_key.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:must_specify_api_key, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/not_found.json.jbuilder b/api/app/views/spree/api/errors/not_found.json.jbuilder new file mode 100644 index 00000000000..0d2e0677ed3 --- /dev/null +++ b/api/app/views/spree/api/errors/not_found.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:resource_not_found, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/not_found.v1.rabl b/api/app/views/spree/api/errors/not_found.v1.rabl deleted file mode 100644 index 0ea0bb4c19d..00000000000 --- a/api/app/views/spree/api/errors/not_found.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:resource_not_found, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/unauthorized.json.jbuilder b/api/app/views/spree/api/errors/unauthorized.json.jbuilder new file mode 100644 index 00000000000..d761df0fa27 --- /dev/null +++ b/api/app/views/spree/api/errors/unauthorized.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:unauthorized, scope: "spree.api")) diff --git a/api/app/views/spree/api/errors/unauthorized.v1.rabl b/api/app/views/spree/api/errors/unauthorized.v1.rabl deleted file mode 100644 index 0a692c0933f..00000000000 --- a/api/app/views/spree/api/errors/unauthorized.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:unauthorized, :scope => "spree.api") } diff --git a/api/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder b/api/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder new file mode 100644 index 00000000000..ac158148cf2 --- /dev/null +++ b/api/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder @@ -0,0 +1 @@ +json.error(Spree.t(:item_not_in_stock_transfer)) diff --git a/api/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl b/api/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl deleted file mode 100644 index f091e28ab27..00000000000 --- a/api/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { Spree.t(:item_not_in_stock_transfer) } diff --git a/api/app/views/spree/api/images/_image.json.jbuilder b/api/app/views/spree/api/images/_image.json.jbuilder new file mode 100644 index 00000000000..b29191eebde --- /dev/null +++ b/api/app/views/spree/api/images/_image.json.jbuilder @@ -0,0 +1,5 @@ +json.(image, *image_attributes) +json.(image, :viewable_type, :viewable_id) +Spree::Image.attachment_definitions[:attachment][:styles].each do |k, _v| + json.set! "#{k}_url", image.attachment.url(k) +end diff --git a/api/app/views/spree/api/images/index.json.jbuilder b/api/app/views/spree/api/images/index.json.jbuilder new file mode 100644 index 00000000000..b13655051f8 --- /dev/null +++ b/api/app/views/spree/api/images/index.json.jbuilder @@ -0,0 +1,3 @@ +json.images(@images) do |image| + json.partial!("spree/api/images/image", image: image) +end diff --git a/api/app/views/spree/api/images/index.v1.rabl b/api/app/views/spree/api/images/index.v1.rabl deleted file mode 100644 index 6fcdd48dbf1..00000000000 --- a/api/app/views/spree/api/images/index.v1.rabl +++ /dev/null @@ -1,4 +0,0 @@ -object false -child(@images => :images) do - extends "spree/api/images/show" -end diff --git a/api/app/views/spree/api/images/show.json.jbuilder b/api/app/views/spree/api/images/show.json.jbuilder new file mode 100644 index 00000000000..c515c19742c --- /dev/null +++ b/api/app/views/spree/api/images/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/images/image", image: @image) diff --git a/api/app/views/spree/api/images/show.v1.rabl b/api/app/views/spree/api/images/show.v1.rabl deleted file mode 100644 index d019ed8bddb..00000000000 --- a/api/app/views/spree/api/images/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @image -attributes *image_attributes -attributes :viewable_type, :viewable_id -Spree::Image.attachment_definitions[:attachment][:styles].each do |k,v| - node("#{k}_url") { |i| i.attachment.url(k) } -end diff --git a/api/app/views/spree/api/inventory_units/show.json.jbuilder b/api/app/views/spree/api/inventory_units/show.json.jbuilder new file mode 100644 index 00000000000..6c27ca6a675 --- /dev/null +++ b/api/app/views/spree/api/inventory_units/show.json.jbuilder @@ -0,0 +1 @@ +json.(@inventory_unit, *inventory_unit_attributes) diff --git a/api/app/views/spree/api/inventory_units/show.rabl b/api/app/views/spree/api/inventory_units/show.rabl deleted file mode 100644 index d9e7960b503..00000000000 --- a/api/app/views/spree/api/inventory_units/show.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @inventory_unit -attributes *inventory_unit_attributes diff --git a/api/app/views/spree/api/line_items/_line_item.json.jbuilder b/api/app/views/spree/api/line_items/_line_item.json.jbuilder new file mode 100644 index 00000000000..f22b2e09794 --- /dev/null +++ b/api/app/views/spree/api/line_items/_line_item.json.jbuilder @@ -0,0 +1,16 @@ +json.cache! [I18n.locale, line_item] do + json.(line_item, *line_item_attributes) + json.single_display_amount(line_item.single_display_amount.to_s) + json.display_amount(line_item.display_amount.to_s) + json.total(line_item.total) + json.variant do + json.partial!("spree/api/variants/small", variant: line_item.variant) + json.(line_item.variant, :product_id) + json.images(line_item.variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end + end + json.adjustments(line_item.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + end +end diff --git a/api/app/views/spree/api/line_items/new.json.jbuilder b/api/app/views/spree/api/line_items/new.json.jbuilder new file mode 100644 index 00000000000..65583e8b62d --- /dev/null +++ b/api/app/views/spree/api/line_items/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes(([*line_item_attributes] - [:id])) +json.required_attributes([:variant_id, :quantity]) diff --git a/api/app/views/spree/api/line_items/new.v1.rabl b/api/app/views/spree/api/line_items/new.v1.rabl deleted file mode 100644 index 6269ff819ee..00000000000 --- a/api/app/views/spree/api/line_items/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*line_item_attributes] - [:id] } -node(:required_attributes) { [:variant_id, :quantity] } diff --git a/api/app/views/spree/api/line_items/show.json.jbuilder b/api/app/views/spree/api/line_items/show.json.jbuilder new file mode 100644 index 00000000000..7cb92fe75c8 --- /dev/null +++ b/api/app/views/spree/api/line_items/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/line_items/line_item", line_item: @line_item) diff --git a/api/app/views/spree/api/line_items/show.v1.rabl b/api/app/views/spree/api/line_items/show.v1.rabl deleted file mode 100644 index e64a9796435..00000000000 --- a/api/app/views/spree/api/line_items/show.v1.rabl +++ /dev/null @@ -1,15 +0,0 @@ -object @line_item -cache [I18n.locale, root_object] -attributes *line_item_attributes -node(:single_display_amount) { |li| li.single_display_amount.to_s } -node(:display_amount) { |li| li.display_amount.to_s } -node(:total) { |li| li.total } -child :variant do - extends "spree/api/variants/small" - attributes :product_id - child(:images => :images) { extends "spree/api/images/show" } -end - -child :adjustments => :adjustments do - extends "spree/api/adjustments/show" -end diff --git a/api/app/views/spree/api/option_types/_option_type.json.jbuilder b/api/app/views/spree/api/option_types/_option_type.json.jbuilder new file mode 100644 index 00000000000..3ef65b01d0f --- /dev/null +++ b/api/app/views/spree/api/option_types/_option_type.json.jbuilder @@ -0,0 +1,4 @@ +json.(option_type, *option_type_attributes) +json.option_values(option_type.option_values) do |option_value| + json.(option_value, *option_value_attributes) +end diff --git a/api/app/views/spree/api/option_types/index.json.jbuilder b/api/app/views/spree/api/option_types/index.json.jbuilder new file mode 100644 index 00000000000..77f9c795fee --- /dev/null +++ b/api/app/views/spree/api/option_types/index.json.jbuilder @@ -0,0 +1,3 @@ +json.array! @option_types do |option_type| + json.partial!("spree/api/option_types/option_type", option_type: option_type) +end diff --git a/api/app/views/spree/api/option_types/index.v1.rabl b/api/app/views/spree/api/option_types/index.v1.rabl deleted file mode 100644 index 839273c05ba..00000000000 --- a/api/app/views/spree/api/option_types/index.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -collection @option_types - -extends "spree/api/option_types/show" diff --git a/api/app/views/spree/api/option_types/show.json.jbuilder b/api/app/views/spree/api/option_types/show.json.jbuilder new file mode 100644 index 00000000000..d5e47051488 --- /dev/null +++ b/api/app/views/spree/api/option_types/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/option_types/option_type", option_type: @option_type) diff --git a/api/app/views/spree/api/option_types/show.v1.rabl b/api/app/views/spree/api/option_types/show.v1.rabl deleted file mode 100644 index e3c71a255aa..00000000000 --- a/api/app/views/spree/api/option_types/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @option_type -attributes *option_type_attributes -child :option_values => :option_values do - attributes *option_value_attributes -end \ No newline at end of file diff --git a/api/app/views/spree/api/option_values/_option_value.json.jbuilder b/api/app/views/spree/api/option_values/_option_value.json.jbuilder new file mode 100644 index 00000000000..f9b4e7f37d8 --- /dev/null +++ b/api/app/views/spree/api/option_values/_option_value.json.jbuilder @@ -0,0 +1 @@ +json.(option_value, *option_value_attributes) diff --git a/api/app/views/spree/api/option_values/index.json.jbuilder b/api/app/views/spree/api/option_values/index.json.jbuilder new file mode 100644 index 00000000000..6877a72228a --- /dev/null +++ b/api/app/views/spree/api/option_values/index.json.jbuilder @@ -0,0 +1,3 @@ +json.array! @option_values do |option_value| + json.partial!("spree/api/option_values/option_value", option_value: option_value) +end diff --git a/api/app/views/spree/api/option_values/index.v1.rabl b/api/app/views/spree/api/option_values/index.v1.rabl deleted file mode 100644 index 0bdfd33be3a..00000000000 --- a/api/app/views/spree/api/option_values/index.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -collection @option_values - -extends "spree/api/option_values/show" diff --git a/api/app/views/spree/api/option_values/show.json.jbuilder b/api/app/views/spree/api/option_values/show.json.jbuilder new file mode 100644 index 00000000000..2dad95c922a --- /dev/null +++ b/api/app/views/spree/api/option_values/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/option_values/option_value", option_value: @option_value) diff --git a/api/app/views/spree/api/option_values/show.v1.rabl b/api/app/views/spree/api/option_values/show.v1.rabl deleted file mode 100644 index 5ed499ef223..00000000000 --- a/api/app/views/spree/api/option_values/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @option_value -attributes *option_value_attributes \ No newline at end of file diff --git a/api/app/views/spree/api/orders/_big.json.jbuilder b/api/app/views/spree/api/orders/_big.json.jbuilder new file mode 100644 index 00000000000..256928bc5ae --- /dev/null +++ b/api/app/views/spree/api/orders/_big.json.jbuilder @@ -0,0 +1,49 @@ +json.partial!("spree/api/orders/order", order: order) +json.payment_methods(order.available_payment_methods) do |payment_method| + json.(payment_method, :id, :name, :partial_name) + json.method_type payment_method.partial_name +end +json.bill_address do + if order.billing_address + json.partial!("spree/api/addresses/address", address: order.billing_address) + else + json.nil! + end +end +json.ship_address do + if order.shipping_address + json.partial!("spree/api/addresses/address", address: order.shipping_address) + else + json.nil! + end +end +json.line_items(order.line_items) do |line_item| + json.partial!("spree/api/line_items/line_item", line_item: line_item) +end +json.payments(order.payments) do |payment| + json.(payment, *payment_attributes) + json.payment_method { json.(payment.payment_method, :id, :name) } + json.source do + if payment.source + json.(payment.source, *payment_source_attributes) + + if @current_user_roles.include?("admin") + json.(payment.source, :gateway_customer_profile_id, :gateway_payment_profile_id) + end + else + json.nil! + end + end +end +json.shipments(order.shipments) do |shipment| + json.partial!("spree/api/shipments/small", shipment: shipment) +end +json.adjustments(order.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) +end +json.permissions do + json.can_update current_ability.can?(:update, order) +end +json.credit_cards(order.valid_credit_cards) do |credit_card| + json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card) +end diff --git a/api/app/views/spree/api/orders/_order.json.jbuilder b/api/app/views/spree/api/orders/_order.json.jbuilder new file mode 100644 index 00000000000..39dc51866de --- /dev/null +++ b/api/app/views/spree/api/orders/_order.json.jbuilder @@ -0,0 +1,10 @@ +json.cache! [I18n.locale, order] do + json.(order, *order_attributes) + json.display_item_total(order.display_item_total.to_s) + json.total_quantity(order.line_items.sum(:quantity)) + json.display_total(order.display_total.to_s) + json.display_ship_total(order.display_ship_total) + json.display_tax_total(order.display_tax_total) + json.token(order.guest_token) + json.checkout_steps(order.checkout_steps) +end diff --git a/api/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder b/api/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder new file mode 100644 index 00000000000..90cd632f9a9 --- /dev/null +++ b/api/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder @@ -0,0 +1 @@ +json.error(@coupon_message) diff --git a/api/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl b/api/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl deleted file mode 100644 index 0a457130637..00000000000 --- a/api/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { @coupon_message } diff --git a/api/app/views/spree/api/orders/could_not_transition.json.jbuilder b/api/app/views/spree/api/orders/could_not_transition.json.jbuilder new file mode 100644 index 00000000000..20de3a70651 --- /dev/null +++ b/api/app/views/spree/api/orders/could_not_transition.json.jbuilder @@ -0,0 +1,2 @@ +json.error(I18n.t(:could_not_transition, scope: "spree.api.order")) +json.errors(@order.errors.to_hash) diff --git a/api/app/views/spree/api/orders/could_not_transition.v1.rabl b/api/app/views/spree/api/orders/could_not_transition.v1.rabl deleted file mode 100644 index 6157703be69..00000000000 --- a/api/app/views/spree/api/orders/could_not_transition.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:error) { I18n.t(:could_not_transition, scope: "spree.api.order") } -node(:errors) { @order.errors.to_hash } diff --git a/api/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder b/api/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder new file mode 100644 index 00000000000..42484dd7859 --- /dev/null +++ b/api/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder @@ -0,0 +1 @@ +json.errors(expected_total: [I18n.t(:expected_total_mismatch, scope: "spree.api.order")]) diff --git a/api/app/views/spree/api/orders/expected_total_mismatch.v1.rabl b/api/app/views/spree/api/orders/expected_total_mismatch.v1.rabl deleted file mode 100644 index 9fe0eb1157d..00000000000 --- a/api/app/views/spree/api/orders/expected_total_mismatch.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:errors) { {expected_total: [I18n.t(:expected_total_mismatch, scope: "spree.api.order")]} } diff --git a/api/app/views/spree/api/orders/index.json.jbuilder b/api/app/views/spree/api/orders/index.json.jbuilder new file mode 100644 index 00000000000..a1cb0c85b80 --- /dev/null +++ b/api/app/views/spree/api/orders/index.json.jbuilder @@ -0,0 +1,6 @@ +json.orders(@orders) do |order| + json.partial!("spree/api/orders/order", order: order) +end +json.count(@orders.count) +json.current_page(@orders.current_page) +json.pages(@orders.total_pages) diff --git a/api/app/views/spree/api/orders/index.v1.rabl b/api/app/views/spree/api/orders/index.v1.rabl deleted file mode 100644 index 03868f7fd34..00000000000 --- a/api/app/views/spree/api/orders/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@orders => :orders) do - extends "spree/api/orders/order" -end -node(:count) { @orders.count } -node(:current_page) { @orders.current_page } -node(:pages) { @orders.total_pages } diff --git a/api/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder b/api/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder new file mode 100644 index 00000000000..00a902ae0c2 --- /dev/null +++ b/api/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder @@ -0,0 +1 @@ +json.errors([I18n.t(:invalid_shipping_method, scope: "spree.api.order")]) diff --git a/api/app/views/spree/api/orders/invalid_shipping_method.v1.rabl b/api/app/views/spree/api/orders/invalid_shipping_method.v1.rabl deleted file mode 100644 index 3bd499fb843..00000000000 --- a/api/app/views/spree/api/orders/invalid_shipping_method.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:errors) { [I18n.t(:invalid_shipping_method, :scope => "spree.api.order")] } diff --git a/api/app/views/spree/api/orders/mine.json.jbuilder b/api/app/views/spree/api/orders/mine.json.jbuilder new file mode 100644 index 00000000000..97ba0101ed5 --- /dev/null +++ b/api/app/views/spree/api/orders/mine.json.jbuilder @@ -0,0 +1,6 @@ +json.orders(@orders) do |order| + json.partial!("spree/api/orders/big", order: order) +end +json.count(@orders.count) +json.current_page(@orders.current_page) +json.pages(@orders.total_pages) diff --git a/api/app/views/spree/api/orders/mine.v1.rabl b/api/app/views/spree/api/orders/mine.v1.rabl deleted file mode 100644 index a18e1066d89..00000000000 --- a/api/app/views/spree/api/orders/mine.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false - -child(@orders => :orders) do - extends "spree/api/orders/show" -end - -node(:count) { @orders.count } -node(:current_page) { @orders.current_page } -node(:pages) { @orders.total_pages } diff --git a/api/app/views/spree/api/orders/order.v1.rabl b/api/app/views/spree/api/orders/order.v1.rabl deleted file mode 100644 index a511dd34e48..00000000000 --- a/api/app/views/spree/api/orders/order.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -cache [I18n.locale, root_object] -attributes *order_attributes -node(:display_item_total) { |o| o.display_item_total.to_s } -node(:total_quantity) { |o| o.line_items.sum(:quantity) } -node(:display_total) { |o| o.display_total.to_s } -node(:display_ship_total) { |o| o.display_ship_total } -node(:display_tax_total) { |o| o.display_tax_total } -node(:token) { |o| o.guest_token } -node(:checkout_steps) { |o| o.checkout_steps } diff --git a/api/app/views/spree/api/orders/show.json.jbuilder b/api/app/views/spree/api/orders/show.json.jbuilder new file mode 100644 index 00000000000..d861cbe2845 --- /dev/null +++ b/api/app/views/spree/api/orders/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/orders/big", order: @order) diff --git a/api/app/views/spree/api/orders/show.v1.rabl b/api/app/views/spree/api/orders/show.v1.rabl deleted file mode 100644 index 4bf27671371..00000000000 --- a/api/app/views/spree/api/orders/show.v1.rabl +++ /dev/null @@ -1,53 +0,0 @@ -object @order -extends "spree/api/orders/order" - -child :available_payment_methods => :payment_methods do - attributes :id, :name, :partial_name - attributes :partial_name, as: :method_type -end - -child :billing_address => :bill_address do - extends "spree/api/addresses/show" -end - -child :shipping_address => :ship_address do - extends "spree/api/addresses/show" -end - -child :line_items => :line_items do - extends "spree/api/line_items/show" -end - -child :payments => :payments do - attributes *payment_attributes - - child :payment_method => :payment_method do - attributes :id, :name - end - - child :source => :source do - attributes *payment_source_attributes - if @current_user_roles.include?('admin') - attributes *(payment_source_attributes + [:gateway_customer_profile_id, :gateway_payment_profile_id]) - else - attributes *payment_source_attributes - end - end -end - -child :shipments => :shipments do - extends "spree/api/shipments/small" -end - -child :adjustments => :adjustments do - extends "spree/api/adjustments/show" -end - -# Necessary for backend's order interface -node :permissions do - { can_update: current_ability.can?(:update, root_object) } -end - -child :valid_credit_cards => :credit_cards do - extends "spree/api/credit_cards/show" -end diff --git a/api/app/views/spree/api/payments/credit_over_limit.json.jbuilder b/api/app/views/spree/api/payments/credit_over_limit.json.jbuilder new file mode 100644 index 00000000000..47b254dd641 --- /dev/null +++ b/api/app/views/spree/api/payments/credit_over_limit.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:credit_over_limit, limit: @payment.credit_allowed, scope: "spree.api.payment")) diff --git a/api/app/views/spree/api/payments/credit_over_limit.v1.rabl b/api/app/views/spree/api/payments/credit_over_limit.v1.rabl deleted file mode 100644 index 3cbf95ad4f1..00000000000 --- a/api/app/views/spree/api/payments/credit_over_limit.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:credit_over_limit, :limit => @payment.credit_allowed, :scope => 'spree.api.payment') } diff --git a/api/app/views/spree/api/payments/index.json.jbuilder b/api/app/views/spree/api/payments/index.json.jbuilder new file mode 100644 index 00000000000..9308bf917b4 --- /dev/null +++ b/api/app/views/spree/api/payments/index.json.jbuilder @@ -0,0 +1,4 @@ +json.payments(@payments) { |payment| json.(payment, *payment_attributes) } +json.count(@payments.count) +json.current_page(@payments.current_page) +json.pages(@payments.total_pages) diff --git a/api/app/views/spree/api/payments/index.v1.rabl b/api/app/views/spree/api/payments/index.v1.rabl deleted file mode 100644 index f989da62136..00000000000 --- a/api/app/views/spree/api/payments/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@payments => :payments) do - attributes *payment_attributes -end -node(:count) { @payments.count } -node(:current_page) { @payments.current_page } -node(:pages) { @payments.total_pages } diff --git a/api/app/views/spree/api/payments/new.json.jbuilder b/api/app/views/spree/api/payments/new.json.jbuilder new file mode 100644 index 00000000000..7bc5516752e --- /dev/null +++ b/api/app/views/spree/api/payments/new.json.jbuilder @@ -0,0 +1,4 @@ +json.attributes([*payment_attributes]) +json.payment_methods(@payment_methods) do |payment_method| + json.(payment_method, *payment_method_attributes) +end diff --git a/api/app/views/spree/api/payments/new.v1.rabl b/api/app/views/spree/api/payments/new.v1.rabl deleted file mode 100644 index 05d227cf83e..00000000000 --- a/api/app/views/spree/api/payments/new.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object false -node(:attributes) { [*payment_attributes] } -child @payment_methods => :payment_methods do - attributes *payment_method_attributes -end diff --git a/api/app/views/spree/api/payments/show.json.jbuilder b/api/app/views/spree/api/payments/show.json.jbuilder new file mode 100644 index 00000000000..971e10508b8 --- /dev/null +++ b/api/app/views/spree/api/payments/show.json.jbuilder @@ -0,0 +1 @@ +json.(@payment, *payment_attributes) diff --git a/api/app/views/spree/api/payments/show.v1.rabl b/api/app/views/spree/api/payments/show.v1.rabl deleted file mode 100644 index e2f48cb940a..00000000000 --- a/api/app/views/spree/api/payments/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @payment -attributes *payment_attributes diff --git a/api/app/views/spree/api/payments/update_forbidden.json.jbuilder b/api/app/views/spree/api/payments/update_forbidden.json.jbuilder new file mode 100644 index 00000000000..7b868519a82 --- /dev/null +++ b/api/app/views/spree/api/payments/update_forbidden.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:update_forbidden, state: @payment.state, scope: "spree.api.payment")) diff --git a/api/app/views/spree/api/payments/update_forbidden.v1.rabl b/api/app/views/spree/api/payments/update_forbidden.v1.rabl deleted file mode 100644 index 7f51e9c3a8c..00000000000 --- a/api/app/views/spree/api/payments/update_forbidden.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:update_forbidden, :state => @payment.state, :scope => 'spree.api.payment') } diff --git a/api/app/views/spree/api/product_properties/index.json.jbuilder b/api/app/views/spree/api/product_properties/index.json.jbuilder new file mode 100644 index 00000000000..5cf15554982 --- /dev/null +++ b/api/app/views/spree/api/product_properties/index.json.jbuilder @@ -0,0 +1,6 @@ +json.product_properties(@product_properties) do |product_property| + json.(product_property, *product_property_attributes) +end +json.count(@product_properties.count) +json.current_page(@product_properties.current_page) +json.pages(@product_properties.total_pages) diff --git a/api/app/views/spree/api/product_properties/index.v1.rabl b/api/app/views/spree/api/product_properties/index.v1.rabl deleted file mode 100644 index 272180f0bc2..00000000000 --- a/api/app/views/spree/api/product_properties/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@product_properties => :product_properties) do - attributes *product_property_attributes -end -node(:count) { @product_properties.count } -node(:current_page) { @product_properties.current_page } -node(:pages) { @product_properties.total_pages } diff --git a/api/app/views/spree/api/product_properties/new.json.jbuilder b/api/app/views/spree/api/product_properties/new.json.jbuilder new file mode 100644 index 00000000000..a03b53b2ed3 --- /dev/null +++ b/api/app/views/spree/api/product_properties/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*product_property_attributes]) +json.required_attributes([]) diff --git a/api/app/views/spree/api/product_properties/new.v1.rabl b/api/app/views/spree/api/product_properties/new.v1.rabl deleted file mode 100644 index 9556ea41320..00000000000 --- a/api/app/views/spree/api/product_properties/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -node(:attributes) { [*product_property_attributes] } -node(:required_attributes) { [] } \ No newline at end of file diff --git a/api/app/views/spree/api/product_properties/show.json.jbuilder b/api/app/views/spree/api/product_properties/show.json.jbuilder new file mode 100644 index 00000000000..23af9bd4d0c --- /dev/null +++ b/api/app/views/spree/api/product_properties/show.json.jbuilder @@ -0,0 +1 @@ +json.(@product_property, *product_property_attributes) diff --git a/api/app/views/spree/api/product_properties/show.v1.rabl b/api/app/views/spree/api/product_properties/show.v1.rabl deleted file mode 100644 index 12e24137b53..00000000000 --- a/api/app/views/spree/api/product_properties/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @product_property -attributes *product_property_attributes diff --git a/api/app/views/spree/api/products/_product.json.jbuilder b/api/app/views/spree/api/products/_product.json.jbuilder new file mode 100644 index 00000000000..089acc4c2d3 --- /dev/null +++ b/api/app/views/spree/api/products/_product.json.jbuilder @@ -0,0 +1,34 @@ +@product_attributes ||= product_attributes +json.cache! [I18n.locale, @current_user_roles.include?('admin'), current_pricing_options, @product_attributes, @exclude_data, product] do + json.(product, *@product_attributes) + json.display_price(product.display_price.to_s) + + @exclude_data ||= {} + unless @exclude_data[:variants] + json.has_variants(product.has_variants?) + json.master do + json.partial!("spree/api/variants/small", variant: product.master) + end + json.variants(product.variants) do |variant| + json.partial!("spree/api/variants/small", variant: variant) + end + end + unless @exclude_data[:option_types] + json.option_types(product.option_types) do |option_type| + json.(option_type, *option_type_attributes) + end + end + unless @exclude_data[:product_properties] + json.product_properties(product.product_properties) do |product_property| + json.(product_property, *product_property_attributes) + end + end + unless @exclude_data[:classifications] + json.classifications(product.classifications) do |classification| + json.(classification, :taxon_id, :position) + json.taxon do + json.partial!("spree/api/taxons/taxon", taxon: classification.taxon) + end + end + end +end diff --git a/api/app/views/spree/api/products/index.json.jbuilder b/api/app/views/spree/api/products/index.json.jbuilder new file mode 100644 index 00000000000..3c774991fe8 --- /dev/null +++ b/api/app/views/spree/api/products/index.json.jbuilder @@ -0,0 +1,8 @@ +json.count(@products.size) +json.total_count(@products.total_count) +json.current_page(@products.current_page) +json.per_page(@products.limit_value) +json.pages(@products.total_pages) +json.products(@products) do |product| + json.partial!("spree/api/products/product", product: product) +end diff --git a/api/app/views/spree/api/products/index.v1.rabl b/api/app/views/spree/api/products/index.v1.rabl deleted file mode 100644 index 6c4e861d0a3..00000000000 --- a/api/app/views/spree/api/products/index.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false -node(:count) { @products.size } -node(:total_count) { @products.total_count } -node(:current_page) { @products.current_page } -node(:per_page) { @products.limit_value } -node(:pages) { @products.total_pages } -child(@products => :products) do - extends "spree/api/products/show" -end diff --git a/api/app/views/spree/api/products/new.json.jbuilder b/api/app/views/spree/api/products/new.json.jbuilder new file mode 100644 index 00000000000..7f0cdbdbb93 --- /dev/null +++ b/api/app/views/spree/api/products/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*product_attributes]) +json.required_attributes(required_fields_for(Spree::Product)) diff --git a/api/app/views/spree/api/products/new.v1.rabl b/api/app/views/spree/api/products/new.v1.rabl deleted file mode 100644 index 71861f91837..00000000000 --- a/api/app/views/spree/api/products/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*product_attributes] } -node(:required_attributes) { required_fields_for(Spree::Product) } diff --git a/api/app/views/spree/api/products/product.v1.rabl b/api/app/views/spree/api/products/product.v1.rabl deleted file mode 100644 index ba18e3f709f..00000000000 --- a/api/app/views/spree/api/products/product.v1.rabl +++ /dev/null @@ -1 +0,0 @@ -attributes *product_attributes diff --git a/api/app/views/spree/api/products/show.json.jbuilder b/api/app/views/spree/api/products/show.json.jbuilder new file mode 100644 index 00000000000..91e5ebe4fea --- /dev/null +++ b/api/app/views/spree/api/products/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/products/product", product: @product) diff --git a/api/app/views/spree/api/products/show.v1.rabl b/api/app/views/spree/api/products/show.v1.rabl deleted file mode 100644 index 9f7d84ae000..00000000000 --- a/api/app/views/spree/api/products/show.v1.rabl +++ /dev/null @@ -1,42 +0,0 @@ -object @product -cache [I18n.locale, @current_user_roles.include?('admin'), current_pricing_options, root_object] - -@product_attributes ||= product_attributes -attributes(*@product_attributes) - -node(:display_price) { |p| p.display_price.to_s } - -@exclude_data ||= {} -unless @exclude_data[:variants] - node(:has_variants) { |p| p.has_variants? } - - child :master => :master do - extends "spree/api/variants/small" - end - - child :variants => :variants do - extends "spree/api/variants/small" - end -end - -unless @exclude_data[:option_types] - child :option_types => :option_types do - attributes(*option_type_attributes) - end -end - -unless @exclude_data[:product_properties] - child :product_properties => :product_properties do - attributes(*product_property_attributes) - end -end - -unless @exclude_data[:classifications] - child :classifications => :classifications do - attributes :taxon_id, :position - - child(:taxon) do - extends "spree/api/taxons/show" - end - end -end diff --git a/api/app/views/spree/api/promotions/handler.json.jbuilder b/api/app/views/spree/api/promotions/handler.json.jbuilder new file mode 100644 index 00000000000..7a14ccd351b --- /dev/null +++ b/api/app/views/spree/api/promotions/handler.json.jbuilder @@ -0,0 +1,4 @@ +json.success(@handler.success) +json.error(@handler.error) +json.successful(@handler.successful?) +json.status_code(@handler.status_code) diff --git a/api/app/views/spree/api/promotions/handler.v1.rabl b/api/app/views/spree/api/promotions/handler.v1.rabl deleted file mode 100644 index e08a89b08ee..00000000000 --- a/api/app/views/spree/api/promotions/handler.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object false -node(:success) { @handler.success } -node(:error) { @handler.error } -node(:successful) { @handler.successful? } -node(:status_code) { @handler.status_code } diff --git a/api/app/views/spree/api/promotions/show.json.jbuilder b/api/app/views/spree/api/promotions/show.json.jbuilder new file mode 100644 index 00000000000..fc4661139d2 --- /dev/null +++ b/api/app/views/spree/api/promotions/show.json.jbuilder @@ -0,0 +1 @@ +json.(@promotion, *promotion_attributes) diff --git a/api/app/views/spree/api/promotions/show.v1.rabl b/api/app/views/spree/api/promotions/show.v1.rabl deleted file mode 100644 index 90a577d22ab..00000000000 --- a/api/app/views/spree/api/promotions/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @promotion -attributes *promotion_attributes diff --git a/api/app/views/spree/api/properties/index.json.jbuilder b/api/app/views/spree/api/properties/index.json.jbuilder new file mode 100644 index 00000000000..4aee811e594 --- /dev/null +++ b/api/app/views/spree/api/properties/index.json.jbuilder @@ -0,0 +1,6 @@ +json.properties(@properties) do |property| + json.(property, *property_attributes) +end +json.count(@properties.count) +json.current_page(@properties.current_page) +json.pages(@properties.total_pages) diff --git a/api/app/views/spree/api/properties/index.v1.rabl b/api/app/views/spree/api/properties/index.v1.rabl deleted file mode 100644 index 27eafc9649f..00000000000 --- a/api/app/views/spree/api/properties/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@properties => :properties) do - attributes *property_attributes -end -node(:count) { @properties.count } -node(:current_page) { @properties.current_page } -node(:pages) { @properties.total_pages } diff --git a/api/app/views/spree/api/properties/new.json.jbuilder b/api/app/views/spree/api/properties/new.json.jbuilder new file mode 100644 index 00000000000..0b578258ec8 --- /dev/null +++ b/api/app/views/spree/api/properties/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*property_attributes]) +json.required_attributes([]) diff --git a/api/app/views/spree/api/properties/new.v1.rabl b/api/app/views/spree/api/properties/new.v1.rabl deleted file mode 100644 index 76f03444e8e..00000000000 --- a/api/app/views/spree/api/properties/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -node(:attributes) { [*property_attributes] } -node(:required_attributes) { [] } diff --git a/api/app/views/spree/api/properties/show.json.jbuilder b/api/app/views/spree/api/properties/show.json.jbuilder new file mode 100644 index 00000000000..1767652e3f6 --- /dev/null +++ b/api/app/views/spree/api/properties/show.json.jbuilder @@ -0,0 +1 @@ +json.(@property, *property_attributes) diff --git a/api/app/views/spree/api/properties/show.v1.rabl b/api/app/views/spree/api/properties/show.v1.rabl deleted file mode 100644 index 08cfbe5e9b6..00000000000 --- a/api/app/views/spree/api/properties/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @property -attributes *property_attributes diff --git a/api/app/views/spree/api/return_authorizations/index.json.jbuilder b/api/app/views/spree/api/return_authorizations/index.json.jbuilder new file mode 100644 index 00000000000..c88ba58ff76 --- /dev/null +++ b/api/app/views/spree/api/return_authorizations/index.json.jbuilder @@ -0,0 +1,6 @@ +json.return_authorizations(@return_authorizations) do |return_authorization| + json.(return_authorization, *return_authorization_attributes) +end +json.count(@return_authorizations.count) +json.current_page(@return_authorizations.current_page) +json.pages(@return_authorizations.total_pages) diff --git a/api/app/views/spree/api/return_authorizations/index.v1.rabl b/api/app/views/spree/api/return_authorizations/index.v1.rabl deleted file mode 100644 index 879b9a4f0fb..00000000000 --- a/api/app/views/spree/api/return_authorizations/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@return_authorizations => :return_authorizations) do - attributes *return_authorization_attributes -end -node(:count) { @return_authorizations.count } -node(:current_page) { @return_authorizations.current_page } -node(:pages) { @return_authorizations.total_pages } diff --git a/api/app/views/spree/api/return_authorizations/new.json.jbuilder b/api/app/views/spree/api/return_authorizations/new.json.jbuilder new file mode 100644 index 00000000000..7e1315a4079 --- /dev/null +++ b/api/app/views/spree/api/return_authorizations/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*return_authorization_attributes]) +json.required_attributes(required_fields_for(Spree::ReturnAuthorization)) diff --git a/api/app/views/spree/api/return_authorizations/new.v1.rabl b/api/app/views/spree/api/return_authorizations/new.v1.rabl deleted file mode 100644 index 362fa8ac9de..00000000000 --- a/api/app/views/spree/api/return_authorizations/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*return_authorization_attributes] } -node(:required_attributes) { required_fields_for(Spree::ReturnAuthorization) } diff --git a/api/app/views/spree/api/return_authorizations/show.json.jbuilder b/api/app/views/spree/api/return_authorizations/show.json.jbuilder new file mode 100644 index 00000000000..2ce06916300 --- /dev/null +++ b/api/app/views/spree/api/return_authorizations/show.json.jbuilder @@ -0,0 +1 @@ +json.(@return_authorization, *return_authorization_attributes) diff --git a/api/app/views/spree/api/return_authorizations/show.v1.rabl b/api/app/views/spree/api/return_authorizations/show.v1.rabl deleted file mode 100644 index 00b07a3b1c2..00000000000 --- a/api/app/views/spree/api/return_authorizations/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @return_authorization -attributes *return_authorization_attributes \ No newline at end of file diff --git a/api/app/views/spree/api/shipments/_big.json.jbuilder b/api/app/views/spree/api/shipments/_big.json.jbuilder new file mode 100644 index 00000000000..eb60c8656dc --- /dev/null +++ b/api/app/views/spree/api/shipments/_big.json.jbuilder @@ -0,0 +1,51 @@ +json.cache! [I18n.locale, shipment] do + json.(shipment, *shipment_attributes) + json.selected_shipping_rate do + if shipment.selected_shipping_rate + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) + else + json.nil! + end + end + json.inventory_units(shipment.inventory_units) do |inventory_unit| + json.(inventory_unit, *inventory_unit_attributes) + json.variant do + json.partial!("spree/api/variants/small", variant: inventory_unit.variant) + json.(inventory_unit.variant, :product_id) + json.images(inventory_unit.variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end + end + json.line_item do + json.(inventory_unit.line_item, *line_item_attributes) + json.single_display_amount(inventory_unit.line_item.single_display_amount.to_s) + json.display_amount(inventory_unit.line_item.display_amount.to_s) + json.total(inventory_unit.line_item.total) + end + end + json.order do + json.partial!("spree/api/orders/order", order: shipment.order) + json.bill_address do + if shipment.order.billing_address + json.partial!("spree/api/addresses/address", address: shipment.order.billing_address) + else + json.nil! + end + end + json.ship_address do + json.partial!("spree/api/addresses/address", address: shipment.order.shipping_address) + end + json.adjustments(shipment.order.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + end + json.payments(shipment.order.payments) do |payment| + json.(payment, :id, :amount, :display_amount, :state) + json.source do + attrs = [:id] + (attrs << :cc_type) if payment.source.respond_to?(:cc_type) + json.(payment.source, *attrs) + end + json.payment_method { json.(payment.payment_method, :id, :name) } + end + end +end diff --git a/api/app/views/spree/api/shipments/_small.json.jbuilder b/api/app/views/spree/api/shipments/_small.json.jbuilder new file mode 100644 index 00000000000..797f607416d --- /dev/null +++ b/api/app/views/spree/api/shipments/_small.json.jbuilder @@ -0,0 +1,32 @@ +json.cache! [I18n.locale, shipment] do + json.(shipment, *shipment_attributes) + json.order_id(shipment.order.number) + json.stock_location_name(shipment.stock_location.name) + json.shipping_rates(shipment.shipping_rates) do |shipping_rate| + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) + end + json.selected_shipping_rate do + if shipment.selected_shipping_rate + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate) + else + json.nil! + end + end + json.shipping_methods(shipment.shipping_methods) do |shipping_method| + json.(shipping_method, :id, :code, :name) + json.zones(shipping_method.zones) do |zone| + json.(zone, :id, :name, :description) + end + json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| + json.(shipping_category, :id, :name) + end + end + json.manifest(shipment.manifest) do |manifest_item| + json.variant_id manifest_item.variant.id + json.quantity(manifest_item.quantity) + json.states(manifest_item.states) + end + json.adjustments(shipment.adjustments) do |adjustment| + json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment) + end +end diff --git a/api/app/views/spree/api/shipments/big.v1.rabl b/api/app/views/spree/api/shipments/big.v1.rabl deleted file mode 100644 index ebfeb235745..00000000000 --- a/api/app/views/spree/api/shipments/big.v1.rabl +++ /dev/null @@ -1,55 +0,0 @@ -object @shipment -cache @shipment -attributes *shipment_attributes - -child selected_shipping_rate: :selected_shipping_rate do - extends "spree/api/shipping_rates/show" -end - -child inventory_units: :inventory_units do - object @inventory_unit - attributes *inventory_unit_attributes - - child :variant do - extends "spree/api/variants/small" - attributes :product_id - child(images: :images) { extends "spree/api/images/show" } - end - - child :line_item do - attributes *line_item_attributes - node(:single_display_amount) { |li| li.single_display_amount.to_s } - node(:display_amount) { |li| li.display_amount.to_s } - node(:total) { |li| li.total } - end -end - -child order: :order do - extends "spree/api/orders/order" - - child billing_address: :bill_address do - extends "spree/api/addresses/show" - end - - child shipping_address: :ship_address do - extends "spree/api/addresses/show" - end - - child adjustments: :adjustments do - extends "spree/api/adjustments/show" - end - - child payments: :payments do - attributes :id, :amount, :display_amount, :state - child source: :source do |s| - attrs = [:id] - if s.respond_to?(:cc_type) - attrs << :cc_type - end - attributes *attrs - end - child payment_method: :payment_method do - attributes :id, :name - end - end -end diff --git a/api/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder b/api/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder new file mode 100644 index 00000000000..77448618416 --- /dev/null +++ b/api/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder @@ -0,0 +1 @@ +json.error(I18n.t(:cannot_ready, scope: "spree.api.shipment")) diff --git a/api/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl b/api/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl deleted file mode 100644 index aab55663d03..00000000000 --- a/api/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:error) { I18n.t(:cannot_ready, :scope => "spree.api.shipment") } diff --git a/api/app/views/spree/api/shipments/mine.json.jbuilder b/api/app/views/spree/api/shipments/mine.json.jbuilder new file mode 100644 index 00000000000..abedfbbf0ef --- /dev/null +++ b/api/app/views/spree/api/shipments/mine.json.jbuilder @@ -0,0 +1,6 @@ +json.count(@shipments.count) +json.current_page(@shipments.current_page) +json.pages(@shipments.total_pages) +json.shipments(@shipments) do |shipment| + json.partial!("spree/api/shipments/big", shipment: shipment) +end diff --git a/api/app/views/spree/api/shipments/mine.v1.rabl b/api/app/views/spree/api/shipments/mine.v1.rabl deleted file mode 100644 index 6b2192bffc3..00000000000 --- a/api/app/views/spree/api/shipments/mine.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false - -node(:count) { @shipments.count } -node(:current_page) { @shipments.current_page } -node(:pages) { @shipments.total_pages } - -child(@shipments => :shipments) do - extends "spree/api/shipments/big" -end diff --git a/api/app/views/spree/api/shipments/show.json.jbuilder b/api/app/views/spree/api/shipments/show.json.jbuilder new file mode 100644 index 00000000000..54feca58c8e --- /dev/null +++ b/api/app/views/spree/api/shipments/show.json.jbuilder @@ -0,0 +1,31 @@ +json.cache! [I18n.locale, @shipment] do + json.(@shipment, *shipment_attributes) + json.order_id(@shipment.order.number) + json.stock_location_name(@shipment.stock_location.name) + json.shipping_rates(@shipment.shipping_rates) do |shipping_rate| + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate) + end + json.selected_shipping_rate do + if @shipment.selected_shipping_rate + json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: @shipment.selected_shipping_rate) + else + json.nil! + end + end + json.shipping_methods(@shipment.shipping_methods) do |shipping_method| + json.(shipping_method, :id, :name) + json.zones(shipping_method.zones) do |zone| + json.(zone, :id, :name, :description) + end + json.shipping_categories(shipping_method.shipping_categories) do |shipping_category| + json.(shipping_category, :id, :name) + end + end + json.manifest(@shipment.manifest) do |manifest_item| + json.variant do + json.partial!("spree/api/variants/small", variant: manifest_item.variant) + end + json.quantity(manifest_item.quantity) + json.states(manifest_item.states) + end +end diff --git a/api/app/views/spree/api/shipments/show.v1.rabl b/api/app/views/spree/api/shipments/show.v1.rabl deleted file mode 100644 index 03b72bbc9db..00000000000 --- a/api/app/views/spree/api/shipments/show.v1.rabl +++ /dev/null @@ -1,32 +0,0 @@ -object @shipment -cache [I18n.locale, root_object] -attributes *shipment_attributes -node(:order_id) { |shipment| shipment.order.number } -node(:stock_location_name) { |shipment| shipment.stock_location.name } - -child :shipping_rates => :shipping_rates do - extends "spree/api/shipping_rates/show" -end - -child :selected_shipping_rate => :selected_shipping_rate do - extends "spree/api/shipping_rates/show" -end - -child :shipping_methods => :shipping_methods do - attributes :id, :name - child :zones => :zones do - attributes :id, :name, :description - end - - child :shipping_categories => :shipping_categories do - attributes :id, :name - end -end - -child :manifest => :manifest do - child :variant => :variant do - extends "spree/api/variants/small" - end - node(:quantity) { |m| m.quantity } - node(:states) { |m| m.states } -end diff --git a/api/app/views/spree/api/shipments/small.v1.rabl b/api/app/views/spree/api/shipments/small.v1.rabl deleted file mode 100644 index 3b8ef491189..00000000000 --- a/api/app/views/spree/api/shipments/small.v1.rabl +++ /dev/null @@ -1,37 +0,0 @@ -object @shipment -cache [I18n.locale, 'small_shipment', root_object] - -attributes *shipment_attributes -node(:order_id) { |shipment| shipment.order.number } -node(:stock_location_name) { |shipment| shipment.stock_location.name } - -child :shipping_rates => :shipping_rates do - extends "spree/api/shipping_rates/show" -end - -child :selected_shipping_rate => :selected_shipping_rate do - extends "spree/api/shipping_rates/show" -end - -child :shipping_methods => :shipping_methods do - attributes :id, :code, :name - child :zones => :zones do - attributes :id, :name, :description - end - - child :shipping_categories => :shipping_categories do - attributes :id, :name - end -end - -child :manifest => :manifest do - glue(:variant) do - attribute :id => :variant_id - end - node(:quantity) { |m| m.quantity } - node(:states) { |m| m.states } -end - -child :adjustments => :adjustments do - extends "spree/api/adjustments/show" -end diff --git a/api/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder b/api/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder new file mode 100644 index 00000000000..1e8d40b18b2 --- /dev/null +++ b/api/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder @@ -0,0 +1,2 @@ +json.(shipping_rate, :id, :name, :cost, :selected, :shipping_method_id, :shipping_method_code) +json.display_cost(shipping_rate.display_cost.to_s) diff --git a/api/app/views/spree/api/shipping_rates/show.v1.rabl b/api/app/views/spree/api/shipping_rates/show.v1.rabl deleted file mode 100644 index 64809f39edc..00000000000 --- a/api/app/views/spree/api/shipping_rates/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -attributes :id, :name, :cost, :selected, :shipping_method_id, :shipping_method_code -node(:display_cost) { |sr| sr.display_cost.to_s } diff --git a/api/app/views/spree/api/states/index.json.jbuilder b/api/app/views/spree/api/states/index.json.jbuilder new file mode 100644 index 00000000000..63b95ba89e1 --- /dev/null +++ b/api/app/views/spree/api/states/index.json.jbuilder @@ -0,0 +1,7 @@ +json.states_required(@country.states_required) if @country +json.states(@states) { |state| json.(state, *state_attributes) } +if @states.respond_to?(:total_pages) + json.count(@states.count) + json.current_page(@states.current_page) + json.pages(@states.total_pages) +end diff --git a/api/app/views/spree/api/states/index.v1.rabl b/api/app/views/spree/api/states/index.v1.rabl deleted file mode 100644 index c0fc8e3ffcc..00000000000 --- a/api/app/views/spree/api/states/index.v1.rabl +++ /dev/null @@ -1,14 +0,0 @@ -object false -if @country - node(:states_required) { @country.states_required } -end - -child(@states => :states) do - attributes *state_attributes -end - -if @states.respond_to?(:total_pages) - node(:count) { @states.count } - node(:current_page) { @states.current_page } - node(:pages) { @states.total_pages } -end diff --git a/api/app/views/spree/api/states/show.json.jbuilder b/api/app/views/spree/api/states/show.json.jbuilder new file mode 100644 index 00000000000..4cf31b89d6a --- /dev/null +++ b/api/app/views/spree/api/states/show.json.jbuilder @@ -0,0 +1 @@ +json.(@state, *state_attributes) diff --git a/api/app/views/spree/api/states/show.v1.rabl b/api/app/views/spree/api/states/show.v1.rabl deleted file mode 100644 index 3b7533d511b..00000000000 --- a/api/app/views/spree/api/states/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @state -attributes *state_attributes diff --git a/api/app/views/spree/api/stock_items/_stock_item.json.jbuilder b/api/app/views/spree/api/stock_items/_stock_item.json.jbuilder new file mode 100644 index 00000000000..4d38a389fcd --- /dev/null +++ b/api/app/views/spree/api/stock_items/_stock_item.json.jbuilder @@ -0,0 +1,4 @@ +json.(stock_item, *stock_item_attributes) +json.variant do + json.partial!("spree/api/variants/small", variant: stock_item.variant) +end diff --git a/api/app/views/spree/api/stock_items/index.json.jbuilder b/api/app/views/spree/api/stock_items/index.json.jbuilder new file mode 100644 index 00000000000..9484871619b --- /dev/null +++ b/api/app/views/spree/api/stock_items/index.json.jbuilder @@ -0,0 +1,6 @@ +json.stock_items(@stock_items) do |stock_item| + json.partial!("spree/api/stock_items/stock_item", stock_item: stock_item) +end +json.count(@stock_items.count) +json.current_page(@stock_items.current_page) +json.pages(@stock_items.total_pages) diff --git a/api/app/views/spree/api/stock_items/index.v1.rabl b/api/app/views/spree/api/stock_items/index.v1.rabl deleted file mode 100644 index 742c829843c..00000000000 --- a/api/app/views/spree/api/stock_items/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@stock_items => :stock_items) do - extends 'spree/api/stock_items/show' -end -node(:count) { @stock_items.count } -node(:current_page) { @stock_items.current_page } -node(:pages) { @stock_items.total_pages } diff --git a/api/app/views/spree/api/stock_items/show.json.jbuilder b/api/app/views/spree/api/stock_items/show.json.jbuilder new file mode 100644 index 00000000000..ca7bc82d7ec --- /dev/null +++ b/api/app/views/spree/api/stock_items/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/stock_items/stock_item", stock_item: @stock_item) diff --git a/api/app/views/spree/api/stock_items/show.v1.rabl b/api/app/views/spree/api/stock_items/show.v1.rabl deleted file mode 100644 index bc96704cdb7..00000000000 --- a/api/app/views/spree/api/stock_items/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @stock_item -attributes *stock_item_attributes -child(:variant) do - extends "spree/api/variants/small" -end diff --git a/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder b/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder new file mode 100644 index 00000000000..814e54754e8 --- /dev/null +++ b/api/app/views/spree/api/stock_locations/_stock_location.json.jbuilder @@ -0,0 +1,15 @@ +json.(stock_location, *stock_location_attributes) +json.country do + if stock_location.country + json.(stock_location.country, *country_attributes) + else + json.nil! + end +end +json.state do + if stock_location.state + json.(stock_location.state, *state_attributes) + else + json.nil! + end +end diff --git a/api/app/views/spree/api/stock_locations/index.json.jbuilder b/api/app/views/spree/api/stock_locations/index.json.jbuilder new file mode 100644 index 00000000000..28a9e34f87e --- /dev/null +++ b/api/app/views/spree/api/stock_locations/index.json.jbuilder @@ -0,0 +1,6 @@ +json.stock_locations(@stock_locations) do |stock_location| + json.partial!("spree/api/stock_locations/stock_location", stock_location: stock_location) +end +json.count(@stock_locations.count) +json.current_page(@stock_locations.current_page) +json.pages(@stock_locations.total_pages) diff --git a/api/app/views/spree/api/stock_locations/index.v1.rabl b/api/app/views/spree/api/stock_locations/index.v1.rabl deleted file mode 100644 index 9f73c2edb13..00000000000 --- a/api/app/views/spree/api/stock_locations/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@stock_locations => :stock_locations) do - extends 'spree/api/stock_locations/show' -end -node(:count) { @stock_locations.count } -node(:current_page) { @stock_locations.current_page } -node(:pages) { @stock_locations.total_pages } diff --git a/api/app/views/spree/api/stock_locations/show.json.jbuilder b/api/app/views/spree/api/stock_locations/show.json.jbuilder new file mode 100644 index 00000000000..ce36b6ac8f0 --- /dev/null +++ b/api/app/views/spree/api/stock_locations/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/stock_locations/stock_location", stock_location: @stock_location) diff --git a/api/app/views/spree/api/stock_locations/show.v1.rabl b/api/app/views/spree/api/stock_locations/show.v1.rabl deleted file mode 100644 index 898e12e88cb..00000000000 --- a/api/app/views/spree/api/stock_locations/show.v1.rabl +++ /dev/null @@ -1,8 +0,0 @@ -object @stock_location -attributes *stock_location_attributes -child(:country) do |address| - attributes *country_attributes -end -child(:state) do |address| - attributes *state_attributes -end diff --git a/api/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder b/api/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder new file mode 100644 index 00000000000..707ec5ecb1a --- /dev/null +++ b/api/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder @@ -0,0 +1,4 @@ +json.(stock_movement, *stock_movement_attributes) +json.stock_item do + json.partial!("spree/api/stock_items/stock_item", stock_item: stock_movement.stock_item) +end diff --git a/api/app/views/spree/api/stock_movements/index.json.jbuilder b/api/app/views/spree/api/stock_movements/index.json.jbuilder new file mode 100644 index 00000000000..e4448fa288a --- /dev/null +++ b/api/app/views/spree/api/stock_movements/index.json.jbuilder @@ -0,0 +1,6 @@ +json.stock_movements(@stock_movements) do |stock_movement| + json.partial!("spree/api/stock_movements/stock_movement", stock_movement: stock_movement) +end +json.count(@stock_movements.count) +json.current_page(@stock_movements.current_page) +json.pages(@stock_movements.total_pages) diff --git a/api/app/views/spree/api/stock_movements/index.v1.rabl b/api/app/views/spree/api/stock_movements/index.v1.rabl deleted file mode 100644 index a1e95af2e21..00000000000 --- a/api/app/views/spree/api/stock_movements/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@stock_movements => :stock_movements) do - extends 'spree/api/stock_movements/show' -end -node(:count) { @stock_movements.count } -node(:current_page) { @stock_movements.current_page } -node(:pages) { @stock_movements.total_pages } diff --git a/api/app/views/spree/api/stock_movements/show.json.jbuilder b/api/app/views/spree/api/stock_movements/show.json.jbuilder new file mode 100644 index 00000000000..4d80c79a6a5 --- /dev/null +++ b/api/app/views/spree/api/stock_movements/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/stock_movements/stock_movement", stock_movement: @stock_movement) diff --git a/api/app/views/spree/api/stock_movements/show.v1.rabl b/api/app/views/spree/api/stock_movements/show.v1.rabl deleted file mode 100644 index 93dff52e7bb..00000000000 --- a/api/app/views/spree/api/stock_movements/show.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @stock_movement -attributes *stock_movement_attributes -child :stock_item do - extends "spree/api/stock_items/show" -end diff --git a/api/app/views/spree/api/stock_transfers/receive.json.jbuilder b/api/app/views/spree/api/stock_transfers/receive.json.jbuilder new file mode 100644 index 00000000000..94f7c66b879 --- /dev/null +++ b/api/app/views/spree/api/stock_transfers/receive.json.jbuilder @@ -0,0 +1,4 @@ +json.(@stock_transfer, *stock_transfer_attributes) +json.received_item do + json.partial!("spree/api/transfer_items/transfer_item", transfer_item: @transfer_item) +end diff --git a/api/app/views/spree/api/stock_transfers/receive.v1.rabl b/api/app/views/spree/api/stock_transfers/receive.v1.rabl deleted file mode 100644 index d165912e80b..00000000000 --- a/api/app/views/spree/api/stock_transfers/receive.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -object @stock_transfer -attributes *stock_transfer_attributes -node(:received_item) do - partial('spree/api/transfer_items/show', object: @transfer_item) -end diff --git a/api/app/views/spree/api/store_credit_events/mine.json.jbuilder b/api/app/views/spree/api/store_credit_events/mine.json.jbuilder new file mode 100644 index 00000000000..84a81ca2ac9 --- /dev/null +++ b/api/app/views/spree/api/store_credit_events/mine.json.jbuilder @@ -0,0 +1,7 @@ +json.store_credit_events(@store_credit_events) do |store_credit_event| + json.(store_credit_event, *store_credit_history_attributes) + json.order_number(store_credit_event.order.try(:number)) +end +json.count(@store_credit_events.count) +json.current_page(@store_credit_events.current_page) +json.pages(@store_credit_events.total_pages) diff --git a/api/app/views/spree/api/store_credit_events/mine.v1.rabl b/api/app/views/spree/api/store_credit_events/mine.v1.rabl deleted file mode 100644 index 34a4d8b20e1..00000000000 --- a/api/app/views/spree/api/store_credit_events/mine.v1.rabl +++ /dev/null @@ -1,10 +0,0 @@ -object false - -child(@store_credit_events => :store_credit_events) do - attributes *store_credit_history_attributes - node(:order_number) { |event| event.order.try(:number) } -end - -node(:count) { @store_credit_events.count } -node(:current_page) { @store_credit_events.current_page } -node(:pages) { @store_credit_events.total_pages } diff --git a/api/app/views/spree/api/stores/index.json.jbuilder b/api/app/views/spree/api/stores/index.json.jbuilder new file mode 100644 index 00000000000..9d0e0c6f1e0 --- /dev/null +++ b/api/app/views/spree/api/stores/index.json.jbuilder @@ -0,0 +1 @@ +json.stores(@stores) { |store| json.(store, *store_attributes) } diff --git a/api/app/views/spree/api/stores/index.v1.rabl b/api/app/views/spree/api/stores/index.v1.rabl deleted file mode 100644 index ae547356bb7..00000000000 --- a/api/app/views/spree/api/stores/index.v1.rabl +++ /dev/null @@ -1,4 +0,0 @@ -object false -child(@stores => :stores) do - attributes *store_attributes -end diff --git a/api/app/views/spree/api/stores/show.json.jbuilder b/api/app/views/spree/api/stores/show.json.jbuilder new file mode 100644 index 00000000000..cbd0823e782 --- /dev/null +++ b/api/app/views/spree/api/stores/show.json.jbuilder @@ -0,0 +1 @@ +json.(@store, *store_attributes) diff --git a/api/app/views/spree/api/stores/show.v1.rabl b/api/app/views/spree/api/stores/show.v1.rabl deleted file mode 100644 index a0e1941b723..00000000000 --- a/api/app/views/spree/api/stores/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @store -attributes *store_attributes diff --git a/api/app/views/spree/api/taxonomies/_nested.json.jbuilder b/api/app/views/spree/api/taxonomies/_nested.json.jbuilder new file mode 100644 index 00000000000..e64ca55d8b6 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/_nested.json.jbuilder @@ -0,0 +1,8 @@ +json.(taxonomy, *taxonomy_attributes) +json.root do + json.(taxonomy.root, *taxon_attributes) + json.taxons(taxonomy.root.children) do |taxon| + json.(taxon, *taxon_attributes) + json.partial!("spree/api/taxons/taxons", taxon: taxon) + end +end diff --git a/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder b/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder new file mode 100644 index 00000000000..35f321ed13a --- /dev/null +++ b/api/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder @@ -0,0 +1,11 @@ +if params[:set] == "nested" + json.partial!("spree/api/taxonomies/nested", taxonomy: taxonomy) +else + json.(taxonomy, *taxonomy_attributes) + json.root do + json.(taxonomy.root, *taxon_attributes) + json.taxons(taxonomy.root.children) do |taxon| + json.(taxon, *taxon_attributes) + end + end +end diff --git a/api/app/views/spree/api/taxonomies/index.json.jbuilder b/api/app/views/spree/api/taxonomies/index.json.jbuilder new file mode 100644 index 00000000000..3709de63589 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/index.json.jbuilder @@ -0,0 +1,6 @@ +json.taxonomies(@taxonomies) do |taxonomy| + json.partial!("spree/api/taxonomies/taxonomy", taxonomy: taxonomy) +end +json.count(@taxonomies.count) +json.current_page(@taxonomies.current_page) +json.pages(@taxonomies.total_pages) diff --git a/api/app/views/spree/api/taxonomies/index.v1.rabl b/api/app/views/spree/api/taxonomies/index.v1.rabl deleted file mode 100644 index 1d6d75893ef..00000000000 --- a/api/app/views/spree/api/taxonomies/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@taxonomies => :taxonomies) do - extends "spree/api/taxonomies/show" -end -node(:count) { @taxonomies.count } -node(:current_page) { @taxonomies.current_page } -node(:pages) { @taxonomies.total_pages } diff --git a/api/app/views/spree/api/taxonomies/jstree.json.jbuilder b/api/app/views/spree/api/taxonomies/jstree.json.jbuilder new file mode 100644 index 00000000000..1dbbd6ff29a --- /dev/null +++ b/api/app/views/spree/api/taxonomies/jstree.json.jbuilder @@ -0,0 +1,6 @@ +json.data @taxonomy.root.name +json.attr do + json.id @taxonomy.root.id + json.name @taxonomy.root.name +end +json.state "closed" diff --git a/api/app/views/spree/api/taxonomies/jstree.rabl b/api/app/views/spree/api/taxonomies/jstree.rabl deleted file mode 100644 index 01b25aa4ccd..00000000000 --- a/api/app/views/spree/api/taxonomies/jstree.rabl +++ /dev/null @@ -1,8 +0,0 @@ -object false -node(:data) { @taxonomy.root.name } -node(:attr) do - { :id => @taxonomy.root.id, - :name => @taxonomy.root.name - } -end -node(:state) { "closed" } diff --git a/api/app/views/spree/api/taxonomies/nested.v1.rabl b/api/app/views/spree/api/taxonomies/nested.v1.rabl deleted file mode 100644 index 312c29140a5..00000000000 --- a/api/app/views/spree/api/taxonomies/nested.v1.rabl +++ /dev/null @@ -1,11 +0,0 @@ -attributes *taxonomy_attributes - -child :root => :root do - attributes *taxon_attributes - - child :children => :taxons do - attributes *taxon_attributes - - extends "spree/api/taxons/taxons" - end -end diff --git a/api/app/views/spree/api/taxonomies/new.json.jbuilder b/api/app/views/spree/api/taxonomies/new.json.jbuilder new file mode 100644 index 00000000000..e1d88898807 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*taxonomy_attributes]) +json.required_attributes(required_fields_for(Spree::Taxonomy)) diff --git a/api/app/views/spree/api/taxonomies/new.v1.rabl b/api/app/views/spree/api/taxonomies/new.v1.rabl deleted file mode 100644 index a3dd32d4efd..00000000000 --- a/api/app/views/spree/api/taxonomies/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*taxonomy_attributes] } -node(:required_attributes) { required_fields_for(Spree::Taxonomy) } diff --git a/api/app/views/spree/api/taxonomies/show.json.jbuilder b/api/app/views/spree/api/taxonomies/show.json.jbuilder new file mode 100644 index 00000000000..dac36f65e12 --- /dev/null +++ b/api/app/views/spree/api/taxonomies/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/taxonomies/taxonomy", taxonomy: @taxonomy) diff --git a/api/app/views/spree/api/taxonomies/show.v1.rabl b/api/app/views/spree/api/taxonomies/show.v1.rabl deleted file mode 100644 index 37d2a1615b3..00000000000 --- a/api/app/views/spree/api/taxonomies/show.v1.rabl +++ /dev/null @@ -1,15 +0,0 @@ -object @taxonomy - -if params[:set] == 'nested' - extends "spree/api/taxonomies/nested" -else - attributes *taxonomy_attributes - - child :root => :root do - attributes *taxon_attributes - - child :children => :taxons do - attributes *taxon_attributes - end - end -end diff --git a/api/app/views/spree/api/taxons/_taxon.json.jbuilder b/api/app/views/spree/api/taxons/_taxon.json.jbuilder new file mode 100644 index 00000000000..88ff92e6a43 --- /dev/null +++ b/api/app/views/spree/api/taxons/_taxon.json.jbuilder @@ -0,0 +1,2 @@ +json.(taxon, *taxon_attributes) +json.taxons(taxon.children) { |taxon| json.(taxon, *taxon_attributes) } diff --git a/api/app/views/spree/api/taxons/_taxons.json.jbuilder b/api/app/views/spree/api/taxons/_taxons.json.jbuilder new file mode 100644 index 00000000000..96d8170ea65 --- /dev/null +++ b/api/app/views/spree/api/taxons/_taxons.json.jbuilder @@ -0,0 +1,4 @@ +json.taxons(taxon.children) do |taxon| + json.(taxon, *taxon_attributes) + json.partial!("spree/api/taxons/taxons", taxon: taxon) +end diff --git a/api/app/views/spree/api/taxons/index.json.jbuilder b/api/app/views/spree/api/taxons/index.json.jbuilder new file mode 100644 index 00000000000..8fa85e5ffb2 --- /dev/null +++ b/api/app/views/spree/api/taxons/index.json.jbuilder @@ -0,0 +1,11 @@ +json.count(@taxons.count) +json.total_count(@taxons.total_count) +json.current_page(@taxons.current_page) +json.per_page(@taxons.limit_value) +json.pages(@taxons.total_pages) +json.taxons(@taxons) do |taxon| + json.(taxon, *taxon_attributes) + unless params[:without_children] + json.partial!("spree/api/taxons/taxons", taxon: taxon) + end +end diff --git a/api/app/views/spree/api/taxons/index.v1.rabl b/api/app/views/spree/api/taxons/index.v1.rabl deleted file mode 100644 index c6e520cdb75..00000000000 --- a/api/app/views/spree/api/taxons/index.v1.rabl +++ /dev/null @@ -1,12 +0,0 @@ -object false -node(:count) { @taxons.count } -node(:total_count) { @taxons.total_count } -node(:current_page) { @taxons.current_page } -node(:per_page) { @taxons.limit_value } -node(:pages) { @taxons.total_pages } -child @taxons => :taxons do - attributes *taxon_attributes - unless params[:without_children] - extends "spree/api/taxons/taxons" - end -end diff --git a/api/app/views/spree/api/taxons/jstree.json.jbuilder b/api/app/views/spree/api/taxons/jstree.json.jbuilder new file mode 100644 index 00000000000..2962875f99a --- /dev/null +++ b/api/app/views/spree/api/taxons/jstree.json.jbuilder @@ -0,0 +1,8 @@ +json.array!(@taxon.children) do |taxon| + json.data taxon.name + json.attr do + json.id taxon.id + json.name taxon.name + end + json.state "closed" +end diff --git a/api/app/views/spree/api/taxons/jstree.rabl b/api/app/views/spree/api/taxons/jstree.rabl deleted file mode 100644 index aed500e0f36..00000000000 --- a/api/app/views/spree/api/taxons/jstree.rabl +++ /dev/null @@ -1,8 +0,0 @@ -collection @taxon.children, :object_root => false -node(:data) { |taxon| taxon.name } -node(:attr) do |taxon| - { :id => taxon.id, - :name => taxon.name - } -end -node(:state) { "closed" } diff --git a/api/app/views/spree/api/taxons/new.json.jbuilder b/api/app/views/spree/api/taxons/new.json.jbuilder new file mode 100644 index 00000000000..dce58bf133e --- /dev/null +++ b/api/app/views/spree/api/taxons/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*taxon_attributes]) +json.required_attributes(required_fields_for(Spree::Taxon)) diff --git a/api/app/views/spree/api/taxons/new.v1.rabl b/api/app/views/spree/api/taxons/new.v1.rabl deleted file mode 100644 index f85dbece9ea..00000000000 --- a/api/app/views/spree/api/taxons/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*taxon_attributes] } -node(:required_attributes) { required_fields_for(Spree::Taxon) } diff --git a/api/app/views/spree/api/taxons/show.json.jbuilder b/api/app/views/spree/api/taxons/show.json.jbuilder new file mode 100644 index 00000000000..acf20b0d7c0 --- /dev/null +++ b/api/app/views/spree/api/taxons/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/taxons/taxon", taxon: @taxon) diff --git a/api/app/views/spree/api/taxons/show.v1.rabl b/api/app/views/spree/api/taxons/show.v1.rabl deleted file mode 100644 index 37a1c1bd90d..00000000000 --- a/api/app/views/spree/api/taxons/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @taxon -attributes *taxon_attributes - -child :children => :taxons do - attributes *taxon_attributes -end diff --git a/api/app/views/spree/api/taxons/taxons.v1.rabl b/api/app/views/spree/api/taxons/taxons.v1.rabl deleted file mode 100644 index e7a1e4239e2..00000000000 --- a/api/app/views/spree/api/taxons/taxons.v1.rabl +++ /dev/null @@ -1,5 +0,0 @@ -child :children => :taxons do - attributes *taxon_attributes - - extends "spree/api/taxons/taxons" -end diff --git a/api/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder b/api/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder new file mode 100644 index 00000000000..a5d7db5f4dc --- /dev/null +++ b/api/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder @@ -0,0 +1,5 @@ +json.(transfer_item, *transfer_item_attributes) +json.variant do + json.partial!("spree/api/variants/small", variant: transfer_item.variant) + json.(transfer_item.variant, *transfer_item_variant_attributes) +end diff --git a/api/app/views/spree/api/transfer_items/show.json.jbuilder b/api/app/views/spree/api/transfer_items/show.json.jbuilder new file mode 100644 index 00000000000..d7f1545e36f --- /dev/null +++ b/api/app/views/spree/api/transfer_items/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/transfer_items/transfer_item", transfer_item: @transfer_item) diff --git a/api/app/views/spree/api/transfer_items/show.v1.rabl b/api/app/views/spree/api/transfer_items/show.v1.rabl deleted file mode 100644 index 062adc054a6..00000000000 --- a/api/app/views/spree/api/transfer_items/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @transfer_item -attributes *transfer_item_attributes -child(:variant) do - extends "spree/api/variants/small" - attributes *transfer_item_variant_attributes -end diff --git a/api/app/views/spree/api/users/_user.json.jbuilder b/api/app/views/spree/api/users/_user.json.jbuilder new file mode 100644 index 00000000000..9a69277da18 --- /dev/null +++ b/api/app/views/spree/api/users/_user.json.jbuilder @@ -0,0 +1,15 @@ +json.(user, *user_attributes) +json.bill_address do + if user.bill_address + json.partial!("spree/api/addresses/address", address: user.bill_address) + else + json.nil! + end +end +json.ship_address do + if user.ship_address + json.partial!("spree/api/addresses/address", address: user.ship_address) + else + json.nil! + end +end diff --git a/api/app/views/spree/api/users/index.json.jbuilder b/api/app/views/spree/api/users/index.json.jbuilder new file mode 100644 index 00000000000..8df9fb496b1 --- /dev/null +++ b/api/app/views/spree/api/users/index.json.jbuilder @@ -0,0 +1,6 @@ +json.users(@users) do |user| + json.partial!("spree/api/users/user", user: user) +end +json.count(@users.count) +json.current_page(@users.current_page) +json.pages(@users.total_pages) diff --git a/api/app/views/spree/api/users/index.v1.rabl b/api/app/views/spree/api/users/index.v1.rabl deleted file mode 100644 index ff8da9768fb..00000000000 --- a/api/app/views/spree/api/users/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@users => :users) do - extends "spree/api/users/show" -end -node(:count) { @users.count } -node(:current_page) { @users.current_page } -node(:pages) { @users.total_pages } diff --git a/api/app/views/spree/api/users/new.json.jbuilder b/api/app/views/spree/api/users/new.json.jbuilder new file mode 100644 index 00000000000..79154283fbb --- /dev/null +++ b/api/app/views/spree/api/users/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*user_attributes]) +json.required_attributes(required_fields_for(Spree.user_class)) diff --git a/api/app/views/spree/api/users/new.v1.rabl b/api/app/views/spree/api/users/new.v1.rabl deleted file mode 100644 index f3e36dd7d33..00000000000 --- a/api/app/views/spree/api/users/new.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object false -node(:attributes) { [*user_attributes] } -node(:required_attributes) { required_fields_for(Spree.user_class) } diff --git a/api/app/views/spree/api/users/show.json.jbuilder b/api/app/views/spree/api/users/show.json.jbuilder new file mode 100644 index 00000000000..9490ace2f31 --- /dev/null +++ b/api/app/views/spree/api/users/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/users/user", user: @user) diff --git a/api/app/views/spree/api/users/show.v1.rabl b/api/app/views/spree/api/users/show.v1.rabl deleted file mode 100644 index 4448a3e7ed6..00000000000 --- a/api/app/views/spree/api/users/show.v1.rabl +++ /dev/null @@ -1,10 +0,0 @@ -object @user - -attributes *user_attributes -child(:bill_address => :bill_address) do - extends "spree/api/addresses/show" -end - -child(:ship_address => :ship_address) do - extends "spree/api/addresses/show" -end \ No newline at end of file diff --git a/api/app/views/spree/api/variants/_big.json.jbuilder b/api/app/views/spree/api/variants/_big.json.jbuilder new file mode 100644 index 00000000000..1eaa38ecfc9 --- /dev/null +++ b/api/app/views/spree/api/variants/_big.json.jbuilder @@ -0,0 +1,13 @@ +json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do + json.(variant, *variant_attributes) + json.partial!("spree/api/variants/small", variant: variant) + json.total_on_hand(variant.total_on_hand) + json.variant_properties(variant.variant_properties) do |variant_property| + json.(variant_property, *variant_property_attributes) + end + json.stock_items(variant.stock_items.accessible_by(current_ability)) do |stock_item| + json.(stock_item, :id, :count_on_hand, :stock_location_id, :backorderable) + json.available stock_item.available? + json.stock_location_name(stock_item.stock_location.name) + end +end diff --git a/api/app/views/spree/api/variants/_small.json.jbuilder b/api/app/views/spree/api/variants/_small.json.jbuilder new file mode 100644 index 00000000000..a6749610c5c --- /dev/null +++ b/api/app/views/spree/api/variants/_small.json.jbuilder @@ -0,0 +1,16 @@ +json.cache! [I18n.locale, variant] do + json.(variant, *variant_attributes) + json.display_price(variant.display_price.to_s) + json.options_text(variant.options_text) + json.track_inventory(variant.should_track_inventory?) + json.in_stock(variant.in_stock?) + json.is_backorderable(variant.is_backorderable?) + json.total_on_hand(variant.total_on_hand) + json.is_destroyed(variant.destroyed?) + json.option_values(variant.option_values) do |option_value| + json.(option_value, *option_value_attributes) + end + json.images(variant.images) do |image| + json.partial!("spree/api/images/image", image: image) + end +end diff --git a/api/app/views/spree/api/variants/big.v1.rabl b/api/app/views/spree/api/variants/big.v1.rabl deleted file mode 100644 index 4fd6d94a022..00000000000 --- a/api/app/views/spree/api/variants/big.v1.rabl +++ /dev/null @@ -1,20 +0,0 @@ -object @variant -attributes *variant_attributes - -cache [I18n.locale, Spree::StockLocation.accessible_by(current_ability).pluck(:id).sort.join(":"), 'big_variant', root_object] - -extends "spree/api/variants/small" - -node :total_on_hand do - root_object.total_on_hand -end - -child :variant_properties => :variant_properties do - attributes *variant_property_attributes -end - -child(root_object.stock_items.accessible_by(current_ability) => :stock_items) do - attributes :id, :count_on_hand, :stock_location_id, :backorderable - attribute :available? => :available - node(:stock_location_name) { |si| si.stock_location.name } -end diff --git a/api/app/views/spree/api/variants/index.json.jbuilder b/api/app/views/spree/api/variants/index.json.jbuilder new file mode 100644 index 00000000000..48e561ed614 --- /dev/null +++ b/api/app/views/spree/api/variants/index.json.jbuilder @@ -0,0 +1,7 @@ +json.count(@variants.count) +json.total_count(@variants.total_count) +json.current_page(@variants.current_page) +json.pages(@variants.total_pages) +json.variants(@variants) do |variant| + json.partial!("spree/api/variants/big", variant: variant) +end diff --git a/api/app/views/spree/api/variants/index.v1.rabl b/api/app/views/spree/api/variants/index.v1.rabl deleted file mode 100644 index 5c9485da3ec..00000000000 --- a/api/app/views/spree/api/variants/index.v1.rabl +++ /dev/null @@ -1,9 +0,0 @@ -object false -node(:count) { @variants.count } -node(:total_count) { @variants.total_count } -node(:current_page) { @variants.current_page } -node(:pages) { @variants.total_pages } - -child(@variants => :variants) do - extends "spree/api/variants/big" -end diff --git a/api/app/views/spree/api/variants/new.json.jbuilder b/api/app/views/spree/api/variants/new.json.jbuilder new file mode 100644 index 00000000000..a779203e8aa --- /dev/null +++ b/api/app/views/spree/api/variants/new.json.jbuilder @@ -0,0 +1,2 @@ +json.attributes([*variant_attributes]) +json.required_attributes([]) diff --git a/api/app/views/spree/api/variants/new.v1.rabl b/api/app/views/spree/api/variants/new.v1.rabl deleted file mode 100644 index 26cf41db3b2..00000000000 --- a/api/app/views/spree/api/variants/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -node(:attributes) { [*variant_attributes] } -node(:required_attributes) { [] } diff --git a/api/app/views/spree/api/variants/show.json.jbuilder b/api/app/views/spree/api/variants/show.json.jbuilder new file mode 100644 index 00000000000..ed96ac719cc --- /dev/null +++ b/api/app/views/spree/api/variants/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/variants/big", variant: @variant) diff --git a/api/app/views/spree/api/variants/show.v1.rabl b/api/app/views/spree/api/variants/show.v1.rabl deleted file mode 100644 index b097e25551d..00000000000 --- a/api/app/views/spree/api/variants/show.v1.rabl +++ /dev/null @@ -1,3 +0,0 @@ -object @variant -cache [I18n.locale, @current_user_roles.include?('admin'), 'show', root_object] -extends "spree/api/variants/big" diff --git a/api/app/views/spree/api/variants/small.v1.rabl b/api/app/views/spree/api/variants/small.v1.rabl deleted file mode 100644 index d6c025ba05d..00000000000 --- a/api/app/views/spree/api/variants/small.v1.rabl +++ /dev/null @@ -1,17 +0,0 @@ -cache [I18n.locale, 'small_variant', root_object] - -attributes *variant_attributes - -node(:display_price) { |p| p.display_price.to_s } -node(:options_text) { |v| v.options_text } -node(:track_inventory) { |v| v.should_track_inventory? } -node(:in_stock) { |v| v.in_stock? } -node(:is_backorderable) { |v| v.is_backorderable? } -node(:total_on_hand) { |v| v.total_on_hand } -node(:is_destroyed) { |v| v.destroyed? } - -child :option_values => :option_values do - attributes *option_value_attributes -end - -child(:images => :images) { extends "spree/api/images/show" } diff --git a/api/app/views/spree/api/zones/_zone.json.jbuilder b/api/app/views/spree/api/zones/_zone.json.jbuilder new file mode 100644 index 00000000000..5a61e09561b --- /dev/null +++ b/api/app/views/spree/api/zones/_zone.json.jbuilder @@ -0,0 +1,4 @@ +json.(zone, :id, :name, :description) +json.zone_members(zone.zone_members) do |zone_member| + json.(zone_member, :id, :name, :zoneable_type, :zoneable_id) +end diff --git a/api/app/views/spree/api/zones/index.json.jbuilder b/api/app/views/spree/api/zones/index.json.jbuilder new file mode 100644 index 00000000000..a209f895732 --- /dev/null +++ b/api/app/views/spree/api/zones/index.json.jbuilder @@ -0,0 +1,6 @@ +json.zones(@zones) do |zone| + json.partial!("spree/api/zones/zone", zone: zone) +end +json.count(@zones.count) +json.current_page(@zones.current_page) +json.pages(@zones.total_pages) diff --git a/api/app/views/spree/api/zones/index.v1.rabl b/api/app/views/spree/api/zones/index.v1.rabl deleted file mode 100644 index f837124a2c4..00000000000 --- a/api/app/views/spree/api/zones/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@zones => :zones) do - extends 'spree/api/zones/show' -end -node(:count) { @zones.count } -node(:current_page) { @zones.current_page } -node(:pages) { @zones.total_pages } diff --git a/api/app/views/spree/api/zones/show.json.jbuilder b/api/app/views/spree/api/zones/show.json.jbuilder new file mode 100644 index 00000000000..c6f16d5add4 --- /dev/null +++ b/api/app/views/spree/api/zones/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/zones/zone", zone: @zone) diff --git a/api/app/views/spree/api/zones/show.v1.rabl b/api/app/views/spree/api/zones/show.v1.rabl deleted file mode 100644 index c8c58d469c7..00000000000 --- a/api/app/views/spree/api/zones/show.v1.rabl +++ /dev/null @@ -1,6 +0,0 @@ -object @zone -attributes :id, :name, :description - -child :zone_members => :zone_members do - attributes :id, :name, :zoneable_type, :zoneable_id -end diff --git a/api/lib/spree/api.rb b/api/lib/spree/api.rb index 889152191d3..77f0b87f449 100644 --- a/api/lib/spree/api.rb +++ b/api/lib/spree/api.rb @@ -1,6 +1,5 @@ require 'spree/core' -require 'rabl' require 'responders' module Spree diff --git a/api/lib/spree/api/engine.rb b/api/lib/spree/api/engine.rb index 0aa431aa30f..6e77b6c9e37 100644 --- a/api/lib/spree/api/engine.rb +++ b/api/lib/spree/api/engine.rb @@ -6,16 +6,6 @@ class Engine < Rails::Engine isolate_namespace Spree engine_name 'spree_api' - Rabl.configure do |config| - config.include_json_root = false - config.include_child_root = false - - # Motivation here it make it call as_json when rendering timestamps - # and therefore display miliseconds. Otherwise it would fall to - # JSON.dump which doesn't display the miliseconds - config.json_engine = ActiveSupport::JSON - end - initializer "spree.api.environment", before: :load_config_initializers do |_app| Spree::Api::Config = Spree::ApiConfiguration.new end diff --git a/api/lib/spree_api.rb b/api/lib/spree_api.rb index ab9bf2f954e..d8f6ec9ff65 100644 --- a/api/lib/spree_api.rb +++ b/api/lib/spree_api.rb @@ -1,3 +1,4 @@ require 'spree/api' require 'spree/api/responders' require 'versioncake' +require 'jbuilder' diff --git a/api/solidus_api.gemspec b/api/solidus_api.gemspec index ebeb84daa37..d9b29103619 100644 --- a/api/solidus_api.gemspec +++ b/api/solidus_api.gemspec @@ -21,8 +21,8 @@ Gem::Specification.new do |gem| gem.required_rubygems_version = '>= 1.8.23' gem.add_dependency 'solidus_core', gem.version - gem.add_dependency 'rabl', '0.13.1' gem.add_dependency 'versioncake', '~> 3.0' gem.add_dependency 'responders' + gem.add_dependency 'jbuilder', '~> 2.6' gem.add_dependency 'kaminari', '>= 0.17', '< 2.0' end diff --git a/api/spec/requests/spree/api/taxons_controller_spec.rb b/api/spec/requests/spree/api/taxons_controller_spec.rb index 502b5ff5bc3..8a078e80b66 100644 --- a/api/spec/requests/spree/api/taxons_controller_spec.rb +++ b/api/spec/requests/spree/api/taxons_controller_spec.rb @@ -120,6 +120,31 @@ module Spree delete spree.api_taxonomy_taxon_path(taxonomy, taxon.id) assert_unauthorized! end + + context "with caching enabled" do + let!(:product) { create(:product, taxons: [taxon]) } + + before do + ActionController::Base.perform_caching = true + end + + it "handles exclude_data correctly" do + get spree.api_taxon_products_path, params: { id: taxon.id, simple: true } + expect(response).to be_success + simple_response = json_response + + get spree.api_taxon_products_path, params: { id: taxon.id } + expect(response).to be_success + full_response = json_response + + expect(simple_response["products"][0]["description"]).to be_nil + expect(full_response["products"][0]["description"]).not_to be_nil + end + + after do + ActionController::Base.perform_caching = false + end + end end context "as an admin" do diff --git a/api/spec/test_views/spree/api/widgets/_widget.json.jbuilder b/api/spec/test_views/spree/api/widgets/_widget.json.jbuilder new file mode 100644 index 00000000000..01468d52026 --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/_widget.json.jbuilder @@ -0,0 +1 @@ +json.(widget, :id, :name, :position) diff --git a/api/spec/test_views/spree/api/widgets/index.json.jbuilder b/api/spec/test_views/spree/api/widgets/index.json.jbuilder new file mode 100644 index 00000000000..a0b8cd990bc --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/index.json.jbuilder @@ -0,0 +1,7 @@ + +json.widgets(@collection) do |widget| + json.partial!("spree/api/widgets/widget", widget: widget) +end +json.count @collection.count +json.current_page (params[:page] or 1) +json.pages @collection.total_pages diff --git a/api/spec/test_views/spree/api/widgets/index.v1.rabl b/api/spec/test_views/spree/api/widgets/index.v1.rabl deleted file mode 100644 index 403d65ea505..00000000000 --- a/api/spec/test_views/spree/api/widgets/index.v1.rabl +++ /dev/null @@ -1,7 +0,0 @@ -object false -child(@collection => :widgets) do - extends "spree/api/widgets/show" -end -node(:count) { @collection.count } -node(:current_page) { params[:page] || 1 } -node(:pages) { @collection.total_pages } diff --git a/api/spec/test_views/spree/api/widgets/new.json.jbuilder b/api/spec/test_views/spree/api/widgets/new.json.jbuilder new file mode 100644 index 00000000000..487b7fa90b9 --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/new.json.jbuilder @@ -0,0 +1 @@ +json.attributes [:name] diff --git a/api/spec/test_views/spree/api/widgets/new.v1.rabl b/api/spec/test_views/spree/api/widgets/new.v1.rabl deleted file mode 100644 index f1a3ddd5fc8..00000000000 --- a/api/spec/test_views/spree/api/widgets/new.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object false -node(:attributes) { [:name] } diff --git a/api/spec/test_views/spree/api/widgets/show.json.jbuilder b/api/spec/test_views/spree/api/widgets/show.json.jbuilder new file mode 100644 index 00000000000..ef552cf43ad --- /dev/null +++ b/api/spec/test_views/spree/api/widgets/show.json.jbuilder @@ -0,0 +1 @@ +json.partial!("spree/api/widgets/widget", widget: @object) diff --git a/api/spec/test_views/spree/api/widgets/show.v1.rabl b/api/spec/test_views/spree/api/widgets/show.v1.rabl deleted file mode 100644 index 7e5b6a7262a..00000000000 --- a/api/spec/test_views/spree/api/widgets/show.v1.rabl +++ /dev/null @@ -1,2 +0,0 @@ -object @object -attributes :id, :name, :position