Module: Engine2::MetaCreateSupport

Includes:
MetaFormSupport
Included in:
CreateMeta
Defined in:
lib/engine2/meta.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MetaFormSupport

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

Methods included from MetaModelSupport

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

Methods included from MetaAPISupport

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

Methods included from MetaTabSupport

#field_tabs, #lazy_tab, #select_tabs

Methods included from MetaPanelSupport

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

Methods included from MetaMenuSupport

#menu, #menu?, #post_process

Methods included from MetaAngularSupport

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

Methods included from MetaOnChangeSupport

#on_change

Class Method Details

.included(meta) ⇒ Object



828
829
830
# File 'lib/engine2/meta.rb', line 828

def self.included meta
    meta.meta_type :create
end

Instance Method Details

#create_record(handler, record) ⇒ Object



844
845
# File 'lib/engine2/meta.rb', line 844

def create_record handler, record
end

#invoke(handler) ⇒ Object



847
848
849
850
851
852
853
854
855
856
857
858
# File 'lib/engine2/meta.rb', line 847

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



832
833
834
835
836
837
838
# File 'lib/engine2/meta.rb', line 832

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



840
841
842
# File 'lib/engine2/meta.rb', line 840

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