From e96594247b9b86fd13ae661285312089a034997a Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 9 Jun 2017 11:04:52 +1200 Subject: [PATCH 01/11] FIX Selector for HTML/plain email content toggle. Show preview button for both. --- code/model/recipients/UserDefinedForm_EmailRecipient.php | 7 ++----- javascript/Recipient.js | 7 +++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/code/model/recipients/UserDefinedForm_EmailRecipient.php b/code/model/recipients/UserDefinedForm_EmailRecipient.php index 79110f3..fb36634 100644 --- a/code/model/recipients/UserDefinedForm_EmailRecipient.php +++ b/code/model/recipients/UserDefinedForm_EmailRecipient.php @@ -258,12 +258,9 @@ class UserDefinedForm_EmailRecipient extends DataObject ->addExtraClass('toggle-html-only'), TextareaField::create('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body')) ->addExtraClass('toggle-plain-only'), - LiteralField::create( - 'EmailPreview', - '
' . $preview . '
' - ) + LiteralField::create('EmailPreview', $preview) )); - + $fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content')); // Custom rules for sending this field diff --git a/javascript/Recipient.js b/javascript/Recipient.js index 0bae6bf..0e97c57 100644 --- a/javascript/Recipient.js +++ b/javascript/Recipient.js @@ -5,12 +5,11 @@ (function ($) { $(document).ready(function () { + var sendPlain = $('input[name="SendPlain"]'); var recipient = { // Some fields are only visible when HTML email are being sent. updateFormatSpecificFields: function () { - var sendPlainChecked = $('#SendPlain') - .find('input[type="checkbox"]') - .is(':checked'); + var sendPlainChecked = sendPlain.is(':checked'); $(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show'](); $(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide'](); @@ -27,7 +26,7 @@ } }); - $('#SendPlain').entwine({ + sendPlain.entwine({ onchange: function () { recipient.updateFormatSpecificFields(); } From bf20e19285d2375ce948cab7e6a86a7532f8008a Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 9 Jun 2017 10:38:49 +1200 Subject: [PATCH 02/11] FIX Ensure HTML email preview content is parsed as HTML including shortcodes --- .../UserDefinedForm_EmailRecipient.php | 11 +++++---- .../UserDefinedForm_EmailRecipientTest.php | 24 +++++++++++++++++++ .../UserDefinedForm_EmailRecipientTest.yml | 4 ++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 tests/model/recipients/UserDefinedForm_EmailRecipientTest.php create mode 100644 tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml diff --git a/code/model/recipients/UserDefinedForm_EmailRecipient.php b/code/model/recipients/UserDefinedForm_EmailRecipient.php index 79110f3..1c80b90 100644 --- a/code/model/recipients/UserDefinedForm_EmailRecipient.php +++ b/code/model/recipients/UserDefinedForm_EmailRecipient.php @@ -221,7 +221,7 @@ class UserDefinedForm_EmailRecipient extends DataObject 'The email address which the recipient is able to \'reply\' to.' )) )); - + $fields->fieldByName('Root.EmailDetails')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILDETAILSTAB', 'Email Details')); // Only show the preview link if the recipient has been saved. @@ -263,7 +263,7 @@ class UserDefinedForm_EmailRecipient extends DataObject '
' . $preview . '
' ) )); - + $fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content')); // Custom rules for sending this field @@ -288,7 +288,7 @@ class UserDefinedForm_EmailRecipient extends DataObject ), $grid )); - + $fields->fieldByName('Root.CustomRules')->setTitle(_t('UserDefinedForm_EmailRecipient.CUSTOMRULESTAB', 'Custom Rules')); $this->extend('updateCMSFields', $fields); @@ -417,7 +417,10 @@ class UserDefinedForm_EmailRecipient extends DataObject */ 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(); } /** diff --git a/tests/model/recipients/UserDefinedForm_EmailRecipientTest.php b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.php new file mode 100644 index 0000000..237560a --- /dev/null +++ b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.php @@ -0,0 +1,24 @@ +objFromFixture('SiteTree', 'about_us'); + + $recipient = UserDefinedForm_EmailRecipient::create(); + $recipient->SendPlain = false; + $recipient->EmailBodyHtml = '

Some email content. About us: [sitetree_link,id=' . $page->ID . '].

