[FEATURE] Allow value attribute for OPTION object in wizard 36/43336/4
authorChristian Fischer <cf@tritum.de>
Tue, 15 Sep 2015 14:37:15 +0000 (16:37 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 16 Sep 2015 13:08:29 +0000 (15:08 +0200)
Now it is possible to add a value to the OPTION object using the
wizard. Furthermore the table within the field options of the
SELECT configuration has been improved. There were no labels shown
which has been fixed now.

Resolves: #69409
Releases: master
Change-Id: I29d6a7b98e7d3cd8c46ab44a7e47a230150cfcbe
Reviewed-on: http://review.typo3.org/43336
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Loek Hilgersom <loek@netcoop.nl>
Tested-by: Loek Hilgersom <loek@netcoop.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-69409-AllowValueAttributeForOPTIONObjectInWizard.rst [new file with mode: 0644]
typo3/sysext/form/Classes/Domain/Model/Json/SelectJsonElement.php
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/Ux/Ext.ux.grid.ItemDeleter.js
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Left/Options/Forms/Options.js

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-69409-AllowValueAttributeForOPTIONObjectInWizard.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-69409-AllowValueAttributeForOPTIONObjectInWizard.rst
new file mode 100644 (file)
index 0000000..3fa84c3
--- /dev/null
@@ -0,0 +1,11 @@
+===================================================================
+Feature: #69409 - Allow value attribute for OPTION object in wizard
+===================================================================
+
+Description
+===========
+
+Now it is possible to add a value to the OPTION object using the
+wizard. Furthermore the table within the field options of the
+SELECT configuration has been improved. There were no labels shown
+which has been fixed now.
index f61e715..1de8377 100644 (file)
@@ -91,6 +91,11 @@ 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;
                                                }
                                                $this->configuration['options'][] = $childElementArguments;
                                        }
index 9d77e37..b25af05 100644 (file)
                        <trans-unit id="fieldoptions_data">
                                <source>Data</source>
                        </trans-unit>
+                       <trans-unit id="fieldoptions_value">
+                               <source>Value</source>
+                       </trans-unit>
+                       <trans-unit id="fieldoptions_delete">
+                               <source>Delete</source>
+                       </trans-unit>
                        <trans-unit id="fieldoptions_selected">
                                <source>Selected</source>
                        </trans-unit>
                        <trans-unit id="elements_option_3">
                                <source>Option 3</source>
                        </trans-unit>
+                       <trans-unit id="elements_value_1">
+                               <source>Value 1</source>
+                       </trans-unit>
+                       <trans-unit id="elements_value_2">
+                               <source>Value 2</source>
+                       </trans-unit>
+                       <trans-unit id="elements_value_3">
+                               <source>Value 3</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>
index 20abc04..2241a88 100644 (file)
@@ -91,11 +91,14 @@ TYPO3.Form.Wizard.Elements.Basic.Select = Ext.extend(TYPO3.Form.Wizard.Elements,
                                },
                                options: [
                                        {
-                                               data: TYPO3.l10n.localize('elements_option_1')
+                                               data: TYPO3.l10n.localize('elements_option_1'),
+                                               value: TYPO3.l10n.localize('elements_value_1')
                                        }, {
-                                               data: TYPO3.l10n.localize('elements_option_2')
+                                               data: TYPO3.l10n.localize('elements_option_2'),
+                                               value: TYPO3.l10n.localize('elements_value_2')
                                        }, {
-                                               data: TYPO3.l10n.localize('elements_option_3')
+                                               data: TYPO3.l10n.localize('elements_option_3'),
+                                               value: TYPO3.l10n.localize('elements_value_3')
                                        }
                                ],
                                layout: 'front',
