Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support date serialization formats for DateBox with list picker type (T854579) #11695

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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