[24613] Fix unsetting date in datepickers

pull/5207/head
Oliver Günther 8 years ago
parent d42c57caac
commit 2b826975ca
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 4
      frontend/app/components/input/transformers/transform-date.directive.ts
  2. 7
      frontend/tests/unit/tests/components/input/transformers/transform-date-test.js

@ -37,13 +37,13 @@ function transformDate(TimezoneService:any) {
ngModelController:any) {
ngModelController.$parsers.push(function(data:any) {
if (!moment(data, 'YYYY-MM-DD', true).isValid()) {
return undefined;
return null;
}
return data;
});
ngModelController.$formatters.push(function(data:any) {
if (!moment(data, 'YYYY-MM-DD', true).isValid()) {
return undefined;
return null;
}
var d = TimezoneService.parseDate(data);
return TimezoneService.formattedISODate(d);

@ -70,10 +70,11 @@ describe('transformDateValue Directive', function() {
});
describe('when given invalid date values', function () {
shouldBehaveLikeAParser('', undefined);
shouldBehaveLikeAParser('invalid', undefined);
shouldBehaveLikeAParser('2016-12', undefined);
shouldBehaveLikeAParser('', null);
shouldBehaveLikeAParser('invalid', null);
shouldBehaveLikeAParser('2016-12', null);
shouldBehaveLikeAFormatter(undefined, '');
shouldBehaveLikeAFormatter(null, '');
shouldBehaveLikeAFormatter('2016-12', '');
});
});

Loading…
Cancel
Save