mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 23:16:15 +08:00
change SAMPLES_TABLE_DEFAULT_STATE
This commit is contained in:
parent
39b6fa66fe
commit
195055f9cf
|
@ -3,7 +3,30 @@ require 'active_record'
|
|||
class SampleDatatable < AjaxDatatablesRails::Base
|
||||
include SamplesHelper
|
||||
|
||||
ASSIGNED_SORT_COL = "assigned"
|
||||
ASSIGNED_SORT_COL = 'assigned'
|
||||
|
||||
SAMPLES_TABLE_DEFAULT_STATE = {
|
||||
'time' => 0,
|
||||
'start' => 0,
|
||||
'length' => 10,
|
||||
'order' => [[2, 'desc']],
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true },
|
||||
'columns' => [],
|
||||
'ColReorder' => [0, 1, 2, 3, 4, 5, 6]
|
||||
}
|
||||
7.times do
|
||||
SAMPLES_TABLE_DEFAULT_STATE['columns'] << {
|
||||
'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true }
|
||||
}
|
||||
end
|
||||
SAMPLES_TABLE_DEFAULT_STATE.freeze
|
||||
|
||||
def initialize(view,
|
||||
organization,
|
||||
|
|
|
@ -18,7 +18,7 @@ class UserOrganization < ActiveRecord::Base
|
|||
def self.create(opt)
|
||||
user = opt[:user]
|
||||
org = opt[:organization]
|
||||
org_status = Constants::SAMPLES_TABLE_DEFAULT_STATE
|
||||
org_status = SampleDatatable::SAMPLES_TABLE_DEFAULT_STATE.deep_dup
|
||||
org.custom_fields.each_with_index do |_, index|
|
||||
org_status['columns'] << { 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
|
|
|
@ -239,51 +239,4 @@ class Constants
|
|||
'Isaac Sandaljian',
|
||||
'Markus Rademacher'
|
||||
].freeze
|
||||
|
||||
SAMPLES_TABLE_DEFAULT_STATE = {
|
||||
'time' => 0,
|
||||
'start' => 0,
|
||||
'length' => 10,
|
||||
'order' => [[2, 'desc']],
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true },
|
||||
'columns' => [{ 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } },
|
||||
{ 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } },
|
||||
{ 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } },
|
||||
{ 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } },
|
||||
{ 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } },
|
||||
{ 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } },
|
||||
{ 'visible' => true,
|
||||
'search' => { 'search' => '',
|
||||
'smart' => true,
|
||||
'regex' => false,
|
||||
'caseInsensitive' => true } }],
|
||||
'ColReorder' => [0, 1, 2, 3, 4, 5, 6]
|
||||
}.freeze
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ class CreateSamplesTables < ActiveRecord::Migration
|
|||
def change
|
||||
create_table :samples_tables do |t|
|
||||
t.jsonb :status, null: false,
|
||||
default: Constants::SAMPLES_TABLE_DEFAULT_STATE
|
||||
default: SampleDatatable::SAMPLES_TABLE_DEFAULT_STATE
|
||||
# Foreign keys
|
||||
t.references :user, null: false
|
||||
t.references :organization, null: false
|
||||
|
@ -15,7 +15,7 @@ class CreateSamplesTables < ActiveRecord::Migration
|
|||
User.find_each do |user|
|
||||
next unless user.organizations
|
||||
user.organizations.find_each do |org|
|
||||
org_status = Constants::SAMPLES_TABLE_DEFAULT_STATE.deep_dup
|
||||
org_status = SampleDatatable::SAMPLES_TABLE_DEFAULT_STATE.deep_dup
|
||||
next unless org.custom_fields
|
||||
org.custom_fields.each_with_index do |_, index|
|
||||
org_status['columns'] << { 'visible' => true,
|
||||
|
|
Loading…
Reference in a new issue