Class: Netzke::Basepack::FormPanel
- Inherits:
-
Netzke::Base
- Object
- Netzke::Base
- Netzke::Basepack::FormPanel
- Includes:
- DataAccessor, selfself::Fields, selfself::Services
- Defined in:
- lib/netzke/basepack/form_panel.rb,
lib/netzke/basepack/form_panel/fields.rb,
lib/netzke/basepack/form_panel/services.rb
Overview
Ext.form.Panel-based component
Netzke-specific config options
-
model
- name of the ActiveRecord model that provides data to this GridPanel. -
record
- record to be displayd in the form. Takes precedence over:record_id
-
record_id
- id of the record to be displayd in the form. Also see:record
-
items
- the layout of the fields as an array. See “Layout configuration”. -
mode
- render mode, accepted options:-
lockable
- makes the form panel load initially in “display mode”, then lets “unlock” it, change the values, and “lock” it again, while updating the values on the server
-
-
updateMask
-Ext.LoadMask
config options for the mask shown while the form is submitting its values
Layout configuration
The layout of the form is configured by supplying the item
config option, same way it would be configured in Ext (thus allowing for complex form layouts). FormPanel will expand fields by looking at their names (unless no_binding
set to true
is specified for a specific field).
Endpoints
FormPanel implements the following endpoints:
-
netzke_load
- loads a record with a given id from the server, e.g.:someFormPanel.netzkeLoad({id: 100});
-
netzke_submit
- gets called when the form gets submitted (e.g. by pressing the Apply button, or by calling onApply) -
get_combobox_options
- gets called when a ‘remote’ combobox field gets expanded
Direct Known Subclasses
Defined Under Namespace
Instance Method Summary collapse
- #configuration ⇒ Object
- #configure_bbar(c) ⇒ Object
- #configure_locked(c) ⇒ Object
-
#js_config ⇒ Object
WIP: Needed for FileUploadField js_include :misc.
-
#js_record_data ⇒ Object
A hash of record data including the meta field.
- #record ⇒ Object
Methods included from DataAccessor
#association_attr?, #combobox_options_for_column, #data_adapter, #data_class, #normalize_attr, #normalize_attrs, #primary_key_attr?, #set_default_virtual
Instance Method Details
#configuration ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/netzke/basepack/form_panel.rb', line 70 def configuration super.tap do |sup| configure_locked(sup) (sup) sup[:record_id] = sup[:record] = nil if sup[:multi_edit] # never set record_id in multi-edit mode end end |
#configure_bbar(c) ⇒ Object
83 84 85 |
# File 'lib/netzke/basepack/form_panel.rb', line 83 def (c) c[:bbar] = [:apply.action] if c[:bbar].nil? && !c[:read_only] end |
#configure_locked(c) ⇒ Object
79 80 81 |
# File 'lib/netzke/basepack/form_panel.rb', line 79 def configure_locked(c) c[:locked] = c[:locked].nil? ? (c[:mode] == :lockable) : c[:locked] end |
#js_config ⇒ Object
WIP: Needed for FileUploadField js_include :misc
100 101 102 103 104 105 |
# File 'lib/netzke/basepack/form_panel.rb', line 100 def js_config super.tap do |res| res[:pri] = data_class && data_class.primary_key.to_s res[:record] = js_record_data if record end end |
#js_record_data ⇒ Object
A hash of record data including the meta field
108 109 110 |
# File 'lib/netzke/basepack/form_panel.rb', line 108 def js_record_data record.netzke_hash(fields).merge(:_meta => ).literalize_keys end |
#record ⇒ Object
112 113 114 |
# File 'lib/netzke/basepack/form_panel.rb', line 112 def record @record ||= config[:record] || config[:record_id] && data_class && data_adapter.find_record(config[:record_id]) end |