[TASK] EXT:form - Use text instead of data attributes 95/43895/11
authorAndreas Häfner <andreas.haefner@tritum.de>
Sun, 8 Nov 2015 12:51:30 +0000 (13:51 +0100)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Sun, 8 Nov 2015 17:51:15 +0000 (18:51 +0100)
The form objects TEXTBLOCK, OPTION and TEXTAREA now use text as
attribute for textual content.

Furthermore, the patchset fixes a bug with duplicated select boxes.

The missing deprecation file from #69957 is added as well.

Resolves: #69369
Resolves: #70448
Releases: master
Change-Id: I99d3d1292dc143989a8483d14fc5d827bd05a560
Reviewed-on: https://review.typo3.org/43895
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
14 files changed:
typo3/sysext/core/Documentation/Changelog/master/Deprecation-69369-UsePropertyTextInsteadOfDataForTEXTAREATEXTBLOCKOPTION.rst [new file with mode: 0644]
typo3/sysext/form/Classes/Domain/Factory/JsonToTypoScript.php
typo3/sysext/form/Classes/Domain/Model/Json/SelectJsonElement.php
typo3/sysext/form/Classes/Domain/Model/Json/TextareaJsonElement.php
typo3/sysext/form/Classes/Domain/Model/Json/TextblockJsonElement.php
typo3/sysext/form/Classes/Utility/CompatibilityLayerUtility.php
typo3/sysext/form/Configuration/PageTS/modWizards.ts
typo3/sysext/form/Resources/Private/Language/locallang_wizard.xlf
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Elements/Basic/Select.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Elements/Basic/Textarea.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Elements/Content/Textblock.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Left/Options/Forms/Attributes.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Left/Options/Forms/Options.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Left/Options/Forms/Various.js

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-69369-UsePropertyTextInsteadOfDataForTEXTAREATEXTBLOCKOPTION.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-69369-UsePropertyTextInsteadOfDataForTEXTAREATEXTBLOCKOPTION.rst
new file mode 100644 (file)
index 0000000..59f90e6
--- /dev/null
@@ -0,0 +1,35 @@
+========================================================
+Deprecation: #69369 - Use property text instead of data
+========================================================
+
+Description
+===========
+
+The FORM elements TEXTAREA and OPTION currently use "data" as property
+name to define default "values" which are used as human readable
+"labels" inside the specific tag. Furthermore, the TEXTBLOCK element uses
+the "content" property to define custom text. All other FORM elements
+use "value". Since "data" implies the possibility to use computed
+values, this patch deprecates "data" and adds a new property
+called "text".
+
+
+Impact
+======
+
+Using the property "data" will trigger a deprecation log entry.
+
+
+Affected Installations
+======================
+
+Any TYPO3 installation using TEXTAREA, OPTION and TEXTBLOCK elements
+which use the property "data".
+
+
+Migration
+=========
+
+Remove usage of the "data" property and use "text" instead. Opening a
+specific form with the form wizard and storing the form again will also
+migrate from "data" to "text".
\ No newline at end of file
index 3d70d26..0db3bd7 100644 (file)
@@ -450,7 +450,7 @@ class JsonToTypoScript
             $optionCounter = 10;
             foreach ($options as $option) {
                 $parent[$elementCounter . '.'][$optionCounter] = 'OPTION';
-                $parent[$elementCounter . '.'][$optionCounter . '.']['data'] = $option['data'];
+                $parent[$elementCounter . '.'][$optionCounter . '.']['text'] = $option['text'];
                 if (isset($option['attributes'])) {
                     $parent[$elementCounter . '.'][$optionCounter . '.'] += $option['attributes'];
                 }
@@ -538,6 +538,8 @@ class JsonToTypoScript
 
                 case 'content':
 
+                case 'text':
+
                 case 'name':
                     $parent[$elementCounter . '.'][$key] = (string)$value;
                     break;
@@ -566,8 +568,12 @@ class JsonToTypoScript
             if (!is_array($value)) {
                 if (strstr($value, LF)) {
                     $typoscript .= str_repeat(TAB, $tabCount) . $key . ' (' . LF;
-                    $value = str_replace(LF, LF . str_repeat(TAB, ($tabCount + 1)), $value);
-                    $typoscript .= str_repeat(TAB, ($tabCount + 1)) . $value . LF;
+                    if ($key !== 'text') {
+                        $value = str_replace(LF, LF . str_repeat(TAB, ($tabCount + 1)), $value);
+                        $typoscript .= str_repeat(TAB, ($tabCount + 1)) . $value . LF;
+                    } else {
+                        $typoscript .= $value . LF;
+                    }
                     $typoscript .= str_repeat(TAB, $tabCount) . ')' . LF;
                 } else {
                     $typoscript .= str_repeat(TAB, $tabCount) . $key . ' = ' . $value . LF;
index 3ad63ab..61f3299 100644 (file)
@@ -105,11 +105,14 @@ class SelectJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonEl
                         if (isset($childElementArguments['selected'])) {
                             $childElementArguments['attributes']['selected'] = $childElementArguments['selected'];
                             unset($childElementArguments['selected']);
-                            if (isset($childElementArguments['value'])) {
-                                $childElementArguments['attributes']['value'] = $childElementArguments['value'];
-                                unset($childElementArguments['value']);
-                            }
-                            $this->configuration['options'][] = $childElementArguments;
+                        }
+                        if (isset($childElementArguments['value'])) {
+                            $childElementArguments['attributes']['value'] = $childElementArguments['value'];
+                            unset($childElementArguments['value']);
+                        }
+                        if (isset($childElementArguments['data']) && !isset($childElementArguments['text'])) {
+                            // preserve backward compatibility by rewriting data to text
+                            $childElementArguments['text'] = $childElementArguments['data'];
                         }
                         $this->configuration['options'][] = $childElementArguments;
                     }
index b545712..b534fb2 100644 (file)
@@ -80,6 +80,22 @@ class TextareaJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\AbstractJson
         'selectionDirection',
         'selectionEnd',
         'selectionStart',
+        'text',
         'wrap'
     );
+
+    /**
+     * Set the attributes according to the allowed attributes of this element
+     *
+     * @param array $parameters Configuration array
+     * @return void
+     */
+    protected function setAttributes(array $parameters)
+    {
+        // preserve backward compatibility by rewriting data to text
+        if (isset($parameters['data'])) {
+            $this->configuration['attributes']['text'] = $parameters['data'];
+        }
+        parent::setAttributes($parameters);
+    }
 }
