From 8deb72d6f017ad0140b6ba8ee21c7568101297bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Tue, 23 Feb 2016 21:05:38 +0100 Subject: [PATCH 1/3] Added several improvements --- Configuration/NodeTypes.yaml | 10 ++++++---- .../Private/Templates/FormBuilder/Index.html | 2 +- .../Private/Templates/NodeTypes/CheckBox.html | 2 +- .../Private/Templates/NodeTypes/Input.html | 2 +- .../Private/Templates/NodeTypes/Option.html | 2 +- .../Templates/NodeTypes/SubmitButton.html | 2 -- .../Private/Templates/NodeTypes/Text.html | 4 ++++ .../Private/Templates/NodeTypes/TextArea.html | 4 ++-- Resources/Private/TypoScript/Root.ts2 | 19 ++++++++++++++++++- composer.json | 3 ++- 10 files changed, 36 insertions(+), 14 deletions(-) delete mode 100644 Resources/Private/Templates/NodeTypes/SubmitButton.html create mode 100644 Resources/Private/Templates/NodeTypes/Text.html diff --git a/Configuration/NodeTypes.yaml b/Configuration/NodeTypes.yaml index 97950ec..d1fcee0 100644 --- a/Configuration/NodeTypes.yaml +++ b/Configuration/NodeTypes.yaml @@ -47,8 +47,13 @@ 'CRON.FormBuilder:Select': true 'CRON.FormBuilder:CheckBox': 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 @@ -92,7 +97,7 @@ 'CRON.FormBuilder:FormElementPlaceholderMixin': abstract: true properties: - value: + placeholder: type: string ui: label: CRON.FormBuilder:NodeTypes.Plugin:field.placeholder @@ -103,7 +108,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 @@ -138,7 +142,6 @@ 'CRON.FormBuilder:Select': superTypes: 'CRON.FormBuilder:FormElementMixin': true - 'CRON.FormBuilder:FormElementValueMixin': true ui: label: CRON.FormBuilder:NodeTypes.Plugin:fields.select childNodes: @@ -199,7 +202,6 @@ 'CRON.FormBuilder:TextArea': superTypes: 'CRON.FormBuilder:FormElementMixin': true - 'CRON.FormBuilder:FormElementValueMixin': true 'CRON.FormBuilder:FormElementPlaceholderMixin': true ui: label: CRON.FormBuilder:NodeTypes.Plugin:fields.textarea diff --git a/Resources/Private/Templates/FormBuilder/Index.html b/Resources/Private/Templates/FormBuilder/Index.html index c83643a..791bd63 100644 --- a/Resources/Private/Templates/FormBuilder/Index.html +++ b/Resources/Private/Templates/FormBuilder/Index.html @@ -2,7 +2,7 @@ {namespace fb=CRON\FormBuilder\ViewHelpers} {namespace ts=TYPO3\TypoScript\ViewHelpers} - + diff --git a/Resources/Private/Templates/NodeTypes/CheckBox.html b/Resources/Private/Templates/NodeTypes/CheckBox.html index abbae0f..764dc36 100644 --- a/Resources/Private/Templates/NodeTypes/CheckBox.html +++ b/Resources/Private/Templates/NodeTypes/CheckBox.html @@ -8,7 +8,7 @@ f:format.raw()} type="checkbox" readonly/> {node.properties.label} - f:format.raw()} type="checkbox" value="{node.properties.value}"/> {node.properties.label} + f:format.raw()} type="checkbox" value="{node.properties.value}" {f:if(condition: value, then: 'checked')}/> {node.properties.label} diff --git a/Resources/Private/Templates/NodeTypes/Input.html b/Resources/Private/Templates/NodeTypes/Input.html index bc83a84..9852302 100644 --- a/Resources/Private/Templates/NodeTypes/Input.html +++ b/Resources/Private/Templates/NodeTypes/Input.html @@ -6,7 +6,7 @@ f:format.raw()} type="text" placeholder="{node.properties.placeholder}" readonly> - f:format.raw()} type="{node.properties.type}" {f:if(condition: placeholder, then: 'placeholder="{node.properties.placeholder}" ')}> + f:format.raw()} type="{node.properties.type}" {f:if(condition: node.properties.placeholder, then: 'placeholder="{node.properties.placeholder}"')}> diff --git a/Resources/Private/Templates/NodeTypes/Option.html b/Resources/Private/Templates/NodeTypes/Option.html index 7a1b4bd..117c56d 100644 --- a/Resources/Private/Templates/NodeTypes/Option.html +++ b/Resources/Private/Templates/NodeTypes/Option.html @@ -4,6 +4,6 @@
  • {node.properties.option}
  • - + diff --git a/Resources/Private/Templates/NodeTypes/SubmitButton.html b/Resources/Private/Templates/NodeTypes/SubmitButton.html deleted file mode 100644 index a4c7622..0000000 --- a/Resources/Private/Templates/NodeTypes/SubmitButton.html +++ /dev/null @@ -1,2 +0,0 @@ - f:format.raw()} type="submit" value="{node.properties.caption}"> - diff --git a/Resources/Private/Templates/NodeTypes/Text.html b/Resources/Private/Templates/NodeTypes/Text.html new file mode 100644 index 0000000..1dfa6d3 --- /dev/null +++ b/Resources/Private/Templates/NodeTypes/Text.html @@ -0,0 +1,4 @@ +{namespace neos=TYPO3\Neos\ViewHelpers} + f:format.raw()}> +{neos:contentElement.editable(property: 'text')} + diff --git a/Resources/Private/Templates/NodeTypes/TextArea.html b/Resources/Private/Templates/NodeTypes/TextArea.html index 8082276..964f81d 100644 --- a/Resources/Private/Templates/NodeTypes/TextArea.html +++ b/Resources/Private/Templates/NodeTypes/TextArea.html @@ -6,7 +6,7 @@ - + - \ No newline at end of file + diff --git a/Resources/Private/TypoScript/Root.ts2 b/Resources/Private/TypoScript/Root.ts2 index 4dc193f..4f3871d 100644 --- a/Resources/Private/TypoScript/Root.ts2 +++ b/Resources/Private/TypoScript/Root.ts2 @@ -5,8 +5,13 @@ 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]} + value.@if.valueWasSubmitted = ${request.internalArguments.__submittedArguments.data[node.identifier]} + multiple = ${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')} attributes.required.@if.isRequired = ${Configuration.setting('CRON.FormBuilder.View.useRequiredAttribute') && this.attributes.required} attributes.class = 'form-control' @@ -29,15 +34,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' diff --git a/composer.json b/composer.json index d9b6773..aefd337 100644 --- a/composer.json +++ b/composer.json @@ -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": { From e629a113d726b9d3e35af12341093be9ba8c4818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Wed, 24 Feb 2016 08:30:14 +0100 Subject: [PATCH 2/3] Added layout for plugin actions views --- .../Controller/FormBuilderController.php | 6 ++- Resources/Private/Layouts/Default.html | 3 ++ .../Private/Templates/FormBuilder/Index.html | 48 ++++++++++--------- .../Templates/FormBuilder/SubmitPending.html | 8 +++- 4 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 Resources/Private/Layouts/Default.html diff --git a/Classes/CRON/FormBuilder/Controller/FormBuilderController.php b/Classes/CRON/FormBuilder/Controller/FormBuilderController.php index 38ad7d7..1abe00c 100644 --- a/Classes/CRON/FormBuilder/Controller/FormBuilderController.php +++ b/Classes/CRON/FormBuilder/Controller/FormBuilderController.php @@ -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); } @@ -95,7 +97,9 @@ public function submitAction($data) { /** * @return void */ - public function submitPendingAction() {} + public function submitPendingAction() { + $this->view->assign('node',$this->request->getInternalArgument('__node')); + } diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html new file mode 100644 index 0000000..eece4e1 --- /dev/null +++ b/Resources/Private/Layouts/Default.html @@ -0,0 +1,3 @@ +
    + +
    diff --git a/Resources/Private/Templates/FormBuilder/Index.html b/Resources/Private/Templates/FormBuilder/Index.html index 791bd63..e845349 100644 --- a/Resources/Private/Templates/FormBuilder/Index.html +++ b/Resources/Private/Templates/FormBuilder/Index.html @@ -2,25 +2,29 @@ {namespace fb=CRON\FormBuilder\ViewHelpers} {namespace ts=TYPO3\TypoScript\ViewHelpers} - - - - - - - - - {elements -> f:format.raw()} - - - - - - - - - - - - - + + + + + + + + + + + + {elements -> f:format.raw()} + + + + + + + + + + + + + + diff --git a/Resources/Private/Templates/FormBuilder/SubmitPending.html b/Resources/Private/Templates/FormBuilder/SubmitPending.html index f0392f7..0f20aa0 100644 --- a/Resources/Private/Templates/FormBuilder/SubmitPending.html +++ b/Resources/Private/Templates/FormBuilder/SubmitPending.html @@ -1,2 +1,6 @@ -

    -

    + + + +

    +

    +
    From 3a1c29eadfe3165dc46b147a66220467373dcacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Wed, 24 Feb 2016 10:00:12 +0100 Subject: [PATCH 3/3] Added checkbox group --- Configuration/NodeTypes.yaml | 31 +++++++++++++++++-- .../Private/Templates/NodeTypes/CheckBox.html | 4 +-- .../Templates/NodeTypes/CheckBoxGroup.html | 19 ++++++++++++ Resources/Private/Translations/de/Main.xlf | 4 +++ .../Translations/de/NodeTypes/Plugin.xlf | 8 +++++ Resources/Private/Translations/en/Main.xlf | 7 +++-- .../Translations/en/NodeTypes/Plugin.xlf | 6 ++++ Resources/Private/TypoScript/Root.ts2 | 25 ++++++++++++++- 8 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 Resources/Private/Templates/NodeTypes/CheckBoxGroup.html diff --git a/Configuration/NodeTypes.yaml b/Configuration/NodeTypes.yaml index d1fcee0..1a057a8 100644 --- a/Configuration/NodeTypes.yaml +++ b/Configuration/NodeTypes.yaml @@ -46,6 +46,7 @@ '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 @@ -152,8 +153,6 @@ 'CRON.FormBuilder:Option': true '*': false properties: - value: - ui: ~ multiple: type: boolean ui: @@ -191,12 +190,40 @@ 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': diff --git a/Resources/Private/Templates/NodeTypes/CheckBox.html b/Resources/Private/Templates/NodeTypes/CheckBox.html index 764dc36..bd0e1c8 100644 --- a/Resources/Private/Templates/NodeTypes/CheckBox.html +++ b/Resources/Private/Templates/NodeTypes/CheckBox.html @@ -5,10 +5,10 @@ diff --git a/Resources/Private/Templates/NodeTypes/CheckBoxGroup.html b/Resources/Private/Templates/NodeTypes/CheckBoxGroup.html new file mode 100644 index 0000000..3942cc1 --- /dev/null +++ b/Resources/Private/Templates/NodeTypes/CheckBoxGroup.html @@ -0,0 +1,19 @@ +{namespace neos=TYPO3\Neos\ViewHelpers} + + + + + + + + + + {elements -> f:format.raw()} + + +
    f:format.raw()}> + {elements -> f:format.raw()} +
    +
    +
    +
    diff --git a/Resources/Private/Translations/de/Main.xlf b/Resources/Private/Translations/de/Main.xlf index c5ec7cd..78aaba3 100644 --- a/Resources/Private/Translations/de/Main.xlf +++ b/Resources/Private/Translations/de/Main.xlf @@ -18,6 +18,10 @@ Please add options Bitte Select-Optionen hinzufügen + + Please add checkboxes + Bitte Auswahlkästen hinzufügen + Following errors occurred: Folgende Fehler sind aufgetreten: diff --git a/Resources/Private/Translations/de/NodeTypes/Plugin.xlf b/Resources/Private/Translations/de/NodeTypes/Plugin.xlf index d44fc91..5a3e7b5 100644 --- a/Resources/Private/Translations/de/NodeTypes/Plugin.xlf +++ b/Resources/Private/Translations/de/NodeTypes/Plugin.xlf @@ -129,6 +129,14 @@ Checkbox Auswahlkasten + + Checkbox-Group + Auswahlkasten-Gruppe + + + Checked + Vorausgewählt + diff --git a/Resources/Private/Translations/en/Main.xlf b/Resources/Private/Translations/en/Main.xlf index 40ac0da..78657e1 100644 --- a/Resources/Private/Translations/en/Main.xlf +++ b/Resources/Private/Translations/en/Main.xlf @@ -9,10 +9,13 @@ The form was submitted successfully. - Please add form elements. + Please add form elements - Please add options. + Please add options + + + Please add checkboxes Following errors occurred: diff --git a/Resources/Private/Translations/en/NodeTypes/Plugin.xlf b/Resources/Private/Translations/en/NodeTypes/Plugin.xlf index 4ab2ec2..f9f20ba 100644 --- a/Resources/Private/Translations/en/NodeTypes/Plugin.xlf +++ b/Resources/Private/Translations/en/NodeTypes/Plugin.xlf @@ -98,6 +98,12 @@ Checkbox + + Checkbox-Group + + + Checked + diff --git a/Resources/Private/TypoScript/Root.ts2 b/Resources/Private/TypoScript/Root.ts2 index 4f3871d..7096ce2 100644 --- a/Resources/Private/TypoScript/Root.ts2 +++ b/Resources/Private/TypoScript/Root.ts2 @@ -9,11 +9,12 @@ prototype(CRON.FormBuilder:FormElement) < prototype(TYPO3.Neos:Content) { value = ${request.internalArguments.__submittedArguments.data[node.identifier]} value.@if.valueWasSubmitted = ${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 + ']' + (q(node).property('multiple') ? '[]' : '')} attributes.required = ${q(node).property('required')} - attributes.required.@if.isRequired = ${Configuration.setting('CRON.FormBuilder.View.useRequiredAttribute') && this.attributes.required} + attributes.required.@if.isRequired = ${Configuration.setting('CRON.FormBuilder.View.useRequiredAttribute') && q(node).property('required')} attributes.class = 'form-control' node = ${node} @@ -23,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) { }