From 4985f6a1ae33c18646b5ecfda13e6e868020337f Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Tue, 17 Sep 2019 12:32:02 +0000 Subject: [PATCH 1/3] [IMP] web: datetime picker style Changed the style of the "Close" button to match the one on the "primary buttons". Task 2068164 --- addons/web/static/src/js/widgets/date_picker.js | 2 +- addons/web/static/src/scss/datepicker.scss | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js index 3f528fe7c37..06d329282c8 100644 --- a/addons/web/static/src/js/widgets/date_picker.js +++ b/addons/web/static/src/js/widgets/date_picker.js @@ -42,7 +42,7 @@ var DateWidget = Widget.extend({ next: 'fa fa-chevron-right', today: 'fa fa-calendar-check-o', clear: 'fa fa-delete', - close: 'fa fa-times' + close: 'fa fa-check primary', }, calendarWeeks: true, buttons: { diff --git a/addons/web/static/src/scss/datepicker.scss b/addons/web/static/src/scss/datepicker.scss index 7232b8c97a8..efc09b2d790 100644 --- a/addons/web/static/src/scss/datepicker.scss +++ b/addons/web/static/src/scss/datepicker.scss @@ -84,6 +84,20 @@ div.dropdown-menu.bootstrap-datetimepicker-widget{ } } +.picker-switch { + span.fa { + margin: 0; + @include transition($btn-transition); + &.primary { + background-color: $o-brand-primary; + color: white; + &:hover { + background-color: darken($o-brand-primary, 10%); + } + } + } +} + // This is rtl language specific fix // it will fix the user agent stylesheet padding // and transform the prev and next icons From f58f17762643a211e77227a326b5fc3a721a2120 Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Tue, 17 Sep 2019 12:31:22 +0000 Subject: [PATCH 2/3] [IMP] web: added increments to the minutes in daterange Minutes can now be chosen by increments of 5 instead of 10. Task 2068164 --- addons/web/static/src/js/fields/basic_fields.js | 2 +- addons/web/static/tests/fields/basic_fields_tests.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index c1d01022c68..a34d024b8e6 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -588,7 +588,7 @@ var FieldDateRange = InputField.extend({ timePicker: !this.isDateField, timePicker24Hour: _t.database.parameters.time_format.search('%H') !== -1, autoUpdateInput: false, - timePickerIncrement: 10, + timePickerIncrement: 5, locale: { format: this.isDateField ? time.getLangDateFormat() : time.getLangDatetimeFormat(), }, diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index aa86ff925e4..63ce02be614 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -2636,7 +2636,7 @@ QUnit.module('basic_fields', { QUnit.module('FieldDateRange'); QUnit.test('Datetime field', async function (assert) { - assert.expect(19); + assert.expect(20); this.data.partner.fields.datetime_end = {string: 'Datetime End', type: 'datetime'}; this.data.partner.records[0].datetime_end = '2017-03-13 00:00:00'; @@ -2685,6 +2685,8 @@ QUnit.module('basic_fields', { "active end date hour should be '5' in date range picker"); assert.strictEqual($('.daterangepicker:first .drp-calendar.right .minuteselect').val(), '30', "active end date minute should be '30' in date range picker"); + assert.containsN($('.daterangepicker:first .drp-calendar.left .minuteselect'), 'option', 12, + "minute selection should contain 12 options (1 for each 5 minutes)"); // Close picker await testUtils.dom.click($('.daterangepicker:first .cancelBtn')); From c49bd8dcdb014474f0af78485b8af1a0b9274571 Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Tue, 17 Sep 2019 12:31:47 +0000 Subject: [PATCH 3/3] [IMP] web: today as default filter for datetime Changed the default value of datetime to "is between" with "today" as the default value (same day 00:00:00 to 23:59:59). Task 2068164 --- .../control_panel/search/search_filters.js | 36 ++++++++++++------- .../static/tests/views/search_view_tests.js | 8 ++--- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/addons/web/static/src/js/views/control_panel/search/search_filters.js b/addons/web/static/src/js/views/control_panel/search/search_filters.js index ae0ed12772e..7a6d605a9b7 100644 --- a/addons/web/static/src/js/views/control_panel/search/search_filters.js +++ b/addons/web/static/src/js/views/control_panel/search/search_filters.js @@ -184,13 +184,13 @@ var DateTime = Field.extend({ type: 'datetime' }, operators: [ + {value: "between", text: _lt("is between")}, {value: "=", text: _lt("is equal to")}, {value: "!=", text: _lt("is not equal to")}, {value: ">", text: _lt("is after")}, {value: "<", text: _lt("is before")}, {value: ">=", text: _lt("is after or equal to")}, {value: "<=", text: _lt("is before or equal to")}, - {value: "between", text: _lt("is between")}, {value: "∃", text: _lt("is set")}, {value: "∄", text: _lt("is not set")} ], @@ -216,15 +216,9 @@ var DateTime = Field.extend({ this._super.apply(this, arguments); if ($operator.val() === "between") { - if (!this.datewidget_1) { - this._create_new_widget("datewidget_1"); - } else { - this.datewidget_1.do_show(); - } + this.datewidget_1.do_show(); } else { - if (this.datewidget_1) { - this.datewidget_1.do_hide(); - } + this.datewidget_1.do_hide(); } }, toString: function () { @@ -238,13 +232,18 @@ var DateTime = Field.extend({ start: function () { return Promise.all([ this._super.apply(this, arguments), - this._create_new_widget("datewidget_0") - ]); + this._create_new_widget("datewidget_0", '00:00:00', 'hh:mm:ss'), + this._create_new_widget("datewidget_1", '23:59:59', 'hh:mm:ss'), + ]).then(() => { + if (this.operators[0].value !== "between") { + this.datewidget_1.do_hide(); + } + }); }, - _create_new_widget: function (name) { + _create_new_widget: function (name, ...time) { this[name] = new (this._get_widget_class())(this); return this[name].appendTo(this.$el).then((function () { - this[name].setValue(moment()); + this[name].setValue(moment(...time)); }).bind(this)); }, _get_widget_class: function () { @@ -256,6 +255,17 @@ var Date = DateTime.extend({ attributes: { type: 'date' }, + operators: [ + {value: "=", text: _lt("is equal to")}, + {value: "!=", text: _lt("is not equal to")}, + {value: ">", text: _lt("is after")}, + {value: "<", text: _lt("is before")}, + {value: ">=", text: _lt("is after or equal to")}, + {value: "<=", text: _lt("is before or equal to")}, + {value: "between", text: _lt("is between")}, + {value: "∃", text: _lt("is set")}, + {value: "∄", text: _lt("is not set")} + ], get_value: function (index) { // retrieve the datepicker value return this["datewidget_" + (index || 0)].getValue(); diff --git a/addons/web/static/tests/views/search_view_tests.js b/addons/web/static/tests/views/search_view_tests.js index bd75f92811b..2664aca2bf5 100644 --- a/addons/web/static/tests/views/search_view_tests.js +++ b/addons/web/static/tests/views/search_view_tests.js @@ -372,7 +372,7 @@ QUnit.module('Search View', { assert.expect(7); const unpatchDate = patchDate(2019,6,31,13,43,0); - + var actionManager = await createActionManager({ actions: this.actions, archs: this.archs, @@ -524,7 +524,7 @@ QUnit.module('Search View', { await testUtils.dom.click($('.o_search_options button span.fa-filter')); await testUtils.dom.click($('.o_filters_menu .o_menu_item a').first()); await testUtils.dom.click($('.o_graph_controller .o_control_panel .o_cp_buttons button').eq(1)); - await testUtils.dom.click($('.o_graph_controller .o_group_by_menu .o_menu_item').eq(1)); + await testUtils.dom.click($('.o_graph_controller .o_group_by_menu .o_menu_item').eq(1)); assert.doesNotHaveClass($('.o_graph_controller .o_group_by_menu .o_menu_item > .dropdown-item').eq(1), 'selected', 'groupby should be still unselected'); actionManager.destroy(); @@ -1116,7 +1116,7 @@ QUnit.module('Search View', { // activate Foo a await testUtils.fields.triggerKey('press', $('.o_searchview_input'), 97); await testUtils.fields.triggerKey('up', $('.o_searchview_input'), 'enter'); - + // activate Date Filter with This Month await testUtils.dom.click($('button .fa-filter')); await testUtils.dom.click($('.o_filters_menu .o_menu_item a')); @@ -1604,7 +1604,7 @@ QUnit.module('Search View', { var $filterDropdown = $('.modal .o_filters_menu'); await testUtils.dom.click($filterDropdown.find('.o_add_custom_filter')); - assert.containsN($filterDropdown, '.o_input', 3); + assert.containsN($filterDropdown, '.o_input', 4); // We really are interested in the click event // We do it twice on each input to make sure