mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4338] Add locale to CardViewDateItemModel and improve logic of LocalizedDat… (#4845)
* Add locale to CardViewDateItemModel and improve logic of LocalizedDatePipe * Fix e2e tests * Fix e2e tests * Fix C305010 test
This commit is contained in:
committed by
Eugenio Romano
parent
e03290d26c
commit
334ebd1256
@@ -15,15 +15,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import moment from 'moment-es6';
|
||||
import { CardViewItem } from '../interfaces/card-view-item.interface';
|
||||
import { DynamicComponentModel } from '../../services/dynamic-component-mapper.service';
|
||||
import { CardViewBaseItemModel } from './card-view-baseitem.model';
|
||||
import { CardViewDateItemProperties } from '../interfaces/card-view.interfaces';
|
||||
import { LocalizedDatePipe } from '../../pipes/localized-date.pipe';
|
||||
|
||||
export class CardViewDateItemModel extends CardViewBaseItemModel implements CardViewItem, DynamicComponentModel {
|
||||
type: string = 'date';
|
||||
format: string = 'MMM DD YYYY';
|
||||
format: string;
|
||||
locale: string;
|
||||
|
||||
localizedDatePipe: LocalizedDatePipe;
|
||||
|
||||
constructor(cardViewDateItemProperties: CardViewDateItemProperties) {
|
||||
super(cardViewDateItemProperties);
|
||||
@@ -32,13 +35,18 @@ export class CardViewDateItemModel extends CardViewBaseItemModel implements Card
|
||||
this.format = cardViewDateItemProperties.format;
|
||||
}
|
||||
|
||||
if (cardViewDateItemProperties.locale) {
|
||||
this.format = cardViewDateItemProperties.locale;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
get displayValue() {
|
||||
if (!this.value) {
|
||||
return this.default;
|
||||
} else {
|
||||
return moment(this.value).format(this.format);
|
||||
this.localizedDatePipe = new LocalizedDatePipe();
|
||||
return this.localizedDatePipe.transform(this.value, this.format, this.locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,5 +21,5 @@ import { CardViewDateItemModel } from './card-view-dateitem.model';
|
||||
|
||||
export class CardViewDatetimeItemModel extends CardViewDateItemModel implements CardViewItem, DynamicComponentModel {
|
||||
type: string = 'datetime';
|
||||
format: string = 'MMM DD YYYY HH:mm';
|
||||
format: string = 'MMM d, y, h:mm';
|
||||
}
|
||||
|
Reference in New Issue
Block a user