Module: RichTableComponent::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/rich_table_component.rb

Overview

Define ControllerMethods

Instance Method Summary collapse

Instance Method Details

#default_sortObject

Define default order by column ralibi



68
69
70
# File 'lib/rich_table_component.rb', line 68

def default_sort
  @default_sort ||= "created_at"
end

#format_remote(format, act = action_name, obj = instance_variable_get("@#{controller_name}"), html_redirect = nil) ⇒ Object



562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/rich_table_component.rb', line 562

def format_remote(format, act = action_name, obj = instance_variable_get("@#{controller_name}"), html_redirect = nil)
  case act
  when :create
    flash[:notice] ||= "#{t(obj.class.name.tableize.singularize)} #{t('was_successfully_created')}."
    format.html { redirect_to controller: obj.class.name.tableize, action: html_redirect.presence || :edit, id: obj.id }
  when :update
    flash[:notice] ||= "#{t(obj.class.name.tableize.singularize)} #{t('was_successfully_updated')}."
    format.html { redirect_to controller: obj.class.name.tableize, action: html_redirect.presence || :edit, id: obj.id }
  else
    format.html { render action: act }
  end
  format.js { render act, formats: [:js] }
  format.json { render json: obj }
end

#generate_recapitulationObject



280
281
282
283
284
285
286
287
# File 'lib/rich_table_component.rb', line 280

def generate_recapitulation
  #puts 'GENERATE RECAPITULATION'
  if params[:group_row].present? || params[:group_col].present?
    generate_recapitulation_start
  else
    @recapitulation_error = {message: 'Pilih baris atau kolom terlebih dahulu'}
  end
end

#generate_recapitulation_startObject



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/rich_table_component.rb', line 289

