From ff9b1f412f27be781b4cb7ebf8f431f91b10352e Mon Sep 17 00:00:00 2001 From: Yana Date: Mon, 11 May 2020 21:39:35 +0300 Subject: [PATCH 1/4] Trying to fix --- js/ui/scheduler/appointmentPopup.js | 3 ++- js/ui/scheduler/ui.scheduler.recurrence_editor.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/ui/scheduler/appointmentPopup.js b/js/ui/scheduler/appointmentPopup.js index 7f1747d94df8..54353753cd5c 100644 --- a/js/ui/scheduler/appointmentPopup.js +++ b/js/ui/scheduler/appointmentPopup.js @@ -10,6 +10,7 @@ import { extend } from '../../core/utils/extend'; import { each } from '../../core/utils/iterator'; import { Deferred, when } from '../../core/utils/deferred'; import { isDefined } from '../../core/utils/type'; +import messageLocalization from '../../localization/message'; const toMs = dateUtils.dateToMilliseconds; @@ -282,7 +283,7 @@ export default class AppointmentPopup { return [ { shortcut: 'done', - options: { text: 'Done' }, + options: { text: messageLocalization.format('Done') }, location: TOOLBAR_ITEM_AFTER_LOCATION, onClick: (e) => this._doneButtonClickHandler(e) }, diff --git a/js/ui/scheduler/ui.scheduler.recurrence_editor.js b/js/ui/scheduler/ui.scheduler.recurrence_editor.js index b3f206f825e1..3ee8c90ea05c 100644 --- a/js/ui/scheduler/ui.scheduler.recurrence_editor.js +++ b/js/ui/scheduler/ui.scheduler.recurrence_editor.js @@ -384,7 +384,8 @@ const RecurrenceEditor = Editor.inherit({ const byDay = this._recurrenceRule.rules()['byday'] ? this._recurrenceRule.rules()['byday'].split(',') : days[firstDayOfWeek]; const that = this; - const itemsButtonGroup = days.slice(firstDayOfWeek).concat(days.slice(0, firstDayOfWeek)).map(item => { return { text: item }; }); + const localDaysNames = dateLocalization.getDayNames('abbreviated'); + const itemsButtonGroup = localDaysNames.slice(firstDayOfWeek).concat(localDaysNames.slice(0, firstDayOfWeek)).map(item => { return { text: item.toUpperCase() }; }); this._$repeatOnWeek = $('
').addClass(RECURRENCE_BUTTON_GROUP).appendTo(this._$repeatOnEditor); From 61502929c804a15962a042db8a7972efbbc73886 Mon Sep 17 00:00:00 2001 From: Yana Date: Tue, 12 May 2020 17:21:55 +0300 Subject: [PATCH 2/4] Fix tests --- js/ui/scheduler/ui.scheduler.recurrence_editor.js | 9 ++++++--- .../recurrenceEditor.tests.js | 10 ++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/js/ui/scheduler/ui.scheduler.recurrence_editor.js b/js/ui/scheduler/ui.scheduler.recurrence_editor.js index 3ee8c90ea05c..d15e18fe5e61 100644 --- a/js/ui/scheduler/ui.scheduler.recurrence_editor.js +++ b/js/ui/scheduler/ui.scheduler.recurrence_editor.js @@ -383,9 +383,11 @@ const RecurrenceEditor = Editor.inherit({ const firstDayOfWeek = this._getFirstDayOfWeek(); const byDay = this._recurrenceRule.rules()['byday'] ? this._recurrenceRule.rules()['byday'].split(',') : days[firstDayOfWeek]; - const that = this; + const localDaysNames = dateLocalization.getDayNames('abbreviated'); - const itemsButtonGroup = localDaysNames.slice(firstDayOfWeek).concat(localDaysNames.slice(0, firstDayOfWeek)).map(item => { return { text: item.toUpperCase() }; }); + const dayNames = days.slice(firstDayOfWeek).concat(days.slice(0, firstDayOfWeek)); + + const itemsButtonGroup = localDaysNames.slice(firstDayOfWeek).concat(localDaysNames.slice(0, firstDayOfWeek)).map((item, index) => { return { text: item, key: dayNames[index] }; }); this._$repeatOnWeek = $('
').addClass(RECURRENCE_BUTTON_GROUP).appendTo(this._$repeatOnEditor); @@ -393,9 +395,10 @@ const RecurrenceEditor = Editor.inherit({ items: itemsButtonGroup, selectionMode: 'multiple', selectedItemKeys: byDay, + keyExpr: 'key', onSelectionChanged: (e) => { const selectedKeys = e.component.option('selectedItemKeys'); - that._recurrenceRule.makeRule('byday', selectedKeys); + this._recurrenceRule.makeRule('byday', selectedKeys); this._changeEditorValue(); } }); diff --git a/testing/tests/DevExpress.ui.widgets.scheduler/recurrenceEditor.tests.js b/testing/tests/DevExpress.ui.widgets.scheduler/recurrenceEditor.tests.js index b844a2ba6cdf..7d587dd2b088 100644 --- a/testing/tests/DevExpress.ui.widgets.scheduler/recurrenceEditor.tests.js +++ b/testing/tests/DevExpress.ui.widgets.scheduler/recurrenceEditor.tests.js @@ -715,13 +715,13 @@ QUnit.test('Repeat-until dateBox should have right firstDayOfWeek after firstDay assert.equal(untilDate.option('calendarOptions.firstDayOfWeek'), 1, 'First day of the week is ok'); }); +const dayNames = [{ key: 'SU', text: 'Sun' }, { key: 'MO', text: 'Mon' }, { key: 'TU', text: 'Tue' }, { key: 'WE', text: 'Wed' }, { key: 'TH', text: 'Thu' }, { key: 'FR', text: 'Fri' }, { key: 'SA', text: 'Sat' }]; + QUnit.test('Repeat-on-week editor should be rendered correctly', function(assert) { this.createInstance({ firstDayOfWeek: 3, value: 'FREQ=WEEKLY;BYDAY=TU' }); const buttonGroup = $('.' + 'dx-buttongroup').eq(0).dxButtonGroup('instance'); - assert.deepEqual(buttonGroup.option('items'), [ - { text: 'WE' }, { text: 'TH' }, { text: 'FR' }, { text: 'SA' }, { text: 'SU' }, { text: 'MO' }, { text: 'TU' } - ]); + assert.deepEqual(buttonGroup.option('items'), dayNames.slice(3).concat(dayNames.slice(0, 3))); }); QUnit.test('Repeat-on-week editor should be rendered correctly after firstDayOfWeek option changing', function(assert) { @@ -729,9 +729,7 @@ QUnit.test('Repeat-on-week editor should be rendered correctly after firstDayOfW this.instance.option('firstDayOfWeek', 5); const buttonGroup = $('.' + 'dx-buttongroup').eq(0).dxButtonGroup('instance'); - assert.deepEqual(buttonGroup.option('items'), [ - { text: 'FR' }, { text: 'SA' }, { text: 'SU' }, { text: 'MO' }, { text: 'TU' }, { text: 'WE' }, { text: 'TH' } - ]); + assert.deepEqual(buttonGroup.option('items'), dayNames.slice(5).concat(dayNames.slice(0, 5))); }); QUnit.test('Repeat-count editor should have correct value after re-initializing values', function(assert) { From 891421d00001f5bbf868ce15ffbb52c4a1bb92eb Mon Sep 17 00:00:00 2001 From: Yana Date: Tue, 12 May 2020 18:20:57 +0300 Subject: [PATCH 3/4] Add test --- .../appointmentPopup.tests.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js b/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js index dc108e058713..44d97514fb12 100644 --- a/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js +++ b/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js @@ -9,6 +9,7 @@ import SchedulerTimezoneEditor from 'ui/scheduler/timezones/ui.scheduler.timezon import fx from 'animation/fx'; import { DataSource } from 'data/data_source/data_source'; import resizeCallbacks from 'core/utils/resize_callbacks'; +import messageLocalization from 'localization/message'; import 'ui/scheduler/ui.scheduler'; import 'ui/switch'; @@ -1058,6 +1059,22 @@ QUnit.test('Done button shouldn\'t be disabled if validation fail', function(ass assert.equal(doneButton.option('disabled'), false, 'done button is not disabled'); }); +QUnit.test('Done button default configuration should be correct', function(assert) { + this.instance.option({ + onAppointmentFormOpening: function(e) { + const popup = e.component.getAppointmentPopup(); + const buttons = popup.option('toolbarItems'); + const doneButton = buttons[0]; + + assert.equal(doneButton.options.text, messageLocalization.format('Done'), 'done button text is ok'); + }, + onAppointmentAdding: function(e) { + e.cancel = true; + } + }); + this.instance.showAppointmentPopup({ startDate: new Date(2015, 1, 1, 1), endDate: new Date(2015, 1, 1, 2), text: 'caption' }); +}); + QUnit.test('Done button custom configuration should be correct', function(assert) { const data = new DataSource({ store: this.tasks From 1cacd10284023191b950aab23a8e25aa397785ac Mon Sep 17 00:00:00 2001 From: Yana Date: Tue, 12 May 2020 18:31:02 +0300 Subject: [PATCH 4/4] small fix --- .../DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js b/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js index 44d97514fb12..3224c307a9a9 100644 --- a/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js +++ b/testing/tests/DevExpress.ui.widgets.scheduler/appointmentPopup.tests.js @@ -1073,6 +1073,7 @@ QUnit.test('Done button default configuration should be correct', function(asser } }); this.instance.showAppointmentPopup({ startDate: new Date(2015, 1, 1, 1), endDate: new Date(2015, 1, 1, 2), text: 'caption' }); + $('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick'); }); QUnit.test('Done button custom configuration should be correct', function(assert) {