Skip to content

Commit

Permalink
Support date serialization formats for DateBox with list picker type …
Browse files Browse the repository at this point in the history
…(T854579) (#11695)
  • Loading branch information
alexander-kotov-dx committed Jan 24, 2020
1 parent d9a0fd7 commit d5d19ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/ui/date_box/ui.date_box.strategy.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const isDate = require('../../core/utils/type').isDate;
const extend = require('../../core/utils/extend').extend;
const dateUtils = require('./ui.date_utils');
const dateLocalization = require('../../localization/date');
const dateSerialization = require('../../core/utils/date_serialization');

const DATE_FORMAT = 'date';

Expand Down Expand Up @@ -231,7 +232,11 @@ const ListStrategy = DateBoxStrategy.inherit({
const day = itemData.getDate();

if(date) {
date = new Date(date);
if(this.dateBox.option('dateSerializationFormat')) {
date = dateSerialization.deserializeDate(date);
} else {
date = new Date(date);
}

date.setHours(hours);
date.setMinutes(minutes);
Expand Down
16 changes: 16 additions & 0 deletions testing/tests/DevExpress.ui.widgets.editors/datebox.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3610,6 +3610,22 @@ QUnit.module('datebox w/ time list', {
const $timeListItems = $('.dx-list .dx-list-item');
assert.ok($timeListItems.length > 0);
});

QUnit.test('should works correctly with serialized dates (T854579)', function(assert) {
this.dateBox.option({
opened: true,
dateSerializationFormat: 'yyyy-MM-ddTHH:mm:ssx',
});
const $input = $(this.dateBox.element()).find(`.${TEXTEDITOR_INPUT_CLASS}`);
const $items = $(this.dateBox.content()).find(LIST_ITEM_SELECTOR);

$items.eq(1).trigger('dxclick');
assert.strictEqual($input.val(), $items.eq(1).text(), 'time is applied');

this.dateBox.open();
$items.eq(3).trigger('dxclick');
assert.strictEqual($input.val(), $items.eq(3).text(), 'new time is applied');
});
});

QUnit.module('keyboard navigation', {
Expand Down

0 comments on commit d5d19ac

Please sign in to comment.