def generate_recapitulation_start
  #puts 'START RECAPITULATION'
  recapitulation_model = (params[:rtc_controller_name].presence || controller_name).classify.constantize


  # DATA FETCHING
  # ----------------------------------------------------------------------------------------------------
  # ----------------------------------------------------------------------------------------------------

  # ROW section
  gd_row = get_group_data(params[:group_row].presence || params[:group_col], recapitulation_model)


  if two_dimension?
    # COL section
    gd_col = get_group_data(params[:group_col], recapitulation_model)
  else
    gd_col = {splitter: []}
  end


  #puts 'JOIN TABLE'
  q_join_table = recapitulation_model
                .joins{gd_row[:splitter].inject((gd_row[:splitter].present? ? self : nil), :__send__)}
                .joins{gd_col[:splitter].inject((gd_col[:splitter].present? ? self : nil), :__send__)}


  #puts 'CONVERT PRESENT QUEUE'
  if params[:q].present?
    params[:q] = params[:q].each_with_object({}){|i, memo| i.first.to_s.end_with?('_present') && i.last.eql?('0') ? memo[(i.first.to_s[0..-9] + '_blank').to_sym] = '1' : memo[i.first] = i.last}
    @q = q_join_table.search(params[:q])
    join_table = @q.result
  else
    join_table = q_join_table
  end

  # executing query for counting record
  #puts 'COUNTING RECORD'
  recapitulations = join_table.count(group: [gd_row[:group_db], gd_col[:group_db]].compact)
  #puts 'END COUNTING RECORD'


  # executing query for value
  if on_operation?
    recapitulations_operation = nil

    # contruct operation_value
    gd_ov = get_group_data(params[:operation_value], recapitulation_model)

    recapitulations_operation = join_table.sum(gd_ov[:group_db], group: [gd_row[:group_db], gd_col[:group_db]].compact)
  end

  # END DATA FETCHING

  #puts 'END DATA FETCHING'




  # in between




  @label_col = []
  @label_row = []

  @recapitulation_matrix_data = []
  @total_each_col = []
  @total_each_row = []

  # executing query for value
  if on_operation?
    @recapitulation_matrix_data_operation = []
    @total_each_col_operation = []
    @total_each_row_operation = []
  end




  # just make sure the attribute name won't conflict
  as_group_row_db = get_as_group_db(gd_row[:group_db])
  as_group_col_db = get_as_group_db(gd_col[:group_db])

  # executing query for row label, this also let us know the total rows
  rows = get_label_record(gd_row, join_table, as_group_row_db)

  # process column if 2 dimension. (row or column position doesn't important. their order, can be transposed, what matters only 1-D or 2-D)
  if two_dimension?
    cols = get_label_record(gd_col, join_table, as_group_col_db)

    # iterate through cols and asign label only, not including value
    cols.each_with_index do |col, j|
      @total_each_col << 0
      @total_each_col_operation << 0 if on_operation?

      @label_col << get_label_item(gd_col, col, as_group_col_db)
    end
  end







  # DATA PROCESS
  # ----------------------------------------------------------------------------------------------------
  # ----------------------------------------------------------------------------------------------------
  #puts 'DATA PROCESS'

  # iterate through rows and summing up matrix value simultanously
  # rows -> label top-bottom
  rows.each_with_index do |row, i|

    # assign label for each row
    @label_row << get_label_item(gd_row, row, as_group_row_db)

    # hash key in result set, eg. [{a: 5}, {c: 8}] or [{[a, b]: 5}, {[c, d]: 9}]. hash key are a, b, c, and d
    key_row = (row.id.present? ? row.id : row.try(as_group_row_db))
    if two_dimension?
      # 2-dimension
      @recapitulation_matrix_data << []
      @total_each_row << 0
      if on_operation?
        @recapitulation_matrix_data_operation << []
        @total_each_row_operation << 0
      end
      cols.each_with_index do |col, j|
        key_col = (col.id.present? ? col.id : col.try(as_group_col_db))
        cell = recapitulations[[key_row, key_col]].presence || 0
        @recapitulation_matrix_data[i] << cell 
        @total_each_row[i] += cell 
        @total_each_col[j] += cell

        if on_operation?
          cell_operation = (recapitulations_operation[[key_row, key_col]].presence || 0).to_f
          @recapitulation_matrix_data_operation[i] << cell_operation
          @total_each_row_operation[i] += cell_operation 
          @total_each_col_operation[j] += cell_operation
        end
      end
    else
      # 1-dimension
      cell = recapitulations[key_row].presence || 0
      @recapitulation_matrix_data << [cell] 
      @total_each_row << cell 

      @total_each_col = [@total_each_row.inject(0, :+)]
      @label_col = [t('subtotal')]

      if on_operation?
        cell_operation = (recapitulations_operation[key_row].presence || 0).to_f
        @recapitulation_matrix_data_operation << [cell_operation]
        @total_each_row_operation << cell_operation 
        @total_each_col_operation = [@total_each_row_operation.inject(0, :+)]
      end
      
    end

    #  
    @recapitulation_matrix = []
    @recapitulation_matrix_data.each do |rm|
      @recapitulation_matrix << (Array.new(rm))
    end
    @recapitulation_matrix << (Array.new(@total_each_col))
    @recapitulation_matrix.each_with_index do |rmwt, index|
      rmwt << (rmwt.inject(0, :+))
      rmwt.unshift(@label_row[index].presence || t('total'))
    end
    @recapitulation_matrix.unshift([''] + Array.new(@label_col + [t('total')]))

    if on_operation?
      @recapitulation_matrix_operation = []
      @recapitulation_matrix_data_operation.each do |rm|
        @recapitulation_matrix_operation << (Array.new(rm))
      end
      @recapitulation_matrix_operation << (Array.new(@total_each_col_operation))
      @recapitulation_matrix_operation.each_with_index do |rmwt, index|
        rmwt << (rmwt.inject(0, :+))
      end


      # calculate matrix data content
      if params[:operation_type] == 'sum'
        @recapitulation_matrix_operation.each_with_index do |rmoi, i|
          rmoi.each_with_index do |rmoj, j|
            @recapitulation_matrix[i + 1][j + 1] = @recapitulation_matrix_operation[i][j]
          end
        end
      else # 'average'
        @recapitulation_matrix_operation.each_with_index do |rmoi, i|
          rmoi.each_with_index do |rmoj, j|
            unless @recapitulation_matrix[i + 1][j + 1] == 0
              @recapitulation_matrix[i + 1][j + 1] = ((@recapitulation_matrix_operation[i][j].round(2).to_f / @recapitulation_matrix[i + 1][j + 1]).to_f * 100).round / 100.0
            end
          end
        end
      end

    end


  end # end rows iteration

  # Execute if 1-dimension 
  unless two_dimension?
    @recapitulation_matrix = @recapitulation_matrix.transpose
    recap_shift = @recapitulation_matrix.shift
    @recapitulation_matrix.shift
    @recapitulation_matrix = Array.new([recap_shift] + @recapitulation_matrix)

    # Transpose if needed, depend on row coulumn position
    @recapitulation_matrix = @recapitulation_matrix.transpose if params[:group_row].present?
  end
