diff --git a/sao/CHANGELOG b/sao/CHANGELOG index a05649cd3e..cc4eeb8374 100644 --- a/sao/CHANGELOG +++ b/sao/CHANGELOG @@ -1,3 +1,4 @@ +* Use toggle button and label on translate dialog * Support border type of images * Manage domain on id in single value list as unique * Do not validate domain and enforce uniqueness for empty fields unless they're required diff --git a/sao/src/sao.less b/sao/src/sao.less index 86ee937604..f3ea5cbf95 100644 --- a/sao/src/sao.less +++ b/sao/src/sao.less @@ -50,6 +50,14 @@ html[theme="default"] { z-index: 3; } +.input-group-addon { + > .label { + position: absolute; + right: 0px; + top: -5px; + } +} + .navbar-inverse { .close { color: @navbar-inverse-link-color; diff --git a/sao/src/view/form.js b/sao/src/view/form.js index bffff2c42e..e22688efc3 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -1313,7 +1313,7 @@ function eval_pyson(value){ class_: 'form', init: function(languages, widget) { var dialog = new Sao.Dialog( - Sao.i18n.gettext('Translate'), this.class_, 'lg'); + Sao.i18n.gettext('Translate'), this.class_, 'md'); this.languages = languages; this.read(widget, dialog); jQuery('', { @@ -1350,24 +1350,23 @@ function eval_pyson(value){ function field_value(result) { return result[0][widget.field_name] || ''; } + dialog.content.addClass('form-horizontal'); this.languages.forEach(lang => { var value; var row = jQuery('
', { - 'class':'row form-group' + 'class':'form-group' }); var input = widget.translate_widget(); input.attr('data-lang-id', lang.id); - var checkbox = jQuery('', { - 'type':'checkbox', - 'title': Sao.i18n.gettext('Edit') - }); + var edit = jQuery('', { + 'type': 'button', + 'class': 'btn btn-default', + }).text(Sao.i18n.gettext('Edit')); if (widget._readonly) { - checkbox.attr('disabled', true); + edit.attr('disabled', true); } - var fuzzy_box = jQuery('', { - 'type':'checkbox', - 'disabled': true, - 'title': Sao.i18n.gettext('Fuzzy') + var fuzzy_label = jQuery('', { + 'class': 'label', }); var prm1 = Sao.rpc({ 'method': 'model.' + widget.model.name + '.read', @@ -1392,25 +1391,28 @@ function eval_pyson(value){ jQuery.when(prm1, prm2).done(function(value, fuzzy_value) { widget.translate_widget_set(input, fuzzy_value); widget.translate_widget_set_readonly( input, true); - fuzzy_box.attr('checked', value !== fuzzy_value); + if (value !== fuzzy_value) { + fuzzy_label.addClass('label-warning'); + fuzzy_label.text(Sao.i18n.gettext("Fuzzy")); + } }); - checkbox.click(function() { + edit.click(function() { + jQuery(this).toggleClass('active'); widget.translate_widget_set_readonly( - input, !jQuery(this).prop('checked')); + input, !jQuery(this).hasClass('active')); }); dialog.body.append(row); + input.uniqueId(); + row.append(jQuery('', { + 'for': input.attr('id'), + 'class': 'col-sm-3 control-label', + }).append(' ' + lang.name)); row.append(jQuery('', { - 'class':'col-sm-2' - }).append(lang.name)); - row.append(jQuery('', { - 'class':'col-sm-8' - }).append(input)); - row.append(jQuery('', { - 'class':'col-sm-1' - }).append(checkbox)); - row.append(jQuery('', { - 'class':'col-sm-1' - }).append(fuzzy_box)); + 'class': 'col-sm-9 input-group', + }).append(input) + .append(jQuery('', { + 'class': 'input-group-addon', + }).append(edit).append(fuzzy_label))); }); }, write: function(widget, dialog) { @@ -2297,10 +2299,12 @@ function eval_pyson(value){ this.input.prop('readonly', readonly); }, translate_widget: function() { - return jQuery('', { + var widget = jQuery('', { 'class': 'form-control', - 'readonly': 'readonly' + 'readonly': 'readonly', }); + widget.css('min-height', this.el.height()); + return widget; } }); diff --git a/tryton/CHANGELOG b/tryton/CHANGELOG index 53f2ef88a4..d660d0cb3c 100644 --- a/tryton/CHANGELOG +++ b/tryton/CHANGELOG @@ -1,3 +1,4 @@ +* Use toggle button and label on translate dialog * Manage domain on id in single value list as unique * Do not validate domain and enforce uniqueness for empty fields unless they're required * Display the number of selected records on xxx2Many diff --git a/tryton/tryton/client.py b/tryton/tryton/client.py index 31d4640399..f5bd1a75dd 100644 --- a/tryton/tryton/client.py +++ b/tryton/tryton/client.py @@ -30,6 +30,9 @@ def main(): label.editable { font-style: italic; } + label.warning { + color: @warning_color; + } .window-title, .wizard-title { font-size: large; font-weight: bold; diff --git a/tryton/tryton/gui/window/view_form/view/form_gtk/widget.py b/tryton/tryton/gui/window/view_form/view/form_gtk/widget.py index fc096bdadc..b88ed75d17 100644 --- a/tryton/tryton/gui/window/view_form/view/form_gtk/widget.py +++ b/tryton/tryton/gui/window/view_form/view/form_gtk/widget.py @@ -204,17 +204,15 @@ class TranslateDialog(NoModal): widget.set_vexpand(self.widget.expand) widget.set_hexpand(True) grid.attach(widget, 1, i, 1, 1) - editing = Gtk.CheckButton() + editing = Gtk.ToggleButton(label=_("Edit")) editing.connect('toggled', self.editing_toggled, widget) editing.props.sensitive = not readonly - tooltips.set_tip(editing, _('Edit')) grid.attach(editing, 2, i, 1, 1) - fuzzy = Gtk.CheckButton() - fuzzy.set_active(value != fuzzy_value) - fuzzy.props.sensitive = False - tooltips.set_tip(fuzzy, _('Fuzzy')) - grid.attach(fuzzy, 4, i, 1, 1) - self.widgets[language['code']] = (widget, editing, fuzzy) + if value != fuzzy_value: + fuzzy = Gtk.Label(_("Fuzzy")) + widget_class(fuzzy, 'warning', True) + grid.attach(fuzzy, 4, i, 1, 1) + self.widgets[language['code']] = (widget, editing) tooltips.enable() vbox = Gtk.VBox() @@ -241,7 +239,7 @@ class TranslateDialog(NoModal): def response(self, win, response): if response == Gtk.ResponseType.OK: for code, widget in self.widgets.items(): - widget, editing, fuzzy = widget + widget, editing = widget if not editing.get_active(): continue value = self.widget.translate_widget_get(widget)