Skip to content

Commit

Permalink
Merge pull request #11 from cron-eu/develop
Browse files Browse the repository at this point in the history
Release 1.0.2
  • Loading branch information
baschny committed Feb 24, 2016
2 parents 31c5930 + 8e3648f commit 2c8cfd4
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public function submitAction($data) {
//we can only handle registered nodes, must be a form manipulation
if($node === NULL) $this->throwStatus(403);

if (is_array($value)) $value = implode(', ', $value);

$fields[] = array('label' => $node->getProperty('label'), 'value' => $value);
}

Expand All @@ -95,7 +97,9 @@ public function submitAction($data) {
/**
* @return void
*/
public function submitPendingAction() {}
public function submitPendingAction() {
$this->view->assign('node',$this->request->getInternalArgument('__node'));
}



Expand Down
41 changes: 35 additions & 6 deletions Configuration/NodeTypes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@
'CRON.FormBuilder:Input': true
'CRON.FormBuilder:Select': true
'CRON.FormBuilder:CheckBox': true
'CRON.FormBuilder:CheckBoxGroup': true
'CRON.FormBuilder:TextArea': true
'CRON.FormBuilder:Text': true
'*': false

'CRON.FormBuilder:Text':
superTypes:
'TYPO3.Neos.NodeTypes:Text': true

'CRON.FormBuilder:FormElementMixin':
superTypes:
'TYPO3.Neos:Content': true
Expand Down Expand Up @@ -92,7 +98,7 @@
'CRON.FormBuilder:FormElementPlaceholderMixin':
abstract: true
properties:
value:
placeholder:
type: string
ui:
label: CRON.FormBuilder:NodeTypes.Plugin:field.placeholder
Expand All @@ -103,7 +109,6 @@
'CRON.FormBuilder:Input':
superTypes:
'CRON.FormBuilder:FormElementMixin': true
'CRON.FormBuilder:FormElementValueMixin': true
'CRON.FormBuilder:FormElementPlaceholderMixin': true
ui:
label: CRON.FormBuilder:NodeTypes.Plugin:fields.textfield
Expand Down Expand Up @@ -138,7 +143,6 @@
'CRON.FormBuilder:Select':
superTypes:
'CRON.FormBuilder:FormElementMixin': true
'CRON.FormBuilder:FormElementValueMixin': true
ui:
label: CRON.FormBuilder:NodeTypes.Plugin:fields.select
childNodes:
Expand All @@ -149,8 +153,6 @@
'CRON.FormBuilder:Option': true
'*': false
properties:
value:
ui: ~
multiple:
type: boolean
ui:
Expand Down Expand Up @@ -188,18 +190,45 @@
inspector:
group: options

'CRON.FormBuilder:CheckBoxGroup':
superTypes:
'CRON.FormBuilder:FormElementMixin': true
ui:
label: CRON.FormBuilder:NodeTypes.Plugin:fields.checkbox.group
childNodes:
elements:
type: 'TYPO3.Neos:ContentCollection'
constraints:
nodeTypes:
'CRON.FormBuilder:CheckBox': true
'*': false
properties:
required:
ui: ~
multiple:
type: boolean
defaultValue: true


'CRON.FormBuilder:CheckBox':
superTypes:
'CRON.FormBuilder:FormElementMixin': true
'CRON.FormBuilder:FormElementValueMixin': true
ui:
label: CRON.FormBuilder:NodeTypes.Plugin:fields.checkbox
properties:
checked:
type: boolean
ui:
label: CRON.FormBuilder:NodeTypes.Plugin:fields.checkbox.checked
reloadIfChanged: true
inspector:
group: options


'CRON.FormBuilder:TextArea':
superTypes:
'CRON.FormBuilder:FormElementMixin': true
'CRON.FormBuilder:FormElementValueMixin': true
'CRON.FormBuilder:FormElementPlaceholderMixin': true
ui:
label: CRON.FormBuilder:NodeTypes.Plugin:fields.textarea
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Layouts/Default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="{node.identifier}">
<f:render section="Content" />
</div>
48 changes: 26 additions & 22 deletions Resources/Private/Templates/FormBuilder/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@
{namespace fb=CRON\FormBuilder\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}

<f:form action="submit" method="post" additionalAttributes="{attributes}">
<f:if condition="{neos:rendering.inBackend(node: documentNode)}">
<f:then>
<f:if condition="{f:count(subject: elementsArray)}">
<f:else>
<strong><f:translate id="formBuilder.index.backend.addFormElements" package="CRON.FormBuilder" /></strong>
</f:else>
</f:if>
{elements -> f:format.raw()}
</f:then>
<f:else>
<f:for each="{elementsArray}" as="element">
<f:validation.results for="data.{element.identifier}">
<ts:render path="{tsPath}" typoScriptPackageKey="{tsPackageKey}" context="{node: element, flattenedErrors: validationResults.flattenedErrors}"/>
</f:validation.results>
</f:for>
<fb:formBuilder elements="{elementsArray}"/>
<f:form.hidden name="__formId" value="{node.identifier}"></f:form.hidden>
</f:else>
</f:if>
<button type="submit" class="btn btn-default">{submitButtonLabel}</button>
</f:form>
<f:layout name="Default" />

<f:section name="Content">
<f:form action="submit" method="post" additionalAttributes="{attributes}" section="{node.identifier}" id="{node.identifier}">
<f:if condition="{neos:rendering.inBackend(node: documentNode)}">
<f:then>
<f:if condition="{f:count(subject: elementsArray)}">
<f:else>
<strong><f:translate id="formBuilder.index.backend.addFormElements" package="CRON.FormBuilder" /></strong>
</f:else>
</f:if>
{elements -> f:format.raw()}
</f:then>
<f:else>
<f:for each="{elementsArray}" as="element">
<f:validation.results for="data.{element.identifier}">
<ts:render path="{tsPath}" typoScriptPackageKey="{tsPackageKey}" context="{node: element, flattenedErrors: validationResults.flattenedErrors}"/>
</f:validation.results>
</f:for>
<fb:formBuilder elements="{elementsArray}"/>
<f:form.hidden name="__formId" value="{node.identifier}"></f:form.hidden>
</f:else>
</f:if>
<button type="submit" class="btn btn-default">{submitButtonLabel}</button>
</f:form>
</f:section>
8 changes: 6 additions & 2 deletions Resources/Private/Templates/FormBuilder/SubmitPending.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<h2><f:translate id="formBuilder.submitPending.thankYou.title" package="CRON.FormBuilder" /></h2>
<p><f:translate id="formBuilder.submitPending.thankYou.message" package="CRON.FormBuilder" /></p>
<f:layout name="Default" />

<f:section name="Content">
<h2><f:translate id="formBuilder.submitPending.thankYou.title" package="CRON.FormBuilder" /></h2>
<p><f:translate id="formBuilder.submitPending.thankYou.message" package="CRON.FormBuilder" /></p>
</f:section>
4 changes: 2 additions & 2 deletions Resources/Private/Templates/NodeTypes/CheckBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<label>
<f:if condition="{neos:rendering.inBackend()}">
<f:then>
<input {attributes -> f:format.raw()} type="checkbox" readonly/> {node.properties.label}
<input {attributes -> f:format.raw()} type="checkbox" {f:if(condition: checked, then: 'checked')} readonly/> {node.properties.label}
</f:then>
<f:else>
<input {attributes -> f:format.raw()} type="checkbox" value="{node.properties.value}"/> {node.properties.label}
<input {attributes -> f:format.raw()} type="checkbox" value="{node.properties.value}" {f:if(condition: checked, then: 'checked')}/> {node.properties.label}
</f:else>
</f:if>
</label>
Expand Down
19 changes: 19 additions & 0 deletions Resources/Private/Templates/NodeTypes/CheckBoxGroup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{namespace neos=TYPO3\Neos\ViewHelpers}
<f:layout name="{layoutName}" />
<f:section name="Content">
<f:if condition="{neos:rendering.inBackend()}">
<f:then>
<f:if condition="{f:count(subject: elementsArray)}">
<f:else>
<strong><f:translate id="formBuilder.index.backend.addCheckBoxGroupElements" package="CRON.FormBuilder" /></strong>
</f:else>
</f:if>
{elements -> f:format.raw()}
</f:then>
<f:else>
<div {attributes -> f:format.raw()}>
{elements -> f:format.raw()}
</div>
</f:else>
</f:if>
</f:section>
2 changes: 1 addition & 1 deletion Resources/Private/Templates/NodeTypes/Input.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<input {attributes -> f:format.raw()} type="text" placeholder="{node.properties.placeholder}" readonly>
</f:then>
<f:else>
<input {attributes -> f:format.raw()} type="{node.properties.type}" {f:if(condition: placeholder, then: 'placeholder="{node.properties.placeholder}" ')}>
<input value="{value}" {attributes -> f:format.raw()} type="{node.properties.type}" {f:if(condition: node.properties.placeholder, then: 'placeholder="{node.properties.placeholder}"')}>
</f:else>
</f:if>
</f:section>
2 changes: 1 addition & 1 deletion Resources/Private/Templates/NodeTypes/Option.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<li>{node.properties.option}</li>
</f:then>
<f:else>
<option value="{node.properties.value}"{f:if(condition: node.properties.selected, then: ' selected')}>{node.properties.option}</option>
<option value="{node.properties.value}"{f:if(condition: selected, then: ' selected')}>{node.properties.option}</option>
</f:else>
</f:if>
2 changes: 0 additions & 2 deletions Resources/Private/Templates/NodeTypes/SubmitButton.html

This file was deleted.

4 changes: 4 additions & 0 deletions Resources/Private/Templates/NodeTypes/Text.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{namespace neos=TYPO3\Neos\ViewHelpers}
<div{attributes -> f:format.raw()}>
{neos:contentElement.editable(property: 'text')}
</div>
4 changes: 2 additions & 2 deletions Resources/Private/Templates/NodeTypes/TextArea.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<textarea {attributes -> f:format.raw()} rows="{node.properties.rows}" cols="{cols}"{f:if(condition: node.properties.placeholder, then: ' placeholder="{node.properties.placeholder}" ')} readonly></textarea>
</f:then>
<f:else>
<textarea {attributes -> f:format.raw()} {f:if(condition: node.properties.rows, then: 'rows="{node.properties.rows}" ')}{f:if(condition: node.properties.cols, then: 'cols="{node.properties.cols}" ')}{f:if(condition: node.properties.placeholder, then: ' placeholder="{node.properties.placeholder}" ')}></textarea>
<textarea {attributes -> f:format.raw()} {f:if(condition: node.properties.rows, then: 'rows="{node.properties.rows}" ')}{f:if(condition: node.properties.cols, then: 'cols="{node.properties.cols}" ')}{f:if(condition: node.properties.placeholder, then: ' placeholder="{node.properties.placeholder}"')}>{value}</textarea>
</f:else>
</f:if>
</f:section>
</f:section>
4 changes: 4 additions & 0 deletions Resources/Private/Translations/de/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<source>Please add options</source>
<target xml:lang="de" state="translated">Bitte Select-Optionen hinzufügen</target>
</trans-unit>
<trans-unit id="formBuilder.index.backend.addCheckBoxGroupElements" xml:space="preserve">
<source>Please add checkboxes</source>
<target xml:lang="de" state="translated">Bitte Auswahlkästen hinzufügen</target>
</trans-unit>
<trans-unit id="formBuilder.index.errors.title" xml:space="preserve">
<source>Following errors occurred:</source>
<target xml:lang="de" state="translated">Folgende Fehler sind aufgetreten:</target>
Expand Down
8 changes: 8 additions & 0 deletions Resources/Private/Translations/de/NodeTypes/Plugin.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@
<source>Checkbox</source>
<target xml:lang="de" state="translated">Auswahlkasten</target>
</trans-unit>
<trans-unit id="fields.checkbox.group" xml:space="preserve">
<source>Checkbox-Group</source>
<target xml:lang="de" state="translated">Auswahlkasten-Gruppe</target>
</trans-unit>
<trans-unit id="fields.checkbox.checked" xml:space="preserve">
<source>Checked</source>
<target xml:lang="de" state="translated">Vorausgewählt</target>
</trans-unit>
</body>
</file>
</xliff>
7 changes: 5 additions & 2 deletions Resources/Private/Translations/en/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
<source>The form was submitted successfully.</source>
</trans-unit>
<trans-unit id="formBuilder.index.backend.addFormElements" xml:space="preserve">
<source>Please add form elements.</source>
<source>Please add form elements</source>
</trans-unit>
<trans-unit id="formBuilder.index.backend.addSelectElements" xml:space="preserve">
<source>Please add options.</source>
<source>Please add options</source>
</trans-unit>
<trans-unit id="formBuilder.index.backend.addCheckBoxGroupElements" xml:space="preserve">
<source>Please add checkboxes</source>
</trans-unit>
<trans-unit id="formBuilder.index.errors.title" xml:space="preserve">
<source>Following errors occurred:</source>
Expand Down
6 changes: 6 additions & 0 deletions Resources/Private/Translations/en/NodeTypes/Plugin.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@
<trans-unit id="fields.checkbox" xml:space="preserve">
<source>Checkbox</source>
</trans-unit>
<trans-unit id="fields.checkbox.group" xml:space="preserve">
<source>Checkbox-Group</source>
</trans-unit>
<trans-unit id="fields.checkbox.checked" xml:space="preserve">
<source>Checked</source>
</trans-unit>
</body>
</file>
</xliff>
44 changes: 42 additions & 2 deletions Resources/Private/TypoScript/Root.ts2
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ prototype(CRON.FormBuilder:FormElement) < prototype(TYPO3.Neos:Content) {
templatePath = ${'resource://CRON.FormBuilder/Private/Templates/NodeTypes/' + String.replace(node.nodeData.nodeType, 'CRON.FormBuilder:', '') + '.html'}
layoutName = 'Wrapper'


value = ${request.internalArguments.__submittedArguments.data[node.identifier]}
[email protected] = ${request.internalArguments.__submittedArguments.data[node.identifier]}
multiple = ${q(node).property('multiple')}
formName = ${'--cron_formbuilder-plugin[data][' + node.identifier + ']' + (q(node).property('multiple') ? '[]' : '')}

attributes.id = ${node.identifier}
attributes.name = ${'--cron_formbuilder-plugin[data][' + node.identifier + ']'}
attributes.name = ${'--cron_formbuilder-plugin[data][' + node.identifier + ']' + (q(node).property('multiple') ? '[]' : '')}
attributes.required = ${q(node).property('required')}
[email protected] = ${Configuration.setting('CRON.FormBuilder.View.useRequiredAttribute') && this.attributes.required}
[email protected] = ${Configuration.setting('CRON.FormBuilder.View.useRequiredAttribute') && q(node).property('required')}
attributes.class = 'form-control'

node = ${node}
Expand All @@ -18,8 +24,30 @@ prototype(CRON.FormBuilder:FormElement) < prototype(TYPO3.Neos:Content) {
prototype(CRON.FormBuilder:CheckBox) < prototype(CRON.FormBuilder:FormElement) {
layoutName = 'CheckboxWrapper'
attributes.class = ''
checked = ${this.value || q(node).property('checked')}
}

prototype(CRON.FormBuilder:CheckBoxGroup) < prototype(CRON.FormBuilder:FormElement) {

elementsArray = ${q(node).children('elements').children().get()}

@context.groupValue = ${this.value}
@context.groupName = ${this.formName}

attributes.name >
attributes.class >

elements = TYPO3.Neos:ContentCollection {
nodePath = 'elements'

prototype(CRON.FormBuilder:CheckBox) {
attributes.name = ${groupName}
checked = ${groupValue ? Array.indexOf(groupValue, q(node).property('value')) > -1 : q(node).property('checked')}
}
}
}


prototype(CRON.FormBuilder:Input) < prototype(CRON.FormBuilder:FormElement) {
}

Expand All @@ -29,15 +57,27 @@ prototype(CRON.FormBuilder:Option) < prototype(CRON.FormBuilder:FormElement) {
prototype(CRON.FormBuilder:Select) < prototype(CRON.FormBuilder:FormElement) {

elementsArray = ${q(node).children('elements').children().get()}
@context.selectValue = ${this.value}
@context.selectMultiple = ${this.multiple}

elements = TYPO3.Neos:ContentCollection {
nodePath = 'elements'

prototype(CRON.FormBuilder:Option) {
selected = ${selectValue ? (selectMultiple ? Array.indexOf(selectValue, q(node).property('value')) > -1 : selectValue == q(node).property('value')) : q(node).property('selected')}
}
}
}

prototype(CRON.FormBuilder:TextArea) < prototype(CRON.FormBuilder:FormElement) {
}

prototype(CRON.FormBuilder:Text) < prototype(CRON.FormBuilder:FormElement) {
attributes.name >
attributes.class >
text = ${q(node).property('text')}
}


prototype(CRON.FormBuilder:Plugin) < prototype(TYPO3.Neos:Plugin) {
package = 'CRON.FormBuilder'
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Component to build and populate forms in the backend",
"require": {
"typo3/neos": "*",
"typo3/swiftmailer": "~5.3.0"
"typo3/swiftmailer": "~5.3.0",
"typo3/neos-nodetypes": "~2.0"
},
"autoload": {
"psr-0": {
Expand Down

0 comments on commit 2c8cfd4

Please sign in to comment.