mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-31 04:32:06 +08:00
Update CREATE, PATCH, DELETE inventory_column endpoints
This commit is contained in:
parent
6625b4019e
commit
9e78de6ef2
3 changed files with 7 additions and 13 deletions
|
@ -24,6 +24,7 @@ module Api
|
|||
@inventory.repository_columns.create!(inventory_column_params)
|
||||
render jsonapi: inventory_column,
|
||||
serializer: InventoryColumnSerializer,
|
||||
hide_list_items: true,
|
||||
status: :created
|
||||
end
|
||||
|
||||
|
@ -37,7 +38,8 @@ module Api
|
|||
@inventory_column.attributes = update_inventory_column_params
|
||||
if @inventory_column.changed? && @inventory_column.save!
|
||||
render jsonapi: @inventory_column,
|
||||
serializer: InventoryColumnSerializer
|
||||
serializer: InventoryColumnSerializer,
|
||||
hide_list_items: true
|
||||
else
|
||||
render body: nil
|
||||
end
|
||||
|
@ -92,6 +94,10 @@ module Api
|
|||
raise ActionController::BadRequest,
|
||||
'Object ID mismatch in URL and request body'
|
||||
end
|
||||
if params.require(:data).require(:attributes).include?(:data_type)
|
||||
raise ActionController::BadRequest,
|
||||
'Update of data_type attribute is not allowed'
|
||||
end
|
||||
inventory_column_params[:attributes]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,12 +10,6 @@ module Api
|
|||
class_name: 'RepositoryListItem',
|
||||
if: -> { object.data_type == 'RepositoryListValue' &&
|
||||
!instance_options[:hide_list_items] }
|
||||
|
||||
def data_type
|
||||
type_id = RepositoryColumn
|
||||
.data_types[object.data_type]
|
||||
I18n.t("api.v1.inventory_data_types.t#{type_id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1943,12 +1943,6 @@ en:
|
|||
status_ok: "Ok"
|
||||
expired_token: "Token is expired"
|
||||
invalid_token: "Token is invalid"
|
||||
v1:
|
||||
inventory_data_types:
|
||||
t0: "text"
|
||||
t1: "date"
|
||||
t2: "list"
|
||||
t3: "file"
|
||||
|
||||
Add: "Add"
|
||||
Asset: "File"
|
||||
|
|
Loading…
Reference in a new issue