Class: Engine2::FormMeta
- Includes:
- MetaAPISupport, MetaAngularSupport, MetaMenuSupport, MetaModelSupport, MetaOnChangeSupport, MetaPanelSupport, MetaQuerySupport, MetaTabSupport
- Defined in:
- lib/engine2/meta/form_meta.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Meta
#action, #assets, #invokable, #static
Instance Method Summary collapse
- #field_template(template) ⇒ Object
- #hr_after(field, message = '-') ⇒ Object
- #post_process ⇒ Object
- #post_run ⇒ Object
- #pre_run ⇒ Object
- #record(handler, record) ⇒ Object
- #template ⇒ Object
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
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
Methods included from MetaMenuSupport
Methods included from MetaAngularSupport
#ng_call, #ng_execute, #ng_info!, #ng_record, #ng_record!
Methods included from MetaOnChangeSupport
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, #request, #request_meta_proc_params, #response, #split_keys
Constructor Details
This class inherits a constructor from Engine2::Meta
Instance Method Details
#field_template(template) ⇒ Object
7 8 9 |
# File 'lib/engine2/meta/form_meta.rb', line 7 def field_template template panel[:field_template] = template end |
#hr_after(field, message = '-') ⇒ Object
71 72 73 |
# File 'lib/engine2/meta/form_meta.rb', line 71 def hr_after field, = '-' info! field, hr: end |
#post_process ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/engine2/meta/form_meta.rb', line 27 def post_process if fields = [:fields] fields = fields - static.get[:fields] if dynamic? decorate(fields) fields.each do |name| # type_info = model.type_info.fetch(name) type_info = get_type_info(name) info[name][:render] ||= begin renderer = DefaultFormRenderers[type_info[:type]] # .merge(default: true) raise E2Error.new("No form renderer found for field '#{type_info[:name]}' of type '#{type_info[:type]}'") unless renderer renderer.(self, type_info) end proc = FormRendererPostProcessors[type_info[:type]] proc.(self, name, type_info) if proc end assoc = assets[:assoc] if assoc && assoc[:type] == :one_to_many # fields.select{|f| assoc[:keys].include? f}.each do |key| # # hide_fields(key) if self[:info, key, :hidden] == nil # info! key, disabled: true # end assoc[:keys].each do |key| info! key, disabled: true if fields.include? key end end end super end |
#post_run ⇒ Object
62 63 64 65 |
# File 'lib/engine2/meta/form_meta.rb', line 62 def post_run super [:primary_fields] = assets[:model].primary_keys end |
#pre_run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/engine2/meta/form_meta.rb', line 11 def pre_run super panel_template 'scaffold/form' field_template 'scaffold/fields' panel_class 'modal-large' :panel_menu do option :approve, icon: "ok", disabled: 'action.action_pending' # text: true, option :cancel, icon: "remove" # text: true, end # modal_action false end |
#record(handler, record) ⇒ Object
24 25 |
# File 'lib/engine2/meta/form_meta.rb', line 24 def record handler, record end |
#template ⇒ Object
67 68 69 |
# File 'lib/engine2/meta/form_meta.rb', line 67 def template Templates end |