fix samples table state, when adding new custom column

This commit is contained in:
Mojca Lorber 2016-12-07 16:37:16 +01:00
parent 5b5342de6f
commit 228990f9da
2 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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