mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-06 15:40:31 +08:00
Merge pull request #3692 from okriuchykhin/ok_SCI_6208
Add endpoint for fetching column data including connected items [SCI-6208]
This commit is contained in:
commit
a58400bec9
3 changed files with 24 additions and 2 deletions
|
@ -34,6 +34,18 @@ class RepositoryColumnsController < ApplicationController
|
|||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def describe_all
|
||||
response_json = @repository.repository_columns.map do |column|
|
||||
{
|
||||
id: column.id,
|
||||
name: escape_input(column.name),
|
||||
data_type: column.data_type,
|
||||
items: column.items&.map { |item| { id: item.id, label: escape_input(item.data) } }
|
||||
}
|
||||
end
|
||||
render json: { response: response_json }
|
||||
end
|
||||
|
||||
def edit
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
|
@ -118,7 +130,8 @@ class RepositoryColumnsController < ApplicationController
|
|||
end
|
||||
|
||||
def load_asset_type_columns
|
||||
render_403 unless can_read_repository?(@repository)
|
||||
render_403 && return unless can_read_repository?(@repository)
|
||||
|
||||
@asset_columns = load_asset_columns(search_params[:q])
|
||||
end
|
||||
|
||||
|
|
|
@ -100,6 +100,11 @@ class RepositoryColumn < ApplicationRecord
|
|||
Constants::REPOSITORY_LIST_ITEMS_DELIMITERS_MAP[metadata['delimiter']&.to_sym] || "\n"
|
||||
end
|
||||
|
||||
def items
|
||||
items_method_name = "#{data_type.chomp('Value').underscore}_items"
|
||||
__send__(items_method_name) if respond_to?(items_method_name, true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def repository_list_value_deep_dup(new_column)
|
||||
|
|
|
@ -584,7 +584,11 @@ Rails.application.routes.draw do
|
|||
get :table_toolbar
|
||||
get :status
|
||||
|
||||
resources :repository_columns, only: %i(index new edit destroy)
|
||||
resources :repository_columns, only: %i(index new edit destroy) do
|
||||
collection do
|
||||
get :describe_all
|
||||
end
|
||||
end
|
||||
resources :repository_rows, only: %i(create show update) do
|
||||
collection do
|
||||
get :print_modal
|
||||
|
|
Loading…
Reference in a new issue