API Move templates to namespaced class locations in the templates folder

This commit is contained in:
Robbie Averill 2017-08-14 12:29:57 +12:00
parent cdb2259307
commit cba7c26950
32 changed files with 33 additions and 30 deletions

View File

@ -165,7 +165,9 @@ class EditableCustomRule extends DataObject
/** /**
* Substitutes configured rule logic with it's JS equivalents and returns them as array elements * Substitutes configured rule logic with it's JS equivalents and returns them as array elements
*
* @return array * @return array
* @throws LogicException If the provided condition option was not able to be handled
*/ */
public function buildExpression() public function buildExpression()
{ {

View File

@ -45,8 +45,8 @@ class EditableCheckbox extends EditableFormField
public function getFormField() public function getFormField()
{ {
$field = CheckboxField::create($this->Name, $this->EscapedTitle, $this->CheckedDefault) $field = CheckboxField::create($this->Name, $this->EscapedTitle, $this->CheckedDefault)
->setFieldHolderTemplate('UserFormsCheckboxField_holder') ->setFieldHolderTemplate(__CLASS__ . '_holder')
->setTemplate('UserFormsCheckboxField'); ->setTemplate(__CLASS__);
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -26,8 +26,8 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField
public function getFormField() public function getFormField()
{ {
$field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()); $field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap());
$field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder'); $field->setFieldHolderTemplate(EditableMultipleOptionField::class . '_holder');
$field->setTemplate('UserFormsCheckboxSetField'); $field->setTemplate('UserFormsCheckboxSetField'); // @todo
// Set the default checked items // Set the default checked items
$defaultCheckedItems = $this->getDefaultOptions(); $defaultCheckedItems = $this->getDefaultOptions();

View File

@ -6,6 +6,7 @@ use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\i18n\i18n; use SilverStripe\i18n\i18n;
use SilverStripe\UserForms\Model\EditableCustomRule; use SilverStripe\UserForms\Model\EditableCustomRule;
use SilverStripe\UserForms\Model\EditableDropdownField;
use SilverStripe\UserForms\Model\EditableFormField; use SilverStripe\UserForms\Model\EditableFormField;
/** /**
@ -38,7 +39,7 @@ class EditableCountryDropdownField extends EditableFormField
$field = DropdownField::create($this->Name, $this->EscapedTitle) $field = DropdownField::create($this->Name, $this->EscapedTitle)
->setSource(i18n::getData()->getCountries()) ->setSource(i18n::getData()->getCountries())
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate('UserFormsField_holder')
->setTemplate('UserFormsDropdownField'); ->setTemplate(EditableDropdownField::class);
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -60,7 +60,7 @@ class EditableDateField extends EditableFormField
$field = FormField::create($this->Name, $this->EscapedTitle, $defaultValue) $field = FormField::create($this->Name, $this->EscapedTitle, $defaultValue)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate('UserFormsField_holder')
->setTemplate('UserFormsField'); ->setTemplate(EditableFormField::class);
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -60,8 +60,8 @@ class EditableDropdown extends EditableMultipleOptionField
public function getFormField() public function getFormField()
{ {
$field = DropdownField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()) $field = DropdownField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap())
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate('UserFormsDropdownField'); ->setTemplate(__CLASS__);
if ($this->UseEmptyString) { if ($this->UseEmptyString) {
$field->setEmptyString(($this->EmptyString) ? $this->EmptyString : ''); $field->setEmptyString(($this->EmptyString) ? $this->EmptyString : '');

View File

@ -32,7 +32,7 @@ class EditableEmailField extends EditableFormField
{ {
$field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default) $field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate('UserFormsField_holder')
->setTemplate('UserFormsField'); ->setTemplate(EditableFormField::class);
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -99,10 +99,10 @@ class EditableFileField extends EditableFormField
{ {
$field = FileField::create($this->Name, $this->EscapedTitle) $field = FileField::create($this->Name, $this->EscapedTitle)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate('UserFormsField_holder')
->setTemplate('UserFormsFileField'); ->setTemplate(__CLASS__);
$field->setFieldHolderTemplate('UserFormsField_holder') $field->setFieldHolderTemplate('UserFormsField_holder')
->setTemplate('UserFormsFileField'); ->setTemplate(__CLASS__);
$field->getValidator()->setAllowedExtensions( $field->getValidator()->setAllowedExtensions(
array_diff( array_diff(

View File

@ -145,7 +145,7 @@ class EditableLiteralField extends EditableFormField
$field = CompositeField::create($content) $field = CompositeField::create($content)
->setName($this->Name) ->setName($this->Name)
// ->setID($this->Name) // @todo // ->setID($this->Name) // @todo
->setFieldHolderTemplate('UserFormsLiteralField_holder'); ->setFieldHolderTemplate(__CLASS__ . '_holder');
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -113,9 +113,9 @@ class EditableMultipleOptionField extends EditableFormField
* @param string $toStage * @param string $toStage
* @param bool $createNewVersion * @param bool $createNewVersion
*/ */
public function doPublish($fromStage, $toStage, $createNewVersion = false) public function copyVersionToStage($fromStage, $toStage, $createNewVersion = false)
{ {
parent::doPublish($fromStage, $toStage, $createNewVersion); parent::copyVersionToStage($fromStage, $toStage, $createNewVersion);
$this->publishOptions($fromStage, $toStage, $createNewVersion); $this->publishOptions($fromStage, $toStage, $createNewVersion);
} }
@ -134,7 +134,7 @@ class EditableMultipleOptionField extends EditableFormField
// Publish all options // Publish all options
foreach ($this->Options() as $option) { foreach ($this->Options() as $option) {
$seenIDs[] = $option->ID; $seenIDs[] = $option->ID;
$option->publish($fromStage, $toStage, $createNewVersion); $option->copyVersionToStage($fromStage, $toStage, $createNewVersion);
} }
// remove any orphans from the "fromStage" // remove any orphans from the "fromStage"

View File

@ -42,8 +42,8 @@ class EditableNumericField extends EditableFormField
public function getFormField() public function getFormField()
{ {
$field = NumericField::create($this->Name, $this->EscapedTitle, $this->Default) $field = NumericField::create($this->Name, $this->EscapedTitle, $this->Default)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate('UserFormsField') ->setTemplate(EditableFormField::class)
->addExtraClass('number'); ->addExtraClass('number');
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -36,8 +36,8 @@ 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())
->setFieldHolderTemplate('UserFormsMultipleOptionField_holder') ->setFieldHolderTemplate(EditableMultipleOptionField::class . '_holder')
->setTemplate('UserFormsOptionSetField'); ->setTemplate('UserFormsOptionSetField'); // @todo
// Set default item // Set default item
$defaultOption = $this->getDefaultOptions()->first(); $defaultOption = $this->getDefaultOptions()->first();

View File

@ -129,13 +129,13 @@ class EditableTextField extends EditableFormField
{ {
if ($this->Rows > 1) { if ($this->Rows > 1) {
$field = TextareaField::create($this->Name, $this->EscapedTitle, $this->Default) $field = TextareaField::create($this->Name, $this->EscapedTitle, $this->Default)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate('UserFormsTextareaField') ->setTemplate(str_replace('EditableTextField', 'EditableTextareaField', __CLASS__))
->setRows($this->Rows); ->setRows($this->Rows);
} else { } else {
$field = TextField::create($this->Name, $this->EscapedTitle, $this->Default) $field = TextField::create($this->Name, $this->EscapedTitle, $this->Default)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate('UserFormsField'); ->setTemplate(EditableFormField::class);
} }
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -31,7 +31,7 @@ class SubmittedFormField extends DataObject
/** /**
* @param Member $member * @param Member $member
* * @param array $context
* @return boolean * @return boolean
*/ */
public function canCreate($member = null, $context = []) public function canCreate($member = null, $context = [])

View File

@ -433,7 +433,7 @@ JS
$this->extend('updateReceivedFormSubmissionData', $data); $this->extend('updateReceivedFormSubmissionData', $data);
return $this->customise([ return $this->customise([
'Content' => $this->customise($data)->renderWith('ReceivedFormSubmission'), 'Content' => $this->customise($data)->renderWith(__CLASS__ . '_ReceivedFormSubmission'),
'Form' => '', 'Form' => '',
]); ]);
} }

View File

@ -1,7 +1,7 @@
<form $AttributesHTML> <form $AttributesHTML>
<% include UserFormProgress %> <% include SilverStripe\\UserForms\\Form\\UserFormProgress %>
<% include UserFormStepErrors %> <% include SilverStripe\\UserForms\\Form\\UserFormStepErrors %>
<% if $Message %> <% if $Message %>
<p id="{$FormName}_error" class="message $MessageType">$Message</p> <p id="{$FormName}_error" class="message $MessageType">$Message</p>
@ -21,9 +21,9 @@
<% end_if %> <% end_if %>
<% if $Steps.Count > 1 %> <% if $Steps.Count > 1 %>
<% include UserFormStepNav %> <% include SilverStripe\\UserForms\\Form\\UserFormStepNav %>
<% else %> <% else %>
<% include UserFormActionNav %> <% include SilverStripe\\UserForms\\Form\\UserFormActionNav %>
<% end_if %> <% end_if %>
</form> </form>