Skip to content

Commit

Permalink
Model: Elevation and Items
Browse files Browse the repository at this point in the history
  • Loading branch information
marczhermo authored and Marco Hermo committed Aug 19, 2019
1 parent 4160003 commit bcf7bc6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"silverstripe/queuedjobs": "^4",
"solarium/solarium": "^4.2",
"minimalcode/search": "^1.0",
"guzzlehttp/guzzle": "^6.3"
"guzzlehttp/guzzle": "^6.3",
"symbiote/silverstripe-gridfieldextensions": "^3"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
Expand Down
27 changes: 26 additions & 1 deletion src/Admins/SearchAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace Firesphere\SolrSearch\Admins;

use Firesphere\SolrSearch\Forms\GridFieldOrderableSearch;
use Firesphere\SolrSearch\Models\SearchClass;
use Firesphere\SolrSearch\Models\Elevation;
use Firesphere\SolrSearch\Models\ElevatedItem;
use SilverStripe\Admin\ModelAdmin;
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;

/**
* Class \Firesphere\SolrSearch\Admins\SearchAdmin
Expand All @@ -12,13 +16,34 @@
class SearchAdmin extends ModelAdmin
{
private static $managed_models = [
SearchClass::class
SearchClass::class,
Elevation::class,
ElevatedItem::class,
];
private static $menu_icon_class = 'font-icon-search';
private static $url_segment = 'searchadmin';
private static $menu_title = 'Search';
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;
}
}
/** **/
26 changes: 26 additions & 0 deletions src/Models/ElevatedItem.php
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
{
private static $table_name = 'ElevatedItem';

private static $db = [
'Rank' => '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'];
}
20 changes: 20 additions & 0 deletions src/Models/Elevation.php
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'];
}

0 comments on commit bcf7bc6

Please sign in to comment.