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

Inherits:
Frontend::Builder show all
Defined in:
decidim-core/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

#append_assets, #initialize

Constructor Details

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

Instance Method Details

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

Renders the geocoding field element for the view. If the component supports geolocation (as determined by ‘show_my_location_button?`), the field will include a button allowing the user to use their current location to autofill the address. Otherwise, a standard geocoding input field is rendered without the location button.

Parameters:

  • object_name (String, Symbol)

    The name of the object the field is being generated for.

  • method (String, Symbol)

    The specific attribute or property of the object.

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

    Additional options for customizing the field’s behavior and appearance.

Returns:

  • (String)

    The HTML markup for the geocoding field.



23
24
25
26
27
28
29
30
31
32
# File 'decidim-core/lib/decidim/map/autocomplete.rb', line 23

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

  if show_my_location_button?
    geocoding_field_with_location_button(object_name, method, options)
  else
    geocoding_field_without_location_button(object_name, method, options)
  end
end