'; + + $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); + } +} diff --git a/tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml new file mode 100644 index 0000000..7ff28c7 --- /dev/null +++ b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml @@ -0,0 +1,4 @@ +SiteTree: + about_us: + Title: About Us + URLSegment: about-us From 1e1b59673977667e1cfb2e0f093860be0db1eb48 Mon Sep 17 00:00:00 2001 From: Franco Springveldt Date: Tue, 27 Jun 2017 11:03:32 +1200 Subject: [PATCH 03/11] FIX use the correct method for CSV exports and include the full file path --- code/model/submissions/SubmittedFileField.php | 2 +- code/model/submissions/SubmittedForm.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/model/submissions/SubmittedFileField.php b/code/model/submissions/SubmittedFileField.php index 557235a..44f8df8 100755 --- a/code/model/submissions/SubmittedFileField.php +++ b/code/model/submissions/SubmittedFileField.php @@ -55,7 +55,7 @@ class SubmittedFileField extends SubmittedFormField { if ($file = $this->UploadedFile()) { if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) { - return $this->UploadedFile()->URL; + return $this->UploadedFile()->AbsoluteLink(); } } } diff --git a/code/model/submissions/SubmittedForm.php b/code/model/submissions/SubmittedForm.php index f026509..33527ce 100755 --- a/code/model/submissions/SubmittedForm.php +++ b/code/model/submissions/SubmittedForm.php @@ -65,9 +65,14 @@ class SubmittedForm extends DataObject $self->Values()->sort('Created', 'ASC') ); + $exportColumns = array( + 'Title' => 'Title', + 'ExportValue' => 'Value' + ); + $config = new GridFieldConfig(); $config->addComponent(new GridFieldDataColumns()); - $config->addComponent(new GridFieldExportButton()); + $config->addComponent(new GridFieldExportButton('after', $exportColumns)); $config->addComponent(new GridFieldPrintButton()); $values->setConfig($config); From c1afb3a5bfb345e0f68de0abf44fe4388a32fb9f Mon Sep 17 00:00:00 2001 From: Sacha Judd Date: Fri, 30 Jun 2017 17:11:36 +1200 Subject: [PATCH 04/11] FIX Remove css fields animation on add :wrench: --- css/UserForm_cms.css | 12 ------------ javascript/FieldEditor.js | 26 +++++++++----------------- scss/UserForm_cms.scss | 26 ++++++++------------------ 3 files changed, 17 insertions(+), 47 deletions(-) diff --git a/css/UserForm_cms.css b/css/UserForm_cms.css index f533cb8..5711a5f 100644 --- a/css/UserForm_cms.css +++ b/css/UserForm_cms.css @@ -1,14 +1,6 @@ /** * Animations */ -@keyframes rowSlide { - 0% { - top: 20%; - } - 100% { - top: 80%; - } -} @keyframes flashBackground { 0% { background-color: white; @@ -42,10 +34,6 @@ .cms .uf-field-editor table.ss-gridfield-table .ss-gridfield-item .handle { min-height: 46px; } -.cms .uf-field-editor table.ss-gridfield-table .ss-gridfield-item.newField { - position: fixed; - animation: rowSlide .5s ease forwards; -} .cms .uf-field-editor table.ss-gridfield-table .ss-gridfield-item.flashBackground { animation: flashBackground 2s linear; } diff --git a/javascript/FieldEditor.js b/javascript/FieldEditor.js index 6d998d4..b456df5 100644 --- a/javascript/FieldEditor.js +++ b/javascript/FieldEditor.js @@ -8,8 +8,8 @@ $(".uf-field-editor tbody").entwine({ onmatch: function() { - var i, - thisLevel, + var i, + thisLevel, depth = 0, $buttonrow = $('.uf-field-editor .ss-gridfield-buttonrow').addClass('stickyButtons'), navHeight = $('.cms-content-header.north').height() + parseInt($('.stickyButtons').css('padding-top'), 10), @@ -17,7 +17,7 @@ self = this; this._super(); - + // Loop through all rows and set necessary styles this.find('.ss-gridfield-item').each(function() { switch($(this).data('class')) { @@ -37,7 +37,7 @@ thisLevel = depth; } } - + $(this).toggleClass('inFieldGroup', thisLevel > 0); for(i = 1; i <= 5; i++) { $(this).toggleClass('inFieldGroup-level-'+i, thisLevel >= i); @@ -76,7 +76,7 @@ var self = this; this._super(); - + // When the 'Add field' button is clicked set a one time listener. // When the GridField is reloaded focus on the newly added field. this.on('addnewinline', function () { @@ -92,19 +92,11 @@ $newField.find('.col-Title input').focus(); } - // animate the row positioning (add the first class) - if (document.createElement('div').style.animationName !== void 0) { - $newField.addClass('newField'); + $newField.addClass('flashBackground'); + $(".cms-content-fields").scrollTop($(".cms-content-fields")[0].scrollHeight); + if($groupEnd) { + $groupEnd.css('visibility', 'visible'); } - - // Once the animation has completed - setTimeout(function () { - $newField.removeClass('newField').addClass('flashBackground'); - $(".cms-content-fields").scrollTop($(".cms-content-fields")[0].scrollHeight); - if($groupEnd) { - $groupEnd.css('visibility', 'visible'); - } - }, 500); }); }); }, diff --git a/scss/UserForm_cms.scss b/scss/UserForm_cms.scss index 43bd20d..a15abbc 100644 --- a/scss/UserForm_cms.scss +++ b/scss/UserForm_cms.scss @@ -2,11 +2,6 @@ * Animations */ -@keyframes rowSlide { - 0% {top: 20%;} - 100% {top: 80%;} -} - @keyframes flashBackground { 0% {background-color: white;} 10% {background-color: #dcfedd;} @@ -30,11 +25,11 @@ &, &:hover { background: white; } - + td { border-right-width: 0; border-top: 1px solid #EEE; - + &:last-child { border-right-width: 1px; } @@ -44,11 +39,6 @@ min-height: 46px; } - &.newField { - position: fixed; - animation: rowSlide .5s ease forwards; - } - &.flashBackground { animation: flashBackground 2s linear; } @@ -62,24 +52,24 @@ &, &:hover { background: #f2f9fd; } - + td { border-bottom: 0; border-top: 1px solid #eee; } - + .col-reorder, .handle { background: #BEE0F8; border-top: 0; } - + &.inFieldGroup-level-2 { .col-reorder, .handle { background: #99CEF4; border-top: 0; } } - + &.inFieldGroup-level-3 { .col-reorder, .handle { background: #89BEF4; @@ -116,7 +106,7 @@ td { border-top: 1px solid #a8d7f5; } - + label { font-weight: bold; color: #444; @@ -135,7 +125,7 @@ .col-buttons .action{ display: none; } - + label { color: #777; } From 1b472cda7b175a73ba44be1b9121a21a3ec0de0d Mon Sep 17 00:00:00 2001 From: Franco Springveldt Date: Tue, 11 Jul 2017 18:16:05 +1200 Subject: [PATCH 05/11] ENHANCEMENT removed needless list from CheckboxGroupField and RadioField --- .../EditableCheckboxGroupField.php | 5 +++-- .../editableformfields/EditableRadioField.php | 5 +++-- templates/UserFormsOptionSetField.ss | 7 +++++++ templates/forms/UserFormsCheckboxSetField.ss | 11 +++++++++++ tests/EditableCheckboxGroupFieldTest.php | 15 +++++++++++++++ tests/EditableRadioFieldTest.php | 15 +++++++++++++++ 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 templates/UserFormsOptionSetField.ss create mode 100644 templates/forms/UserFormsCheckboxSetField.ss create mode 100644 tests/EditableCheckboxGroupFieldTest.php create mode 100644 tests/EditableRadioFieldTest.php diff --git a/code/model/editableformfields/EditableCheckboxGroupField.php b/code/model/editableformfields/EditableCheckboxGroupField.php index c36f7fa..b78a66f 100755 --- a/code/model/editableformfields/EditableCheckboxGroupField.php +++ b/code/model/editableformfields/EditableCheckboxGroupField.php @@ -18,8 +18,9 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField public function getFormField() { - $field = new UserFormsCheckboxSetField($this->Name, $this->EscapedTitle, $this->getOptionsMap()); - $field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder'); + $field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()) + ->setFieldHolderTemplate('UserFormsMultipleOptionField_holder') + ->setTemplate('UserFormsCheckboxSetField'); // Set the default checked items $defaultCheckedItems = $this->getDefaultOptions(); diff --git a/code/model/editableformfields/EditableRadioField.php b/code/model/editableformfields/EditableRadioField.php index 2129bb4..d58262b 100755 --- a/code/model/editableformfields/EditableRadioField.php +++ b/code/model/editableformfields/EditableRadioField.php @@ -28,8 +28,9 @@ class EditableRadioField extends EditableMultipleOptionField public function getFormField() { - $field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()); - $field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder'); + $field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()) + ->setFieldHolderTemplate('UserFormsMultipleOptionField_holder') + ->setTemplate('UserFormsOptionSetField'); // Set default item $defaultOption = $this->getDefaultOptions()->first(); diff --git a/templates/UserFormsOptionSetField.ss b/templates/UserFormsOptionSetField.ss new file mode 100644 index 0000000..836ba5b --- /dev/null +++ b/templates/UserFormsOptionSetField.ss @@ -0,0 +1,7 @@ +<% loop $Options %> +
+ + checked<% end_if %><% if $isDisabled %> disabled<% end_if %> <% if $Up.Required %>required<% end_if %> /> + +
+<% end_loop %> diff --git a/templates/forms/UserFormsCheckboxSetField.ss b/templates/forms/UserFormsCheckboxSetField.ss new file mode 100644 index 0000000..290fd78 --- /dev/null +++ b/templates/forms/UserFormsCheckboxSetField.ss @@ -0,0 +1,11 @@ +<% if $Options.Count %> + <% loop $Options %> +
+ + checked="checked"<% end_if %><% if $isDisabled %> disabled="disabled"<% end_if %> /> + +
+ <% end_loop %> +<% else %> +

