Class: Forma::MapField
Overview
Map field.
Instance Attribute Summary
Attributes inherited from Field
#actions, #after, #autofocus, #before, #child_model_name, #hint, #i18n, #icon, #inline_hint, #label, #model, #model_name, #name, #parent, #readonly, #required, #tag, #turbolink, #url
Instance Method Summary collapse
- #edit_element(val) ⇒ Object
- #height ⇒ Object
- #value ⇒ Object
- #view_element(val) ⇒ Object
- #width ⇒ Object
Methods inherited from Field
#action, #id, #initialize, #localization_key, #localized_hint, #localized_label, #name_as_chain, #parameter_name, #to_html
Methods included from Html
Methods included from Utils
extract_value, number_format, #simple_value, singular_name
Constructor Details
This class inherits a constructor from Forma::Field
Instance Method Details
#edit_element(val) ⇒ Object
210 211 212 213 214 215 216 217 218 |
# File 'lib/forma/field.rb', line 210 def edit_element(val) el('div', attrs: { style: { width: "#{self.width}px", height: "#{self.height}px", position: 'relative' } }, children: [ el('div', attrs: { id: self.id, class: 'ff-map' }), # google_import, map_display(val, true), el('input', attrs: { name: latitude_name, id: "#{self.id}_latitude", value: val[0], type: 'hidden' }), el('input', attrs: { name: longitude_name, id: "#{self.id}_longitude", value: val[1], type: 'hidden' }), ]) end |
#height ⇒ Object
200 |
# File 'lib/forma/field.rb', line 200 def height; @height || 500 end |
#value ⇒ Object
189 190 191 192 193 194 195 196 197 |
# File 'lib/forma/field.rb', line 189 def value val = super if val then val else lat = extract_value(self.model, "#{self.name}_latitude") || Forma.config.map.default_latitude long = extract_value(self.model, "#{self.name}_longitude") || Forma.config.map.default_longitude [ lat, long ] end end |
#view_element(val) ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/forma/field.rb', line 202 def view_element(val) el('div', attrs: { style: { width: "#{self.width}px", height: "#{self.height}px", position: 'relative' } }, children: [ el('div', attrs: { id: self.id, class: 'ff-map' }), # google_import, map_display(val, false) ]) end |
#width ⇒ Object
199 |
# File 'lib/forma/field.rb', line 199 def width; @width || 500 end |