mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-5645] card view dateitem parse fix (#9017)
* card view dateitem parse fix * remove unused prop * remove dead link from demo shell
This commit is contained in:
@@ -42,8 +42,7 @@ export class AppLayoutComponent {
|
||||
{ href: '/form', icon: 'poll', title: 'Form' }
|
||||
]},
|
||||
{ href: '/login', icon: 'vpn_key', title: 'Login' },
|
||||
{ href: '/settings-layout', icon: 'settings', title: 'Settings' },
|
||||
{ href: '/treeview', icon: 'nature', title: 'Tree View' }
|
||||
{ href: '/settings-layout', icon: 'settings', title: 'Settings' }
|
||||
];
|
||||
|
||||
enableRedirect = true;
|
||||
|
@@ -61,10 +61,6 @@ describe('CardViewDateItemComponent', () => {
|
||||
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
it('should pick date format from appConfigService', () => {
|
||||
expect(component.dateFormat).toEqual('shortDate');
|
||||
});
|
||||
|
||||
it('should render the label and value', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -319,7 +315,6 @@ describe('CardViewDateItemComponent', () => {
|
||||
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 = new Date('Jul 10 2017 00:01:00');
|
||||
const expectedDate = new Date('Jul 10 2018');
|
||||
fixture.detectChanges();
|
||||
|
@@ -20,7 +20,6 @@ import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
|
||||
import { DatetimeAdapter, MAT_DATETIME_FORMATS, MatDatetimepickerComponent, MatDatetimepickerInputEvent } from '@mat-datetimepicker/core';
|
||||
import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
|
||||
import { UserPreferencesService, UserPreferenceValues } from '../../../common/services/user-preferences.service';
|
||||
import { AppConfigService } from '../../../app-config/app-config.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { BaseCardView } from '../base-card-view';
|
||||
@@ -41,7 +40,8 @@ import { isValid } from 'date-fns';
|
||||
selector: 'adf-card-view-dateitem',
|
||||
templateUrl: './card-view-dateitem.component.html',
|
||||
styleUrls: ['./card-view-dateitem.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-card-view-dateitem' }
|
||||
})
|
||||
export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemModel> implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
@@ -60,19 +60,16 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
|
||||
public datepicker: MatDatetimepickerComponent<any>;
|
||||
|
||||
valueDate: Date;
|
||||
dateFormat: string;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
private dateAdapter: DateAdapter<Date>,
|
||||
private userPreferencesService: UserPreferencesService,
|
||||
private appConfig: AppConfigService,
|
||||
private clipboardService: ClipboardService,
|
||||
private translateService: TranslationService
|
||||
) {
|
||||
super();
|
||||
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -91,7 +88,7 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
|
||||
}
|
||||
} else {
|
||||
if (this.property.value && !Array.isArray(this.property.value)) {
|
||||
this.valueDate = DateFnsUtils.localToUtc(DateFnsUtils.parseDate(this.property.value, this.dateFormat));
|
||||
this.valueDate = DateFnsUtils.localToUtc(new Date(this.property.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user