[AAE-485] Fix card view int item validator (#5135)

* [AAE-485] Fix card view int item validator

* Improve code

* Fix unit tests

* Remove outdated test

* Fix login of int validator

* Fix e2e test

* fix linting
This commit is contained in:
davidcanonieto
2019-10-21 11:18:55 +01:00
committed by Eugenio Romano
parent f2c1778eda
commit 2a033507b3
6 changed files with 14 additions and 69 deletions

View File

@@ -46,12 +46,13 @@ describe('CardViewTextItemModel', () => {
expect(itemModel.displayValue).toBe('Banuk');
});
it('should return the default value if the value is not present', () => {
it('should return the default value if the value is not present the first time it loads', () => {
properties.value = undefined;
properties.default = 'default-value';
const itemModel = new CardViewTextItemModel(properties);
expect(itemModel.displayValue).toBe('default-value');
itemModel.value = '';
expect(itemModel.displayValue).toBe('');
});
it('should apply a pipe on the value if it is present', () => {

View File

@@ -33,14 +33,14 @@ export class CardViewTextItemModel extends CardViewBaseItemModel implements Card
this.multivalued = !!cardViewTextItemProperties.multivalued;
this.pipes = cardViewTextItemProperties.pipes || [];
this.clickCallBack = cardViewTextItemProperties.clickCallBack ? cardViewTextItemProperties.clickCallBack : null;
if (this.default && this.isEmpty()) {
this.value = this.default;
}
}
get displayValue() {
if (this.isEmpty()) {
return this.default;
} else {
return this.applyPipes(this.value);
}
get displayValue(): string {
return this.applyPipes(this.value);
}
private applyPipes(displayValue) {