module Ezframe::SubPageKit::Index

Public Instance Methods

button_for_index_line(data) click to toggle source

一覧ページ用ボタン

# File lib/ezframe/sub_page_kit.rb, line 62
def button_for_index_line(data)
  Ht.button(class: %w[btn right], ezevent: "on=click:url=#{make_base_url(data[:id])}/edit", child: [Ht.icon("edit"), Message[:edit_button_label]])
end
list_for_index() click to toggle source

一覧ページ用のデータリスト生成

# File lib/ezframe/sub_page_kit.rb, line 57
def list_for_index
  return @column_set.dataset.where(@parent_key.to_sym => get_parent_id, deleted_at: nil).order(@sort_key).all
end
make_index_column(key) click to toggle source

一覧表示の1カラムを生成

# File lib/ezframe/sub_page_kit.rb, line 51
def make_index_column(key)
  column = @column_set[key.to_sym]
  return column.view(force: true)
end
make_index_line(target_keys, data) click to toggle source

一覧表示の1行を生成

# File lib/ezframe/sub_page_kit.rb, line 44
def make_index_line(target_keys, data)
  @column_set.clear
  @column_set.set_values(data, from_db: true)
  return target_keys.map { |key| make_index_column(key) }
end
make_index_page() click to toggle source

一覧表の生成

# File lib/ezframe/sub_page_kit.rb, line 11
def make_index_page
  list = list_for_index
  target_keys = @index_keys
  unless target_keys
    target_keys = @column_set.keys.select { |k| !@column_set[k].no_view? }
  end
  # 項目名欄の生成
  if @table_labels
    thead = Ht.thead(Ht.tr(@table_labels.map { |label| Ht.th(label) }))
  else
    thead = Ht.thead(Ht.tr(target_keys.map { |key|
      if @column_set[key].respond_to?(:label)
        Ht.th(@column_set[key].label(force: true))
      else
        nil
      end
    })).compact
  end

  tr_a = list.map do |data|
    view_a = make_index_line(target_keys, data)
    td_a = view_a.map { |view| Ht.td(view) }
    Ht.tr(id: "tr-#{@class_snake}-#{data[:id]}", child: td_a, ezevent: "on=click:url=#{make_base_url(data[:id])}/detail")
  end
  tbody = Ht.tbody(tr_a)
  return [
           area_for_create,
           Ht.table(id: "enable_datatable_#{@class_snake}", child: [thead, tbody], ezload: "command=enable_datatable:target=#enable_datatable_#{@class_snake}"),
           Ht.div(id: edit_inject_element),
         ]
end