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

ADD: filter callback to ensure list items can be rendered (prevents a… #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
91 changes: 43 additions & 48 deletions src/Components/BaseComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverWare\Forms\FieldSection;
use SilverWare\Model\Component;

Expand Down Expand Up @@ -126,54 +127,48 @@ class BaseComponent extends Component
*/
public function getCMSFields()
{
// Obtain Field Objects (from parent):

$fields = parent::getCMSFields();

// Define Placeholder:

$placeholder = _t(__CLASS__ . '.DROPDOWNDEFAULT', '(default)');

// Create Style Fields:

$fields->addFieldsToTab(
'Root.Style',
[
FieldSection::create(
'TitleStyle',
$this->fieldLabel('TitleStyle'),
[
DropdownField::create(
'TitleLevel',
$this->fieldLabel('TitleLevel'),
$this->getTitleLevelOptions()
)->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder)
]
)
]
);

// Create Options Fields:

$fields->addFieldsToTab(
'Root.Options',
[
FieldSection::create(
'TitleOptions',
$this->fieldLabel('TitleOptions'),
[
CheckboxField::create(
'HideTitle',
$this->fieldLabel('HideTitle')
)
]
)
]
);

// Answer Field Objects:

return $fields;
$this->beforeUpdateCMSFields(function (FieldList $fields) {

$placeholder = _t(__CLASS__ . '.DROPDOWNDEFAULT', '(default)');

// Create Style Fields:
$fields->addFieldsToTab(
'Root.Style',
[
FieldSection::create(
'TitleStyle',
$this->fieldLabel('TitleStyle'),
[
DropdownField::create(
'TitleLevel',
$this->fieldLabel('TitleLevel'),
$this->getTitleLevelOptions()
)->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder)
]
)
]
);

// Create Options Fields:
$fields->addFieldsToTab(
'Root.Options',
[
FieldSection::create(
'TitleOptions',
$this->fieldLabel('TitleOptions'),
[
CheckboxField::create(
'HideTitle',
$this->fieldLabel('HideTitle')
)
]
)
]
);

});

return parent::getCMSFields();;
}

