Skip to content
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

Bugfix/section nav type summary #55

Merged
merged 3 commits into from
Jan 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Elements/ElementFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ElementFeatures extends BaseElement
*/
private static $db = [
'Content' => 'HTMLText',
'Alternate' => 'Boolean'
'Alternate' => 'Boolean',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Elements/ElementHero.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ElementHero extends BaseElement
* @var array
*/
private static $owns = array(
'Image'
'Image',
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Elements/ElementImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ElementImage extends BaseElement
* @var array
*/
private static $owns = array(
'Image'
'Image',
);

/**
Expand Down
1 change: 1 addition & 0 deletions src/Elements/ElementOembed.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function ElementSummary()
if ($this->EmbeddedObject()->ID) {
return DBField::create_field('HTMLText', $this->EmbeddedObject->Description)->Summary(20);
}

return DBField::create_field('HTMLText', '<p>External Content</p>')->Summary(20);
}

Expand Down
18 changes: 18 additions & 0 deletions src/Elements/ElementSectionNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Dynamic\Elements\Elements;

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;

/**
* Class ElementSectionNavigation.
Expand Down Expand Up @@ -46,4 +48,20 @@ public function getSectionNavigation()

return false;
}

/**
* @return DBHTMLText
*/
public function ElementSummary()
{
return DBField::create_field('HTMLText', '<p>Section Navigation</p>')->Summary(20);
}

/**
* @return string
*/
public function getType()
{
return _t(__CLASS__.'.BlockType', 'Section Navigation');
}
}
4 changes: 2 additions & 2 deletions src/Extensions/ElementContentDataExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function updateCMSFields(FieldList $fields)
);
$fields->insertBefore($fields->dataFieldByName('ElementLinkID'), 'HTML');

$image = $fields->dataFieldByName('Image')
$image = $fields->dataFieldByName('Image')
->setDescription('Optional. Display an image with this content.')
->setFolderName('Uploads/Elements/Content');
$fields->insertBefore($image, 'HTML');
$fields->insertBefore($image, 'HTML');
}
}
1 change: 1 addition & 0 deletions src/Model/AccordionPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AccordionPanel extends BaseElementObject

/**
* @return FieldList
*
* @throws \Exception
*/
public function getCMSFields()
Expand Down
3 changes: 2 additions & 1 deletion src/Model/BaseElementObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BaseElementObject extends DataObject
* @var array
*/
private static $owns = array(
'Image'
'Image',
);

/**
Expand Down Expand Up @@ -82,6 +82,7 @@ class BaseElementObject extends DataObject

/**
* @return FieldList
*
* @throws \Exception
*/
public function getCMSFields()
Expand Down
1 change: 1 addition & 0 deletions src/Model/FeatureObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class FeatureObject extends BaseElementObject

/**
* @return FieldList
*
* @throws \Exception
*/
public function getCMSFields()
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GalleryImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GalleryImage extends BaseElementObject
* @var array
*/
private static $owns = array(
'Image'
'Image',
);

/**
Expand All @@ -67,6 +67,7 @@ class GalleryImage extends BaseElementObject

/**
* @return FieldList
*
* @throws \Exception
*/
public function getCMSFields()
Expand Down
1 change: 1 addition & 0 deletions src/Model/PromoObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PromoObject extends BaseElementObject

/**
* @return FieldList
*
* @throws \Exception
*/
public function getCMSFields()
Expand Down
20 changes: 20 additions & 0 deletions tests/Elements/ElementSectionNavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dynamic\Elements\Elements\ElementSectionNavigation;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\ORM\FieldType\DBField;

/**
* Class ElementSectionNavigationTest.
Expand All @@ -21,4 +22,23 @@ public function testGetSectionNavigation()

// TODO - figure out how to mock up element areas
}

/**
*
*/
public function testGetElementSummary()
{
$object = Injector::inst()->create(ElementSectionNavigation::class);
$expected = DBField::create_field('HTMLText', '<p>Section Navigation</p>')->Summary(20);
$this->assertEquals($object->ElementSummary(), $expected);
}

/**
*
*/
public function testGetType()
{
$object = Injector::inst()->create(ElementSectionNavigation::class);
$this->assertEquals($object->getType(), 'Section Navigation');
}
}
1 change: 0 additions & 1 deletion tests/Extensions/ElementContentDataExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Dynamic\Elements\Tests;

use DNADesign\Elemental\Models\ElementContent;
use Dynamic\FlexSlider\Model\SlideImage;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Forms\FieldList;

Expand Down