Class: Spree::Api::V3::Admin::TranslatableResourcesController
- Inherits:
-
Admin::BaseController
- Object
- Admin::BaseController
- Spree::Api::V3::Admin::TranslatableResourcesController
- Defined in:
- app/controllers/spree/api/v3/admin/translatable_resources_controller.rb
Overview
Self-describing discovery of every translatable resource and its translatable fields (the Spree.translatable_resources registry made public). Lets the dashboard render translation editors and the centralized translations grid generically, with no per-model code.
Constant Summary collapse
- READABLE_RESOURCE_TYPES =
Public resource types with a dedicated nested read route (
…/:id/translations). Other registered types are writable via the batch endpoint and readable inline (e.g. option values are returned as children of an option type), so the dashboard must not GET a standalone matrix for them. Keep in sync with the:translatableroute concern mounts inspree/api/config/routes.rb. %w[product category option_type].freeze
Instance Method Summary collapse
-
#index ⇒ Object
GET /api/v3/admin/translatable_resources.
Instance Method Details
#index ⇒ Object
GET /api/v3/admin/translatable_resources
21 22 23 24 25 26 27 |
# File 'app/controllers/spree/api/v3/admin/translatable_resources_controller.rb', line 21 def index data = Spree::Translations.registry.map do |entry| entry.merge('readable' => READABLE_RESOURCE_TYPES.include?(entry['resource_type'])) end render json: { data: data } end |