Skip to content

Commit

Permalink
Merge branch 'v3-dev' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Jun 20, 2019
2 parents 67a17c9 + 1976006 commit 864e1f6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.5.2 - 2019-06-20
### Improved
- FeedMe can now import the individual map parts

## 3.5.1 - 2019-06-20
### Added
- Maps can now populate address and lat/lng data based off only a postcode
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ether/simplemap",
"description": "A beautifully simple Map field type for Craft CMS 3",
"version": "3.5.1",
"version": "3.5.2",
"type": "craft-plugin",
"license": "MIT",
"minimum-stability": "dev",
Expand Down
17 changes: 10 additions & 7 deletions src/elements/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ public function __construct (array $config = [])
if ($this->address === null)
$this->address = '';

if ($this->parts && !is_array($this->parts))
$this->parts = Json::decodeIfJson($this->parts);

if (Parts::isLegacy($this->parts))
$this->parts = new PartsLegacy($this->parts);
else
$this->parts = new Parts($this->parts);
if (!($this->parts instanceof Parts))
{
if ($this->parts && !is_array($this->parts))
$this->parts = Json::decodeIfJson($this->parts);

if (Parts::isLegacy($this->parts))
$this->parts = new PartsLegacy($this->parts);
else
$this->parts = new Parts($this->parts);
}

$this->distance = SimpleMap::getInstance()->map->getDistance($this);
}
Expand Down
12 changes: 12 additions & 0 deletions src/integrations/feedme/FeedMeMaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,22 @@ public function parseField ()
return null;

foreach ($fields as $subFieldHandle => $subFieldInfo)
{
if ($subFieldHandle === 'parts') {
foreach ($subFieldInfo as $handle => $info)
$preppedData[$subFieldHandle][$handle] = DataHelper::fetchValue(
$this->feedData,
$info
);

continue;
}

$preppedData[$subFieldHandle] = DataHelper::fetchValue(
$this->feedData,
$subFieldInfo
);
}

if (isset($preppedData['parts']))
$preppedData['parts'] = new Parts($preppedData['parts']);
Expand Down
22 changes: 19 additions & 3 deletions src/templates/_feedme-mapping.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,30 @@
lat: 'Latitude'|t('simplemap'),
lng: 'Longitude'|t('simplemap'),
zoom: 'Zoom'|t('simplemap'),
address: 'Address'|t('simplemap'),
address: 'Full Address'|t('simplemap'),
'parts.number': 'Number'|t('simplemap'),
'parts.address': 'Address'|t('simplemap'),
'parts.city': 'City'|t('simplemap'),
'parts.postcode': 'Postcode'|t('simplemap'),
'parts.county': 'County'|t('simplemap'),
'parts.state': 'State'|t('simplemap'),
'parts.country': 'Country'|t('simplemap'),
} %}

{% for key, col in simpleMapSubfields %}
{% set splitKey = '.' in key %}
{% set subKey = null %}

{% if splitKey %}
{% set key = key|split('.') %}
{% set subKey = key[1] %}
{% set key = key[0] %}
{% endif %}

{% set nameLabel = col %}
{% set instructionsHandle = handle ~ '[' ~ key ~ ']' %}
{% set instructionsHandle = handle ~ '[' ~ key ~ ']' ~ (subKey ? '[' ~ subKey ~ ']') %}

{% set path = prefixPath | merge ([ 'fields', key ]) %}
{% set path = prefixPath | merge ([ 'fields', key, subKey ]|filter) %}

{% set default = default ?? {
type: 'text',
Expand Down

0 comments on commit 864e1f6

Please sign in to comment.