Merge remote-tracking branch 'origin/4'
This commit is contained in:
commit
67ead916f5
|
@ -131,14 +131,13 @@ class UserDefinedForm extends Page
|
||||||
/**
|
/**
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
Requirements::css(USERFORMS_DIR . '/css/UserForm_cms.css');
|
Requirements::css(USERFORMS_DIR . '/css/UserForm_cms.css');
|
||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
|
|
||||||
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
|
|
||||||
|
|
||||||
|
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
|
||||||
// define tabs
|
// define tabs
|
||||||
$fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
|
$fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
|
||||||
$fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients'));
|
$fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients'));
|
||||||
|
@ -180,12 +179,6 @@ class UserDefinedForm extends Page
|
||||||
|
|
||||||
|
|
||||||
// view the submissions
|
// view the submissions
|
||||||
$submissions = new GridField(
|
|
||||||
'Submissions',
|
|
||||||
_t('UserDefinedForm.SUBMISSIONS', 'Submissions'),
|
|
||||||
$self->Submissions()->sort('Created', 'DESC')
|
|
||||||
);
|
|
||||||
|
|
||||||
// make sure a numeric not a empty string is checked against this int column for SQL server
|
// make sure a numeric not a empty string is checked against this int column for SQL server
|
||||||
$parentID = (!empty($self->ID)) ? (int) $self->ID : 0;
|
$parentID = (!empty($self->ID)) ? (int) $self->ID : 0;
|
||||||
|
|
||||||
|
@ -245,6 +238,7 @@ SQL;
|
||||||
|
|
||||||
// attach every column to the print view form
|
// attach every column to the print view form
|
||||||
$columns['Created'] = 'Created';
|
$columns['Created'] = 'Created';
|
||||||
|
$columns['SubmittedBy.Email'] = 'Submitter';
|
||||||
$filter->setColumns($columns);
|
$filter->setColumns($columns);
|
||||||
|
|
||||||
// print configuration
|
// print configuration
|
||||||
|
@ -256,23 +250,33 @@ SQL;
|
||||||
$export->setCsvHasHeader(true);
|
$export->setCsvHasHeader(true);
|
||||||
$export->setExportColumns($columns);
|
$export->setExportColumns($columns);
|
||||||
|
|
||||||
$submissions->setConfig($config);
|
$submissions = GridField::create(
|
||||||
|
'Submissions',
|
||||||
|
_t('UserDefinedForm.SUBMISSIONS', 'Submissions'),
|
||||||
|
$self->Submissions()->sort('Created', 'DESC'),
|
||||||
|
$config
|
||||||
|
);
|
||||||
$fields->addFieldToTab('Root.Submissions', $submissions);
|
$fields->addFieldToTab('Root.Submissions', $submissions);
|
||||||
$fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')));
|
$fields->addFieldToTab(
|
||||||
|
'Root.FormOptions',
|
||||||
|
CheckboxField::create(
|
||||||
|
'DisableSaveSubmissions',
|
||||||
|
_t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')
|
||||||
|
)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
if ($this->EmailRecipients()->Count() == 0 && static::config()->recipients_warning_enabled) {
|
if ($this->EmailRecipients()->Count() == 0 && static::config()->recipients_warning_enabled) {
|
||||||
$fields->addFieldToTab("Root.Main", new LiteralField("EmailRecipientsWarning",
|
$fields->addFieldToTab("Root.Main", new LiteralField("EmailRecipientsWarning",
|
||||||
"<p class=\"message warning\">" . _t("UserDefinedForm.NORECIPIENTS",
|
"<p class=\"message warning\">" . _t("UserDefinedForm.NORECIPIENTS",
|
||||||
"Warning: You have not configured any recipients. Form submissions may be missed.")
|
"Warning: You have not configured any recipients. Form submissions may be missed.")
|
||||||
. "</p>"), "Title");
|
. "</p>"), "Title");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow overriding the EmailRecipients on a {@link DataExtension}
|
* Allow overriding the EmailRecipients on a {@link DataExtension}
|
||||||
|
@ -483,7 +487,7 @@ class UserDefinedForm_Controller extends Page_Controller
|
||||||
}
|
}
|
||||||
if ($watch) {
|
if ($watch) {
|
||||||
$rules .= $this->buildWatchJS($watch);
|
$rules .= $this->buildWatchJS($watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add customScript if $default or $rules is defined
|
// Only add customScript if $default or $rules is defined
|
||||||
if ($rules) {
|
if ($rules) {
|
||||||
|
|
|
@ -1078,7 +1078,7 @@ class EditableFormField extends DataObject
|
||||||
foreach ($this->EffectiveDisplayRules() as $rule) {
|
foreach ($this->EffectiveDisplayRules() as $rule) {
|
||||||
// Get the field which is effected
|
// Get the field which is effected
|
||||||
/** @var EditableFormField $formFieldWatch */
|
/** @var EditableFormField $formFieldWatch */
|
||||||
$formFieldWatch = EditableFormField::get()->byId($rule->ConditionFieldID);
|
$formFieldWatch = DataObject::get_by_id('EditableFormField', $rule->ConditionFieldID);
|
||||||
// Skip deleted fields
|
// Skip deleted fields
|
||||||
if (! $formFieldWatch) {
|
if (! $formFieldWatch) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -221,14 +221,17 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
||||||
'The email address which the recipient is able to \'reply\' to.'
|
'The email address which the recipient is able to \'reply\' to.'
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->fieldByName('Root.EmailDetails')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILDETAILSTAB', 'Email Details'));
|
$fields->fieldByName('Root.EmailDetails')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILDETAILSTAB', 'Email Details'));
|
||||||
|
|
||||||
// Only show the preview link if the recipient has been saved.
|
// Only show the preview link if the recipient has been saved.
|
||||||
if (!empty($this->EmailTemplate)) {
|
if (!empty($this->EmailTemplate)) {
|
||||||
$preview = sprintf(
|
$preview = sprintf(
|
||||||
'<p><a href="%s" target="_blank" class="ss-ui-button">%s</a></p><em>%s</em>',
|
'<p><a href="%s" target="_blank" class="ss-ui-button">%s</a></p><em>%s</em>',
|
||||||
"admin/pages/edit/EditForm/field/EmailRecipients/item/{$this->ID}/preview",
|
Controller::join_links(
|
||||||
|
singleton('CMSPageEditController')->getEditForm()->FormAction(),
|
||||||
|
"field/EmailRecipients/item/{$this->ID}/preview"
|
||||||
|
),
|
||||||
_t('UserDefinedForm.PREVIEW_EMAIL', 'Preview email'),
|
_t('UserDefinedForm.PREVIEW_EMAIL', 'Preview email'),
|
||||||
_t('UserDefinedForm.PREVIEW_EMAIL_DESCRIPTION', 'Note: Unsaved changes will not appear in the preview.')
|
_t('UserDefinedForm.PREVIEW_EMAIL_DESCRIPTION', 'Note: Unsaved changes will not appear in the preview.')
|
||||||
);
|
);
|
||||||
|
|
|
@ -20,11 +20,19 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest
|
||||||
*/
|
*/
|
||||||
public function preview()
|
public function preview()
|
||||||
{
|
{
|
||||||
return $this->customise(new ArrayData(array(
|
// Enable theme for preview (may be needed for Shortcodes)
|
||||||
|
Config::nest();
|
||||||
|
Config::inst()->update('SSViewer', 'theme_enabled', true);
|
||||||
|
|
||||||
|
$content = $this->customise(new ArrayData(array(
|
||||||
'Body' => $this->record->getEmailBodyContent(),
|
'Body' => $this->record->getEmailBodyContent(),
|
||||||
'HideFormData' => $this->record->HideFormData,
|
'HideFormData' => $this->record->HideFormData,
|
||||||
'Fields' => $this->getPreviewFieldData()
|
'Fields' => $this->getPreviewFieldData()
|
||||||
)))->renderWith($this->record->EmailTemplate);
|
)))->renderWith($this->record->EmailTemplate);
|
||||||
|
|
||||||
|
Config::unnest();
|
||||||
|
|
||||||
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,7 +57,23 @@ class SubmittedForm extends DataObject
|
||||||
|
|
||||||
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
|
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
|
||||||
$fields->removeByName('Values');
|
$fields->removeByName('Values');
|
||||||
$fields->dataFieldByName('SubmittedByID')->setDisabled(true);
|
|
||||||
|
//check to ensure there is a Member to extract an Email from else null value
|
||||||
|
if($self->SubmittedBy() && $self->SubmittedBy()->exists()){
|
||||||
|
$submitter = $self->SubmittedBy()->Email;
|
||||||
|
} else {
|
||||||
|
$submitter = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//replace scaffolded field with readonly submitter
|
||||||
|
$fields->replaceField(
|
||||||
|
'SubmittedByID',
|
||||||
|
ReadonlyField::create(
|
||||||
|
'Submitter',
|
||||||
|
'Submitter',
|
||||||
|
$submitter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$values = new GridField(
|
$values = new GridField(
|
||||||
'Values',
|
'Values',
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "~3.1",
|
"silverstripe/framework": "~3.2",
|
||||||
"silverstripe/cms": "~3.1",
|
"silverstripe/cms": "~3.2",
|
||||||
"silverstripe-australia/gridfieldextensions": "~1.1",
|
"silverstripe-australia/gridfieldextensions": "~1.1",
|
||||||
"silverstripe/segment-field": "^1.0"
|
"silverstripe/segment-field": "^1.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,8 +47,8 @@
|
||||||
// Make sure gridfield buttons stick to top of page when user scrolls down
|
// Make sure gridfield buttons stick to top of page when user scrolls down
|
||||||
stickyHeaderInterval = setInterval(function () {
|
stickyHeaderInterval = setInterval(function () {
|
||||||
var offsetTop = fieldEditor.offset().top;
|
var offsetTop = fieldEditor.offset().top;
|
||||||
$buttonrow.width(self.width());
|
$buttonrow.width('100%');
|
||||||
if (offsetTop > navHeight || offsetTop === 0) {
|
if (offsetTop > navHeight || offsetTop === 0) {
|
||||||
$buttonrow.removeClass('stickyButtons');
|
$buttonrow.removeClass('stickyButtons');
|
||||||
} else {
|
} else {
|
||||||
$buttonrow.addClass('stickyButtons');
|
$buttonrow.addClass('stickyButtons');
|
||||||
|
|
Loading…
Reference in New Issue