mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge branch '4'
This commit is contained in:
commit
8d4cd036f7
@ -4,9 +4,6 @@ sudo: false
|
|||||||
|
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
# Support PHP 5.3
|
|
||||||
dist: precise
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.3
|
- php: 5.3
|
||||||
|
@ -92,19 +92,11 @@
|
|||||||
$newField.find('.col-Title input').focus();
|
$newField.find('.col-Title input').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// animate the row positioning (add the first class)
|
$newField.addClass('flashBackground');
|
||||||
if (document.createElement('div').style.animationName !== void 0) {
|
|
||||||
$newField.addClass('newField');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once the animation has completed
|
|
||||||
setTimeout(function () {
|
|
||||||
$newField.removeClass('newField').addClass('flashBackground');
|
|
||||||
$(".cms-content-fields").scrollTop($(".cms-content-fields")[0].scrollHeight);
|
$(".cms-content-fields").scrollTop($(".cms-content-fields")[0].scrollHeight);
|
||||||
if($groupEnd) {
|
if($groupEnd) {
|
||||||
$groupEnd.css('visibility', 'visible');
|
$groupEnd.css('visibility', 'visible');
|
||||||
}
|
}
|
||||||
}, 500);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5,12 +5,11 @@
|
|||||||
(function ($) {
|
(function ($) {
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
var sendPlain = $('input[name="SendPlain"]');
|
||||||
var recipient = {
|
var recipient = {
|
||||||
// Some fields are only visible when HTML email are being sent.
|
// Some fields are only visible when HTML email are being sent.
|
||||||
updateFormatSpecificFields: function () {
|
updateFormatSpecificFields: function () {
|
||||||
var sendPlainChecked = $('#SendPlain')
|
var sendPlainChecked = sendPlain.is(':checked');
|
||||||
.find('input[type="checkbox"]')
|
|
||||||
.is(':checked');
|
|
||||||
|
|
||||||
$(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show']();
|
$(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show']();
|
||||||
$(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide']();
|
$(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide']();
|
||||||
@ -27,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#SendPlain').entwine({
|
sendPlain.entwine({
|
||||||
onchange: function () {
|
onchange: function () {
|
||||||
recipient.updateFormatSpecificFields();
|
recipient.updateFormatSpecificFields();
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,6 @@
|
|||||||
* Animations
|
* Animations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@keyframes rowSlide {
|
|
||||||
0% {top: 20%;}
|
|
||||||
100% {top: 80%;}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes flashBackground {
|
@keyframes flashBackground {
|
||||||
0% {background-color: white;}
|
0% {background-color: white;}
|
||||||
10% {background-color: #dcfedd;}
|
10% {background-color: #dcfedd;}
|
||||||
@ -44,11 +39,6 @@
|
|||||||
min-height: 46px;
|
min-height: 46px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.newField {
|
|
||||||
position: fixed;
|
|
||||||
animation: rowSlide .5s ease forwards;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.flashBackground {
|
&.flashBackground {
|
||||||
animation: flashBackground 2s linear;
|
animation: flashBackground 2s linear;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,9 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField
|
|||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
{
|
{
|
||||||
$field = new UserFormsCheckboxSetField($this->Name, $this->EscapedTitle, $this->getOptionsMap());
|
$field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap())
|
||||||
$field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder');
|
->setFieldHolderTemplate('UserFormsMultipleOptionField_holder')
|
||||||
|
->setTemplate('UserFormsCheckboxSetField');
|
||||||
|
|
||||||
// Set the default checked items
|
// Set the default checked items
|
||||||
$defaultCheckedItems = $this->getDefaultOptions();
|
$defaultCheckedItems = $this->getDefaultOptions();
|
||||||
|
@ -45,10 +45,14 @@ class EditableFileField extends EditableFormField
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields->addFieldToTab("Root.Main", new LiteralField("FileUploadWarning",
|
$fields->addFieldToTab("Root.Main", new LiteralField(
|
||||||
"<p class=\"message notice\">" . _t("UserDefinedForm.FileUploadWarning",
|
"FileUploadWarning",
|
||||||
"Files uploaded through this field could be publicly accessible if the exact URL is known")
|
"<p class=\"message notice\">"
|
||||||
. "</p>"), "Type");
|
. _t(
|
||||||
|
"UserDefinedForm.FileUploadWarning",
|
||||||
|
"Files uploaded through this field could be publicly accessible if the exact URL is known"
|
||||||
|
) . "</p>"
|
||||||
|
), "Type");
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Main',
|
'Root.Main',
|
||||||
@ -57,6 +61,8 @@ class EditableFileField extends EditableFormField
|
|||||||
->setDescription("Note: Maximum php allowed size is {$this->getPHPMaxFileSizeMB()} MB")
|
->setDescription("Note: Maximum php allowed size is {$this->getPHPMaxFileSizeMB()} MB")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$fields->removeByName('Default');
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,9 @@ class EditableRadioField extends EditableMultipleOptionField
|
|||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
{
|
{
|
||||||
$field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap());
|
$field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap())
|
||||||
$field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder');
|
->setFieldHolderTemplate('UserFormsMultipleOptionField_holder')
|
||||||
|
->setTemplate('UserFormsOptionSetField');
|
||||||
|
|
||||||
// Set default item
|
// Set default item
|
||||||
$defaultOption = $this->getDefaultOptions()->first();
|
$defaultOption = $this->getDefaultOptions()->first();
|
||||||
|
@ -261,10 +261,7 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
|||||||
->addExtraClass('toggle-html-only'),
|
->addExtraClass('toggle-html-only'),
|
||||||
TextareaField::create('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body'))
|
TextareaField::create('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body'))
|
||||||
->addExtraClass('toggle-plain-only'),
|
->addExtraClass('toggle-plain-only'),
|
||||||
LiteralField::create(
|
LiteralField::create('EmailPreview', $preview)
|
||||||
'EmailPreview',
|
|
||||||
'<div id="EmailPreview" class="field toggle-html-only">' . $preview . '</div>'
|
|
||||||
)
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content'));
|
$fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content'));
|
||||||
@ -421,7 +418,10 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
|||||||
*/
|
*/
|
||||||
public function getEmailBodyContent()
|
public function getEmailBodyContent()
|
||||||
{
|
{
|
||||||
return $this->SendPlain ? $this->EmailBody : $this->EmailBodyHtml;
|
if ($this->SendPlain) {
|
||||||
|
return DBField::create_field('HTMLText', $this->EmailBody)->NoHTML();
|
||||||
|
}
|
||||||
|
return DBField::create_field('HTMLText', $this->EmailBodyHtml)->RAW();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ class SubmittedFileField extends SubmittedFormField
|
|||||||
{
|
{
|
||||||
if ($file = $this->UploadedFile()) {
|
if ($file = $this->UploadedFile()) {
|
||||||
if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) {
|
if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) {
|
||||||
return $this->UploadedFile()->URL;
|
return $this->UploadedFile()->AbsoluteLink();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,15 +75,20 @@ class SubmittedForm extends DataObject
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$values = new GridField(
|
$values = GridField::create(
|
||||||
'Values',
|
'Values',
|
||||||
'SubmittedFormField',
|
'SubmittedFormField',
|
||||||
$self->Values()->sort('Created', 'ASC')
|
$self->Values()->sort('Created', 'ASC')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$exportColumns = array(
|
||||||
|
'Title' => 'Title',
|
||||||
|
'ExportValue' => 'Value'
|
||||||
|
);
|
||||||
|
|
||||||
$config = new GridFieldConfig();
|
$config = new GridFieldConfig();
|
||||||
$config->addComponent(new GridFieldDataColumns());
|
$config->addComponent(new GridFieldDataColumns());
|
||||||
$config->addComponent(new GridFieldExportButton());
|
$config->addComponent(new GridFieldExportButton('after', $exportColumns));
|
||||||
$config->addComponent(new GridFieldPrintButton());
|
$config->addComponent(new GridFieldPrintButton());
|
||||||
$values->setConfig($config);
|
$values->setConfig($config);
|
||||||
|
|
||||||
|
@ -9,13 +9,16 @@
|
|||||||
<p id="{$FormName}_error" class="message $MessageType" aria-hidden="true" style="display: none;"></p>
|
<p id="{$FormName}_error" class="message $MessageType" aria-hidden="true" style="display: none;"></p>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
|
<% if $Legend %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<% if $Legend %><legend>$Legend</legend><% end_if %>
|
<legend>$Legend</legend>
|
||||||
<% loop $Fields %>
|
<% include UserFormFields %>
|
||||||
$FieldHolder
|
|
||||||
<% end_loop %>
|
|
||||||
<div class="clear"><!-- --></div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<% else %>
|
||||||
|
<div class="userform-fields">
|
||||||
|
<% include UserFormFields %>
|
||||||
|
</div>
|
||||||
|
<% end_if %>
|
||||||
|
|
||||||
<% if $Steps.Count > 1 %>
|
<% if $Steps.Count > 1 %>
|
||||||
<% include UserFormStepNav %>
|
<% include UserFormStepNav %>
|
||||||
|
5
templates/Includes/UserFormFields.ss
Normal file
5
templates/Includes/UserFormFields.ss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<% loop $Fields %>
|
||||||
|
$FieldHolder
|
||||||
|
<% end_loop %>
|
||||||
|
<div class="clear"><!-- --></div>
|
||||||
|
|
@ -1,8 +1,6 @@
|
|||||||
<% if $Steps.Count > 1 %>
|
<% if $Steps.Count > 1 %>
|
||||||
<fieldset class="error-container form-wide-errors" aria-hidden="true" style="display: none;">
|
<div class="error-container form-wide-errors" aria-hidden="true" style="display: none;">
|
||||||
<div>
|
|
||||||
<h4></h4>
|
<h4></h4>
|
||||||
<ul class="error-list"></ul>
|
<ul class="error-list"></ul>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
7
templates/UserFormsOptionSetField.ss
Normal file
7
templates/UserFormsOptionSetField.ss
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<% loop $Options %>
|
||||||
|
<div class="$Class">
|
||||||
|
<input id="$ID" class="radio" name="$Name" type="radio" value="$Value.ATT"<% if $isChecked %>
|
||||||
|
checked<% end_if %><% if $isDisabled %> disabled<% end_if %> <% if $Up.Required %>required<% end_if %> />
|
||||||
|
<label for="$ID">$Title</label>
|
||||||
|
</div>
|
||||||
|
<% end_loop %>
|
11
templates/forms/UserFormsCheckboxSetField.ss
Normal file
11
templates/forms/UserFormsCheckboxSetField.ss
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<% if $Options.Count %>
|
||||||
|
<% loop $Options %>
|
||||||
|
<div class="$Class">
|
||||||
|
<input id="$ID" class="checkbox" name="$Name" type="checkbox" value="$Value.ATT"<% if $isChecked %>
|
||||||
|
checked="checked"<% end_if %><% if $isDisabled %> disabled="disabled"<% end_if %> />
|
||||||
|
<label for="$ID">$Title</label>
|
||||||
|
</div>
|
||||||
|
<% end_loop %>
|
||||||
|
<% else %>
|
||||||
|
<p>No options available</p>
|
||||||
|
<% end_if %>
|
@ -1,5 +1,5 @@
|
|||||||
<div id="$Name" class="field<% if $extraClass %> $extraClass<% end_if %>">
|
<div id="$Name" class="field<% if $extraClass %> $extraClass<% end_if %>">
|
||||||
<% if $Title %><label class="left">$Title</label><% end_if %>
|
<% if $Title %><p class="left">$Title</p><% end_if %>
|
||||||
<div class="middleColumn">
|
<div class="middleColumn">
|
||||||
<% loop $FieldList %>
|
<% loop $FieldList %>
|
||||||
$Field
|
$Field
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<fieldset id="$Name" class="form-step $extraClass" data-title="$Title">
|
<div id="$Name" class="form-step $extraClass" data-title="$Title">
|
||||||
<% if $Form.DisplayErrorMessagesAtTop %>
|
<% if $Form.DisplayErrorMessagesAtTop %>
|
||||||
<fieldset class="error-container" aria-hidden="true" style="display: none;">
|
<div class="error-container" aria-hidden="true" style="display: none;">
|
||||||
<div>
|
<div>
|
||||||
<h4></h4>
|
<h4></h4>
|
||||||
<ul class="error-list"></ul>
|
<ul class="error-list"></ul>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</div>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% loop $Children %>
|
<% loop $Children %>
|
||||||
$FieldHolder
|
$FieldHolder
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
|
|
||||||
</fieldset>
|
</div>
|
||||||
|
15
tests/EditableCheckboxGroupFieldTest.php
Normal file
15
tests/EditableCheckboxGroupFieldTest.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class EditableCheckboxGroupFieldTest extends SapphireTest
|
||||||
|
{
|
||||||
|
protected static $fixture_file = 'EditableFormFieldTest.yml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that this element is rendered with a custom template
|
||||||
|
*/
|
||||||
|
public function testRenderedWithCustomTemplate()
|
||||||
|
{
|
||||||
|
$checkboxGroup = $this->objFromFixture('EditableCheckboxGroupField', 'checkbox-group');
|
||||||
|
$this->assertEquals('UserFormsCheckboxSetField', $checkboxGroup->getFormField()->getTemplate());
|
||||||
|
}
|
||||||
|
}
|
15
tests/EditableRadioFieldTest.php
Normal file
15
tests/EditableRadioFieldTest.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class EditableRadioFieldTest extends SapphireTest
|
||||||
|
{
|
||||||
|
protected static $fixture_file = 'EditableFormFieldTest.yml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that this element is rendered with a custom template
|
||||||
|
*/
|
||||||
|
public function testRenderedWithCustomTemplate()
|
||||||
|
{
|
||||||
|
$radio = $this->objFromFixture('EditableRadioField', 'radio-field');
|
||||||
|
$this->assertEquals('UserFormsOptionSetField', $radio->getFormField()->getTemplate());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class UserDefinedForm_EmailRecipientTest extends SapphireTest
|
||||||
|
{
|
||||||
|
protected static $fixture_file = 'UserDefinedForm_EmailRecipientTest.yml';
|
||||||
|
|
||||||
|
public function testShortcodesAreRenderedInEmailPreviewContent()
|
||||||
|
{
|
||||||
|
$page = $this->objFromFixture('SiteTree', 'about_us');
|
||||||
|
|
||||||
|
$recipient = UserDefinedForm_EmailRecipient::create();
|
||||||
|
$recipient->SendPlain = false;
|
||||||
|
$recipient->EmailBodyHtml = '<p>Some email content. About us: [sitetree_link,id=' . $page->ID . '].</p>';
|
||||||
|
|
||||||
|
$result = $recipient->getEmailBodyContent();
|
||||||
|
$this->assertContains('/about-us/', $result);
|
||||||
|
|
||||||
|
$recipient->SendPlain = true;
|
||||||
|
$recipient->EmailBody = 'Some email content. About us: [sitetree_link,id=' . $page->ID . '].';
|
||||||
|
|
||||||
|
$result = $recipient->getEmailBodyContent();
|
||||||
|
$this->assertContains('/about-us/', $result);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
SiteTree:
|
||||||
|
about_us:
|
||||||
|
Title: About Us
|
||||||
|
URLSegment: about-us
|
Loading…
Reference in New Issue
Block a user