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

misc cleanup #9

Merged
merged 1 commit into from
Oct 27, 2017
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
97 changes: 0 additions & 97 deletions src/Elements/DynamicBaseElement.php

This file was deleted.

24 changes: 0 additions & 24 deletions src/Elements/ElementBlogPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;

/*
if (!class_exists('SilverStripe\\Blog\\Model\\Blog')) {
return;
}
*/

/**
* Class RecentBlogPostsBlock
*/
Expand Down Expand Up @@ -100,22 +94,4 @@ public function getCMSFields()

return $fields;
}

/**
* @param null $member
* @return bool
*/
public function canCreate($member = null, $context = [])
{
return parent::canCreate();
}

/**
* @param null $member
* @return bool
*/
public function canView($member = null, $context = [])
{
return parent::canView();
}
}
8 changes: 4 additions & 4 deletions src/Elements/ElementFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function getCMSFields()
if ($this->ID) {
// Features
$config = GridFieldConfig_RecordEditor::create();
$config->addComponent(new GridFieldOrderableRows('Sort'));
$config->addComponent(new GridFieldOrderableRows('SortOrder'));
$config->removeComponentsByType('GridFieldAddExistingAutocompleter');
$config->removeComponentsByType('GridFieldDeleteAction');
$config->addComponent(new GridFieldDeleteAction(false));
$sectionsField = GridField::create('Features', 'Features', $this->Features()->sort('Sort'), $config);
$sectionsField = GridField::create('Features', 'Features', $this->Features(), $config);
$fields->addFieldsToTab('Root.Features', array(
$sectionsField,
));
Expand All @@ -77,9 +77,9 @@ public function getCMSFields()
/**
* @return mixed
*/
public function getFeatures()
public function getFeaturesList()
{
return $this->Features()->sort('Sort');
return $this->Features()->sort('SortOrder');
}

/**
Expand Down
11 changes: 3 additions & 8 deletions src/Elements/ElementPromos.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,12 @@ public function getCMSFields()
{
$fields = parent::getCMSFields();

$fields->removeByName(array(
'Promos',
));

if ($this->ID) {
$config = GridFieldConfig_RelationEditor::create();
$promoField = $fields->dataFieldByName('Promos');
$config = $promoField->getConfig();
$config->addComponent(new GridFieldOrderableRows('SortOrder'));
$config->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
$config->addComponent(new GridFieldAddExistingSearchButton());
$promos = $this->Promos();
$promoField = GridField::create('Promos', 'Promos', $promos, $config);

$fields->addFieldsToTab('Root.Main', array(
$promoField,
Expand All @@ -95,7 +90,7 @@ public function getCMSFields()
*/
public function getPromoList()
{
return $this->Promos()->sort('Sort');
return $this->Promos()->sort('SortOrder');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Model/FeatureObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @property string $Name
* @property string $Title
* @property DBHTMLText $Content
* @property int $Sort
* @property int $SortOrder
* @property int $ImageID
* @property int $ElementFeaturesID
*/
Expand All @@ -38,7 +38,7 @@ class FeatureObject extends DataObject
'Name' => 'Varchar(255)',
'Title' => 'Varchar(255)',
'Content' => 'HTMLText',
'Sort' => 'Int',
'SortOrder' => 'Int',
);

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ public function getCMSFields()

$fields->removeByName(array(
'ElementFeaturesID',
'Sort',
'SortOrder',
));

$fields->dataFieldByName('Name')->setDescription('For internal reference only');
Expand Down
2 changes: 1 addition & 1 deletion templates/Dynamic/Elements/Elements/ElementBlogPosts.ss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="$CSSClasses">
<% if $BlogID %>
<% if $Blog.BlogPosts %>
<% loop $Blog.BlogPosts.Limit($Limit) %>
<p><a href="$Link.ATT">$Title</a></p>
<% end_loop %>
Expand Down
22 changes: 16 additions & 6 deletions templates/Dynamic/Elements/Elements/ElementFeatures.ss
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<div class="element_content__content <% if $Style %>element_content__$CssStyle<% end_if %>">
<% if $Headline %><h2 class="homeheadline">$Headline</h2><% end_if %>
<% if $Image %><img src="$Image.SetWidth(400).URL" class="img-responsive pull-right"><% end_if %>
$Content
<div class="clearfix"></div>
</div>
<div class="$CSSClasses">
<% if $FeaturesList %>
<div class="row">
<% loop $FeaturesList %>
<div class="col-md-4">
<% if $Title %><div class='block_title'><h3>$Title</h3></div><% end_if %>
<% if $Image %><img src="$Image.URL" class="img-responsive" alt="$Title.ATT"><% end_if %>
<% if $Content %><div class='block_content'>$Content</div><% end_if %>
<% if $LinkType != None %><a href="<% if $LinkType == 'External'%>$ExternalLink<% else_if $LinkType == 'Internal'%>$PageLink.Link<% end_if %>"<% if $LinkType == 'External' %> target="_blank"<% end_if %> title="$PageLink.MenuTitle.XML"><% end_if %>
$LinkLabel
<% if $LinkType != None %></a><% end_if %>
</div>
<% end_loop %>
</div>
<% end_if %>
</div>
93 changes: 0 additions & 93 deletions tests/DynamicBaseElementTest.php

This file was deleted.

8 changes: 8 additions & 0 deletions tests/ElementFeaturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dynamic\Elements\Elements\ElementFeatures;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataList;

class ElementFeaturesTest extends SapphireTest
{
Expand All @@ -22,4 +23,11 @@ public function testGetCMSFields()
$fields = $object->getCMSFields();
$this->assertInstanceOf(FieldList::class, $fields);
}

public function testGetFeaturesList()
{
$object = $this->objFromFixture(ElementFeatures::class, 'one');
$this->assertInstanceOf(DataList::class, $object->getFeaturesList());
$this->assertEquals($object->getFeaturesList(), $object->Features()->sort('SortOrder'));
}
}
2 changes: 1 addition & 1 deletion tests/ElementPromosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public function testGetPromoList()
{
$object = $this->objFromFixture(ElementPromos::class, 'one');
$this->assertInstanceOf(DataList::class, $object->getPromoList());
$this->assertEquals($object->getPromoList(), $object->Promos()->sort('Sort'));
$this->assertEquals($object->getPromoList(), $object->Promos()->sort('SortOrder'));
}
}
3 changes: 0 additions & 3 deletions tests/fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ SilverStripe\Security\Member:
Surname: "Member"
Email: "user"
Password: "user"
Dynamic\Elements\Elements\DynamicBaseElement:
default:
Title: "Base Element"
Dynamic\Elements\Model\AccordionPanel:
one:
Name: "Panel One"
Expand Down