summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2018-07-27 12:42:10 +0200
committerqsm-odoo <qsm@odoo.com>2018-07-27 12:42:10 +0200
commit2b3017974bc7cd4b3a74f83c956224cfe4e5a918 (patch)
treeff6aab8dc6bfa7afbe9ef714ca157ebc0185d2fd /addons/web/static/src/js/widgets
parent8ed8b46f6434a2a3adea69e0134317e30bf9b936 (diff)
parent519594e9cab9a6362ef7c3e911605e4507a0a008 (diff)
[MERGE] *: migrate Bootstrap 3.3.7 to 4.1.3
See sub-commits for details. task-49280 Closes https://github.com/odoo/odoo/pull/25045
Diffstat (limited to 'addons/web/static/src/js/widgets')
-rw-r--r--addons/web/static/src/js/widgets/data_export.js20
-rw-r--r--addons/web/static/src/js/widgets/date_picker.js103
-rw-r--r--addons/web/static/src/js/widgets/debug_manager.js8
-rw-r--r--addons/web/static/src/js/widgets/domain_selector.js2
-rw-r--r--addons/web/static/src/js/widgets/dropdown_menu.js14
-rw-r--r--addons/web/static/src/js/widgets/model_field_selector.js6
-rw-r--r--addons/web/static/src/js/widgets/switch_company_menu.js6
7 files changed, 93 insertions, 66 deletions
diff --git a/addons/web/static/src/js/widgets/data_export.js b/addons/web/static/src/js/widgets/data_export.js
index 30e17604077..d05bf2d33fc 100644
--- a/addons/web/static/src/js/widgets/data_export.js
+++ b/addons/web/static/src/js/widgets/data_export.js
@@ -49,7 +49,7 @@ var DataExport = Dialog.extend({
function process_children() {
var $this = $(this);
- if($this.hasClass('open')) {
+ if($this.hasClass('show')) {
$this.children('.o_export_tree_item')
.addClass('o_selected')
.each(process_children);
@@ -77,19 +77,19 @@ var DataExport = Dialog.extend({
switch(e.keyCode || e.which) {
case $.ui.keyCode.LEFT:
- if ($elem.hasClass('open')) {
+ if ($elem.hasClass('show')) {
this.on_expand_action(record);
}
break;
case $.ui.keyCode.RIGHT:
- if (!$elem.hasClass('open')) {
+ if (!$elem.hasClass('show')) {
this.on_expand_action(record);
}
break;
case $.ui.keyCode.UP:
var $prev = $elem.prev('.o_export_tree_item');
if($prev.length === 1) {
- while($prev.hasClass('open')) {
+ while($prev.hasClass('show')) {
$prev = $prev.children('.o_export_tree_item').last();
}
} else {
@@ -104,7 +104,7 @@ var DataExport = Dialog.extend({
break;
case $.ui.keyCode.DOWN:
var $next;
- if($elem.hasClass('open')) {
+ if($elem.hasClass('show')) {
$next = $elem.children('.o_export_tree_item').first();
} else {
$next = $elem.next('.o_export_tree_item');
@@ -408,7 +408,7 @@ var DataExport = Dialog.extend({
var self = this;
if(expansion) {
this.$('.o_export_tree_item[data-id="' + expansion + '"]')
- .addClass('open')
+ .addClass('show')
.find('.o_expand_parent')
.toggleClass('fa-chevron-right fa-chevron-down')
.next()
@@ -429,8 +429,8 @@ var DataExport = Dialog.extend({
},
show_content: function(id) {
var $this = this.$('.o_export_tree_item[data-id="' + id + '"]');
- $this.toggleClass('open');
- var is_open = $this.hasClass('open');
+ $this.toggleClass('show');
+ var is_open = $this.hasClass('show');
$this.children('.o_expand_parent').toggleClass('fa-chevron-down', !!is_open).toggleClass('fa-chevron-right', !is_open);
@@ -441,8 +441,8 @@ var DataExport = Dialog.extend({
if(!is_open) {
$child.hide();
} else if(child_len === $child_field.eq(i).data('id').split("/").length) {
- if ($child.hasClass('open')) {
- $child.removeClass('open');
+ if ($child.hasClass('show')) {
+ $child.removeClass('show');
$child.children('.o_expand_parent').removeClass('fa-chevron-down').addClass('fa-chevron-right');
}
$child.show();
diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js
index 8f87b36c874..9d47e79f6a7 100644
--- a/addons/web/static/src/js/widgets/date_picker.js
+++ b/addons/web/static/src/js/widgets/date_picker.js
@@ -1,69 +1,74 @@
odoo.define('web.datepicker', function (require) {
"use strict";
-var core = require('web.core');
var field_utils = require('web.field_utils');
var time = require('web.time');
var Widget = require('web.Widget');
-var _t = core._t;
-
var DateWidget = Widget.extend({
template: "web.datepicker",
type_of_date: "date",
events: {
- 'dp.change': 'changeDatetime',
- 'dp.show': '_onShow',
+ 'change.datetimepicker': 'changeDatetime',
+ 'show.datetimepicker': '_onShow',
+ 'click input.o_datepicker_input': '_onClick',
'change .o_datepicker_input': 'changeDatetime',
+ 'input input': '_onInput',
},
/**
* @override
*/
- init: function(parent, options) {
+ init: function (parent, options) {
this._super.apply(this, arguments);
- var l10n = _t.database.parameters;
-
this.name = parent.name;
- this.options = _.defaults(options || {}, {
+ this.options = _.extend({
format : this.type_of_date === 'datetime' ? time.getLangDatetimeFormat() : time.getLangDateFormat(),
minDate: moment({ y: 1900 }),
maxDate: moment().add(200, "y"),
- calendarWeeks: true,
+ useCurrent: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
- next: 'fa fa-chevron-right',
- previous: 'fa fa-chevron-left',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
- close: 'fa fa-times',
+ previous: 'fa fa-chevron-left',
+ next: 'fa fa-chevron-right',
+ today: 'fa fa-calendar-check-o',
+ clear: 'fa fa-delete',
+ close: 'fa fa-times'
+ },
+ calendarWeeks: true,
+ buttons: {
+ showToday: false,
+ showClear: false,
+ showClose: false,
},
- locale : moment.locale(),
- allowInputToggle: true,
- keyBinds: null,
widgetParent: 'body',
- useCurrent: false,
- });
+ keyBinds: null,
+ allowInputToggle: true,
+ }, options || {});
},
/**
* @override
*/
- start: function() {
+ start: function () {
this.$input = this.$('input.o_datepicker_input');
- this.$input.focus(function(e) {
+ this.$input.focus(function (e) {
e.stopImmediatePropagation();
});
+ this.__libInput = true;
this.$input.datetimepicker(this.options);
- this.picker = this.$input.data('DateTimePicker');
- this.$input.click(this.picker.toggle.bind(this.picker));
+ this.__libInput = false;
this._setReadonly(false);
},
/**
* @override
*/
- destroy: function() {
- this.picker.destroy();
+ destroy: function () {
+ this.__libInput = true;
+ this.$input.datetimepicker('destroy');
+ this.__libInput = false;
this._super.apply(this, arguments);
},
@@ -82,7 +87,7 @@ var DateWidget = Widget.extend({
var hasChanged = !oldValue !== !newValue;
if (oldValue && newValue) {
var formattedOldValue = oldValue.format(time.getLangDatetimeFormat());
- var formattedNewValue = newValue.format(time.getLangDatetimeFormat())
+ var formattedNewValue = newValue.format(time.getLangDatetimeFormat());
if (formattedNewValue !== formattedOldValue) {
hasChanged = true;
}
@@ -106,13 +111,13 @@ var DateWidget = Widget.extend({
*/
isValid: function () {
var value = this.$input.val();
- if(value === "") {
+ if (value === "") {
return true;
} else {
try {
this._parseClient(value);
return true;
- } catch(e) {
+ } catch (e) {
return false;
}
}
@@ -124,9 +129,9 @@ var DateWidget = Widget.extend({
this.set({'value': value});
var formatted_value = value ? this._formatClient(value) : null;
this.$input.val(formatted_value);
- if (this.picker) {
- this.picker.date(value || null);
- }
+ this.__libInput = true;
+ this.$input.datetimepicker('date', value || null);
+ this.__libInput = false;
},
//--------------------------------------------------------------------------
@@ -162,7 +167,7 @@ var DateWidget = Widget.extend({
*
* @private
*/
- _setValueFromUi: function() {
+ _setValueFromUi: function () {
var value = this.$input.val() || false;
this.setValue(this._parseClient(value));
},
@@ -172,6 +177,23 @@ var DateWidget = Widget.extend({
//--------------------------------------------------------------------------
/**
+ * @private
+ */
+ _onClick: function () {
+ this.__libInput = true;
+ this.$input.datetimepicker('toggle');
+ this.__libInput = false;
+ },
+ /**
+ * @private
+ * @param {Event} ev
+ */
+ _onInput: function (ev) {
+ if (this.__libInput) {
+ ev.stopImmediatePropagation();
+ }
+ },
+ /**
* set the date of the picker by the current date or the today date
*
* @private
@@ -179,9 +201,11 @@ var DateWidget = Widget.extend({
_onShow: function () {
//when opening datetimepicker the date and time by default should be the one from
//the input field if any or the current day otherwise
- if(this.$input.val().length !== 0 && this.isValid()) {
+ if (this.$input.val().length !== 0 && this.isValid()) {
var value = this._parseClient(this.$input.val());
- this.picker.date(value);
+ this.__libInput = true;
+ this.$input.datetimepicker('date', value);
+ this.__libInput = false;
this.$input.select();
}
},
@@ -189,11 +213,14 @@ var DateWidget = Widget.extend({
var DateTimeWidget = DateWidget.extend({
type_of_date: "datetime",
- init: function() {
- this._super.apply(this, arguments);
- this.options = _.defaults(this.options, {
- showClose: true,
- });
+ init: function (parent, options) {
+ this._super(parent, _.extend({
+ buttons: {
+ showToday: false,
+ showClear: false,
+ showClose: true,
+ },
+ }, options || {}));
},
});
diff --git a/addons/web/static/src/js/widgets/debug_manager.js b/addons/web/static/src/js/widgets/debug_manager.js
index 4eee9266594..d553387f153 100644
--- a/addons/web/static/src/js/widgets/debug_manager.js
+++ b/addons/web/static/src/js/widgets/debug_manager.js
@@ -23,12 +23,12 @@ var DebugManager = Widget.extend({
template: "WebClient.DebugManager",
events: {
"click a[data-action]": "perform_callback",
- "mouseover .o_debug_dropdowns > li:not(.open)": function(e) {
+ "mouseover .o_debug_dropdowns > li:not(.show)": function(e) {
// Open other dropdowns on mouseover
- var $opened = this.$('.o_debug_dropdowns > li.open');
+ var $opened = this.$('.o_debug_dropdowns > li.show');
if($opened.length) {
- $opened.removeClass('open');
- $(e.currentTarget).addClass('open').find('> a').focus();
+ $opened.removeClass('show');
+ $(e.currentTarget).addClass('show').find('> a').focus();
}
},
},
diff --git a/addons/web/static/src/js/widgets/domain_selector.js b/addons/web/static/src/js/widgets/domain_selector.js
index c5a561b1b77..dab0c97108b 100644
--- a/addons/web/static/src/js/widgets/domain_selector.js
+++ b/addons/web/static/src/js/widgets/domain_selector.js
@@ -161,7 +161,7 @@ var DomainNode = Widget.extend({
var DomainTree = DomainNode.extend({
template: "DomainTree",
events: _.extend({}, DomainNode.prototype.events, {
- "click .o_domain_tree_operator_selector > ul > li > a": "_onOperatorChange",
+ "click .o_domain_tree_operator_selector .dropdown-item": "_onOperatorChange",
}),
custom_events: {
// If a domain child sends a request to add a child or remove one, call
diff --git a/addons/web/static/src/js/widgets/dropdown_menu.js b/addons/web/static/src/js/widgets/dropdown_menu.js
index a3a83519678..6f8f78a13d5 100644
--- a/addons/web/static/src/js/widgets/dropdown_menu.js
+++ b/addons/web/static/src/js/widgets/dropdown_menu.js
@@ -11,8 +11,8 @@ var QWeb = core.qweb;
var DropdownMenu = Widget.extend({
template: 'web.DropdownMenu',
events: {
- 'click li.o_menu_item': '_onItemClick',
- 'click li.o_item_option': '_onOptionClick',
+ 'click .o_menu_item': '_onItemClick',
+ 'click .o_item_option': '_onOptionClick',
'click span.o_trash_button': '_onTrashClick',
'hidden.bs.dropdown': '_onBootstrapClose',
},
@@ -44,12 +44,12 @@ var DropdownMenu = Widget.extend({
this.dropdownCategory = dropdownHeader.category;
this.dropdownTitle = dropdownHeader.title;
this.dropdownIcon = dropdownHeader.icon;
- this.dropdownSymbol = dropdownHeader.symbol || 'caret';
+ this.dropdownSymbol = dropdownHeader.symbol || false;
// this parameter fixes the menu style. By default,
// the style used is the one used in the search view
this.dropdownStyle = dropdownHeader.style || {
el: {class: 'btn-group o_dropdown', attrs: {}},
- mainButton: {class: 'o_dropdown_toggler_btn btn btn-sm btn-default dropdown-toggle'},
+ mainButton: {class: 'o_dropdown_toggler_btn btn btn-secondary dropdown-toggle' + (this.dropdownSymbol ? ' o-no-caret' : '')},
};
this.items = items;
_.each(this.items, this._prepareItem.bind(this));
@@ -105,8 +105,8 @@ var DropdownMenu = Widget.extend({
*/
_renderMenuItems: function () {
var newMenuItems = QWeb.render('DropdownMenu.MenuItems', {widget: this});
- this.$el.find('.o_menu_item,.divider[data-removable="1"]').remove();
- this.$('ul.o_dropdown_menu').prepend($(newMenuItems));
+ this.$el.find('.o_menu_item, .dropdown-divider[data-removable="1"]').remove();
+ this.$('.o_dropdown_menu').prepend($(newMenuItems));
},
/**
* this function computes some default values for some of the item keys
@@ -189,7 +189,7 @@ var DropdownMenu = Widget.extend({
* @param {jQueryEvent} event
*/
_onBootstrapClose: function () {
- _.each(this.items, function(item) {
+ _.each(this.items, function (item) {
item.isOpen = false;
});
this._renderMenuItems();
diff --git a/addons/web/static/src/js/widgets/model_field_selector.js b/addons/web/static/src/js/widgets/model_field_selector.js
index 81abfbe0d6c..e9990ac5105 100644
--- a/addons/web/static/src/js/widgets/model_field_selector.js
+++ b/addons/web/static/src/js/widgets/model_field_selector.js
@@ -253,7 +253,7 @@ var ModelFieldSelector = Widget.extend({
if (!this._isOpen) return;
this._isOpen = false;
- this.$popover.addClass("hidden");
+ this.$popover.addClass('d-none');
if (this.dirty) {
this.dirty = false;
@@ -332,7 +332,7 @@ var ModelFieldSelector = Widget.extend({
}));
// Toggle the warning message
- this.$valid.toggleClass("hidden", !!this.isValid());
+ this.$valid.toggleClass('d-none', !!this.isValid());
// Adapt the popover content
var page = _.last(this.pages);
@@ -376,7 +376,7 @@ var ModelFieldSelector = Widget.extend({
if (this._isOpen) return;
this._isOpen = true;
- this.$popover.removeClass("hidden");
+ this.$popover.removeClass('d-none');
},
/**
* Toggles the valid status of the widget and display the error message if
diff --git a/addons/web/static/src/js/widgets/switch_company_menu.js b/addons/web/static/src/js/widgets/switch_company_menu.js
index 01c224370d2..c9498950a04 100644
--- a/addons/web/static/src/js/widgets/switch_company_menu.js
+++ b/addons/web/static/src/js/widgets/switch_company_menu.js
@@ -18,7 +18,7 @@ var _t = core._t;
var SwitchCompanyMenu = Widget.extend({
template: 'SwitchCompanyMenu',
events: {
- 'click .dropdown-menu li a[data-menu]': '_onClick',
+ 'click .dropdown-item[data-menu]': '_onClick',
},
/**
* @override
@@ -53,8 +53,8 @@ var SwitchCompanyMenu = Widget.extend({
} else {
a = '<span style="margin-right: 24px;"/>';
}
- companiesList += '<li><a href="#" data-menu="company" data-company-id="' +
- company[0] + '">' + a + company[1] + '</a></li>';
+ companiesList += '<a href="#" class="dropdown-item" data-menu="company" data-company-id="' +
+ company[0] + '">' + a + company[1] + '</a>';
});
this.$('.dropdown-menu').html(companiesList);
return this._super();