mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 03:46:39 +08:00
Add archived label for inventories and item in item card relationships and modal [SCI-9122] (#6884)
This commit is contained in:
parent
3b97571777
commit
e31448c8e7
5 changed files with 19 additions and 10 deletions
|
@ -90,8 +90,8 @@ class RepositoryRowConnectionsController < ApplicationController
|
|||
.page(params[:page] || 1)
|
||||
.per(Constants::SEARCH_LIMIT)
|
||||
render json: {
|
||||
data: repositories.select(:id, :name)
|
||||
.map { |repository| { id: repository.id, name: repository.name } },
|
||||
data: repositories.select(:id, :name, :archived)
|
||||
.map { |repository| { id: repository.id, name: repository.name_with_label } },
|
||||
next_page: repositories.next_page
|
||||
}
|
||||
end
|
||||
|
@ -103,8 +103,9 @@ class RepositoryRowConnectionsController < ApplicationController
|
|||
.page(params[:page] || 1)
|
||||
.per(Constants::SEARCH_LIMIT)
|
||||
render json: {
|
||||
data: repository_rows.select(:id, :name)
|
||||
.map { |repository| { id: repository.id, name: repository.name } },
|
||||
data: repository_rows.select(:id, :name, :archived, :repository_id)
|
||||
.preload(:repository)
|
||||
.map { |row| { id: row.id, name: row.name_with_label } },
|
||||
next_page: repository_rows.next_page
|
||||
}
|
||||
end
|
||||
|
|
|
@ -50,9 +50,9 @@ module ArchivableModel
|
|||
|
||||
def name_with_label
|
||||
raise NotImplementedError, "Archivable model must implement the '.archived_branch?' method!" unless respond_to?(:archived_branch?)
|
||||
return "#{I18n.t('labels.archived')} #{parent&.name || name}" if archived_branch?
|
||||
return "#{I18n.t('labels.archived')} #{name || parent&.name}" if archived_branch?
|
||||
|
||||
parent&.name || name
|
||||
name || parent&.name
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -275,6 +275,10 @@ class Repository < RepositoryBase
|
|||
.destroy_all
|
||||
end
|
||||
|
||||
def archived_branch?
|
||||
archived?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sync_name_with_snapshots
|
||||
|
|
|
@ -192,4 +192,8 @@ class RepositoryRow < ApplicationRecord
|
|||
def relationship_count
|
||||
parent_connections.size + child_connections.size
|
||||
end
|
||||
|
||||
def archived_branch?
|
||||
archived?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,9 +55,9 @@ json.relationships do
|
|||
json.array! @repository_row.parent_repository_rows.preload(:repository).each do |parent|
|
||||
json.id parent.id
|
||||
json.code parent.code
|
||||
json.name parent.name
|
||||
json.name parent.name_with_label
|
||||
json.path repository_repository_row_path(parent.repository, parent)
|
||||
json.repository_name parent.repository.name
|
||||
json.repository_name parent.repository.name_with_label
|
||||
json.repository_path repository_path(parent.repository)
|
||||
json.unlink_path repository_repository_row_repository_row_connection_path(parent.repository,
|
||||
parent,
|
||||
|
@ -69,9 +69,9 @@ json.relationships do
|
|||
json.array! @repository_row.child_repository_rows.preload(:repository).each do |child|
|
||||
json.id child.id
|
||||
json.code child.code
|
||||
json.name child.name
|
||||
json.name child.name_with_label
|
||||
json.path repository_repository_row_path(child.repository, child)
|
||||
json.repository_name child.repository.name
|
||||
json.repository_name child.repository.name_with_label
|
||||
json.repository_path repository_path(child.repository)
|
||||
json.unlink_path repository_repository_row_repository_row_connection_path(child.repository,
|
||||
child,
|
||||
|
|
Loading…
Add table
Reference in a new issue