Class: Decidim::Map::Autocomplete::Builder

Inherits:
Frontend::Builder show all
Defined in:
lib/decidim/map/autocomplete.rb

Overview

A builder for the geocoding autocompletion to be attached to the views. Provides all the necessary functionality to initialize the front-end geocoding autocompletion functionality.

Instance Method Summary collapse

Methods inherited from Frontend::Builder

#initialize, #javascript_snippets, #stylesheet_snippets

Constructor Details

This class inherits a constructor from Decidim::Map::Frontend::Builder

Instance Method Details

#geocoding_field(object_name, method, options = {}) ⇒ String

Displays the geocoding field element’s markup for the view.

Parameters:

  • object_name (String, Symbol)

    The name for the object for which the field is generated for.

  • method (String, Symbol)

    The method/property in the object that the field is for.

  • options (Hash) (defaults to: {})

    Extra options for the field.

Returns:

  • (String)

    The field element’s markup.



20
21
22
23
24
25
26
27
28
# File 'lib/decidim/map/autocomplete.rb', line 20

def geocoding_field(object_name, method, options = {})
  options[:autocomplete] ||= "off"

  template.text_field(
    object_name,
    method,
    options.merge("data-decidim-geocoding" => view_options.to_json)
  )
end