diff --git a/src/Admins/SearchAdmin.php b/src/Admins/SearchAdmin.php index 42aa2372..bcb4baaf 100644 --- a/src/Admins/SearchAdmin.php +++ b/src/Admins/SearchAdmin.php @@ -14,6 +14,11 @@ use Firesphere\SolrSearch\Models\SolrLog; use SilverStripe\Admin\ModelAdmin; use SilverStripe\View\Requirements; +use Firesphere\SolrSearch\Forms\GridFieldOrderableSearch; +use Firesphere\SolrSearch\Models\SearchClass; +use Firesphere\SolrSearch\Models\Elevation; +use Firesphere\SolrSearch\Models\ElevatedItem; +use Symbiote\GridFieldExtensions\GridFieldOrderableRows; /** * Class \Firesphere\SolrSearch\Admins\SearchAdmin @@ -31,6 +36,8 @@ class SearchAdmin extends ModelAdmin SearchSynonym::class, SolrLog::class, DirtyClass::class, + Elevation::class, + ElevatedItem::class, ]; /** @@ -57,4 +64,23 @@ public function init() Requirements::css('firesphere/solr-search:client/dist/main.css'); } + + public function getEditForm($id = null, $fields = null) + { + $oldImportFrom = $this->showImportForm; + $this->showImportForm = false; + /** @var GridField $gridField */ + $form = parent::getEditForm($id, $fields); + $this->showImportForm = $oldImportFrom; + + if ($this->modelClass === ElevatedItem::class) { + $gridField = $form->Fields()->dataFieldByName($this->sanitiseClassName($this->modelClass)); + + $gridField + ->getConfig() + ->addComponent(new GridFieldOrderableRows('Rank')); + } + + return $form; + } } diff --git a/src/Models/ElevatedItem.php b/src/Models/ElevatedItem.php new file mode 100644 index 00000000..96f6be92 --- /dev/null +++ b/src/Models/ElevatedItem.php @@ -0,0 +1,26 @@ + 'Int', + 'Title' => 'Varchar(255)', + 'ObjectClass' => 'Varchar(255)', + 'ObjectID' => 'Int', + 'SolrID' => 'Varchar(255)', + 'Include' => 'Boolean(1)', + 'Exclude' => 'Boolean(0)', + ]; + + private static $belongs_many_many = [ + 'Keywords' => Elevation::class, + ]; + + private static $summary_fields = ['Title', 'Rank', 'ObjectClass', 'SolrID', 'Include', 'Exclude']; +} diff --git a/src/Models/Elevation.php b/src/Models/Elevation.php new file mode 100644 index 00000000..5f6d6965 --- /dev/null +++ b/src/Models/Elevation.php @@ -0,0 +1,20 @@ + 'Varchar(255)', + ]; + + private static $many_many = [ + 'Items' => ElevatedItem::class, + ]; + + private static $summary_fields = ['ID', 'Keyword']; +}