end

#get_as_group_db(group_db) ⇒ Object



209
210
211
212
213
# File 'lib/rich_table_component.rb', line 209

def get_as_group_db(group_db)
  as_group_db = "#{group_db.to_s.gsub('.', '__')}"
  as_group_db = 'datetime_calculation' if as_group_db.index('curdate').present? || as_group_db.downcase.index('year(').present? || as_group_db.downcase.index('month(').present?
  as_group_db
end

#get_group_data(str_param, recapitulation_model) ⇒ Object



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/rich_table_component.rb', line 223

def get_group_data(str_param, recapitulation_model)
  splitter_attr = str_param.split('__')

  splitter = splitter_attr.first.split('.')
  splitter_time = splitter_attr.find{|f| f.first(5).eql?('time.')}.try('split', '.')
  group = splitter.pop
  join_model = splitter.present? ? splitter.last.classify.constantize : recapitulation_model
  group_attr = join_model.columns_hash[group].present? ? group : group + '_id'
  #puts group_attr
  group_attr = join_model.columns_hash[group_attr].present? ? group_attr : group.classify.constantize.table_name.singularize + '_id'
  group_db = get_group_db(splitter, splitter_attr, splitter_time, group_attr, join_model, recapitulation_model)
  splitter_mapping = splitter_attr.find{|f| f.first(8).eql?('mapping.')}.try('split', '.')

  {
    splitter_attr: splitter_attr,
    splitter: splitter,
    splitter_time: splitter_time,
    group: group,
    join_model: join_model,
    group_attr: group_attr,
    group_db: group_db,
    splitter_mapping: splitter_mapping,
    is_id: group_attr.last(3).eql?('_id')
  }
end

#get_group_db(splitter, splitter_attr, splitter_time, group_attr, join_model, recapitulation_model) ⇒ Object

Group methods for recapitulation




181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/rich_table_component.rb', line 181

def get_group_db(splitter, splitter_attr, splitter_time, group_attr, join_model, recapitulation_model)
  group_db = [splitter.last.try('classify').try('constantize').try('table_name'), group_attr].compact.join('.')
  group_db = (group_db.split('.').length > 1) ? group_db : [recapitulation_model.table_name, group_db].join('.')

  if splitter_time.present?
    case join_model.columns_hash[group_attr].type
    when :date
      old_since = splitter_time[2].eql?('old') ? "#{splitter_time[1]}(curdate()) - " : ""

      if old_since.eql?("") && splitter_time[1].eql?('month')
        group_db = "(concat(year(#{recapitulation_model.table_name}.#{group_attr}), '/', LPAD(month(#{recapitulation_model.table_name}.#{group_attr}), 2, '0')  ))" 
      else
        group_db = "(#{old_since}#{splitter_time[1]}(#{recapitulation_model.table_name}.#{group_attr}))"  
      end

      if splitter_time[3].presence
        group_db = "(floor((#{group_db}) / #{splitter_time[3].to_i}))"
      end
    when :datetime
      old_since = splitter_time[2].eql?('old') ? "{splitter_time[1]}(curdate()) - " : ""
      group_db = "(#{old_since}#{splitter_time[1]}(#{recapitulation_model.table_name}.#{group_attr}))"
    else
    end
  end

  group_db
