module Ezframe::PageKit::Edit
Public Instance Methods
act_after_cancel()
click to toggle source
キャンセル時の表示
# File lib/ezframe/single_page_kit.rb, line 145 def act_after_cancel return public_detail_post end
act_after_edit()
click to toggle source
編集完了後の表示
# File lib/ezframe/single_page_kit.rb, line 140 def act_after_edit return [public_default_post, public_detail_post] end
make_edit_form(command = :edit)
click to toggle source
編集フォームの生成
# File lib/ezframe/single_page_kit.rb, line 121 def make_edit_form(command = :edit) @id ||= get_id target_keys = @edit_keys || @column_set.keys list = target_keys.map do |colkey| column = @column_set[colkey.to_sym] unless column EzLog.error("undefined column entry: #{colkey}") next end form = column.form Ht.p(class: %w[form-line], child: [Ht.small(column.label), form]) if form end send_button = Ht.button(id: "#{@class_snake}-#{command}-finish-button", class: %w[btn], child: [Ht.icon("check"), Message[:edit_finish_button_label]], ezevent: "on=click:url=#{make_base_url(@id)}/#{command}:with=form") cancel_button = make_cancel_button("on=click:url=#{make_base_url(@id)}/#{command}:cancel=true:with=form") list.push(Ht.p(class: %w[edit-finish-buttons], child: [send_button, cancel_button])) return make_form("#{make_base_url}/edit", list) end
public_create_post()
click to toggle source
新規データ登録
# File lib/ezframe/single_page_kit.rb, line 73 def public_create_post @form = @event[:form] EzLog.debug("public_create_post: event=#{@event}") if @event[:cancel] return { inject: "##{@dom_id[:create]}", body: Html.convert(make_index_top) } elsif !@form return { inject: "##{@dom_id[:create]}", body: Html.convert(make_edit_form(:create)) } else # 値の保存 @column_set.clear form_values = @form form_values.update(@env["url_params"]) # @column_set.values = form_values @column_set[:id].value = @id = @column_set.create(form_values) return { redirect: make_base_url(@id) } # return public_default_post end end
public_edit_post()
click to toggle source
データ編集受信
# File lib/ezframe/single_page_kit.rb, line 93 def public_edit_post @id = get_id validation = @column_set.validate(@form) if @event[:branch] == "single_validate" EzLog.debug("public_edit_post: single validate:event=#{@event}, form=#{@form}") return single_validation(validation, @event[:target_key]) end unless @event[:form] data = @column_set.set_from_db(@id) return show_message_page("no data", "data is not defined: #{@id}") unless data # フォームの表示 form = make_edit_form found_a = Ht.search(form, tag: "input") found_a.each { |h| h.add_class("#{@class_snake}-edit-box") if h[:size] } return { inject: "##{@dom_id[:detail]}", body: Html.convert(form) } else if @event[:cancel] data = @column_set.set_from_db(@id) return act_after_cancel else # 値を保存 @column_set.update(@id, @event[:form]) end return act_after_edit end end