Module: Ezframe::SubPageKit::Detail

Defined in:
lib/ezframe/sub_page_kit.rb

Instance Method Summary collapse

Instance Method Details

#button_for_detail_box(data) ⇒ Object

詳細ページ用ボタン



194
195
196
197
198
199
200
# File 'lib/ezframe/sub_page_kit.rb', line 194

def button_for_detail_box(data)
  buttons = [Ht.button(class: %w[btn right], ezevent: "on=click:url=#{make_base_url(data[:id])}/edit", child: [Ht.icon("edit"), Message[:edit_button_label]])]
  if @show_delete_button
    buttons.push(make_delete_button)
  end
  return Ht.div(class: %w[button-box], child: buttons)
end

#make_detail_line(column) ⇒ Object

詳細表示欄の一行を生成



184
185
186
187
188
189
190
191
# File 'lib/ezframe/sub_page_kit.rb', line 184

def make_detail_line(column)
  view = column.view
  if view
    view = Ht.pre(view) if view.index("\n")
    return Ht.p([Ht.small(column.label), view])
  end
  return nil
end

#public_detail_postObject

データ詳細表示



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/ezframe/sub_page_kit.rb', line 166

def public_detail_post
  @id = get_id
  data = @column_set.set_from_db(@id)
  target_keys = @show_keys || @column_set.keys.select { |key| !@column_set[key].attribute[:no_view] }
  line_a = []
  target_keys.each do |key|
    column = @column_set[key]
    v = make_detail_line(column)
    line_a.push(v) if v
  end
  table = Ht.div(line_a)
  collection = Materialize::Collection.new
  # 詳細表示用のblockを追加
  collection.push(Ht.div(class: "detail-box", child: [button_for_detail_box(data), table]))
  return { inject: "##{edit_inject_element}", body: Html.convert(collection.to_h) }
end