end

#get_label_item(group_data, record, as_group_db) ⇒ Object



264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/rich_table_component.rb', line 264

def get_label_item(group_data, record, as_group_db)
  label_item = ((group_data[:is_id] ? record.to_s : record.try(as_group_db)).to_s.presence || t('unknown'))

  # label row for range value like age old or date since
  label_item = get_label_range(group_data, label_item)

  # row mapping
  if group_data[:splitter_mapping].present?
    idx = group_data[:splitter_mapping].index(label_item)
    label_item = group_data[:splitter_mapping][idx + 1].presence || label_item if idx.present?
  end

  label_item
end

#get_label_range(group_data, labels) ⇒ Object



254
255
256
257
258
259
260
261
262
# File 'lib/rich_table_component.rb', line 254

def get_label_range(group_data, labels)
  if group_data[:splitter_time].present? && group_data[:splitter_time].try('fourth').present?
    lri = labels.to_i
    spli = group_data[:splitter_time][3].to_i
    "#{lri * spli} - #{(lri * spli) + spli - 1}"
  else
    labels
  end
end

#get_label_record(group_data, join_table, as_group_db) ⇒ Object



249
250
251
252
# File 'lib/rich_table_component.rb', line 249

def get_label_record(group_data, join_table, as_group_db)
  # puts 'GET LABEL RECORD'
  group_data[:is_id] ? group_data[:group].tableize.classify.constantize.where{id.in(join_table.select(group_data[:group_db]).order(group_data[:group_db].to_s + ' ASC').uniq.to_a.collect(&(group_data[:group_attr]).to_sym))} : join_table.select(group_data[:group_db] + ' AS ' + as_group_db).order(as_group_db + ' ASC').uniq
end

#init_document_uploadObject

Just providing object document call this method in object that has many documents



174
175
176
# File 'lib/rich_table_component.rb', line 174

def init_document_upload
  @document = Document.new
end

#notification_meta(record, opts = {}) ⇒ Object



579
580
581
# File 'lib/rich_table_component.rb', line 579

def notification_meta record, opts={}
  (record.notification_meta ||= {current_user: current_user}).merge! opts if record.respond_to? :notification_meta
end

#on_operation?Boolean

Returns:

  • (Boolean)


215
216
217
# File 'lib/rich_table_component.rb', line 215

def on_operation?
  params[:operation_value].present? && params[:operation_type].present?
end

#respond_to_remote(act = action_name, obj = instance_variable_get("@#{controller_name}")) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/rich_table_component.rb', line 511

