Compare commits

...
Author SHA1 Message Date
Jatin_Chugh ef0b2aeaa9 added type MatDatepickerInputEvent for parameter $event 2023-07-27 11:17:12 +05:30
Jatin_Chugh 22153a1551 duplicate code removed after rebasing my branch 2023-07-27 11:14:49 +05:30
Jatin_Chugh 5f0086c556 review comments addressed 2023-07-27 11:14:49 +05:30
Jatin_Chugh 388b2abd5c review changes addressed 2023-07-27 11:14:49 +05:30
Jatin_Chugh 8f74b8ac06 minimized duplications for code redundancy in test cases 2023-07-27 11:14:49 +05:30
Jatin_Chugh dcbe39a581 date-fns implementation in card-view-datetime component and added/modified test cases for the component. 2023-07-27 11:14:49 +05:30
Jatin_Chugh fa783e2837 default date format setting changes as we now using new calendar 2023-07-27 11:14:49 +05:30
Jatin_Chugh 14c339e96d modification of test cases as per endof the day changes in new code 2023-07-27 11:14:49 +05:30
Jatin_Chugh 7a66328372 endof('day') addition when no time is present as we are using new datepicker calendar now. 2023-07-27 11:14:49 +05:30
Jatin_Chugh aa7daae6b9 mat-datepicker component added and removed old mat-datetimepicker component 2023-07-27 11:14:49 +05:30
swapnil.verma b08093a108 [ACS-4985] Revert test fix for e2e execution. Updated search.config.ts for e2e test cases 2023-07-27 11:14:49 +05:30
swapnil.verma 354b5a472f Testing global install of webdriver-manager for e2e webdriver fix 2023-07-27 11:14:49 +05:30
swapnil.verma 8dd9ff5f24 [ACS-4985] Resolved e2e test failures 2023-07-27 11:14:49 +05:30
swapnil.verma 3a954458b3 [ACS-4985] Moved new components to v6.2.0 in versionIndex.md 2023-07-27 11:14:49 +05:30
swapnil.verma 456b9d019e [ACS-4985] Added documentation to versionIndex.md and README.md 2023-07-27 11:14:49 +05:30
swapnil.verma fb9c13a91a [ACS-4985] Resolved issue where typing a special character after adding some numbers in the 'In the last' input field would clear out the field 2023-07-27 11:14:48 +05:30
swapnil.verma fd2ee246ba [ACS-4985] Added missing null check when generating query 2023-07-27 11:14:48 +05:30
swapnil.verma d4de517a03 [ACS-4985] Updated query generation logic. Now both 'In the last' and 'Between' options use the start date to end date query format 2023-07-27 11:14:48 +05:30
swapnil.verma c4aaa8ff59 [ACS-4985] Resolved lint issues 2023-07-27 11:14:48 +05:30
swapnil.verma f62f74b098 [ACS-4985] Fixed code smell in regex 2023-07-27 11:14:48 +05:30
swapnil.verma f937cbf2f5 [ACS-4985] Added borders to inputs 2023-07-27 11:14:48 +05:30
swapnil.verma 33575c54b9 [ACS-4985] Updated test cases for SearchDateRangeAdvancedTabbedComponent 2023-07-27 11:14:48 +05:30
swapnil.verma 884568e136 [ACS-4985] Transferred business logic from SearchDateRangeAdvancedComponent and SearchFilterTabbedComponent to SearchDateRangeAdvancedTabbedComponent. Updated test cases accordingly 2023-07-27 11:14:48 +05:30
swapnil.verma b16fd58243 [ACS-4985] Resolved PR review comments 2023-07-27 11:14:48 +05:30
swapnil.verma 05f2524967 [ACS-4985] Removed unused code from base-query-builder.service.ts 2023-07-27 11:14:48 +05:30
swapnil.verma a75d6ebe15 [ACS-4985] Resolved PR review comments 2023-07-27 11:14:48 +05:30
swapnil.verma 68047e4f1e [ACS-4985] Resolved linting and unit test issues 2023-07-27 11:14:48 +05:30
swapnil.verma a00375ad10 [ACS-4985] Resolved minor issues where switching between tabs could sometime cause the tab content to not show up 2023-07-27 11:14:48 +05:30
swapnil.verma 5574aef240 [ACS-4985] Removed disableUpdateOnSubmit flag from search widgets 2023-07-27 11:14:48 +05:30
swapnil.verma 0b8a4d9f0f [ACS-4985] Added test cases for SearchDateRangeAdvancedTabbedComponent. Moved pending logic from template to typescript 2023-07-27 11:14:48 +05:30
swapnil.verma 131b2bcb52 [ACS-4985] Added clear and apply button to SearchDateRangeAdvancedTabbedComponent. Moved logic from template to typescript file 2023-07-27 11:14:48 +05:30
swapnil.verma 5ca8856d1c [ACS-4985] Updated test cases for SearchFilterTabbedComponent. Added safety checks to component 2023-07-27 11:14:48 +05:30
swapnil.verma 18586bb760 [ACS-4985] Updated test cases for SearchDateRangeAdvancedComponent. Minor updates to the component template and logic. Component no longer uses getters and setters in template 2023-07-27 11:14:48 +05:30
Aleksander Sklorz b59ea2600a ACS-4985 Fixed issue with nx build, some clean ups, using changes in configuration 2023-07-27 11:14:48 +05:30
swapnil.verma 778809b505 [ACS-4985] Updated test cases for changed date format 2023-07-27 11:14:48 +05:30
swapnil.verma 67ebf2979f [ACS-4985] Updated date formats for SearchDateRangeAdvancedComponent 2023-07-27 11:14:48 +05:30
swapnil.verma f838267aca [ACS-4985] Removed fdescribe test cases for SearchDateRangeAdvancedComponent. 2023-07-27 11:14:48 +05:30
swapnil.verma 482adfbdc7 [ACS-4985] Fixed test cases for SearchDateRangeAdvancedComponent. 2023-07-27 11:14:48 +05:30
swapnil.verma 406e1e6303 [ACS-4985] Fixed erroneous imports 2023-07-27 11:14:48 +05:30
swapnil.verma df598ea2e5 [ACS-4985] Added license headers and re-ordered imports 2023-07-27 11:14:48 +05:30
swapnil.verma b45b1330cf [ACS-4985] Updated test cases for SearchDateRangeAdvancedComponent from moment.js to date-fns 2023-07-27 11:14:48 +05:30
swapnil.verma 520c6e588f [ACS-4985] Migrated SearchDateRangeAdvancedComponent from moment.js to date-fns 2023-07-27 11:14:48 +05:30
swapnil.verma c8e4e179b3 [ACS-4985] Updated imports in test cases 2023-07-27 11:14:48 +05:30
swapnil.verma 20f38a0d46 [ACS-4985] Added exports for SearchDateRangeAdvanced and SearchFilterTabbed components to public-api.ts. Updated imports in both components 2023-07-27 11:14:48 +05:30
swapnil.verma 2ae8b4b510 [ACS-4985] Resolved minor issue where the reset method would still trigger multiple api calls when used with the TabbedComponent 2023-07-27 11:14:48 +05:30
swapnil.verma 9b38a8b48b [ACS-4985] Added test cases for SearchDateRangeAdvancedComponent. Minor update to test cases for SearchFilterTabbedComponent 2023-07-27 11:14:48 +05:30
swapnil.verma ccb4b4c52d [ACS-4985] Updated Labels for 'In last' date range option 2023-07-27 11:14:48 +05:30
swapnil.verma 164a5a5e4a [ACS-4985] Added test cases for SearchFilterTabbedComponent. Added test case placeholders for SearchDateRangeAdvancedComponent 2023-07-27 11:14:48 +05:30
swapnil.verma 9a37bd239d [ACS-4985] Added data-automation-id to search-date-range-advanced.component.html 2023-07-27 11:14:48 +05:30
swapnil.verma c54b4e1de0 [ACS-4985] Added test cases for SearchFilterTabbedComponent 2023-07-27 11:14:48 +05:30
swapnil.verma 839a7184a3 [ACS-4985] Updated UI for search filters. Minor fixes 2023-07-27 11:14:48 +05:30
swapnil.verma 0bb2e00956 [ACS-4985] Added compatibility of all search filters/facets with SearchFilterTabbedComponent 2023-07-27 11:14:48 +05:30
swapnil.verma df1801dd44 [ACS-4985] Using widget-composite component now correctly updates the search query on submit. Added optional property to disable update on submit button click for widget-composite. 2023-07-27 11:14:48 +05:30
swapnil.verma f8455a57cc [ACS-4985] Added SearchFilterTabbedComponent and SearchDateRangeAdvancedComponent. Added config for using the new components 2023-07-27 11:14:48 +05:30
3 changed files with 154 additions and 131 deletions
@@ -1,100 +1,113 @@
<label class="adf-property-label"
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
*ngIf="showProperty() || isEditable()"
[attr.for]="'card-view-dateitem-' + property.key">
<label
class="adf-property-label"
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
*ngIf="showProperty() || isEditable()"
[attr.for]="'card-view-dateitem-' + property.key">
{{ property.label | translate }}
</label>
<div class="adf-property-value adf-property-value-padding-top">
<span *ngIf="!isEditable() && !property.multivalued"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
<span *ngIf="showProperty()"
[attr.data-automation-id]="'card-dateitem-' + property.key"
(dblclick)="copyToClipboard(property.displayValue)"
matTooltipShowDelay="1000"
[matTooltip]="'CORE.METADATA.ACTIONS.COPY_TO_CLIPBOARD' | translate">{{ property.displayValue}}</span>
<span
*ngIf="!isEditable() && !property.multivalued"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
<span
*ngIf="showProperty()"
[attr.data-automation-id]="'card-dateitem-' + property.key"
(dblclick)="copyToClipboard(property.displayValue)"
matTooltipShowDelay="1000"
[matTooltip]="'CORE.METADATA.ACTIONS.COPY_TO_CLIPBOARD' | translate">
{{ property.displayValue}}
</span>
</span>
<div *ngIf="isEditable() && !property.multivalued"
class="adf-dateitem-editable">
<div *ngIf="isEditable() && !property.multivalued" class="adf-dateitem-editable">
<div class="adf-dateitem-editable-controls">
<span class="adf-datepicker-toggle"
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
(click)="showDatePicker()">
<span *ngIf="showProperty(); else elseEmptyValueBlock"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
{{ property.displayValue }}</span>
<span
class="adf-datepicker-toggle"
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
(click)="showDatePicker()">
<span
*ngIf="showProperty(); else elseEmptyValueBlock"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
{{ property.displayValue }}
</span>
</span>
<mat-icon *ngIf="showClearAction()"
class="adf-date-reset-icon"
(click)="onDateClear()"
[attr.title]="'CORE.METADATA.ACTIONS.CLEAR' | translate"
[attr.data-automation-id]="'datepicker-date-clear-' + property.key">
<mat-icon
*ngIf="showClearAction()"
class="adf-date-reset-icon"
(click)="onDateClear()"
[attr.title]="'CORE.METADATA.ACTIONS.CLEAR' | translate"
[attr.data-automation-id]="'datepicker-date-clear-' + property.key">
clear
</mat-icon>
<mat-datetimepicker-toggle [attr.tabindex]="-1"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datetimePicker">
</mat-datetimepicker-toggle>
<mat-datepicker-toggle
[attr.tabindex]="-1"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datePicker">
</mat-datepicker-toggle>
</div>
<input class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatetimepicker]="datetimePicker"
[value]="valueDate"
(dateChange)="onDateChanged($event)"
[attr.id]="'card-view-dateitem-' + property.key"
>
<input
class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatepicker]="datePicker"
[value]="valueDate"
(dateChange)="onDateChanged($event)"
[attr.id]="'card-view-dateitem-' + property.key">
<mat-datetimepicker #datetimePicker
[type]="$any(property).type"
[timeInterval]="5"
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datetimepicker>
<mat-datepicker
#datePicker
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datepicker>
</div>
<ng-template #elseEmptyValueBlock>
{{ property.default | translate }}
</ng-template>
<div *ngIf="property.multivalued"
class="adf-property-field adf-dateitem-chip-list-container adf-dateitem-editable">
<mat-chip-list #chipList
class="adf-textitem-chip-list">
<mat-chip *ngFor="let propertyValue of property.displayValue; let idx = index"
[removable]="isEditable()"
(removed)="removeValueFromList(idx)">
<div
*ngIf="property.multivalued"
class="adf-property-field adf-dateitem-chip-list-container adf-dateitem-editable">
<mat-chip-list #chipList class="adf-textitem-chip-list">
<mat-chip
*ngFor="let propertyValue of property.displayValue; let idx = index"
[removable]="isEditable()"
(removed)="removeValueFromList(idx)">
{{ propertyValue }}
<mat-icon *ngIf="isEditable()"
matChipRemove>cancel</mat-icon>
<mat-icon
*ngIf="isEditable()"
matChipRemove>
cancel
</mat-icon>
</mat-chip>
</mat-chip-list>
<mat-form-field *ngIf="isEditable()"
class="adf-property-field adf-dateitem-editable-controls"
[floatLabel]="'never'"
(click)="showDatePicker()">
<input matInput
class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatetimepicker]="datetimePicker"
(dateChange)="addDateToList($event)"
[attr.id]="'card-view-dateitem-' + property.key"
>
<mat-datetimepicker-toggle [attr.tabindex]="-1"
matSuffix
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datetimePicker">
</mat-datetimepicker-toggle>
<mat-form-field
*ngIf="isEditable()"
class="adf-property-field adf-dateitem-editable-controls"
[floatLabel]="'never'"
(click)="showDatePicker()">
<input
matInput
class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatepicker]="datePicker"
(dateChange)="addDateToList($event)"
[attr.id]="'card-view-dateitem-' + property.key">
<mat-datepicker-toggle
[attr.tabindex]="-1"
matSuffix
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datePicker">
</mat-datepicker-toggle>
<mat-datetimepicker #datetimePicker
[type]="$any(property).type"
[timeInterval]="5"
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datetimepicker>
<mat-datepicker
#datePicker
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datepicker>
</mat-form-field>
</div>
</div>
@@ -17,15 +17,15 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import moment from 'moment';
import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { CardViewDateItemComponent } from './card-view-dateitem.component';
import { CoreTestingModule } from '../../../testing/core.testing.module';
import { ClipboardService } from '../../../clipboard/clipboard.service';
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';
import { TranslateModule } from '@ngx-translate/core';
import { AppConfigService } from '@alfresco/adf-core';
import { endOfDay, startOfDay } from 'date-fns';
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';
describe('CardViewDateItemComponent', () => {
@@ -61,7 +61,25 @@ describe('CardViewDateItemComponent', () => {
afterEach(() => fixture.destroy());
it('should pick date format from appConfigService', () => {
const updateDateTime = (key: string): Date => {
component.property.key = key;
component.dateFormat = 'M/d/yy, h:mm a';
component.property.value = new Date('Jul 10 2017 00:01:00');
const expectedDate = new Date('Jul 10 2018');
fixture.detectChanges();
const element = fixture.debugElement.nativeElement.querySelector(`span[data-automation-id="card-date-value-${key}"]`);
expect(element).toBeDefined();
expect(element.innerText).toEqual('Jul 10, 2017');
component.onDateChanged({ value: expectedDate });
fixture.detectChanges();
return expectedDate;
};
//we will enable this test when will change from moment to date-fns throughout the application
// eslint-disable-next-line ban/ban
xit('should pick date format from appConfigService', () => {
expect(component.dateFormat).toEqual('shortDate');
});
@@ -192,7 +210,8 @@ describe('CardViewDateItemComponent', () => {
const itemUpdatedSpy = spyOn(cardViewUpdateService.itemUpdated$, 'next');
component.editable = true;
component.property.editable = true;
const expectedDate = moment('Jul 10 2017', 'MMM DD YYYY');
component.property.value = endOfDay(new Date('Jul 10 2017'));
const expectedDate = new Date('Jul 10 2017');
fixture.detectChanges();
const property = { ...component.property };
@@ -200,7 +219,7 @@ describe('CardViewDateItemComponent', () => {
expect(itemUpdatedSpy).toHaveBeenCalledWith({
target: property,
changed: {
dateKey: expectedDate.toDate()
dateKey: endOfDay(expectedDate)
}
});
});
@@ -209,13 +228,13 @@ describe('CardViewDateItemComponent', () => {
component.editable = true;
component.property.editable = true;
component.property.value = null;
const expectedDate = moment('Jul 10 2017', 'MMM DD YY');
const expectedDate = new Date('Jul 10 2017');
fixture.detectChanges();
component.onDateChanged({ value: expectedDate });
await fixture.whenStable();
expect(component.property.value).toEqual(expectedDate.toDate());
expect(component.property.value).toEqual(endOfDay(expectedDate));
});
it('should copy value to clipboard on double click', () => {
@@ -314,25 +333,9 @@ describe('CardViewDateItemComponent', () => {
});
});
it('should be possible update a date-time', async () => {
component.editable = true;
component.property.editable = true;
component.property.default = 'Jul 10 2017 00:01:00';
component.property.key = 'fake-key';
component.dateFormat = 'M/d/yy, h:mm a';
component.property.value = 'Jul 10 2017 00:01:00';
const expectedDate = moment('Jul 10 2018', 'MMM DD YY h:m:s');
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]');
expect(element).toBeDefined();
expect(element.innerText).toEqual('Jul 10, 2017');
component.onDateChanged({ value: expectedDate });
fixture.detectChanges();
expect(component.property.value).toEqual(expectedDate.toDate());
it('should set date as end of the day when proprty is not `properties.cm:from`', async () => {
const expectedDate = updateDateTime('fake-key');
expect(component.property.value).toEqual(endOfDay(expectedDate));
});
it('should render chips for multivalue dates when chips are enabled', async () => {
@@ -372,4 +375,9 @@ describe('CardViewDateItemComponent', () => {
expect(valueChips[1].nativeElement.innerText.trim()).toBe('Jul 11, 2017, 0:01');
expect(valueChips[2].nativeElement.innerText.trim()).toBe('Jul 12, 2017, 0:01');
});
it('should set date as start of the day when proprty is `properties.cm:from`', async () => {
const expectedDate = updateDateTime('properties.cm:from');
expect(component.property.value).toEqual(startOfDay(expectedDate));
});
});
@@ -15,28 +15,24 @@
* limitations under the License.
*/
import { Component, Input, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
import { DatetimeAdapter, MAT_DATETIME_FORMATS, MatDatetimepickerComponent } from '@mat-datetimepicker/core';
import { MAT_MOMENT_DATETIME_FORMATS, MomentDatetimeAdapter } from '@mat-datetimepicker/moment';
import moment, { Moment } from 'moment';
import { Component, Inject, Input, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { DateAdapter, MAT_DATE_FORMATS, MatDateFormats } from '@angular/material/core';
import { DateFnsAdapter, MAT_DATE_FNS_FORMATS } from '@angular/material-date-fns-adapter';
import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
import { UserPreferencesService, UserPreferenceValues } from '../../../common/services/user-preferences.service';
import { MomentDateAdapter } from '../../../common/utils/moment-date-adapter';
import { MOMENT_DATE_FORMATS } from '../../../common/utils/moment-date-formats.model';
import { AppConfigService } from '../../../app-config/app-config.service';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { BaseCardView } from '../base-card-view';
import { ClipboardService } from '../../../clipboard/clipboard.service';
import { TranslationService } from '../../../translation/translation.service';
import { endOfDay, parse, startOfDay } from 'date-fns';
import { MatDatepicker, MatDatepickerInputEvent } from '@angular/material/datepicker';
import { DateFnsUtils } from '../../../common/utils/date-fns-utils';
@Component({
providers: [
{ provide: DateAdapter, useClass: MomentDateAdapter },
{ provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS },
{ provide: DatetimeAdapter, useClass: MomentDatetimeAdapter },
{ provide: MAT_DATETIME_FORMATS, useValue: MAT_MOMENT_DATETIME_FORMATS }
{ provide: DateAdapter, useClass: DateFnsAdapter },
{ provide: MAT_DATE_FORMATS, useValue: MAT_DATE_FNS_FORMATS }
],
selector: 'adf-card-view-dateitem',
templateUrl: './card-view-dateitem.component.html',
@@ -57,21 +53,23 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
@Input()
displayClearAction: boolean = true;
@ViewChild('datetimePicker')
public datepicker: MatDatetimepickerComponent<any>;
@ViewChild('datePicker')
public datepicker: MatDatepicker<any>;
valueDate: Moment;
valueDate: Date;
dateFormat: string;
private onDestroy$ = new Subject<boolean>();
constructor(private dateAdapter: DateAdapter<Moment>,
constructor(private dateAdapter: DateAdapter<DateFnsAdapter>,
private userPreferencesService: UserPreferencesService,
private appConfig: AppConfigService,
private clipboardService: ClipboardService,
private translateService: TranslationService) {
private translateService: TranslationService,
@Inject(MAT_DATE_FORMATS) private dateFormatConfig: MatDateFormats) {
super();
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
// need to change this to app.config when will change from moment to date-fns throughout the application
// this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
this.dateFormat = 'MMM d, y';
}
ngOnInit() {
@@ -79,14 +77,14 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
.select(UserPreferenceValues.Locale)
.pipe(takeUntil(this.onDestroy$))
.subscribe(locale => {
this.dateAdapter.setLocale(locale);
this.dateAdapter.setLocale(DateFnsUtils.getLocaleFromString(locale));
this.property.locale = locale;
});
(this.dateAdapter as MomentDateAdapter).overrideDisplayFormat = 'MMM DD';
this.dateFormatConfig.display.dateInput = this.dateFormat;
if (this.property.value) {
this.valueDate = moment(this.property.value, this.dateFormat);
this.valueDate = parse(this.property.value, this.dateFormat, new Date());
} else if (this.property.multivalued && !this.property.value) {
this.property.value = [];
}
@@ -113,12 +111,12 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
this.datepicker.open();
}
onDateChanged(newDateValue) {
onDateChanged(newDateValue: MatDatepickerInputEvent<any, any>) {
if (newDateValue) {
const momentDate = moment(newDateValue.value, this.dateFormat, true);
if (momentDate.isValid()) {
this.valueDate = momentDate;
this.property.value = momentDate.toDate();
const date = this.getDateValue(newDateValue);
if (date) {
this.valueDate = date;
this.property.value = date;
this.update();
}
}
@@ -136,11 +134,11 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
this.clipboardService.copyContentToClipboard(valueToCopy, clipboardMessage);
}
addDateToList(newDateValue) {
addDateToList(newDateValue: MatDatepickerInputEvent<any, any>) {
if (newDateValue) {
const momentDate = moment(newDateValue.value, this.dateFormat, true);
if (momentDate.isValid()) {
this.property.value.push(momentDate.toDate());
const date = this.getDateValue(newDateValue);
if (date) {
this.property.value.push(date);
this.update();
}
}
@@ -154,4 +152,8 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
update() {
this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, this.property.value);
}
getDateValue(newDateValue: MatDatepickerInputEvent<any, any>): Date {
return this.property.key === 'properties.cm:from' ? startOfDay(newDateValue.value) : endOfDay(newDateValue.value);
}
}