mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
fixes
This commit is contained in:
+5
-5
@@ -25,9 +25,9 @@ import { DateFnsUtils } from '@alfresco/adf-core';
|
|||||||
describe('SearchDatetimeRangeComponent', () => {
|
describe('SearchDatetimeRangeComponent', () => {
|
||||||
let fixture: ComponentFixture<SearchDatetimeRangeComponent>;
|
let fixture: ComponentFixture<SearchDatetimeRangeComponent>;
|
||||||
let component: SearchDatetimeRangeComponent;
|
let component: SearchDatetimeRangeComponent;
|
||||||
const fromDatetime = '2016-10-16 12:30';
|
const fromDatetime = '2016-10-16 12:30 GMT';
|
||||||
const toDatetime = '2017-10-16 20:00';
|
const toDatetime = '2017-10-16 20:00 GMT';
|
||||||
const maxDatetime = '10-Mar-20 20:00';
|
const maxDatetime = '10-Mar-20 20:00 GMT';
|
||||||
const datetimeFormatFixture = 'DD-MMM-YY HH:mm';
|
const datetimeFormatFixture = 'DD-MMM-YY HH:mm';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -154,7 +154,7 @@ describe('SearchDatetimeRangeComponent', () => {
|
|||||||
to: toDatetime
|
to: toDatetime
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
const expectedQuery = `cm:created:['2016-10-16T12:30:00Z' TO '2017-10-16T20:00:59Z']`;
|
const expectedQuery = `cm:created:['2016-10-16T12:30:00.000Z' TO '2017-10-16T20:00:59.999Z']`;
|
||||||
|
|
||||||
expect(context.queryFragments[component.id]).toEqual(expectedQuery);
|
expect(context.queryFragments[component.id]).toEqual(expectedQuery);
|
||||||
expect(context.update).toHaveBeenCalled();
|
expect(context.update).toHaveBeenCalled();
|
||||||
@@ -182,7 +182,7 @@ describe('SearchDatetimeRangeComponent', () => {
|
|||||||
to: toInGmt
|
to: toInGmt
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
const expectedQuery = `cm:created:['2021-02-24T15:00:00Z' TO '2021-02-28T13:00:59Z']`;
|
const expectedQuery = `cm:created:['2021-02-24T15:00:00.000Z' TO '2021-02-28T13:00:59.999Z']`;
|
||||||
|
|
||||||
expect(context.queryFragments[component.id]).toEqual(expectedQuery);
|
expect(context.queryFragments[component.id]).toEqual(expectedQuery);
|
||||||
expect(context.update).toHaveBeenCalled();
|
expect(context.update).toHaveBeenCalled();
|
||||||
|
|||||||
+5
-6
@@ -27,7 +27,6 @@ import { Subject } from 'rxjs';
|
|||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { DatetimeAdapter, MAT_DATETIME_FORMATS } from '@mat-datetimepicker/core';
|
import { DatetimeAdapter, MAT_DATETIME_FORMATS } from '@mat-datetimepicker/core';
|
||||||
import { MAT_MOMENT_DATETIME_FORMATS } from '@mat-datetimepicker/moment';
|
import { MAT_MOMENT_DATETIME_FORMATS } from '@mat-datetimepicker/moment';
|
||||||
import { DateFnsAdapter } from '@angular/material-date-fns-adapter';
|
|
||||||
import { startOfMinute, isBefore, isValid, endOfMinute } from 'date-fns';
|
import { startOfMinute, isBefore, isValid, endOfMinute } from 'date-fns';
|
||||||
|
|
||||||
export interface DatetimeRangeValue {
|
export interface DatetimeRangeValue {
|
||||||
@@ -65,7 +64,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
|
|||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(private dateAdapter: DatetimeAdapter<DateFnsAdapter>, private userPreferencesService: UserPreferencesService) {}
|
constructor(private dateAdapter: DatetimeAdapter<string>, private userPreferencesService: UserPreferencesService) {}
|
||||||
|
|
||||||
getFromValidationMessage(): string {
|
getFromValidationMessage(): string {
|
||||||
return this.from.hasError('invalidOnChange') || this.hasParseError(this.from)
|
return this.from.hasError('invalidOnChange') || this.hasParseError(this.from)
|
||||||
@@ -128,12 +127,12 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
|
|||||||
this.onDestroy$.complete();
|
this.onDestroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(model: { from: string; to: string }, isValid: boolean) {
|
apply(model: { from: string; to: string }, isFieldValid: boolean) {
|
||||||
if (isValid && this.id && this.context && this.settings && this.settings.field) {
|
if (isFieldValid && this.id && this.context && this.settings && this.settings.field) {
|
||||||
this.isActive = true;
|
this.isActive = true;
|
||||||
|
|
||||||
const start = DateFnsUtils.formatDate(startOfMinute(new Date(model.from)), `yyyy-MM-dd'T'HH:mm:ss'Z'`);
|
const start = startOfMinute(new Date(model.from)).toISOString();
|
||||||
const end = DateFnsUtils.formatDate(endOfMinute(new Date(model.to)), `yyyy-MM-dd'T'HH:mm:ss'Z'`);
|
const end = endOfMinute(new Date(model.to)).toISOString();
|
||||||
|
|
||||||
this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`;
|
this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`;
|
||||||
this.updateDisplayValue();
|
this.updateDisplayValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user