def respond_to_remote(act = action_name, obj = instance_variable_get("@#{controller_name}"))
  respond_to do |format|
    case act
    when :create
      flash[:notice] ||= "#{t(obj.class.name.tableize.singularize)} #{t('was_successfully_created')}."
      format.html { redirect_to controller: obj.class.name.tableize, action: :edit, id: obj.id }
    when :update
      flash[:notice] ||= "#{t(obj.class.name.tableize.singularize)} #{t('was_successfully_updated')}."
      format.html { redirect_to controller: obj.class.name.tableize, action: :edit, id: obj.id }
    when :destroy
      flash[:notice] ||= "#{t(obj.class.name.tableize.singularize)} #{t('was_successfully_deleted')}."
      format.html { redirect_to controller: obj.class.name.tableize, action: :index }
    else
      format.html # index.html.erb
    end
    if params[:pgos].eql?('true')
      format.js { render 'index', formats: [:js] }
      format.xls { render 'index' }
      format.pdf {
         render pdf: "#{controller_name}",
            template: lookup_context.exists?("#{controller_path}/index") ? "#{controller_path}/index" : "application/index",
            layout: 'print/pdf.html',  # for pdf.html.erb
            disposition: 'attachment'
      }
    elsif params[:recapitulation].eql?('true')
      if params[:group_row].present? || params[:group_col].present?
        generate_recapitulation
        format.pdf {
           render pdf: "#{controller_name}",
              template: "application/recapitulation",
              layout: 'print/recapitulation.html',  # for pdf.html.erb
              disposition: 'attachment'
        }
        headers["Content-Disposition"] = "attachment; filename=\"#{controller_name}.xls\"" 
        format.xls { render 'recapitulation' }
      end
      format.js { render 'recapitulation', formats: [:js] }
    else
      format.js { render act, formats: [:js] }
      format.xls
      format.pdf {
         render pdf: "#{controller_name}",
            template: lookup_context.exists?("#{controller_path}/index") ? "#{controller_path}/index" : "application/index",
            layout: 'print/pdf.html',  # for pdf.html.erb
            disposition: 'attachment'
      }
    end
    format.json { render json: obj }
  end
end

#rich_table_component(relation = {}, _sort_column = {}, _sort_direction = nil, pagination = true) ⇒ Object

The result from Rich Table Component manipulation



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/rich_table_component.rb', line 95

def rich_table_component(relation = {}, _sort_column = {}, _sort_direction = nil, pagination = true)

  #puts 'RICH TABLE COMPONENT'
  case relation
  when Hash
    _sort_column = relation[:sort_column]
    _sort_direction = relation[:sort_direction]
    pagination = relation[:pagination] == false ? false : true
    relation = relation[:relation]
    _association_records_count = [relation[:association_records_count]].compact.flatten.collect(&:to_s)
  else
    _association_records_count = nil
    case _sort_column
    when Hash
      _sort_direction = _sort_column[:sort_direction]
      pagination = _sort_column[:pagination] == false ? false : true
      _association_records_count = [_sort_column[:association_records_count]].compact.flatten.collect(&:to_s)
      _sort_column = _sort_column[:sort_column]
    end
  end

  pagination = false if ['application/pdf', 'application/xls'].include? request.format.to_s

  @default_sort = _sort_column.presence || nil
  @sort_direction = _sort_direction
  sort = sort_column
  direction = sort_direction
  _relation_table_name = relation.respond_to?('klass') ? relation.klass.table_name : relation.name.tableize
  @default_sort = nil
  @sort_direction = nil

  order_table_name = _relation_table_name

  if params[:sort_relation].present?
    splitter = params[:sort_relation].index('__').present? ? params[:sort_relation].split('__') : params[:sort_relation].split('.')
    order_table_name = splitter.last.try(:tableize).presence || _relation_table_name
    relation = relation.joins{splitter.inject((splitter.present? ? self : nil), :__send__).outer}
  elsif sort.index('.').present?
    splitter = sort.split('.')
    sort = splitter.pop
    order_table_name = splitter.last.try(:tableize).presence || _relation_table_name
    relation = relation.joins{splitter.inject((splitter.present? ? self : nil), :__send__).outer}
  end
  
  if _association_records_count.present? && _association_records_count.map{|m| "number_of_" + m}.include?(sort)
    index_arc = _association_records_count.map{|m| "number_of_" + m}.index(sort)
    relation = relation.joins{[_association_records_count[index_arc]].inject(([_association_records_count[index_arc]].present? ? self : nil), :__send__).outer}.select("#{_relation_table_name}.*, COUNT(#{_association_records_count[index_arc]}.id) number_of_#{_association_records_count[index_arc]}")
    relation = relation.order("#{sort} #{direction}")      
  else
    relation = relation.order("#{order_table_name}.#{sort} #{direction}")
  end

  if pagination
    params[:page] ||= 1
    params[:per_page] ||= session_per_page
    session[:per_page] = params[:per_page]
    relation = relation.page(params[:page].to_i).per_page(params[:per_page].to_i)
  end

  relation = relation.uniq
  relation
