Skip to content

Commit

Permalink
add support for Elemental 4 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish authored Jan 20, 2019
1 parent 5b4ae98 commit 0c2defa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Sponsors element for the [SilverStripe Elemental](https://github.com/dnadesign/s

## Requirements

- SilverStripe ^4.0
- SilverStripe Elemental ^2.0
* silverstripe/recipe-cms: ^4@dev
* dnadesign/silverstripe-elemental: ^4@dev

## Installation

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dynamic/silverstripe-elemental-sponsors",
"type": "silverstripe-vendormodule",
"description": "A sponsors element for the SilverStripe Elemental module",
"description": "Display a list of sponsor logos with links.",
"keywords": [
"silverstripe",
"sponsors",
Expand All @@ -16,9 +16,9 @@
}
],
"require": {
"dnadesign/silverstripe-elemental": "^2@dev || ^3@dev",
"dynamic/silverstripe-elemental-baseobject": "^1@dev",
"silverstripe/recipe-cms": "^1@dev || ^4@dev",
"dnadesign/silverstripe-elemental": "^4@dev",
"dynamic/silverstripe-elemental-baseobject": "^2@dev",
"silverstripe/recipe-cms": "^4@dev",
"silverstripe/vendor-plugin": "^1@dev",
"symbiote/silverstripe-gridfieldextensions": "^3@dev"
},
Expand All @@ -31,7 +31,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "2.0.x-dev"
}
},
"autoload": {
Expand Down
34 changes: 29 additions & 5 deletions src/Elements/ElementSponsor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ElementSponsor extends BaseElement
/**
* @var string
*/
private static $icon = 'vendor/dnadesign/silverstripe-elemental/images/base.svg';
private static $icon = 'font-icon-external-link';

/**
* @var string
Expand Down Expand Up @@ -73,11 +73,35 @@ class ElementSponsor extends BaseElement
);

/**
* @return \SilverStripe\ORM\FieldType\DBHTMLText
* Set to false to prevent an in-line edit form from showing in an elemental area. Instead the element will be
* clickable and a GridFieldDetailForm will be used.
*
* @config
* @var bool
*/
public function ElementSummary()
private static $inline_editable = false;

/**
* @return string
*/
public function getSummary()
{
if ($this->Sponsors()->count() == 1) {
$label = ' sponsor';
} else {
$label = ' sponsors';
}
return DBField::create_field('HTMLText', $this->Sponsors()->count() . $label)->Summary(20);
}

/**
* @return array
*/
protected function provideBlockSchema()
{
return DBField::create_field('HTMLText', $this->Content)->Summary(20);
$blockSchema = parent::provideBlockSchema();
$blockSchema['content'] = $this->getSummary();
return $blockSchema;
}

/**
Expand All @@ -99,7 +123,7 @@ function (FieldList $fields) {
->setRows(8);

$fields->dataFieldByName('Limit')
->setTitle('Sponsors to show')
->setTitle('Number of sponsors to show')
->setDescription('0 will show all sponsors');

if ($this->exists()) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Elements/ElementSponsorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class ElementSponsorTest extends SapphireTest
/**
*
*/
public function testElementSummary()
public function testGetSummary()
{
$element = $this->objFromFixture(ElementSponsor::class, 'one');
$this->assertEquals($element->dbObject('Content')->Summary(20), $element->ElementSummary());
$this->assertEquals('4 sponsors', $element->getSummary());
}

/**
Expand Down

0 comments on commit 0c2defa

Please sign in to comment.