mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.10' into 4
This commit is contained in:
commit
3202ef7c52
@ -12,10 +12,10 @@ use SilverStripe\Forms\TextField;
|
|||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\Filters\SearchFilter;
|
||||||
use SilverStripe\View\ArrayData;
|
use SilverStripe\View\ArrayData;
|
||||||
use SilverStripe\View\SSViewer;
|
use SilverStripe\View\SSViewer;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use SilverStripe\ORM\Filters\SearchFilter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is is responsible for adding objects to another object's has_many
|
* This class is is responsible for adding objects to another object's has_many
|
||||||
@ -347,7 +347,7 @@ class GridFieldAddExistingAutocompleter extends AbstractGridFieldComponent imple
|
|||||||
// so we need to check the original setting.
|
// so we need to check the original setting.
|
||||||
// If the field is defined $searchable_fields = array('MyField'),
|
// If the field is defined $searchable_fields = array('MyField'),
|
||||||
// then default to StartsWith filter, which makes more sense in this context.
|
// then default to StartsWith filter, which makes more sense in this context.
|
||||||
if (!$customSearchableFields || array_search($name, $customSearchableFields)) {
|
if (!$customSearchableFields || array_search($name, $customSearchableFields) !== false) {
|
||||||
$filter = 'StartsWith';
|
$filter = 'StartsWith';
|
||||||
} else {
|
} else {
|
||||||
$filterName = $spec['filter'];
|
$filterName = $spec['filter'];
|
||||||
|
@ -14,6 +14,7 @@ use SilverStripe\Forms\Tests\GridField\GridFieldAddExistingAutocompleterTest\Tes
|
|||||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader;
|
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader;
|
||||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
||||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||||
|
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Stadium;
|
||||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
@ -29,7 +30,8 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
|||||||
Team::class,
|
Team::class,
|
||||||
Cheerleader::class,
|
Cheerleader::class,
|
||||||
Player::class,
|
Player::class,
|
||||||
Permissions::class
|
Permissions::class,
|
||||||
|
Stadium::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static $extra_controllers = [
|
protected static $extra_controllers = [
|
||||||
@ -41,15 +43,12 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
|||||||
$autoCompleter = new GridFieldAddExistingAutocompleter($targetFragment = 'before', ['Test']);
|
$autoCompleter = new GridFieldAddExistingAutocompleter($targetFragment = 'before', ['Test']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
'Name:PartialMatch',
|
'Name:StartsWith',
|
||||||
'City:StartsWith',
|
'City:EndsWith',
|
||||||
'Cheerleaders.Name:StartsWith'
|
'Country:ExactMatch',
|
||||||
|
'Type:Fulltext'
|
||||||
],
|
],
|
||||||
$autoCompleter->scaffoldSearchFields(Team::class)
|
$autoCompleter->scaffoldSearchFields(Stadium::class)
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
[ 'Name:StartsWith' ],
|
|
||||||
$autoCompleter->scaffoldSearchFields(Cheerleader::class)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
tests/php/Forms/GridField/GridFieldTest/Stadium.php
Normal file
33
tests/php/Forms/GridField/GridFieldTest/Stadium.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Forms\Tests\GridField\GridFieldTest;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Filters\EndsWithFilter;
|
||||||
|
|
||||||
|
class Stadium extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $table_name = 'GridFieldTest_Stadium';
|
||||||
|
|
||||||
|
private static $db = [
|
||||||
|
'Name' => 'Varchar',
|
||||||
|
'City' => 'Varchar',
|
||||||
|
'Country' => 'Varchar',
|
||||||
|
'Type' => 'Varchar'
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $searchable_fields = [
|
||||||
|
'Name',
|
||||||
|
'City' => [
|
||||||
|
'filter' => EndsWithFilter::class
|
||||||
|
],
|
||||||
|
'Country' => [
|
||||||
|
'filter' => 'ExactMatchFilter'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $extensions = [
|
||||||
|
StadiumExtension::class,
|
||||||
|
];
|
||||||
|
}
|
16
tests/php/Forms/GridField/GridFieldTest/StadiumExtension.php
Normal file
16
tests/php/Forms/GridField/GridFieldTest/StadiumExtension.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Forms\Tests\GridField\GridFieldTest;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\ORM\Filters\FulltextFilter;
|
||||||
|
use SilverStripe\Forms\Tests\GridField\GridFieldTest\StadiumExtension;
|
||||||
|
|
||||||
|
class StadiumExtension extends DataExtension implements TestOnly
|
||||||
|
{
|
||||||
|
public function updateSearchableFields(&$fields)
|
||||||
|
{
|
||||||
|
$fields['Type']['filter'] = new FulltextFilter();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user