Skip to content

Commit

Permalink
add support for Elemental 4 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Jan 20, 2019
1 parent a66fb68 commit 7a5ca7b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 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 @@ A multi file block for SilverStripe Elemental.

## Requirements

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

## Installation

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"type": "silverstripe-vendormodule",
"license": "BSD-3-Clause",
"require": {
"dnadesign/silverstripe-elemental": "^2@dev || ^3@dev",
"silverstripe/recipe-cms": "^1@dev || ^4@dev",
"dnadesign/silverstripe-elemental": "^4@dev",
"silverstripe/recipe-cms": "^4@dev",
"silverstripe/vendor-plugin": "^1@dev"
},
"require-dev": {
Expand All @@ -35,7 +35,7 @@
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "2.0.x-dev"
}
}
}
34 changes: 32 additions & 2 deletions src/Elements/ElementFileList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

use DNADesign\Elemental\Models\BaseElement;
use Dynamic\Elements\FileList\Model\FileListObject;
use SilverStripe\ORM\FieldType\DBField;

class ElementFileList extends BaseElement
{
/**
* @var string
*/
private static $icon = 'font-icon-block-file-list';

/**
* @var string
*/
Expand Down Expand Up @@ -36,12 +42,36 @@ class ElementFileList extends BaseElement
'Files',
];

/**
* 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
*/
private static $inline_editable = false;

/**
* @return DBHTMLText
*/
public function ElementSummary()
public function getSummary()
{
if ($this->Files()->count() == 1) {
$label = ' file';
} else {
$label = ' files';
}
return DBField::create_field('HTMLText', $this->Files()->count() . $label)->Summary(20);
}

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

/**
Expand Down

0 comments on commit 7a5ca7b

Please sign in to comment.