Skip to content

Commit

Permalink
Changes plugin vendor name and namespace to vaersaagod. Adds apiLangu…
Browse files Browse the repository at this point in the history
…age and apiRegion settings. Bump to 2.2.0
  • Loading branch information
mmikkel committed Feb 10, 2020
1 parent 5ab3de6 commit ffa035b
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"pluginName":"Locate","pluginDescription":"Harness the power of the Google Autocomplete API inside Craft. Adds an autocomplete search box to Craft entries.","pluginVersion":"2.1.1","pluginAuthorName":"Isaac Gray","pluginVendorName":"swixpop","pluginAuthorUrl":"https://www.vaersaagod.no/","pluginAuthorGithub":"swixpop","codeComments":"yes","pluginComponents":["controllers","fieldtypes","models","services","settings"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
{"pluginName":"Locate","pluginDescription":"Harness the power of the Google Autocomplete API inside Craft. Adds an autocomplete search box to Craft entries.","pluginVersion":"2.1.1","pluginAuthorName":"Isaac Gray","pluginVendorName":"vaersaagod","pluginAuthorUrl":"https://www.vaersaagod.no/","pluginAuthorGithub":"vaersaagod","codeComments":"yes","pluginComponents":["controllers","fieldtypes","models","services","settings"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.2.0 - 2020-02-10
### Added
- Adds `apiLanguage` and `apiRegion` settings
### Changed
- Changes plugin vendor name and namespace from "swixpop" to "vaersaagod"

## 2.1.1 - 2019-02-27
### Fixed
- Bug where place data with emojis would prevent saving of field
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "swixpop/locate",
"name": "vaersaagod/locate",
"description": "Harness the power of the Google Autocomplete API inside Craft. Adds an autocomplete search box to Craft entries.",
"type": "craft-plugin",
"version": "2.1.1",
"version": "2.2.0",
"keywords": [
"craft",
"cms",
Expand All @@ -16,8 +16,8 @@
"locations"
],
"support": {
"docs": "https://github.com/swixpop/craft-locate/blob/master/README.md",
"issues": "https://github.com/swixpop/craft-locate/issues"
"docs": "",
"issues": ""
},
"license": "MIT",
"authors": [
Expand All @@ -32,15 +32,15 @@
},
"autoload": {
"psr-4": {
"swixpop\\locate\\": "src/"
"vaersaagod\\locate\\": "src/"
}
},
"extra": {
"name": "Locate",
"handle": "locate",
"hasCpSettings": true,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/swixpop/craft-locate/master/CHANGELOG.md",
"class": "swixpop\\locate\\Locate"
"changelogUrl": "",
"class": "vaersaagod\\locate\\Locate"
}
}
6 changes: 3 additions & 3 deletions src/Locate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* @copyright Copyright (c) 2018 Isaac Gray
*/

namespace swixpop\locate;
namespace vaersaagod\locate;

use swixpop\locate\models\Settings;
use swixpop\locate\fields\LocateField as LocateFieldField;
use vaersaagod\locate\models\Settings;
use vaersaagod\locate\fields\LocateField as LocateFieldField;

use Craft;
use craft\base\Plugin;
Expand Down
4 changes: 2 additions & 2 deletions src/assetbundles/locate/LocateAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @copyright Copyright (c) 2018 Isaac Gray
*/

namespace swixpop\locate\assetbundles\Locate;
namespace vaersaagod\locate\assetbundles\Locate;

use Craft;
use craft\web\AssetBundle;
Expand All @@ -31,7 +31,7 @@ class LocateAsset extends AssetBundle
public function init()
{
// define the path that your publishable resources live
$this->sourcePath = "@swixpop/locate/assetbundles/locate/dist";
$this->sourcePath = "@vaersaagod/locate/assetbundles/locate/dist";

// define the dependencies
$this->depends = [
Expand Down
4 changes: 2 additions & 2 deletions src/assetbundles/locatefieldfield/LocateFieldFieldAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @copyright Copyright (c) 2018 Isaac Gray
*/

namespace swixpop\locate\assetbundles\locatefieldfield;
namespace vaersaagod\locate\assetbundles\locatefieldfield;

use Craft;
use craft\web\AssetBundle;
Expand All @@ -32,7 +32,7 @@ class LocateFieldFieldAsset extends AssetBundle
public function init()
{
// define the path that your publishable resources live
$this->sourcePath = "@swixpop/locate/assetbundles/locatefieldfield/dist";
$this->sourcePath = "@vaersaagod/locate/assetbundles/locatefieldfield/dist";

// define the dependencies
$this->depends = [
Expand Down
28 changes: 22 additions & 6 deletions src/fields/LocateField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
* @copyright Copyright (c) 2018 Isaac Gray
*/

namespace swixpop\locate\fields;
namespace vaersaagod\locate\fields;

use craft\base\Plugin;
use craft\base\PluginInterface;
use craft\elements\db\ElementQueryInterface;
use swixpop\locate\Locate;
use swixpop\locate\assetbundles\locatefieldfield\LocateFieldFieldAsset;
use swixpop\locate\models\LocateModel;
use vaersaagod\locate\Locate;
use vaersaagod\locate\assetbundles\locatefieldfield\LocateFieldFieldAsset;
use vaersaagod\locate\models\LocateModel;

use craft\helpers\StringHelper;

Expand Down Expand Up @@ -192,11 +192,27 @@ public function getInputHtml($value, ElementInterface $element = null): string
// Get our id and namespace
$id = Craft::$app->getView()->formatInputId($this->handle);
$namespacedId = Craft::$app->getView()->namespaceInputId($id);
$apiKey = Locate::getInstance()->getSettings()->googleMapsApiKey;

$settings = Locate::getInstance()->getSettings();

$apiKey = $settings->googleMapsApiKey;

if ($apiKey) {
Craft::$app->getView()->registerJsFile('https://maps.googleapis.com/maps/api/js?key=' . $apiKey . '&libraries=places');

$apiLanguage = $settings->apiLanguage;
$apiRegion = $settings->apiRegion;

$apiUrl = 'https://maps.googleapis.com/maps/api/js?key=' . $apiKey . '&libraries=places';

if ($apiLanguage) {
$apiUrl .= "&language={$apiLanguage}";
}

if ($apiRegion) {
$apiUrl .= "&region={$apiRegion}";
}

Craft::$app->getView()->registerJsFile($apiUrl);

if ($this->getSettings()['optionsObject']) {
$jsonOptions = $this->getSettings()['optionsObject'];
Expand Down
4 changes: 2 additions & 2 deletions src/models/LocateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* @copyright Copyright (c) 2018 Isaac Gray
*/

namespace swixpop\locate\models;
namespace vaersaagod\locate\models;

use swixpop\locate\Locate;
use vaersaagod\locate\Locate;

use Craft;
use craft\base\Model;
Expand Down
16 changes: 13 additions & 3 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* @copyright Copyright (c) 2018 Isaac Gray
*/

namespace swixpop\locate\models;
namespace vaersaagod\locate\models;

use swixpop\locate\Locate;
use vaersaagod\locate\Locate;

use Craft;
use craft\base\Model;
Expand All @@ -35,13 +35,23 @@ class Settings extends Model
*/
public $autocompleteOptions;

/**
* @var string|null
*/
public $apiLanguage;

/**
* @var string|null
*/
public $apiRegion;

/**
* @inheritDoc
*/
public function rules()
{
return [
[['googleMapsApiKey', 'autocompleteOptions'], 'string']
[['googleMapsApiKey', 'autocompleteOptions', 'apiLanguage', 'apiRegion'], 'string']
];
}
}
2 changes: 1 addition & 1 deletion src/templates/_components/fields/LocateField_settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

{% import "_includes/forms" as forms %}

{% do view.registerAssetBundle("swixpop\\locate\\assetbundles\\locate\\LocateAsset") %}
{% do view.registerAssetBundle("vaersaagod\\locate\\assetbundles\\locate\\LocateAsset") %}
<div class="swixpop-locate">
{{ forms.textareaField({
label: 'Google autocomplete options' | t('locate'),
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="swixpop-locate">
{% import "_includes/forms" as forms %}

{% do view.registerAssetBundle("swixpop\\locate\\assetbundles\\locate\\LocateAsset") %}
{% do view.registerAssetBundle("vaersaagod\\locate\\assetbundles\\locate\\LocateAsset") %}

{{ forms.textField({
label: 'Google Maps API Key' | t('locate'),
Expand Down

0 comments on commit ffa035b

Please sign in to comment.