Class: Engine2::CreateMeta

Inherits:
FormMeta show all
Defined in:
lib/engine2/meta/form_meta.rb

Instance Attribute Summary

Attributes inherited from Meta

#action, #assets, #invokable, #static

Instance Method Summary collapse

Methods inherited from FormMeta

#field_template, #hr_after, #post_process, #post_run, #template

Methods included from MetaAPISupport

#config, #decorate, #field_filter, #hide_fields, #info, #info!, #render, #show_fields

Methods included from MetaModelSupport

#action_defined, #get_type_info, #hide_pk, #show_pk, #unsupported_association

Methods included from MetaQuerySupport

#get_query, #post_run, #query, #select

Methods included from MetaTabSupport

#field_tabs, #lazy_tab, #select_tabs

Methods included from MetaPanelSupport

#glyphicon, #modal_action, #panel, #panel_class, #panel_panel_template, #panel_template, #panel_title, #post_run

Methods included from MetaMenuSupport

#menu, #post_process

Methods included from MetaAngularSupport

#ng_call, #ng_execute, #ng_info!, #ng_record, #ng_record!

Methods included from MetaOnChangeSupport

#on_change

Methods inherited from Meta

#action_defined, #check_static_meta, #dynamic?, #freeze_meta, #get, http_method, #http_method, inherited, #initialize, #invoke!, #lookup, #merge, #meta_type, meta_type, #post_process, #post_run, #request, #request_meta_proc_params, #response, #split_keys

Constructor Details

This class inherits a constructor from Engine2::Meta

Instance Method Details

#create_record(handler, record) ⇒ Object



91
92
# File 'lib/engine2/meta/form_meta.rb', line 91

def create_record handler, record
end

#invoke(handler) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/engine2/meta/form_meta.rb', line 94

def invoke handler
    record = {}
    if assoc = assets[:assoc]
        case assoc[:type]
        when :one_to_many
            handler.permit parent = handler.params[:parent_id]
            assoc[:keys].zip(split_keys(parent)).each{|key, val| record[key] = val}
        end
    end
    static.record(handler, record)
    {record: record, new: true}
end

#pre_runObject



79
80
81
82
83
84
85
# File 'lib/engine2/meta/form_meta.rb', line 79

def pre_run
    super
    panel_title LOCS[:create_title]
    action.parent.*.menu(:menu).option_at 0, action.name, icon: "plus-sign", button_loc: false

    hide_pk unless assets[:model].natural_key
end

#record(handler, record) ⇒ Object



87
88
89
# File 'lib/engine2/meta/form_meta.rb', line 87

def record handler, record
    create_record(handler, record)
end