Move list-type column includes to param, unify naming [SCI-6738] (#4036)

* Add default includes for inventory columns with lists [SCI-6738]

* Move list-type column includes to param, unify naming [SCI-6738]
This commit is contained in:
artoscinote 2022-04-20 11:07:15 +02:00 committed by GitHub
parent 54474b2bba
commit e3cbf5903a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -15,6 +15,8 @@ module Api
columns = @inventory.repository_columns
.includes(:repository_list_items)
.includes(:repository_status_items)
.includes(:repository_checklist_items)
.includes(:repository_stock_unit_items)
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: columns,
@ -34,7 +36,7 @@ module Api
def show
render jsonapi: @inventory_column,
serializer: InventoryColumnSerializer,
include: %i(inventory_list_items repository_stock_unit_items)
include: include_params
end
def update
@ -87,6 +89,15 @@ module Api
end
inventory_column_params[:attributes]
end
def permitted_includes
%w(
inventory_list_items
inventory_checklist_items
inventory_status_items
inventory_stock_unit_items
)
end
end
end
end

View file

@ -22,7 +22,7 @@ module Api
!instance_options[:hide_list_items]
end)
has_many :repository_status_items,
key: :repository_status_items,
key: :inventory_status_items,
serializer: InventoryStatusItemSerializer,
class_name: 'RepositoryStatusItem',
if: (lambda do
@ -30,7 +30,7 @@ module Api
!instance_options[:hide_list_items]
end)
has_many :repository_stock_unit_items,
key: :repository_stock_unit_items,
key: :inventory_stock_unit_items,
serializer: InventoryStockUnitItemSerializer,
class_name: 'RepositoryStockUnitItem',
if: (lambda do