* Fix for #185 and #194

* Fix for #185 and #194

* Fix for #185 and #194
This commit is contained in:
torleif 2017-01-30 23:24:00 +13:00 committed by Daniel Hensby
parent 35dca0f62d
commit 8c27891600
4 changed files with 52 additions and 1 deletions

View File

@ -205,6 +205,20 @@ SQL;
$config->addComponent($export = new GridFieldExportButton('buttons-after-left')); $config->addComponent($export = new GridFieldExportButton('buttons-after-left'));
$config->addComponent($print = new GridFieldPrintButton('buttons-after-left')); $config->addComponent($print = new GridFieldPrintButton('buttons-after-left'));
// show user form items in the summary tab
$summaryarray = array(
'ID' => 'ID',
'Created' => 'Created',
'LastEdited' => 'Last Edited'
);
foreach(EditableFormField::get()->filter(array("ParentID" => $parentID)) as $eff) {
if($eff->ShowInSummary) {
$summaryarray[$eff->Name] = $eff->Title ?: $eff->Name;
}
}
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields($summaryarray);
/** /**
* Support for {@link https://github.com/colymba/GridFieldBulkEditingTools} * Support for {@link https://github.com/colymba/GridFieldBulkEditingTools}
*/ */

View File

@ -86,6 +86,7 @@ class EditableFormField extends DataObject
"ExtraClass" => "Text", // from CustomSettings "ExtraClass" => "Text", // from CustomSettings
"RightTitle" => "Varchar(255)", // from CustomSettings "RightTitle" => "Varchar(255)", // from CustomSettings
"ShowOnLoad" => "Boolean(1)", // from CustomSettings "ShowOnLoad" => "Boolean(1)", // from CustomSettings
"ShowInSummary" => "Boolean",
); );
private static $defaults = array( private static $defaults = array(
@ -160,6 +161,7 @@ class EditableFormField extends DataObject
_t('EditableFormField.TYPE', 'Type'), _t('EditableFormField.TYPE', 'Type'),
$this->i18n_singular_name() $this->i18n_singular_name()
), ),
CheckboxField::create('ShowInSummary', _t('EditableFormField.SHOWINSUMMARY', 'Show in summary gridfield')),
LiteralField::create( LiteralField::create(
'MergeField', 'MergeField',
_t( _t(

View File

@ -50,6 +50,26 @@ class UserDefinedFormTest extends FunctionalTest
$this->assertTrue($fields->dataFieldByName('OnCompleteMessage') != null); $this->assertTrue($fields->dataFieldByName('OnCompleteMessage') != null);
} }
public function testGetCMSFieldsShowInSummary()
{
$this->logInWithPermission('ADMIN');
$form = $this->objFromFixture('UserDefinedForm', 'summary-rules-form');
$fields = $form->getCMSFields();
$this->assertInstanceOf('GridField', $fields->dataFieldByName('Submissions'));
$submissionsgrid = $fields->dataFieldByName('Submissions');
$gridFieldDataColumns = $submissionsgrid->getConfig()->getComponentByType('GridFieldDataColumns');
$summaryFields = $gridFieldDataColumns->getDisplayFields($submissionsgrid);
$this->assertContains('SummaryShow', array_keys($summaryFields), 'Summary field not showing displayed field');
$this->assertNotContains('SummaryHide', array_keys($summaryFields), 'Summary field showing displayed field');
}
public function testEmailRecipientPopup() public function testEmailRecipientPopup()
{ {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');

View File

@ -107,6 +107,16 @@ EditableTextField:
Required: true Required: true
CustomErrorMessage: 'This field is required' CustomErrorMessage: 'This field is required'
summary-show:
Name: SummaryShow
Title: Summary Text Field
ShowInSummary: true
summary-hide:
Name: SummaryHide
Title: Summary Text Field
ShowInSummary: false
EditableDropdown: EditableDropdown:
basic-dropdown: basic-dropdown:
Name: basic-dropdown Name: basic-dropdown
@ -250,7 +260,12 @@ UserDefinedForm:
custom-rules-form: custom-rules-form:
Title: Custom Rules Form Title: Custom Rules Form
Fields: =>EditableFormStep.form4step1,=>EditableCheckbox.checkbox-2, =>EditableTextField.basic-text-2 Fields: =>EditableCheckbox.checkbox-2, =>EditableTextField.basic-text-2
summary-rules-form:
Title: Summary Fields Form
Fields: =>EditableTextField.summary-show, =>EditableTextField.summary-hide
empty-form: empty-form:
Title: Empty Form Title: Empty Form