2018-08-08 22:55:51 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class InventoryColumnSerializer < ActiveModel::Serializer
|
|
|
|
type :inventory_columns
|
|
|
|
attributes :name, :data_type
|
|
|
|
has_many :repository_list_items, key: :inventory_list_items,
|
|
|
|
serializer: InventoryListItemSerializer,
|
2018-10-06 19:47:41 +08:00
|
|
|
class_name: 'RepositoryListItem',
|
|
|
|
if: -> { object.data_type == 'RepositoryListValue' &&
|
|
|
|
!instance_options[:hide_list_items] }
|
2018-08-08 22:55:51 +08:00
|
|
|
|
|
|
|
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
|