index ac5c7be..0e401d0 100644 (file)
@@ -34,7 +34,7 @@ class TextblockJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\AbstractJso
     public $configuration = array(
         'attributes' => array(),
         'various' => array(
-            'content' => ''
+            'text' => ''
         )
     );
 
@@ -75,8 +75,11 @@ class TextblockJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\AbstractJso
      */
     protected function setVarious(array $parameters)
     {
-        if (isset($parameters['content'])) {
-            $this->configuration['various']['content'] = $parameters['content'];
+        if (isset($parameters['text'])) {
+            $this->configuration['various']['text'] = $parameters['text'];
+        } elseif (isset($parameters['content'])) {
+            // preserve backward compatibility by rewriting content to text
+            $this->configuration['various']['text'] = $parameters['content'];
         }
     }
 }
index d8eb566..e1646bc 100644 (file)
@@ -246,6 +246,13 @@ class CompatibilityLayerUtility
                         $layout = '<td style="width: 200px;"><label /></td><td><inputvalue /></td>';
                     }
                     break;
+                case 'TEXTBLOCK':
+                    if ($action === 'show') {
+                        $layout = '<textblock />';
+                    } else {
+                        $layout = '';
+                    }
+                    break;
             }
         }
         return $layout;
index 09b61dd..e42812d 100644 (file)
@@ -46,7 +46,7 @@ prefix = tx_form
                                                        showProperties = label
                                                }
                                                attributes {
-                                                       showProperties = accept, accept-charset, accesskey, action, alt, autocomplete, autofocus, checked, class, cols, contenteditable, contextmenu, dir, draggable, dropzone, disabled, enctype, hidden, height, id, inputmode, label, lang, list, max, maxlength, method, min, minlength, multiple, name, novalidate, pattern, placeholder, readonly, required, rows, selected, selectionDirection, selectionEnd, selectionStart, size, spellcheck, src, step, style, tabindex, title, translate, type, value, width, wrap
+                                                       showProperties = accept, accept-charset, accesskey, action, alt, autocomplete, autofocus, checked, class, cols, contenteditable, contextmenu, dir, draggable, dropzone, disabled, enctype, hidden, height, id, inputmode, label, lang, list, max, maxlength, method, min, minlength, multiple, name, novalidate, pattern, placeholder, readonly, required, rows, selected, selectionDirection, selectionEnd, selectionStart, size, spellcheck, src, step, style, tabindex, text, title, translate, type, value, width, wrap
                                                }
                                                validation {
                                                        showRules = alphabetic, alphanumeric, between, date, digit, email, equals, fileallowedtypes, filemaximumsize, fileminimumsize, float, greaterthan, inarray, integer, ip, length, lessthan, regexp, required, uri
@@ -316,7 +316,7 @@ prefix = tx_form
                                showAccordions = label, attributes, validation, filters
                                accordions {
                                        attributes {
-                                               showProperties = name, placeholder, cols, rows, class, id, required
+                                               showProperties = name, placeholder, cols, rows, class, id, required, text
                                        }
                                        filtering {
                                                showFilters = alphabetic, alphanumeric, lowercase, regexp, stripnewlines, titlecase, trim, uppercase
index 3551230..2066e59 100644 (file)
                        <trans-unit id="attributes_tabindex">
                                <source>Tabindex</source>
                        </trans-unit>
+                       <trans-unit id="attributes_text">
+                               <source>Text</source>
+                       </trans-unit>
                        <trans-unit id="attributes_title">
                                <source>Title</source>
                        </trans-unit>
                        <trans-unit id="fieldoptions_emptytext">
                                <source>No options to display</source>
                        </trans-unit>
-                       <trans-unit id="fieldoptions_data">
-                               <source>Data</source>
+                       <trans-unit id="fieldoptions_text">
+                               <source>Text</source>
                        </trans-unit>
                        <trans-unit id="fieldoptions_value">
                                <source>Value</source>
                        <trans-unit id="various_properties_suffix">
                                <source>Show suffix</source>
                        </trans-unit>
+                       <trans-unit id="various_properties_text">
+                               <source>Text</source>
+                       </trans-unit>
                        <trans-unit id="various_properties_middlename">
                                <source>Show middle name</source>
                        </trans-unit>
index 1036fb3..f8e1560 100644 (file)
@@ -28,7 +28,7 @@ TYPO3.Form.Wizard.Elements.Basic.Select = Ext.extend(TYPO3.Form.Wizard.Elements,
                        '</tpl>',
                        '<select {[this.getAttributes(values.attributes)]}>',
                                '<tpl for="options">',
-                                       '<option {[this.getAttributes(values.attributes)]}>{data}</option>',
+                                       '<option {[this.getAttributes(values.attributes)]}>{text}</option>',
                                '</tpl>',
                        '</select>',
                        '<tpl for="label">',
@@ -103,14 +103,20 @@ TYPO3.Form.Wizard.Elements.Basic.Select = Ext.extend(TYPO3.Form.Wizard.Elements,
                                },
                                options: [
                                        {
-                                               data: TYPO3.l10n.localize('elements_option_1'),
-                                               value: TYPO3.l10n.localize('elements_value_1')
+                                               text: TYPO3.l10n.localize('elements_option_1'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_1')
+                                               }
                                        }, {
-                                               data: TYPO3.l10n.localize('elements_option_2'),
-                                               value: TYPO3.l10n.localize('elements_value_2')
+                                               text: TYPO3.l10n.localize('elements_option_2'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_2')
+                                               }
                                        }, {
-                                               data: TYPO3.l10n.localize('elements_option_3'),
-                                               value: TYPO3.l10n.localize('elements_value_3')
+                                               text: TYPO3.l10n.localize('elements_option_3'),
+                                               attributes: {
+                                                       value: TYPO3.l10n.localize('elements_value_3')
+                                               }
                                        }
                                ],
                                layout: 'front',
index e1df261..267391c 100644 (file)
@@ -26,7 +26,7 @@ TYPO3.Form.Wizard.Elements.Basic.Textarea = Ext.extend(TYPO3.Form.Wizard.Element
                                        '<label for="">{value}{[this.getMessage(parent.validation)]}</label>',
                                '</tpl>',
                        '</tpl>',
-                       '<textarea {[this.getAttributes(values.attributes)]}>{data}</textarea>',
+                       '<textarea {[this.getAttributes(values.attributes)]}>{values.attributes.text}</textarea>',
                        '<tpl for="label">',
                                '<tpl if="value && parent.layout == \'back\'">',
                                        '<label for="">{value}{[this.getMessage(parent.validation)]}</label>',
@@ -100,9 +100,9 @@ TYPO3.Form.Wizard.Elements.Basic.Textarea = Ext.extend(TYPO3.Form.Wizard.Element
                                        'selectionDirection': '',
                                        'selectionEnd': '',
                                        'selectionStart': '',
+                                       'text': '',
                                        'wrap': ''
                                },
-                               data: '',
                                filters: {},
                                label: {
                                        value: TYPO3.l10n.localize('elements_label')
index cd7c85d..01f5ee0 100644 (file)
@@ -23,7 +23,7 @@ TYPO3.Form.Wizard.Elements.Content.Textblock = Ext.extend(TYPO3.Form.Wizard.Elem
                '<div class="overflow-hidden">',
                        '<tpl for="various">',
                                '<div {[this.getAttributes(parent.attributes)]}>',
-                               '{content:nl2br}',
+                               '{text:nl2br}',
                                '</{type}>',
                        '</tpl>',
                '</div>',
@@ -59,7 +59,7 @@ TYPO3.Form.Wizard.Elements.Content.Textblock = Ext.extend(TYPO3.Form.Wizard.Elem
                                        title: ''
                                },
                                various: {
-                                       content: TYPO3.l10n.localize('elements_textblock_content')
+                                       text: TYPO3.l10n.localize('elements_textblock_content')
                                }
                        }
                });
index ad1d6c8..1af7d46 100644 (file)
@@ -849,6 +849,24 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Attributes = Ext.extend(Ext.FormPa
                                                }
                                        });
                                        break;
+                               case 'text':
+                                       formItems.push({
+                                               fieldLabel: TYPO3.l10n.localize('attributes_text'),
+                                               xtype: 'textarea',
+                                               name: 'text',
+                                               allowBlank: true,
+                                               listeners: {
+                                                       'triggerclick': {
+                                                               scope: this,
+                                                               fn: this.storeValue
+                                                       },
+                                                       'blur': {
+                                                               scope: this,
+                                                               fn: this.storeValue
+                                                       }
+                                               }
+                                       });
+                                       break;
                                case 'title':
                                        formItems.push({
                                                fieldLabel: TYPO3.l10n.localize('attributes_title'),
index 2379a34..cc9ea62 100644 (file)
@@ -19,7 +19,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
         * The id of a column in this grid that should expand to fill unused space.
         * This value specified here can not be 0.
         */
-       autoExpandColumn: 'data',
+       autoExpandColumn: 'text',
 
        /**
         * @cfg {Number/String} padding
@@ -56,8 +56,8 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
        initComponent: function () {
                var optionRecord = Ext.data.Record.create([
                        {
-                               name: 'data',
-                               mapping: 'data',
+                               name: 'text',
+                               mapping: 'text',
                                type: 'string'
                        }, {
                                name: 'selected',
@@ -65,7 +65,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                                type: 'bool'
                        }, {
                                name: 'value',
-                               mapping: 'value',
+                               mapping: 'attributes.value',
                                type: 'string'
                        }
                ]);
@@ -111,13 +111,13 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                                        {
                                                width: 40,
                                                id: 'data',
-                                               header: TYPO3.l10n.localize('fieldoptions_data'),
-                                               dataIndex: 'data',
+                                               header: TYPO3.l10n.localize('fieldoptions_text'),
+                                               dataIndex: 'text',
                                                editor: new Ext.ux.form.TextFieldSubmit({
                                                        allowBlank: false,
                                                        listeners: {
                                                                'triggerclick': function (field) {
-                                                                       field.gridEditor.record.set('data', field.getValue());
+                                                                       field.gridEditor.record.set('text', field.getValue());
                                                                }
                                                        }
                                                })
@@ -164,7 +164,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
        addOption: function () {
                var option = this.store.recordType;
                var newOption = new option({
-                       data: TYPO3.l10n.localize('fieldoptions_new'),
+                       text: TYPO3.l10n.localize('fieldoptions_new'),
                        selected: false,
                        value: TYPO3.l10n.localize('fieldoptions_value')
                });
@@ -188,7 +188,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                        var options = [];
                        this.store.each(function (record) {
                                var option = {
-                                       data: record.get('data')
+                                       text: record.get('text')
                                };
                                if (record.get('selected')) {
                                        if (!option.attributes) {
index 074bcf0..1891b15 100644 (file)
@@ -81,6 +81,24 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Various = Ext.extend(Ext.FormPanel
                                                }
                                        });
                                        break;
+                               case 'text':
+                                       formItems.push({
+                                               fieldLabel: TYPO3.l10n.localize('various_properties_text'),
+                                               xtype: 'textarea',
+                                               name: 'text',
+                                               allowBlank: false,
+                                               listeners: {
+                                                       'triggerclick': {
+                                                               scope: this,
+                                                               fn: this.storeValue
+                                                       },
+                                                       'blur': {
+                                                               scope: this,
+                                                               fn: this.storeValue
+                                                       }
+                                               }
+                                       });
+                                       break;
                                case 'headingSize':
                                        formItems.push({
                                                fieldLabel: TYPO3.l10n.localize('various_properties_headingsize'),