No options available

+<% end_if %> diff --git a/tests/EditableCheckboxGroupFieldTest.php b/tests/EditableCheckboxGroupFieldTest.php new file mode 100644 index 0000000..47f2b0f --- /dev/null +++ b/tests/EditableCheckboxGroupFieldTest.php @@ -0,0 +1,15 @@ +objFromFixture('EditableCheckboxGroupField', 'checkbox-group'); + $this->assertEquals('UserFormsCheckboxSetField', $checkboxGroup->getFormField()->getTemplate()); + } +} diff --git a/tests/EditableRadioFieldTest.php b/tests/EditableRadioFieldTest.php new file mode 100644 index 0000000..825785a --- /dev/null +++ b/tests/EditableRadioFieldTest.php @@ -0,0 +1,15 @@ +objFromFixture('EditableRadioField', 'radio-field'); + $this->assertEquals('UserFormsOptionSetField', $radio->getFormField()->getTemplate()); + } +} From 0f841cd982d0bd5a5ad349ec5c116a8acb4f0581 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 12 Jul 2017 14:21:29 +1200 Subject: [PATCH 06/11] NEW Use a paragraph instead of a label for literal field titles --- templates/forms/UserFormsLiteralField_holder.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/forms/UserFormsLiteralField_holder.ss b/templates/forms/UserFormsLiteralField_holder.ss index 910e0fe..a7736de 100644 --- a/templates/forms/UserFormsLiteralField_holder.ss +++ b/templates/forms/UserFormsLiteralField_holder.ss @@ -1,5 +1,5 @@
- <% if $Title %><% end_if %> + <% if $Title %>

