Class: Netzke::Form::Base

Inherits:
Base
  • Object
show all
Includes:
Basepack::Attributes, Basepack::DataAccessor, Basepack::Fields, Endpoints, Services
Defined in:
lib/netzke/form/base.rb

Direct Known Subclasses

Basepack::PagingForm

Constant Summary

Constants included from Basepack::Attributes

Basepack::Attributes::ATTRIBUTE_METHOD_NAME

Instance Method Summary collapse

Methods included from Basepack::DataAccessor

#model, #model_adapter

Methods included from Basepack::Fields

#fields, #fields_from_items, #items

Methods included from Basepack::Attributes

#apply_attribute_dsl, #association_attr?, #association_value_defaults, #attribute_overrides, #attributes, #augment_attribute_config

Methods included from Services

#submit, #values

Instance Method Details

#bbarObject



117
118
119
# File 'lib/netzke/form/base.rb', line 117

def bbar
  config.has_key?(:bbar) ? config[:bbar] : default_bbar
end

#configure_client(c) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/netzke/form/base.rb', line 71

def configure_client(c)
  super

  configure_locked(c)

  if model_adapter
    c.pri = model_adapter.primary_key
  end

  if !c.multiedit
    c.record = js_record_data if record
  else
    c.record_id = c.record = nil if c.multiedit # never set record_id in multi-edit mode
  end
end

#configure_locked(c) ⇒ Object



99
100
101
# File 'lib/netzke/form/base.rb', line 99

def configure_locked(c)
  c[:locked] = c[:locked].nil? ? (c[:mode] == :lockable) : c[:locked]
end

#default_bbarObject



121
122
123
124
125
126
127
# File 'lib/netzke/form/base.rb', line 121

def default_bbar
  [].tap do |bbar|
    unless config.read_only
      bbar << "->" << :apply
    end
  end
end

#js_record_dataObject

A hash of record data including the meta field



109
110
111
# File 'lib/netzke/form/base.rb', line 109

def js_record_data
  model_adapter.record_to_hash(record, fields.values).merge(:meta => meta_field).netzke_literalize_keys
end

#multiedit?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/netzke/form/base.rb', line 129

def multiedit?
  !!config.multiedit
end

#recordObject



113
114
115
# File 'lib/netzke/form/base.rb', line 113

def record
  @record ||= config[:record] || config[:record_id] && model_adapter.find_record(config[:record_id])
end