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 ssmarco committed Mar 4, 2020
1 parent 65d65c9 commit 77a4b04
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Admins/SearchAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +36,8 @@ class SearchAdmin extends ModelAdmin
SearchSynonym::class,
SolrLog::class,
DirtyClass::class,
Elevation::class,
ElevatedItem::class,
];

/**
Expand All @@ -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;
}
}
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 77a4b04

Please sign in to comment.