From 8e3dacc233e9b2dab6c6aef0444648b33c4d1583 Mon Sep 17 00:00:00 2001 From: Marco Hermo Date: Sun, 26 May 2019 00:28:21 +1200 Subject: [PATCH] Elevation: Change field name to text worked for elevation Model: Elevation and Items --- Solr/5/extras/elevate.xml | 10 +++++----- Solr/5/extras/solrconfig.xml | 16 ++++++++-------- composer.json | 3 ++- src/Admins/SearchAdmin.php | 27 ++++++++++++++++++++++++++- src/Models/ElevatedItem.php | 27 +++++++++++++++++++++++++++ src/Models/Elevation.php | 21 +++++++++++++++++++++ 6 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 src/Models/ElevatedItem.php create mode 100644 src/Models/Elevation.php diff --git a/Solr/5/extras/elevate.xml b/Solr/5/extras/elevate.xml index d0d6a4e3..0e934fdd 100644 --- a/Solr/5/extras/elevate.xml +++ b/Solr/5/extras/elevate.xml @@ -23,14 +23,14 @@ - - - + + + - - + + diff --git a/Solr/5/extras/solrconfig.xml b/Solr/5/extras/solrconfig.xml index b01b3db7..4386de28 100644 --- a/Solr/5/extras/solrconfig.xml +++ b/Solr/5/extras/solrconfig.xml @@ -810,7 +810,7 @@ explicit 10 - _text + text default - _text + text solr.DirectSolrSpellChecker internal @@ -1307,7 +1307,7 @@ wordbreak solr.WordBreakSolrSpellChecker - _text + text true true 10 @@ -1367,7 +1367,7 @@ --> - _text + text - _text + text true @@ -1551,7 +1551,7 @@ --> - string + text elevate.xml diff --git a/composer.json b/composer.json index b8d64a06..5c70391b 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "silverstripe/queuedjobs": "^4", "solarium/solarium": "^5.0", "minimalcode/search": "^1.0", - "guzzlehttp/guzzle": "^6.3" + "guzzlehttp/guzzle": "^6.3", + "symbiote/silverstripe-gridfieldextensions": "^3" }, "require-dev": { "phpunit/phpunit": "^5.7", diff --git a/src/Admins/SearchAdmin.php b/src/Admins/SearchAdmin.php index 83e7f735..7bd86fb7 100644 --- a/src/Admins/SearchAdmin.php +++ b/src/Admins/SearchAdmin.php @@ -3,9 +3,13 @@ namespace Firesphere\SolrSearch\Admins; use Firesphere\SolrSearch\Models\DirtyClass; +use Firesphere\SolrSearch\Models\ElevatedItem; +use Firesphere\SolrSearch\Models\Elevation; use Firesphere\SolrSearch\Models\SolrLog; use SilverStripe\Admin\ModelAdmin; +use SilverStripe\Forms\GridField\GridField; use SilverStripe\View\Requirements; +use Symbiote\GridFieldExtensions\GridFieldOrderableRows; /** * Class \Firesphere\SolrSearch\Admins\SearchAdmin @@ -24,6 +28,8 @@ class SearchAdmin extends ModelAdmin private static $managed_models = [ SolrLog::class, DirtyClass::class, + Elevation::class, + ElevatedItem::class, ]; /** @@ -54,6 +60,25 @@ public function init() { parent::init(); - Requirements::css('firesphere/solr-search:client/dist/main.css'); + //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..2e0c6f3b --- /dev/null +++ b/src/Models/ElevatedItem.php @@ -0,0 +1,27 @@ + 'Int', + 'SolrID' => 'Varchar(255)', + 'Include' => 'Boolean(1)', + 'Exclude' => 'Boolean(0)', + ]; + + private static $has_one = [ + 'Record' => DataObject::class, + ]; + + private static $belongs_many_many = [ + 'Keywords' => Elevation::class, + ]; + + private static $summary_fields = ['ID', 'Rank', 'SolrID', 'Include', 'Exclude']; +} diff --git a/src/Models/Elevation.php b/src/Models/Elevation.php new file mode 100644 index 00000000..6d2d070d --- /dev/null +++ b/src/Models/Elevation.php @@ -0,0 +1,21 @@ + 'Varchar(255)', + ]; + + private static $many_many = [ + 'Items' => ElevatedItem::class, + ]; + + private static $summary_fields = ['ID', 'Keyword']; +} + \ No newline at end of file