-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
WIP: Elevation Configuration #56
base: primary
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't |
||
]; | ||
|
||
/** | ||
|
@@ -57,4 +64,23 @@ public function init() | |
|
||
Requirements::css('firesphere/solr-search:client/dist/main.css'); | ||
} | ||
|
||
public function getEditForm($id = null, $fields = null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid variables with short names like $id. Configured minimum length is 3. |
||
{ | ||
$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')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe also add inline editing if it's possible? Saves users from clicking "new" etc. |
||
} | ||
|
||
return $form; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Firesphere\SolrSearch\Models; | ||
|
||
use SilverStripe\ORM\DataObject; | ||
|
||
class ElevatedItem extends DataObject | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The property $table_name is not named in camelCase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The property $belongs_many_many is not named in camelCase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The property $summary_fields is not named in camelCase. |
||
{ | ||
private static $table_name = 'ElevatedItem'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid unused private fields such as '$table_name'. |
||
|
||
private static $db = [ | ||
'Rank' => 'Int', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you stick to my standard of aligning the |
||
'Title' => 'Varchar(255)', | ||
'ObjectClass' => 'Varchar(255)', | ||
'ObjectID' => 'Int', | ||
'SolrID' => 'Varchar(255)', | ||
'Include' => 'Boolean(1)', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For readability, I prefer using |
||
'Exclude' => 'Boolean(0)', | ||
]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very thorough |
||
|
||
private static $belongs_many_many = [ | ||
'Keywords' => Elevation::class, | ||
]; | ||
|
||
private static $summary_fields = ['Title', 'Rank', 'ObjectClass', 'SolrID', 'Include', 'Exclude']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make it a list 😄 Also, I think |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Firesphere\SolrSearch\Models; | ||
|
||
use SilverStripe\ORM\DataObject; | ||
|
||
class Elevation extends DataObject | ||
{ | ||
private static $table_name = 'Elevation'; | ||
|
||
private static $db = [ | ||
'Keyword' => 'Varchar(255)', | ||
]; | ||
|
||
private static $many_many = [ | ||
'Items' => ElevatedItem::class, | ||
]; | ||
|
||
private static $summary_fields = ['ID', 'Keyword']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, it would be good to list them out instead of using as a string. Also, I'd add |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rename is good, but I'm mildly afraid it might clash at some point with the
Text
DBObject from SilverStripe, causing confusion in naming etc.. Do you have any thoughts about that?