mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-11 07:34:41 +08:00
fix samples table state, when adding new custom column
This commit is contained in:
parent
5b5342de6f
commit
228990f9da
2 changed files with 18 additions and 1 deletions
|
@ -14,4 +14,21 @@ class CustomField < ActiveRecord::Base
|
|||
foreign_key: 'last_modified_by_id',
|
||||
class_name: 'User'
|
||||
has_many :sample_custom_fields, inverse_of: :custom_field
|
||||
|
||||
def self.new(opt)
|
||||
user = opt[:user]
|
||||
org = opt[:organization]
|
||||
samples_table = SamplesTable.where(user: user,
|
||||
organization: org)
|
||||
org_status = samples_table.first['status']
|
||||
index = org_status['columns'].count
|
||||
org_status['columns'][index] = { 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } }
|
||||
org_status['ColReorder'] << index
|
||||
samples_table.first.update(status: org_status)
|
||||
super(opt)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ class UserOrganization < ActiveRecord::Base
|
|||
I18n.t("user_organizations.enums.role.#{role.to_s}")
|
||||
end
|
||||
|
||||
def self.create(opt)
|
||||
def self.new(opt)
|
||||
user = opt[:user]
|
||||
org = opt[:organization]
|
||||
org_status = SampleDatatable::SAMPLES_TABLE_DEFAULT_STATE.deep_dup
|
||||
|
|
Loading…
Add table
Reference in a new issue