mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-24 14:31:41 +00:00
[ACS-5857] addressed review comments
This commit is contained in:
@@ -1505,7 +1505,7 @@ export const formDateVisibility = {
|
||||
existingColspan: 1,
|
||||
maxColspan: 2
|
||||
},
|
||||
dateDisplayFormat: 'yyyy-M-d'
|
||||
dateDisplayFormat: 'yyyy-MM-dd'
|
||||
}
|
||||
],
|
||||
2: [
|
||||
|
@@ -729,7 +729,7 @@ describe('FormFieldValidator', () => {
|
||||
|
||||
it('should take into account that max value is in UTC and fail validating value checking the time', () => {
|
||||
const maxValueFromActivitiInput = '31-3-2018 12:00 AM';
|
||||
const maxValueSavedInForm = format(parse(maxValueFromActivitiInput, 'd-M-yyyy hh:mm a', new Date()), `yyyy-MM-dd'T'HH:mm:ssxxx`);
|
||||
const maxValueSavedInForm = format(parse(maxValueFromActivitiInput, 'dd-M-yyyy hh:mm a', new Date()), `yyyy-MM-dd'T'HH:mm:ssxxx`);
|
||||
|
||||
const localInvalidValue = '2018-3-31 12:01 AM';
|
||||
|
||||
|
@@ -301,14 +301,14 @@ describe('FormFieldModel', () => {
|
||||
readOnly: false
|
||||
}
|
||||
},
|
||||
dateDisplayFormat: 'yyyy-MM-dd hh:mm'
|
||||
dateDisplayFormat: 'yyyy-MM-dd HH:mm'
|
||||
});
|
||||
|
||||
const currentDateTime = new Date();
|
||||
const formattedDate = format(currentDateTime, 'yyyy-MM-dd');
|
||||
const formattedTime = format(currentDateTime, 'hh:mm');
|
||||
const formattedTime = format(currentDateTime, 'HH:mm');
|
||||
|
||||
const expectedDateTime = format(currentDateTime, 'yyyy-MM-dd hh:mm');
|
||||
const expectedDateTime = format(currentDateTime, 'yyyy-MM-dd HH:mm');
|
||||
const expectedDateTimeFormat = formattedDate + `T${formattedTime}:00.000Z`;
|
||||
|
||||
expect(field.value).toBe(expectedDateTime);
|
||||
|
@@ -50,7 +50,7 @@ import { DateFnsUtils } from '../../../../common/utils/date-fns-utils';
|
||||
})
|
||||
export class DateWidgetComponent extends WidgetComponent implements OnInit, OnDestroy {
|
||||
|
||||
DATE_FORMAT = 'd-M-yyyy';
|
||||
DATE_FORMAT = 'dd-M-yyyy';
|
||||
|
||||
minDate: string;
|
||||
maxDate: string;
|
||||
|
@@ -392,7 +392,6 @@ describe('DateWidgetComponent', () => {
|
||||
|
||||
describe('check date validation by dynamic date ranges', () => {
|
||||
it('should minValue be equal to today date minus minDateRangeValue', async () => {
|
||||
spyOn(widget, 'getTodaysDate').and.returnValue(new Date('2022-07-22'));
|
||||
widget.field = new FormFieldModel(null, {
|
||||
dynamicDateRangeSelection: true,
|
||||
maxDateRangeValue: null,
|
||||
@@ -404,7 +403,8 @@ describe('DateWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expectedMinValueString = format(new Date('2022-07-21'), DATE_FORMAT_CLOUD);
|
||||
const currentDate = new Date();
|
||||
const expectedMinValueString = format(subDays(currentDate, 1), DATE_FORMAT_CLOUD);
|
||||
|
||||
expect(widget.field.minValue).toEqual(expectedMinValueString);
|
||||
expect(widget.maxDate).toBeUndefined();
|
||||
@@ -412,7 +412,6 @@ describe('DateWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should maxValue be equal to today date plus maxDateRangeValue', async () => {
|
||||
spyOn(widget, 'getTodaysDate').and.returnValue(new Date('2022-07-22'));
|
||||
widget.field = new FormFieldModel(null, {
|
||||
dynamicDateRangeSelection: true,
|
||||
maxDateRangeValue: 8,
|
||||
@@ -424,7 +423,8 @@ describe('DateWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expectedMaxValueString = format(new Date('2022-07-30'), DATE_FORMAT_CLOUD);
|
||||
const currentDate = new Date();
|
||||
const expectedMaxValueString = format(addDays(currentDate, 8), DATE_FORMAT_CLOUD);
|
||||
|
||||
expect(widget.field.maxValue).toEqual(expectedMaxValueString);
|
||||
expect(widget.minDate).toBeUndefined();
|
||||
@@ -432,7 +432,6 @@ describe('DateWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should maxValue and minValue be null if maxDateRangeValue and minDateRangeValue are null', async () => {
|
||||
spyOn(widget, 'getTodaysDate').and.returnValue(new Date('22-07-2022'));
|
||||
widget.field = new FormFieldModel(null, {
|
||||
dynamicDateRangeSelection: true,
|
||||
maxDateRangeValue: null,
|
||||
@@ -451,7 +450,6 @@ describe('DateWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should maxValue and minValue not be null if maxDateRangeVale and minDateRangeValue are not null', async () => {
|
||||
spyOn(widget, 'getTodaysDate').and.returnValue(new Date('2022-07-22'));
|
||||
widget.field = new FormFieldModel(null, {
|
||||
dynamicDateRangeSelection: true,
|
||||
maxDateRangeValue: 8,
|
||||
@@ -463,8 +461,9 @@ describe('DateWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const expectedMaxValueString = format(new Date('2022-07-30'), DATE_FORMAT_CLOUD);
|
||||
const expectedMinValueString = format(new Date('2022-07-12'), DATE_FORMAT_CLOUD);
|
||||
const currentDate = new Date();
|
||||
const expectedMaxValueString = format(addDays(currentDate, 8), DATE_FORMAT_CLOUD);
|
||||
const expectedMinValueString = format(subDays(currentDate, 10), DATE_FORMAT_CLOUD);
|
||||
|
||||
expect(widget.field.maxValue).toEqual(expectedMaxValueString);
|
||||
expect(widget.field.minValue).toEqual(expectedMinValueString);
|
||||
|
@@ -71,7 +71,7 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit,
|
||||
|
||||
if (this.field) {
|
||||
if (this.field.dynamicDateRangeSelection) {
|
||||
const today = this.getTodaysDate();
|
||||
const today = new Date();
|
||||
if (Number.isInteger(this.field.minDateRangeValue)) {
|
||||
this.minDate = format(subDays(today, this.field.minDateRangeValue), DATE_FORMAT_CLOUD);
|
||||
this.field.minValue = this.minDate;
|
||||
@@ -93,10 +93,6 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit,
|
||||
}
|
||||
}
|
||||
|
||||
getTodaysDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
|
Reference in New Issue
Block a user