index f1ddd7b..bbc94fe 100644 (file)
@@ -10,6 +10,7 @@ Ext.ux.grid.ItemDeleter = Ext.extend(Ext.grid.RowSelectionModel, {
        menuDisabled: true,
        fixed: true,
        id: 'deleter',
+       header: TYPO3.l10n.localize('fieldoptions_delete'),
 
        initEvents: function(){
                Ext.ux.grid.ItemDeleter.superclass.initEvents.call(this);
index cd6bd6b..2379a34 100644 (file)
@@ -42,7 +42,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
         * the config options available for Ext.grid.GridView can be specified here. This option
         * is ignored if view is specified.
         */
-       viewConfig:{
+       viewConfig: {
                forceFit: true,
                emptyText: TYPO3.l10n.localize('fieldoptions_emptytext'),
                scrollOffset: 0
@@ -53,16 +53,20 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
         *
         * Configure store and columns for the grid
         */
-       initComponent: function() {
+       initComponent: function () {
                var optionRecord = Ext.data.Record.create([
                        {
                                name: 'data',
-                               mapping:'data',
+                               mapping: 'data',
                                type: 'string'
                        }, {
                                name: 'selected',
                                convert: this.convertSelected,
                                type: 'bool'
+                       }, {
+                               name: 'value',
+                               mapping: 'value',
+                               type: 'string'
                        }
                ]);
 
@@ -92,7 +96,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                        id: 'selected',
                        header: TYPO3.l10n.localize('fieldoptions_selected'),
                        dataIndex: 'selected',
-                       width: 30
+                       width: 20
                });
 
                var itemDeleter = new Ext.ux.grid.ItemDeleter();
@@ -105,19 +109,34 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                                },
                                columns: [
                                        {
+                                               width: 40,
                                                id: 'data',
                                                header: TYPO3.l10n.localize('fieldoptions_data'),
                                                dataIndex: 'data',
                                                editor: new Ext.ux.form.TextFieldSubmit({
                                                        allowBlank: false,
                                                        listeners: {
-                                                               'triggerclick': function(field) {
+                                                               'triggerclick': function (field) {
                                                                        field.gridEditor.record.set('data', field.getValue());
                                                                }
                                                        }
                                                })
                                        },
                                        checkColumn,
+                                       {
+                                               width: 40,
+                                               id: 'value',
+                                               header: TYPO3.l10n.localize('fieldoptions_value'),
+                                               dataIndex: 'value',
+                                               editor: new Ext.ux.form.TextFieldSubmit({
+                                                       allowBlank: true,
+                                                       listeners: {
+                                                               'triggerclick': function (field) {
+                                                                       field.gridEditor.record.set('value', field.getValue());
+                                                               }
+                                                       }
+                                               })
+                                       },
                                        itemDeleter
                                ]
                        }),
@@ -130,10 +149,10 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
                        }]
                };
 
-                       // apply config
+               // apply config
                Ext.apply(this, Ext.apply(this.initialConfig, config));
 
-                       // call parent
+               // call parent
                TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options.superclass.initComponent.apply(this, arguments);
        },
 
@@ -142,11 +161,12 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
         *
         * Called when the button to add option in the top bar has been clicked
         */
-       addOption: function() {
+       addOption: function () {
                var option = this.store.recordType;
                var newOption = new option({
                        data: TYPO3.l10n.localize('fieldoptions_new'),
-                       selected: false
+                       selected: false,
+                       value: TYPO3.l10n.localize('fieldoptions_value')
                });
                this.stopEditing();
                this.store.add(newOption);
@@ -160,20 +180,27 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
         * @param store
         * @param record
         */
-       storeOptions: function(store, record) {
+       storeOptions: function (store, record) {
                if (record && record.dirty) {
                        record.commit();
                } else {
                        var option = {};
                        var options = [];
-                       this.store.each(function(record) {
+                       this.store.each(function (record) {
                                var option = {
                                        data: record.get('data')
                                };
                                if (record.get('selected')) {
-                                       option.attributes = {
-                                               selected: 'selected'
-                                       };
+                                       if (!option.attributes) {
+                                               option.attributes = {};
+                                       }
+                                       option.attributes['selected'] = 'selected';
+                               }
+                               if (record.get('value')) {
+                                       if (!option.attributes) {
+                                               option.attributes = {};
+                                       }
+                                       option.attributes['value'] = record.get('value');
                                }
                                options.push(option);
                        });
@@ -193,7 +220,7 @@ TYPO3.Form.Wizard.Viewport.Left.Options.Forms.Options = Ext.extend(Ext.grid.Edit
         * @param record
         * @returns {Boolean}
         */
-       convertSelected: function(v, record) {
+       convertSelected: function (v, record) {
                if (record.attributes && record.attributes.selected) {
                        if (record.attributes.selected == 'selected') {
                                return true;