diff options
Diffstat (limited to 'addons/web/static/src/js/fields')
4 files changed, 34 insertions, 23 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index eab0093ed50..7cf72791be5 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -304,7 +304,6 @@ var AbstractField = Widget.extend({ this._reset(record, event); return this._render() || $.when(); }, - /** * Remove the invalid class on a field */ @@ -312,7 +311,15 @@ var AbstractField = Widget.extend({ this.$el.removeClass('o_field_invalid'); this.$el.removeAttr('aria-invalid'); }, - + /** + * Sets the given id on the focusable element of the field and as 'for' + * attribute of potential internal labels. + * + * @param {string} id + */ + setIDForLabel: function (id) { + this.getFocusableElement().attr('id', id); + }, /** * add the invalid class on a field */ @@ -320,7 +327,6 @@ var AbstractField = Widget.extend({ this.$el.addClass('o_field_invalid'); this.$el.attr('aria-invalid', 'true'); }, - /** * Update the modifiers with the newest value. * Now this.attrs.modifiersValue can be used consistantly even with diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 51816220c9f..bd13305df0c 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -701,8 +701,8 @@ var FieldBoolean = AbstractField.extend({ // The formatValue of boolean fields renders HTML elements similar to // the one rendered by the widget itself. Even though the event might // have been fired on the non-widget version of this field, we can still - // test the presence of its o_checkbox class. - if (activated && options && options.event && $(options.event.target).parents('.o_checkbox').length) { + // test the presence of its custom class. + if (activated && options && options.event && $(options.event.target).closest('.custom-control.custom-checkbox').length) { this._setValue(!this.value); // Toggle the checkbox } return activated; @@ -737,6 +737,15 @@ var FieldBoolean = AbstractField.extend({ } return rendered; }, + /** + * Associates the 'for' attribute of the internal label. + * + * @override + */ + setIDForLabel: function (id) { + this._super.apply(this, arguments); + this.$('.custom-control-label').attr('for', id); + }, //-------------------------------------------------------------------------- // Private @@ -1612,10 +1621,7 @@ var AttachmentImage = AbstractField.extend({ var StateSelectionWidget = AbstractField.extend({ template: 'FormSelection', events: { - 'click a': function (e) { - e.preventDefault(); - }, - 'click li': '_setSelection' + 'click .dropdown-item': '_setSelection', }, supportedFieldTypes: ['selection'], @@ -1696,13 +1702,12 @@ var StateSelectionWidget = AbstractField.extend({ * @param {MouseEvent} ev */ _setSelection: function (ev) { - var li = $(ev.target).closest('li'); - if (li.length) { - var value = String(li.data('value')); - this._setValue(value); - if (this.mode === 'edit') { - this._render(); - } + ev.preventDefault(); + var $item = $(ev.currentTarget); + var value = String($item.data('value')); + this._setValue(value); + if (this.mode === 'edit') { + this._render(); } }, }); @@ -1778,7 +1783,7 @@ var LabelSelection = AbstractField.extend({ _render: function () { this.classes = this.nodeOptions && this.nodeOptions.classes || {}; var labelClass = this.classes[this.value] || 'primary'; - this.$el.addClass('label label-' + labelClass).text(this._formatValue(this.value)); + this.$el.addClass('badge badge-' + labelClass).text(this._formatValue(this.value)); }, }); @@ -2693,9 +2698,9 @@ var ImageSelection = AbstractField.extend({ var self = this; this.$el.empty(); _.each(this.nodeOptions, function (val, key) { - var $container = $('<div>').addClass('col-xs-3 text-center'); + var $container = $('<div>').addClass('col-3 text-center'); var $img = $('<img>') - .addClass('img img-responsive img-thumbnail ml16') + .addClass('img img-fluid img-thumbnail ml16') .toggleClass('btn-info', key === self.value) .attr('src', val.image_link) .data('key', key); diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index c1c458d1935..ba83de415e7 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -968,7 +968,7 @@ var FieldX2Many = AbstractField.extend({ _renderButtons: function () { if (!this.isReadonly && this.view.arch.tag === 'kanban') { this.$buttons = $(qweb.render('KanbanView.buttons', { - btnClass: 'btn-default', + btnClass: 'btn-secondary', create_text: this.nodeOptions.create_text, })); this.$buttons.on('click', 'button.o-kanban-button-new', this._onAddRecord.bind(this)); @@ -1887,7 +1887,7 @@ var FormFieldMany2ManyTags = FieldMany2ManyTags.extend({ this.$color_picker.dropdown('toggle'); this.$color_picker.attr("tabindex", 1).focus(); if (!tagColor) { - this.$('.o_checkbox input').prop('checked', true); + this.$('.custom-checkbox input').prop('checked', true); } } }, @@ -1909,7 +1909,7 @@ var FormFieldMany2ManyTags = FieldMany2ManyTags.extend({ var changes = {}; if ($target.is('.o_hide_in_kanban')) { - var $checkbox = $('.o_hide_in_kanban .o_checkbox input'); + var $checkbox = $('.o_hide_in_kanban .custom-checkbox input'); $checkbox.prop('checked', !$checkbox.prop('checked')); // toggle checkbox this.prevColors = this.prevColors ? this.prevColors : {}; if ($checkbox.is(':checked')) { diff --git a/addons/web/static/src/js/fields/upgrade_fields.js b/addons/web/static/src/js/fields/upgrade_fields.js index 119a64881e3..dd91ca2efc2 100644 --- a/addons/web/static/src/js/fields/upgrade_fields.js +++ b/addons/web/static/src/js/fields/upgrade_fields.js @@ -94,7 +94,7 @@ var AbstractFieldUpgrade = { this._super.apply(this, arguments); this._insertEnterpriseLabel($("<span>", { text: "Enterprise", - 'class': "label label-primary oe_inline o_enterprise_label" + 'class': "badge badge-primary oe_inline o_enterprise_label" })); }, /** |
