mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 13:28:53 +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)
|
.page(params[:page] || 1)
|
||||||
.per(Constants::SEARCH_LIMIT)
|
.per(Constants::SEARCH_LIMIT)
|
||||||
render json: {
|
render json: {
|
||||||
data: repositories.select(:id, :name)
|
data: repositories.select(:id, :name, :archived)
|
||||||
.map { |repository| { id: repository.id, name: repository.name } },
|
.map { |repository| { id: repository.id, name: repository.name_with_label } },
|
||||||
next_page: repositories.next_page
|
next_page: repositories.next_page
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -103,8 +103,9 @@ class RepositoryRowConnectionsController < ApplicationController
|
||||||
.page(params[:page] || 1)
|
.page(params[:page] || 1)
|
||||||
.per(Constants::SEARCH_LIMIT)
|
.per(Constants::SEARCH_LIMIT)
|
||||||
render json: {
|
render json: {
|
||||||
data: repository_rows.select(:id, :name)
|
data: repository_rows.select(:id, :name, :archived, :repository_id)
|
||||||
.map { |repository| { id: repository.id, name: repository.name } },
|
.preload(:repository)
|
||||||
|
.map { |row| { id: row.id, name: row.name_with_label } },
|
||||||
next_page: repository_rows.next_page
|
next_page: repository_rows.next_page
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,9 +50,9 @@ module ArchivableModel
|
||||||
|
|
||||||
def name_with_label
|
def name_with_label
|
||||||
raise NotImplementedError, "Archivable model must implement the '.archived_branch?' method!" unless respond_to?(:archived_branch?)
|
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
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -275,6 +275,10 @@ class Repository < RepositoryBase
|
||||||
.destroy_all
|
.destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def archived_branch?
|
||||||
|
archived?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def sync_name_with_snapshots
|
def sync_name_with_snapshots
|
||||||
|
|
|
@ -192,4 +192,8 @@ class RepositoryRow < ApplicationRecord
|
||||||
def relationship_count
|
def relationship_count
|
||||||
parent_connections.size + child_connections.size
|
parent_connections.size + child_connections.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def archived_branch?
|
||||||
|
archived?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,9 +55,9 @@ json.relationships do
|
||||||
json.array! @repository_row.parent_repository_rows.preload(:repository).each do |parent|
|
json.array! @repository_row.parent_repository_rows.preload(:repository).each do |parent|
|
||||||
json.id parent.id
|
json.id parent.id
|
||||||
json.code parent.code
|
json.code parent.code
|
||||||
json.name parent.name
|
json.name parent.name_with_label
|
||||||
json.path repository_repository_row_path(parent.repository, parent)
|
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.repository_path repository_path(parent.repository)
|
||||||
json.unlink_path repository_repository_row_repository_row_connection_path(parent.repository,
|
json.unlink_path repository_repository_row_repository_row_connection_path(parent.repository,
|
||||||
parent,
|
parent,
|
||||||
|
@ -69,9 +69,9 @@ json.relationships do
|
||||||
json.array! @repository_row.child_repository_rows.preload(:repository).each do |child|
|
json.array! @repository_row.child_repository_rows.preload(:repository).each do |child|
|
||||||
json.id child.id
|
json.id child.id
|
||||||
json.code child.code
|
json.code child.code
|
||||||
json.name child.name
|
json.name child.name_with_label
|
||||||
json.path repository_repository_row_path(child.repository, child)
|
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.repository_path repository_path(child.repository)
|
||||||
json.unlink_path repository_repository_row_repository_row_connection_path(child.repository,
|
json.unlink_path repository_repository_row_repository_row_connection_path(child.repository,
|
||||||
child,
|
child,
|
||||||
|
|
Loading…
Add table
Reference in a new issue