changeset d5d1af65c83a in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=d5d1af65c83a
description:
        Set field's name as input's name attribute

        This makes the browser autocomplete suggestion smarter.

        issue9461
        review325741002
diffstat:

 CHANGELOG        |   1 +
 src/common.js    |   1 +
 src/view/form.js |  41 ++++++++++++++++++++++++++++-------------
 3 files changed, 30 insertions(+), 13 deletions(-)

diffs (168 lines):

diff -r 5f9363fcdf4f -r d5d1af65c83a CHANGELOG
--- a/CHANGELOG Mon Aug 03 00:03:15 2020 +0200
+++ b/CHANGELOG Wed Aug 05 00:30:02 2020 +0200
@@ -1,3 +1,4 @@
+* Set field's name as input's name attribute
 * Position copied records based on order
 * Sanitize translated RichtText fields content (issue9453)
 * Allow configuration of default colors for graph and calendar
diff -r 5f9363fcdf4f -r d5d1af65c83a src/common.js
--- a/src/common.js     Mon Aug 03 00:03:15 2020 +0200
+++ b/src/common.js     Wed Aug 05 00:30:02 2020 +0200
@@ -766,6 +766,7 @@
             } else {
                 this.el = jQuery('<button/>', {
                     title: attributes.string || '',
+                    name: attributes.name || '',
                 });
                 this.el.text(attributes.string || '');
                 if (this.attributes.rule) {
diff -r 5f9363fcdf4f -r d5d1af65c83a src/view/form.js
--- a/src/view/form.js  Mon Aug 03 00:03:15 2020 +0200
+++ b/src/view/form.js  Wed Aug 05 00:30:02 2020 +0200
@@ -895,6 +895,7 @@
             Sao.View.Form.Link._super.init.call(this, attributes);
             this.el = jQuery('<button/>', {
                 'class': this.class_ + ' btn btn-link',
+                'name': attributes.name,
             });
             if (attributes.icon) {
                 var img = jQuery('<img/>', {
@@ -1420,7 +1421,8 @@
             }).appendTo(this.el);
             this.input = this.labelled = jQuery('<input/>', {
                 'type': 'text',
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             }).appendTo(this.group);
             if (!jQuery.isEmptyObject(attributes.autocomplete)) {
                 this.datalist = jQuery('<datalist/>').appendTo(this.el);
@@ -1513,7 +1515,8 @@
         translate_widget: function() {
             return jQuery('<input/>', {
                 'class': 'form-control',
-                'readonly': 'readonly'
+                'readonly': 'readonly',
+                'name': this.attributes.name,
             });
         }
     });
@@ -1572,7 +1575,8 @@
                 }).appendTo(this.date));
             this.input = jQuery('<input/>', {
                 'type': 'text',
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             }).appendTo(this.date);
             this.date.datetimepicker({
                 'locale': moment.locale(),
@@ -1714,7 +1718,8 @@
             });
             this.input = this.labelled = jQuery('<input/>', {
                 'type': 'text',
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             }).appendTo(this.el);
             this.el.change(this.focus_out.bind(this));
         },
@@ -1897,7 +1902,8 @@
                 'class': this.class_
             });
             this.select = this.labelled = jQuery('<select/>', {
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             });
             this.el.append(this.select);
             this.select.change(this.focus_out.bind(this));
@@ -1995,7 +2001,8 @@
             });
             this.input = this.labelled = jQuery('<input/>', {
                 'type': 'checkbox',
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             }).appendTo(this.el);
             this.input.change(this.focus_out.bind(this));
             this.input.click(function() {
@@ -2035,7 +2042,8 @@
                 'class': this.class_
             });
             this.input = this.labelled = jQuery('<textarea/>', {
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             }).appendTo(this.el);
             this.input.change(this.focus_out.bind(this));
             if (this.attributes.translate) {
@@ -2363,7 +2371,8 @@
             }).appendTo(this.el);
             this.entry = this.labelled = jQuery('<input/>', {
                 'type': 'input',
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             }).appendTo(group);
             this.but_primary = jQuery('<img/>', {
                 'class': 'icon',
@@ -3039,7 +3048,8 @@
             if (attributes.add_remove) {
                 this.wid_text = jQuery('<input/>', {
                     type: 'text',
-                    'class': 'form-control input-sm'
+                    'class': 'form-control input-sm',
+                    'name': attributes.name,
                 }).appendTo(group);
                 // TODO add completion
                 //
@@ -3546,7 +3556,8 @@
             }).appendTo(toolbar);
             this.entry = jQuery('<input/>', {
                 type: 'text',
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': attributes.name,
             }).appendTo(group);
             // Use keydown to not receive focus-in TAB
             this.entry.on('keydown', this.key_press.bind(this));
@@ -3903,7 +3914,8 @@
             this.size = jQuery('<input/>', {
                 type: 'input',
                 'class': 'form-control input-sm',
-                'readonly': true
+                'readonly': true,
+                'name': attributes.name,
             }).appendTo(group);
 
             if (this.filename && attributes.filename_visible) {
@@ -4309,6 +4321,7 @@
                 'type': 'text',
                 'class': 'form-control input-sm',
                 'placeholder': Sao.i18n.gettext('Search'),
+                'name': attributes.name,
             }).appendTo(group);
 
             // TODO completion
@@ -4583,7 +4596,8 @@
             }).appendTo(this.el);
             this.input = this.labelled = jQuery('<input/>', {
                 'type': 'text',
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': this.name,
             }).appendTo(group);
             this.button = jQuery('<button/>', {
                 'class': 'btn btn-default',
@@ -4637,7 +4651,8 @@
         create_widget: function() {
             Sao.View.Form.Dict.SelectionEntry._super.create_widget.call(this);
             var select = jQuery('<select/>', {
-                'class': 'form-control input-sm mousetrap'
+                'class': 'form-control input-sm mousetrap',
+                'name': this.name,
             });
             select.change(
                     this.parent_widget.focus_out.bind(this.parent_widget));

Reply via email to