mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Fix repository users list and filtering by row name [SCI-6457]
This commit is contained in:
parent
60859fec4e
commit
6d877e6bf7
3 changed files with 11 additions and 6 deletions
|
@ -374,10 +374,10 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def repository_users
|
||||
users = User.where(id:
|
||||
Repository.first.repository_rows
|
||||
.joins(params[:archived_by] ? :archived_by : :created_by)
|
||||
.select('users.id').distinct)
|
||||
rows_type = params[:archived_by].present? ? :archived_repository_rows : :created_repository_rows
|
||||
users = User.joins(rows_type)
|
||||
.where(rows_type => { repository: @repository })
|
||||
.group(:id)
|
||||
|
||||
render json: { users: users.map do |u|
|
||||
{
|
||||
|
|
|
@ -195,6 +195,11 @@ class User < ApplicationRecord
|
|||
foreign_key: 'restored_by_id',
|
||||
inverse_of: :restored_by,
|
||||
dependent: :nullify
|
||||
has_many :created_repository_rows,
|
||||
class_name: 'RepositoryRow',
|
||||
foreign_key: 'created_by_id',
|
||||
inverse_of: :created_by,
|
||||
dependent: :nullify
|
||||
has_many :archived_repository_rows,
|
||||
class_name: 'RepositoryRow',
|
||||
foreign_key: 'archived_by_id',
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class RepositoryDatatableService
|
||||
attr_reader :repository_rows, :all_count, :mappings
|
||||
|
||||
PREDEFINED_COLUMNS = %w(row_id name added_on added_by archived_by assigned).freeze
|
||||
PREDEFINED_COLUMNS = %w(row_id row_name added_on added_by archived_by assigned).freeze
|
||||
|
||||
def initialize(repository, params, user, my_module = nil)
|
||||
@repository = repository
|
||||
|
@ -127,7 +127,7 @@ class RepositoryDatatableService
|
|||
case filter_element_params[:repository_column_id]
|
||||
when 'row_id'
|
||||
build_row_id_filter_condition(repository_rows, filter_element_params)
|
||||
when 'name'
|
||||
when 'row_name'
|
||||
build_name_filter_condition(repository_rows, filter_element_params)
|
||||
when 'added_on'
|
||||
build_added_on_filter_condition(repository_rows, filter_element_params)
|
||||
|
|
Loading…
Reference in a new issue