2023-09-18 22:24:07 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-10-27 16:31:38 +08:00
|
|
|
json.id @repository_row.id
|
2023-10-12 20:43:17 +08:00
|
|
|
json.repository do
|
|
|
|
json.id @repository.id
|
|
|
|
json.name @repository.name
|
|
|
|
end
|
|
|
|
|
2023-10-16 23:43:53 +08:00
|
|
|
json.update_path update_cell_repository_repository_row_path(@repository, @repository_row)
|
2023-10-19 18:59:45 +08:00
|
|
|
|
2023-09-27 15:55:53 +08:00
|
|
|
json.permissions do
|
2023-11-22 21:53:08 +08:00
|
|
|
json.can_export_repository_stock can_export_repository_stock?(@repository)
|
2023-11-23 18:11:43 +08:00
|
|
|
json.can_manage can_manage_repository_rows?(@repository) if @repository.is_a?(Repository)
|
2023-09-27 15:55:53 +08:00
|
|
|
end
|
2023-10-12 21:46:13 +08:00
|
|
|
|
|
|
|
json.actions do
|
|
|
|
if @my_module.present?
|
|
|
|
json.assign_repository_row do
|
|
|
|
json.assign_url my_module_repositories_path(@my_module.id)
|
|
|
|
json.disabled @my_module_assign_error.present?
|
|
|
|
end
|
|
|
|
end
|
2023-10-26 18:59:11 +08:00
|
|
|
json.direct_file_upload_path rails_direct_uploads_url
|
2023-10-30 16:47:10 +08:00
|
|
|
if @repository_row.has_stock?
|
|
|
|
json.stock_value_url edit_repository_stock_repository_repository_row_url(@repository, @repository_row)
|
|
|
|
elsif @repository.has_stock_management?
|
|
|
|
json.stock_value_url new_repository_stock_repository_repository_row_url(@repository, @repository_row)
|
2023-10-27 16:31:38 +08:00
|
|
|
end
|
2023-10-12 21:46:13 +08:00
|
|
|
end
|
|
|
|
|
2023-09-18 22:24:07 +08:00
|
|
|
json.default_columns do
|
|
|
|
json.name @repository_row.name
|
|
|
|
json.code @repository_row.code
|
2023-10-12 21:26:41 +08:00
|
|
|
json.added_on I18n.l(@repository_row.created_at, format: :full)
|
2023-09-18 22:24:07 +08:00
|
|
|
json.added_by @repository_row.created_by&.full_name
|
|
|
|
json.archived @repository_row.archived?
|
2023-10-16 16:51:08 +08:00
|
|
|
if @repository_row.archived?
|
|
|
|
json.archived_on I18n.l(@repository_row.archived_on, format: :full)
|
|
|
|
json.archived_by @repository_row.archived_by
|
|
|
|
end
|
2023-09-18 22:24:07 +08:00
|
|
|
end
|
2023-10-13 15:51:50 +08:00
|
|
|
|
2023-09-18 22:24:07 +08:00
|
|
|
json.custom_columns do
|
2023-10-16 22:38:43 +08:00
|
|
|
json.array! repository_columns_ordered_by_state(@repository_row.repository).each do |repository_column|
|
2023-10-13 15:51:50 +08:00
|
|
|
repository_cell = @repository_row.repository_cells.find_by(repository_column: repository_column)
|
2023-10-24 21:49:37 +08:00
|
|
|
|
2023-10-25 19:47:06 +08:00
|
|
|
options = case repository_column.data_type
|
2023-10-24 21:49:37 +08:00
|
|
|
when 'RepositoryListValue'
|
|
|
|
{
|
2023-10-25 19:47:06 +08:00
|
|
|
options_path: items_repository_repository_columns_list_column_path(@repository, repository_column)
|
2023-10-24 21:49:37 +08:00
|
|
|
}
|
|
|
|
when 'RepositoryStatusValue'
|
|
|
|
{
|
2023-10-25 19:47:06 +08:00
|
|
|
options_path: items_repository_repository_columns_status_column_path(@repository, repository_column)
|
2023-10-24 21:49:37 +08:00
|
|
|
}
|
|
|
|
when 'RepositoryChecklistValue'
|
|
|
|
{
|
2023-10-25 19:47:06 +08:00
|
|
|
options_path: items_repository_repository_columns_checklist_column_path(@repository, repository_column)
|
2023-10-24 21:49:37 +08:00
|
|
|
}
|
2023-11-24 00:45:50 +08:00
|
|
|
when 'RepositoryNumberValue'
|
|
|
|
{
|
|
|
|
decimals: repository_column.metadata.fetch(
|
|
|
|
'decimals', Constants::REPOSITORY_NUMBER_TYPE_DEFAULT_DECIMALS
|
|
|
|
).to_i
|
|
|
|
}
|
2023-10-24 21:49:37 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
options_path: ''
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-10-13 15:51:50 +08:00
|
|
|
if repository_cell
|
2023-10-27 16:31:38 +08:00
|
|
|
json.merge! serialize_repository_cell_value(
|
|
|
|
repository_cell, @repository.team, @repository, reminders_enabled: @reminders_present
|
|
|
|
).merge(
|
|
|
|
repository_cell.repository_column.as_json(only: %i(id name data_type))
|
2023-10-24 21:49:37 +08:00
|
|
|
).merge(options)
|
2023-10-13 15:51:50 +08:00
|
|
|
else
|
2023-10-24 21:49:37 +08:00
|
|
|
json.merge! repository_column.as_json(only: %i(id name data_type)).merge(options)
|
2023-10-13 15:51:50 +08:00
|
|
|
end
|
2023-09-18 22:24:07 +08:00
|
|
|
end
|
|
|
|
end
|
2023-09-19 21:37:01 +08:00
|
|
|
|
|
|
|
json.assigned_modules do
|
2023-09-25 14:29:54 +08:00
|
|
|
json.total_assigned_size @assigned_modules.size
|
2023-09-19 21:37:01 +08:00
|
|
|
json.viewable_modules do
|
|
|
|
json.array! @viewable_modules do |my_module|
|
2023-09-27 15:36:23 +08:00
|
|
|
json.merge! serialize_assigned_my_module_value(my_module)
|
2023-09-19 21:37:01 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|