end

#save_documents_with_attached_from(doc_ids, att_from_obj) ⇒ Object

Saving object with document by Jquery File Upload document assigned with id from att_from_obj



160
161
162
163
164
165
166
167
168
169
170
# File 'lib/rich_table_component.rb', line 160

def save_documents_with_attached_from(doc_ids, att_from_obj)
  if doc_ids.present?
    doc_ids.collect(&:to_i).each do |document_id|
      document = Document.find(document_id)
      document.attached_from_id = att_from_obj.id
      document.document_type = att_from_obj.class.name.tableize.singularize
      document.save
    end
  end
  @document = Document.new
end

#session_per_pageObject

get session per page for pagination



48
49
50
# File 'lib/rich_table_component.rb', line 48

def session_per_page
  session[:per_page] ||= DEFAULT_PER_PAGE
end

#set_parent_resources(*args) ⇒ Object

Set parent resource of the current resource Used in breadcrumbs



585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/rich_table_component.rb', line 585

def set_parent_resources(*args)
  args.each_with_index do |pr, i|
    pr_singular = pr.singularize
    pr_id = params["#{pr_singular}_id"]

    if pr_id.blank? && i == 0
      controller_object = controller_name.classify.constantize.where{id.eq(my{params[:id]})}.first
      if controller_object.present? && controller_object.respond_to?(pr_singular.to_sym)
        pr_id = controller_object.send("#{pr_singular}_id")
      end
    end

    if pr_id.present?
      @parent_resources ||= []
      @parent_resources << pr
      pr_object = pr.classify.constantize.find(pr_id)
      instance_variable_set("@#{pr_singular}", pr_object)
    elsif i > 0
      prev_pr = args[i - 1]
      prev_pr_singular = prev_pr.singularize
      prev_pr_id = params["#{prev_pr_singular}_id"].presence || instance_variable_get("@#{prev_pr_singular}").try(:id)
      if prev_pr_id.present?
        prev_pr_object = prev_pr.classify.constantize.find(prev_pr_id)
        if prev_pr_object.respond_to? pr_singular.to_sym
          pr_id = prev_pr_object.send("#{pr_singular}_id")
          if pr_id.present?
            @parent_resources ||= []
            @parent_resources << pr
            pr_object = pr.classify.constantize.find(pr_id)
            instance_variable_set("@#{pr_singular}", pr_object)
          end
        end
      end
    end
  end
end

#sort_column(mdl = nil) ⇒ Object

Formulate order by column string. Also handling column from related table ralibi



86
87
88
89
90
91
92
# File 'lib/rich_table_component.rb', line 86

def sort_column(mdl = nil)
  if mdl.nil?
    params[:sort] || default_sort
  else
    sort_relation ? (params[:sort] || default_sort) : (mdl.column_names.include?(params[:sort]) ? params[:sort] : default_sort)
  end
end

#sort_directionObject

Set sorting direction for table grid ralibi



74
75
76
# File 'lib/rich_table_component.rb', line 74

def sort_direction
  %w[asc desc].include?(params[:direction]) ?  params[:direction] : (@sort_direction ||= "desc")
end

#sort_relationObject

Set table relation for table grid ralibi



80
81
82
# File 'lib/rich_table_component.rb', line 80

def sort_relation
  params[:relation] || nil
end

#strip_search_paramObject

Removes leading and trailing whitespace from ransack search params



56
57
58
59
60
61
62
63
64
# File 'lib/rich_table_component.rb', line 56

def strip_search_param
  case params[:q]
  when String
    params[:q].strip!
  when Hash
    params[:q].each_pair{|k, v| params[:q][k] = v.strip}
  else
  end
end

#two_dimension?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/rich_table_component.rb', line 219

def two_dimension?
  params[:group_row].present? && params[:group_col].present?
end