Skip to content

Commit 9cc271f

Browse files
authored
Merge pull request BetterBrief#32 from timezoneone/ss4-upgrade
Ss4 upgrade
2 parents cc331fc + f70dd9d commit 9cc271f

File tree

9 files changed

+41
-16
lines changed

9 files changed

+41
-16
lines changed

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ checks:
6666
argument_type_checks: true
6767

6868
filter:
69-
paths: [code/*, tests/*]
69+
paths: [src/*, tests/*]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ You can also search for locations using the search box, which uses the Google Ma
1717
|------|-------|-----------|
1818
|`field_names`|See `GoogleMapField.yml`'s `default_options.field_names`|A map of field names to save the map data into your object.|
1919

20+
##### make sure `api_key` config added in site yml file
21+
```yml
22+
BetterBrief\GoogleMapField:
23+
default_options:
24+
api_key: 'GOOGLE_API_KEY'
25+
```
26+
2027
##### `Field` options
2128

2229
|Option|Default|Description|

_config.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

_config/googlemapfield.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
Name: googlemapfield
3+
Before: '*'
34
---
4-
GoogleMapField:
5+
BetterBrief\GoogleMapField:
56
default_options:
67
api_key: null
78
show_search_box: true

css/GoogleMapField.css renamed to client/css/GoogleMapField.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
border: 1px solid #b3b3b3;
88
margin-top: 8px;
99
box-sizing: border-box;
10-
max-width: 512px;
1110
}
File renamed without changes.

composer.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "betterbrief/silverstripe-googlemapfield",
3-
"type": "silverstripe-module",
3+
"type": "silverstripe-vendormodule",
44
"description": "Save locations using latitude/longitude DataObject fields.",
55
"keywords": ["maps","google", "googlemapfield", "silverstripe", "map", "geolocation"],
66
"homepage": "http://github.com/BetterBrief/googlemapfield",
@@ -13,10 +13,19 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=5.3.0",
17-
"composer/installers": "~1.0"
16+
"php": ">=5.5.0",
17+
"composer/installers": "~1.0",
18+
"silverstripe/framework": "^4"
1819
},
19-
"extra" : {
20-
"installer-name": "googlemapfield"
20+
"autoload": {
21+
"psr-4": {
22+
"BetterBrief\\": "src/"
23+
}
24+
},
25+
"extra": {
26+
"expose": [
27+
"client/css",
28+
"client/js"
29+
]
2130
}
2231
}

code/GoogleMapField.php renamed to src/GoogleMapField.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
* Maps Geocoding API.
1010
* @author <@willmorgan>
1111
*/
12+
13+
namespace BetterBrief;
14+
15+
use SilverStripe\Forms\FormField;
16+
use SilverStripe\ORM\DataObject;
17+
use SilverStripe\Forms\HiddenField;
18+
use SilverStripe\Forms\TextField;
19+
use SilverStripe\View\Requirements;
20+
use SilverStripe\ORM\DataObjectInterface;
21+
use SilverStripe\Forms\FieldList;
22+
use SilverStripe\Core\Convert;
23+
1224
class GoogleMapField extends FormField {
1325

1426
protected $data;
@@ -166,15 +178,15 @@ protected function requireDependencies() {
166178
if($key = $this->getOption('api_key')) {
167179
$gmapsParams['key'] = $key;
168180
}
169-
Requirements::css(GOOGLEMAPFIELD_BASE .'/css/GoogleMapField.css');
170-
Requirements::javascript(GOOGLEMAPFIELD_BASE .'/javascript/GoogleMapField.js');
181+
Requirements::css('betterbrief/silverstripe-googlemapfield: client/css/GoogleMapField.css');
182+
Requirements::javascript('betterbrief/silverstripe-googlemapfield: client/js/GoogleMapField.js');
171183
Requirements::javascript('//maps.googleapis.com/maps/api/js?' . http_build_query($gmapsParams));
172184
}
173185

174186
/**
175187
* {@inheritdoc}
176188
*/
177-
public function setValue($record) {
189+
public function setValue($record, $data = null) {
178190
$this->latField->setValue(
179191
$record['Latitude']
180192
);

templates/GoogleMapField.ss renamed to templates/BetterBrief/GoogleMapField.ss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="googlemapfield $extraClass" $AttributesHTML>
22
<div class="googlemapfield-controls">
3-
<% loop ChildFields %>
4-
$Field
3+
<% loop $ChildFields %>
4+
$Field
55
<% end_loop %>
66
</div>
77
<div class="googlemapfield-map"></div>

0 commit comments

Comments
 (0)