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
|
2024-01-11 18:44:14 +08:00
|
|
|
json.is_snapshot @repository.is_a?(RepositorySnapshot)
|
2023-10-12 20:43:17 +08:00
|
|
|
end
|
2023-12-12 00:05:54 +08:00
|
|
|
json.notification @notification
|
2023-10-12 20:43:17 +08:00
|
|
|
|
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)
|
2024-01-04 16:47:40 +08:00
|
|
|
json.can_connect_rows can_connect_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-12-11 17:43:47 +08:00
|
|
|
json.row_connections do
|
|
|
|
json.inventories_url repository_row_connections_repositories_url
|
2024-01-15 16:41:52 +08:00
|
|
|
json.inventory_items_url repository_rows_repository_repository_row_repository_row_connections_path(@repository,
|
|
|
|
@repository_row)
|
2023-12-11 17:43:47 +08:00
|
|
|
json.create_url repository_repository_row_repository_row_connections_url(@repository, @repository_row)
|
|
|
|
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-11-14 21:04:46 +08:00
|
|
|
json.relationships do
|
|
|
|
json.parents_count @repository_row.parent_connections_count
|
|
|
|
json.children_count @repository_row.child_connections_count
|
|
|
|
json.parents do
|
2023-12-11 17:43:47 +08:00
|
|
|
json.array! @repository_row.parent_repository_rows.preload(:repository).each do |parent|
|
2024-01-03 21:15:30 +08:00
|
|
|
json.id parent.id
|
2023-11-14 21:04:46 +08:00
|
|
|
json.code parent.code
|
2024-01-11 00:23:15 +08:00
|
|
|
json.name parent.name_with_label
|
2023-11-14 21:04:46 +08:00
|
|
|
json.path repository_repository_row_path(parent.repository, parent)
|
2024-01-11 00:23:15 +08:00
|
|
|
json.repository_name parent.repository.name_with_label
|
2023-11-14 21:04:46 +08:00
|
|
|
json.repository_path repository_path(parent.repository)
|
2024-01-03 21:15:30 +08:00
|
|
|
json.unlink_path repository_repository_row_repository_row_connection_path(parent.repository,
|
|
|
|
parent,
|
|
|
|
@repository_row.parent_connections
|
|
|
|
.find_by(parent: parent))
|
2023-11-14 21:04:46 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
json.children do
|
2023-12-11 17:43:47 +08:00
|
|
|
json.array! @repository_row.child_repository_rows.preload(:repository).each do |child|
|
2024-01-03 21:15:30 +08:00
|
|
|
json.id child.id
|
2023-11-14 21:04:46 +08:00
|
|
|
json.code child.code
|
2024-01-11 00:23:15 +08:00
|
|
|
json.name child.name_with_label
|
2023-11-14 21:04:46 +08:00
|
|
|
json.path repository_repository_row_path(child.repository, child)
|
2024-01-11 00:23:15 +08:00
|
|
|
json.repository_name child.repository.name_with_label
|
2023-11-14 21:04:46 +08:00
|
|
|
json.repository_path repository_path(child.repository)
|
2024-01-03 21:15:30 +08:00
|
|
|
json.unlink_path repository_repository_row_repository_row_connection_path(child.repository,
|
|
|
|
child,
|
|
|
|
@repository_row.child_connections
|
|
|
|
.find_by(child: child))
|
2023-11-14 21:04:46 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
2023-11-14 21:04:46 +08:00
|
|
|
|
|
|
|
json.icons do
|
|
|
|
json.delimiter_path asset_path 'icon_small/navigate_next.svg'
|
|
|
|
json.unlink_path asset_path 'icon_small/unlink.svg'
|
2023-12-12 00:05:54 +08:00
|
|
|
json.notification_path asset_path 'icon_small/info.svg'
|
2023-11-14 21:04:46 +08:00
|
|
|
end
|