Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REFACTOR LocationPage modeling #223

Merged
merged 14 commits into from
Jul 21, 2020
8 changes: 7 additions & 1 deletion _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ Dynamic\Locator\Location:
- Dynamic\SilverStripeGeocoder\AddressDataExtension
- SilverStripe\Versioned\Versioned('Stage','Live')

Dynamic\Locator\Locator:
Dynamic\Locator\Page\LocationPage:
extensions:
- Dynamic\SilverStripeGeocoder\DistanceDataExtension
- Dynamic\SilverStripeGeocoder\AddressDataExtension
- SilverStripe\Versioned\Versioned('Stage','Live')
muskie9 marked this conversation as resolved.
Show resolved Hide resolved

Dynamic\Locator\Page\Locator:
infoWindowTemplate: 'dynamic/silverstripe-locator: client/infowindow-description.html'
listTemplate: 'dynamic/silverstripe-locator: client/location-list-description.html'
limit: 50
Expand Down
6 changes: 3 additions & 3 deletions _config/legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name: locatorlegacy
---
SilverStripe\ORM\DatabaseAdmin:
classname_value_remapping:
Location: Dynamic\Locator\Location
Locator: Dynamic\Locator\Locator
LocationCategory: Dynamic\Locator\LocationCategory
Dynamic\Locator\Location: Dynamic\Locator\Location
Dynamic\Locator\Locator: Dynamic\Locator\Page\Locator
Dynamic\Locator\LocationCategory: Dynamic\Locator\Model\LocationCategory
2 changes: 1 addition & 1 deletion src/objects/Location.php → src/Model/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Dynamic\Locator;

use Dynamic\Locator\Model\LocationCategory;
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Security\PermissionProvider;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\EmailField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Security\Permission;
use Symbiote\GridFieldExtensions\GridFieldAddExistingSearchButton;

Expand Down
27 changes: 15 additions & 12 deletions src/objects/LocationCategory.php → src/Model/LocationCategory.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

namespace Dynamic\Locator;
namespace Dynamic\Locator\Model;

use Dynamic\Locator\Location;
use Dynamic\Locator\Page\Locator;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
Expand All @@ -15,8 +18,8 @@
* Class LocationCategory
*
* @property string $Name
* @method Locations|ManyManyList LocationSet()
* @method Locators|ManyManyList Locators()
* @method ManyManyList LocationSet()
* @method ManyManyList Locators()
*/
class LocationCategory extends DataObject
{
Expand All @@ -33,17 +36,17 @@ class LocationCategory extends DataObject
/**
* @var array
*/
private static $db = array(
private static $db = [
'Name' => 'Varchar(100)',
);
];

/**
* @var array
*/
private static $belongs_many_many = array(
private static $belongs_many_many = [
'Locators' => Locator::class,
'LocationSet' => Location::class,
);
];

/**
* @var string
Expand All @@ -60,7 +63,7 @@ class LocationCategory extends DataObject
*/
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function ($fields) {
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName([
'Locations',
'LocationSet',
Expand All @@ -74,17 +77,17 @@ public function getCMSFields()
$config = GridFieldConfig_RelationEditor::create();
$config->removeComponentsByType([
GridFieldAddExistingAutocompleter::class,
GridFieldAddNewButton::class
GridFieldAddNewButton::class,
])
->addComponents([
new GridFieldAddExistingSearchButton(),
]);
$locations = $this->Locations();
$locationField = GridField::create('Locations', 'Locations', $locations, $config);

$fields->addFieldsToTab('Root.Main', array(
$fields->addFieldsToTab('Root.Main', [
$locationField,
));
]);
}
});

Expand All @@ -95,7 +98,7 @@ public function getCMSFields()

/**
* For backwards compatability
* @return Locations|ManyManyList
* @return ManyManyList
*/
public function Locations()
{
Expand Down
Loading