Sha256: 97071e7ec4da276978359a90a6724a5f8c390fe5ddc4002c9d9b34816a3d1169

Contents?: true

Size: 899 Bytes

Versions: 44

Compression:

Stored size: 899 Bytes

Contents

/* eslint-disable require-jsdoc */

// If you want to customize the geocoder address format which is displayed
// when showing the geocoding results list, add this configuration code to
// your geocoder at config/initializers/decidim.rb:
// config.maps = {
//   # ... other configs ...
//   autocomplete: {
//     address_format: [%w(street houseNumber), "city", "country"]
//   }
// }
//
// For the available address keys, refer to the provider's own documentation.
const compact = (items) => items.filter(
  (part) => part !== null && typeof part !== "undefined" && `${part}`.trim().length > 0
);

export default function formatAddress(object, keys, separator = ", ") {
  const parts = keys.map((key) => {
    if (Array.isArray(key)) {
      return formatAddress(object, key, " ");
    }
    return object[key] || object[key.toLowerCase()];
  })

  return compact(parts).join(separator).trim();
}

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-core-0.26.8 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.27.4 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.27.3 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.7 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.5 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.27.2 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.27.1 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.4 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.27.0 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.3 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.27.0.rc2 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.27.0.rc1 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.2 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.1 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.0 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.0.rc2 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.26.0.rc1 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.25.2 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.25.1 app/packs/src/decidim/geocoding/format_address.js
decidim-core-0.25.0 app/packs/src/decidim/geocoding/format_address.js