mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
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:
parent
54474b2bba
commit
e3cbf5903a
2 changed files with 14 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue