mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 20:23:16 +08:00
fix edit row action
This commit is contained in:
parent
1cdba5e0d3
commit
fad4001273
3 changed files with 13 additions and 24 deletions
|
@ -148,8 +148,9 @@ class RepositoryRowsController < ApplicationController
|
|||
repository_column: existing.repository_column
|
||||
).find(value) unless value == '-1'
|
||||
if item
|
||||
existing.repository_list_value
|
||||
.update_attribute(:repository_list_item_id, item)
|
||||
existing.value.update_attribute(
|
||||
:repository_list_item_id, item.id
|
||||
)
|
||||
else
|
||||
existing.delete
|
||||
end
|
||||
|
|
|
@ -28,10 +28,6 @@ class RepositoryCell < ActiveRecord::Base
|
|||
validates :repository_row,
|
||||
uniqueness: { scope: :repository_column }
|
||||
|
||||
belongs_to :repository_text_value, optional: true, foreign_key: :value_id
|
||||
belongs_to :repository_date_value, optional: true, foreign_key: :value_id
|
||||
belongs_to :repository_list_value, optional: true, foreign_key: :value_id
|
||||
|
||||
private
|
||||
|
||||
def repository_column_data_type
|
||||
|
|
|
@ -61,22 +61,14 @@ class RepositoryDatatableService
|
|||
end
|
||||
|
||||
def search(value)
|
||||
includes_json = {
|
||||
repository_cells: [
|
||||
:repository_text_value,
|
||||
repository_list_value: :repository_list_item
|
||||
]
|
||||
}
|
||||
RepositoryRow .left_outer_joins(:created_by)
|
||||
.left_outer_joins(includes_json)
|
||||
.where(repository: @repository)
|
||||
.where_attributes_like(
|
||||
['repository_rows.name',
|
||||
'users.full_name',
|
||||
'repository_text_values.data',
|
||||
'repository_list_items.data'],
|
||||
value
|
||||
)
|
||||
includes_json = { repository_cells: Extends::REPOSITORY_SEARCH_INCLUDES }
|
||||
searchable_attributes = ['repository_rows.name', 'users.full_name'] +
|
||||
Extends::REPOSITORY_EXTRA_SEARCH_ATTR
|
||||
|
||||
RepositoryRow.left_outer_joins(:created_by)
|
||||
.left_outer_joins(includes_json)
|
||||
.where(repository: @repository)
|
||||
.where_attributes_like(searchable_attributes, value)
|
||||
end
|
||||
|
||||
def build_conditions(params)
|
||||
|
@ -101,8 +93,8 @@ class RepositoryDatatableService
|
|||
end
|
||||
|
||||
def sort_rows(column_obj, records)
|
||||
dir = %w(DESC ASC).find do |dir|
|
||||
dir == column_obj[:dir].upcase
|
||||
dir = %w(DESC ASC).find do |direction|
|
||||
direction == column_obj[:dir].upcase
|
||||
end || 'ASC'
|
||||
column_index = column_obj[:column]
|
||||
col_order = @repository.repository_table_states
|
||||
|
|
Loading…
Reference in a new issue