mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 21:55:20 +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
|
repository_column: existing.repository_column
|
||||||
).find(value) unless value == '-1'
|
).find(value) unless value == '-1'
|
||||||
if item
|
if item
|
||||||
existing.repository_list_value
|
existing.value.update_attribute(
|
||||||
.update_attribute(:repository_list_item_id, item)
|
:repository_list_item_id, item.id
|
||||||
|
)
|
||||||
else
|
else
|
||||||
existing.delete
|
existing.delete
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,10 +28,6 @@ class RepositoryCell < ActiveRecord::Base
|
||||||
validates :repository_row,
|
validates :repository_row,
|
||||||
uniqueness: { scope: :repository_column }
|
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
|
private
|
||||||
|
|
||||||
def repository_column_data_type
|
def repository_column_data_type
|
||||||
|
|
|
@ -61,22 +61,14 @@ class RepositoryDatatableService
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(value)
|
def search(value)
|
||||||
includes_json = {
|
includes_json = { repository_cells: Extends::REPOSITORY_SEARCH_INCLUDES }
|
||||||
repository_cells: [
|
searchable_attributes = ['repository_rows.name', 'users.full_name'] +
|
||||||
:repository_text_value,
|
Extends::REPOSITORY_EXTRA_SEARCH_ATTR
|
||||||
repository_list_value: :repository_list_item
|
|
||||||
]
|
RepositoryRow.left_outer_joins(:created_by)
|
||||||
}
|
.left_outer_joins(includes_json)
|
||||||
RepositoryRow .left_outer_joins(:created_by)
|
.where(repository: @repository)
|
||||||
.left_outer_joins(includes_json)
|
.where_attributes_like(searchable_attributes, value)
|
||||||
.where(repository: @repository)
|
|
||||||
.where_attributes_like(
|
|
||||||
['repository_rows.name',
|
|
||||||
'users.full_name',
|
|
||||||
'repository_text_values.data',
|
|
||||||
'repository_list_items.data'],
|
|
||||||
value
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_conditions(params)
|
def build_conditions(params)
|
||||||
|
@ -101,8 +93,8 @@ class RepositoryDatatableService
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_rows(column_obj, records)
|
def sort_rows(column_obj, records)
|
||||||
dir = %w(DESC ASC).find do |dir|
|
dir = %w(DESC ASC).find do |direction|
|
||||||
dir == column_obj[:dir].upcase
|
direction == column_obj[:dir].upcase
|
||||||
end || 'ASC'
|
end || 'ASC'
|
||||||
column_index = column_obj[:column]
|
column_index = column_obj[:column]
|
||||||
col_order = @repository.repository_table_states
|
col_order = @repository.repository_table_states
|
||||||
|
|
Loading…
Add table
Reference in a new issue