FIX: Minor fixtures

This commit is contained in:
Tony Air 2022-05-25 16:37:44 +02:00
parent 28bf9d80a3
commit 3769c12602
2 changed files with 37 additions and 8 deletions

View File

@ -15,6 +15,7 @@ use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TreeMultiselectField; use SilverStripe\Forms\TreeMultiselectField;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use Symbiote\Addressable\Addressable;
//use BetterBrief\GoogleMapField; //use BetterBrief\GoogleMapField;
@ -44,11 +45,11 @@ class SiteConfigExtension extends DataExtension
'Longitude' => 'Decimal(10, 8)', 'Longitude' => 'Decimal(10, 8)',
'Latitude' => 'Decimal(11, 8)', 'Latitude' => 'Decimal(11, 8)',
'MapZoom' => 'Int', 'MapZoom' => 'Int',
//'MapAPIKey' => 'Varchar(255)',
'Description' => 'Varchar(255)', 'Description' => 'Varchar(255)',
'Address' => 'Varchar(255)', 'Address' => 'Varchar(255)',
'Suburb' => 'Varchar(255)', 'Suburb' => 'Varchar(255)',
'State' => 'Varchar(255)', 'State' => 'Varchar(255)',
'Country' => 'Varchar(255)',
'ZipCode' => 'Varchar(6)', 'ZipCode' => 'Varchar(6)',
]; ];
@ -98,12 +99,40 @@ class SiteConfigExtension extends DataExtension
$mapTab = $fields->findOrMakeTab('Root.Maps'); $mapTab = $fields->findOrMakeTab('Root.Maps');
$mapTab->setTitle('Address / Map'); $mapTab->setTitle('Address / Map');
$fields->addFieldsToTab('Root.Maps', [
$addrFields =[
TextField::create('Address'), TextField::create('Address'),
TextField::create('Suburb', 'City'),
TextField::create('State'),
TextField::create('ZipCode'), TextField::create('ZipCode'),
]); TextField::create('Suburb', 'City'),
];
if (\class_exists(Addressable::class)) {
$addr = \singleton(Addressable::class);
$stateLabel = _t('Addressable.STATE', 'State');
$allowedStates = $addr->getAllowedStates();
if (count($allowedStates) >= 1) {
// If allowed states are restricted, only allow those
$addrFields[] = DropdownField::create('State', $stateLabel, $allowedStates);
} elseif (!$allowedStates) {
// If no allowed states defined, allow the user to type anything
$addrFields[] = TextField::create('State', $stateLabel);
}
// Get country field
$addrFields[] = DropdownField::create(
'Country',
_t('Addressable.COUNTRY', 'Country'),
$addr->getAllowedCountries()
);
} else {
$addrFields[] = TextField::create('State');
$addrFields[] = TextField::create('Country');
}
$fields->addFieldsToTab('Root.Maps', $addrFields);
if (MapboxField::getAccessToken()) { if (MapboxField::getAccessToken()) {
$fields->addFieldsToTab('Root.Maps', [ $fields->addFieldsToTab('Root.Maps', [

View File

@ -66,7 +66,7 @@ class DeferredRequirements implements TemplateGlobalProvider
// Main libs // Main libs
if (!$config['nojquery']) { if (!$config['nojquery']) {
self::loadJS( self::loadJS(
'//ajax.googleapis.com/ajax/libs/jquery/' 'https://ajax.googleapis.com/ajax/libs/jquery/'
.$config['jquery_version'].'/jquery.min.js' .$config['jquery_version'].'/jquery.min.js'
); );
} }
@ -140,9 +140,9 @@ class DeferredRequirements implements TemplateGlobalProvider
if ($config['fontawesome_svg']) { if ($config['fontawesome_svg']) {
Requirements::customScript('FontAwesomeConfig={searchPseudoElements:true}'); Requirements::customScript('FontAwesomeConfig={searchPseudoElements:true}');
self::loadJS('//use.fontawesome.com/releases/v'.$v.'/js/all.js'); self::loadJS('https://use.fontawesome.com/releases/v'.$v.'/js/all.js');
} else { } else {
self::loadCSS('//use.fontawesome.com/releases/v'.$v.'/css/all.css'); self::loadCSS('https://use.fontawesome.com/releases/v'.$v.'/css/all.css');
} }
} }