/**
Expand Down
281 changes: 137 additions & 144 deletions src/Components/BaseListComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,152 +187,145 @@ class BaseListComponent extends BaseComponent
*/
public function getCMSFields()
{
// Obtain Field Objects (from parent):

$fields = parent::getCMSFields();

// Define Placeholders:

$placeholderDefault = _t(__CLASS__ . '.DROPDOWNDEFAULT', '(default)');

// Create Style Fields:

$fields->addFieldsToTab(
'Root.Style',
[
FieldSection::create(
'ListStyle',
$this->fieldLabel('ListStyle'),
[
DropdownField::create(
'HeadingLevel',
$this->fieldLabel('HeadingLevel'),
$this->getTitleLevelOptions()
)->setEmptyString(' ')->setAttribute('data-placeholder', $placeholderDefault),
DropdownField::create(
'ImageAlign',
$this->fieldLabel('ImageAlign'),
$this->getImageAlignOptions()
)->setEmptyString(' ')->setAttribute('data-placeholder', $placeholderDefault),
ColorField::create(
'OverlayBackground',
$this->fieldLabel('OverlayBackground')
),
ColorField::create(
'OverlayForeground',
$this->fieldLabel('OverlayForeground')
),
FontIconField::create(
'OverlayIcon',
$this->fieldLabel('OverlayIcon')
),
ColorField::create(
'OverlayIconColor',
$this->fieldLabel('OverlayIconColor')
),
FontIconField::create(
'ButtonIcon',
$this->fieldLabel('ButtonIcon')
)
]
)
]
);

// Add List Style Fields:

$fields->addFieldsToTab('Root.Style', $this->getListStyleFields());

// Create Options Fields:

$fields->addFieldsToTab(
'Root.Options',
[
FieldSection::create(
'ListOptions',
$this->fieldLabel('ListOptions'),
[
DropdownField::create(
'ShowImage',
$this->fieldLabel('ShowImage'),
$this->getShowOptions()
),
DropdownField::create(
'ShowHeader',
$this->fieldLabel('ShowHeader'),
$this->getShowOptions()
),
DropdownField::create(
'ShowDetails',
$this->fieldLabel('ShowDetails'),
$this->getShowOptions()
),
DropdownField::create(
'ShowSummary',
$this->fieldLabel('ShowSummary'),
$this->getShowOptions()
),
DropdownField::create(
'ShowContent',
$this->fieldLabel('ShowContent'),
$this->getShowOptions()
),
DropdownField::create(
'ShowFooter',
$this->fieldLabel('ShowFooter'),
$this->getShowOptions()
),
TextField::create(
'ButtonLabel',
$this->fieldLabel('ButtonLabel')
),
CheckboxField::create(
'ButtonLink',
$this->fieldLabel('ButtonLink')
),
CheckboxField::create(
'LinkTitles',
$this->fieldLabel('LinkTitles')
),
CheckboxField::create(
'HideNoDataMessage',
$this->fieldLabel('HideNoDataMessage')
)
]
),
FieldSection::create(
'ListImageOptions',
$this->fieldLabel('ListImageOptions'),
[
DropdownField::create(
'ImageLinksTo',
$this->fieldLabel('ImageLinksTo'),
$this->getImageLinksToOptions()
),
CheckboxField::create(
'OverlayImages',
$this->fieldLabel('OverlayImages')
),
CheckboxField::create(
'OverlayTitle',
$this->fieldLabel('OverlayTitle')
),
CheckboxField::create(
'LinkImages',
$this->fieldLabel('LinkImages')
)
]
)
]
);

// Add List Option Fields:

$fields->addFieldsToTab('Root.Options', $this->getListOptionFields());

// Answer Field Objects:
$this->beforeUpdateCMSFields(function (FieldList $fields) {

// Define Placeholders:
$placeholderDefault = _t(__CLASS__ . '.DROPDOWNDEFAULT', '(default)');

// Create Style Fields:
$fields->addFieldsToTab(
'Root.Style',
[
FieldSection::create(
'ListStyle',
$this->fieldLabel('ListStyle'),
[
DropdownField::create(
'HeadingLevel',
$this->fieldLabel('HeadingLevel'),
$this->getTitleLevelOptions()
)->setEmptyString(' ')->setAttribute('data-placeholder', $placeholderDefault),
DropdownField::create(
'ImageAlign',
$this->fieldLabel('ImageAlign'),
$this->getImageAlignOptions()
)->setEmptyString(' ')->setAttribute('data-placeholder', $placeholderDefault),
ColorField::create(
'OverlayBackground',
$this->fieldLabel('OverlayBackground')
),
ColorField::create(
'OverlayForeground',
$this->fieldLabel('OverlayForeground')
),
FontIconField::create(
'OverlayIcon',
$this->fieldLabel('OverlayIcon')
),
ColorField::create(
'OverlayIconColor',
$this->fieldLabel('OverlayIconColor')
),
FontIconField::create(
'ButtonIcon',
$this->fieldLabel('ButtonIcon')
)
]
)
]
);

// Add List Style Fields:
$fields->addFieldsToTab('Root.Style', $this->getListStyleFields());

// Create Options Fields:
$fields->addFieldsToTab(
'Root.Options',
[
FieldSection::create(
'ListOptions',
$this->fieldLabel('ListOptions'),
[
DropdownField::create(
'ShowImage',
$this->fieldLabel('ShowImage'),
$this->getShowOptions()
),
DropdownField::create(
'ShowHeader',
$this->fieldLabel('ShowHeader'),
$this->getShowOptions()
),
DropdownField::create(
'ShowDetails',
$this->fieldLabel('ShowDetails'),
$this->getShowOptions()
),
DropdownField::create(
'ShowSummary',
$this->fieldLabel('ShowSummary'),
$this->getShowOptions()
),
DropdownField::create(
'ShowContent',
$this->fieldLabel('ShowContent'),
$this->getShowOptions()
),
DropdownField::create(
'ShowFooter',
$this->fieldLabel('ShowFooter'),
$this->getShowOptions()
),
TextField::create(
'ButtonLabel',
$this->fieldLabel('ButtonLabel')
),
CheckboxField::create(
'ButtonLink',
$this->fieldLabel('ButtonLink')
),
CheckboxField::create(
'LinkTitles',
$this->fieldLabel('LinkTitles')
),
CheckboxField::create(
'HideNoDataMessage',
$this->fieldLabel('HideNoDataMessage')
)
]
),
FieldSection::create(
'ListImageOptions',
$this->fieldLabel('ListImageOptions'),
[
DropdownField::create(
'ImageLinksTo',
$this->fieldLabel('ImageLinksTo'),
$this->getImageLinksToOptions()
),
CheckboxField::create(
'OverlayImages',
$this->fieldLabel('OverlayImages')
),
CheckboxField::create(
'OverlayTitle',
$this->fieldLabel('OverlayTitle')
),
CheckboxField::create(
'LinkImages',
$this->fieldLabel('LinkImages')
)
]
)
]
);

// Add List Option Fields:
$fields->addFieldsToTab('Root.Options', $this->getListOptionFields());
});

return $fields;
return parent::getCMSFields();;
}

/**
Expand Down
Loading