$Title

<% end_if %>
<% loop $FieldList %> $Field From 88335936d619855d1b29879c30a187663b3c3ff3 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 12 Jul 2017 17:12:23 +1200 Subject: [PATCH 07/11] Rename silverstripe-australia to symbiote in composer requirements (#640) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 930e378..610ba53 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "require": { "silverstripe/framework": "~3.2", "silverstripe/cms": "~3.2", - "silverstripe-australia/gridfieldextensions": "~1.1", + "symbiote/silverstripe-gridfieldextensions": "~1.1", "silverstripe/segment-field": "^1.0" }, "suggest": { From c98fa0bab4881d5f1fb62722f1c5e65398232f21 Mon Sep 17 00:00:00 2001 From: Franco Springveldt Date: Thu, 13 Jul 2017 15:06:21 +1200 Subject: [PATCH 08/11] FIX fieldset without a legend shouldn't be a fieldset --- templates/Includes/UserForm.ss | 19 +++++++++++-------- templates/Includes/UserFormFields.ss | 5 +++++ templates/Includes/UserFormStepErrors.ss | 10 ++++------ templates/forms/UserFormsStepField.ss | 8 ++++---- 4 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 templates/Includes/UserFormFields.ss diff --git a/templates/Includes/UserForm.ss b/templates/Includes/UserForm.ss index 852e967..77fe039 100644 --- a/templates/Includes/UserForm.ss +++ b/templates/Includes/UserForm.ss @@ -1,5 +1,5 @@
- + <% include UserFormProgress %> <% include UserFormStepErrors %> @@ -9,13 +9,16 @@ <% end_if %> -
- <% if $Legend %>$Legend<% end_if %> - <% loop $Fields %> - $FieldHolder - <% end_loop %> -
-
+<% if $Legend %> +
+ $Legend + <% include UserFormFields %> +
+<% else %> +
+ <% include UserFormFields %> +
+<% end_if %> <% if $Steps.Count > 1 %> <% include UserFormStepNav %> diff --git a/templates/Includes/UserFormFields.ss b/templates/Includes/UserFormFields.ss new file mode 100644 index 0000000..9c45c17 --- /dev/null +++ b/templates/Includes/UserFormFields.ss @@ -0,0 +1,5 @@ +<% loop $Fields %> + $FieldHolder +<% end_loop %> +
+ diff --git a/templates/Includes/UserFormStepErrors.ss b/templates/Includes/UserFormStepErrors.ss index 8e97344..9ccd4f2 100644 --- a/templates/Includes/UserFormStepErrors.ss +++ b/templates/Includes/UserFormStepErrors.ss @@ -1,8 +1,6 @@ <% if $Steps.Count > 1 %> - + <% end_if %> diff --git a/templates/forms/UserFormsStepField.ss b/templates/forms/UserFormsStepField.ss index 957599b..2d98657 100644 --- a/templates/forms/UserFormsStepField.ss +++ b/templates/forms/UserFormsStepField.ss @@ -1,15 +1,15 @@ -
+
<% if $Form.DisplayErrorMessagesAtTop %> - +
<% end_if %> <% loop $Children %> $FieldHolder <% end_loop %> -
+
From a626d0a66e23b7c7173ba1b42388c92b8c061eb7 Mon Sep 17 00:00:00 2001 From: Franco Springveldt Date: Sun, 16 Jul 2017 18:39:03 +1200 Subject: [PATCH 09/11] NEW Update GridField creation to be injectable --- code/model/submissions/SubmittedForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/model/submissions/SubmittedForm.php b/code/model/submissions/SubmittedForm.php index 7e8ec61..ff62413 100755 --- a/code/model/submissions/SubmittedForm.php +++ b/code/model/submissions/SubmittedForm.php @@ -75,7 +75,7 @@ class SubmittedForm extends DataObject ) ); - $values = new GridField( + $values = GridField::create( 'Values', 'SubmittedFormField', $self->Values()->sort('Created', 'ASC') From bf326b86c23c948727959c13cdb169d6473deec8 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Tue, 1 Aug 2017 10:05:07 +1200 Subject: [PATCH 10/11] Remove default value field from EditableFileField --- .../model/editableformfields/EditableFileField.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/code/model/editableformfields/EditableFileField.php b/code/model/editableformfields/EditableFileField.php index f272925..b81a1f2 100755 --- a/code/model/editableformfields/EditableFileField.php +++ b/code/model/editableformfields/EditableFileField.php @@ -45,10 +45,14 @@ class EditableFileField extends EditableFormField ) ); - $fields->addFieldToTab("Root.Main", new LiteralField("FileUploadWarning", - "

" . _t("UserDefinedForm.FileUploadWarning", - "Files uploaded through this field could be publicly accessible if the exact URL is known") - . "

"), "Type"); + $fields->addFieldToTab("Root.Main", new LiteralField( + "FileUploadWarning", + "

" + . _t( + "UserDefinedForm.FileUploadWarning", + "Files uploaded through this field could be publicly accessible if the exact URL is known" + ) . "

" + ), "Type"); $fields->addFieldToTab( 'Root.Main', @@ -57,6 +61,8 @@ class EditableFileField extends EditableFormField ->setDescription("Note: Maximum php allowed size is {$this->getPHPMaxFileSizeMB()} MB") ); + $fields->removeByName('Default'); + return $fields; } From 8e3c0cc7cd24298c5565ce0b3f3b3b6f7ac79c5b Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 21 Aug 2017 15:32:17 +1200 Subject: [PATCH 11/11] Use precise dist to continue PHP 5.3 support --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9f1d072..d957452 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ sudo: false language: php +dist: precise + matrix: include: - php: 5.3