[ADF-5390] [ADF-5391] Add multivalue cardview for Date, Datetime, Integers and Decimal properties. (#6980)

* [ADF-5390] Addd multivalue cardview for Date, Datetime, Integers and Decimal properties

* Fix unit test

* Fix linting

* Fix e2e tests

* fix e2e

Co-authored-by: Eugenio Romano <eugenio.romano@alfresco.com>
This commit is contained in:
davidcanonieto
2021-05-09 04:05:26 +01:00
committed by GitHub
parent 71cad4c287
commit bd805cb34b
23 changed files with 280 additions and 54 deletions

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { ChangeDetectorRef, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { CardViewTextItemModel } from '../../models/card-view-textitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { BaseCardView } from '../base-card-view';
@@ -68,7 +68,8 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
constructor(cardViewUpdateService: CardViewUpdateService,
private clipboardService: ClipboardService,
private translateService: TranslationService) {
private translateService: TranslationService,
private cd: ChangeDetectorRef) {
super(cardViewUpdateService);
}
@@ -76,7 +77,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
if (changes.property && changes.property.firstChange) {
this.textInput.valueChanges
.pipe(
filter(textInputValue => textInputValue !== this.editedValue),
filter(textInputValue => textInputValue !== this.editedValue && textInputValue !== null),
debounceTime(50),
takeUntil(this.onDestroy$)
)
@@ -125,9 +126,8 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
update(): void {
if (this.property.isValid(this.editedValue)) {
const updatedValue = this.prepareValueForUpload(this.property, this.editedValue);
this.cardViewUpdateService.update(<CardViewTextItemModel> { ...this.property }, updatedValue);
this.property.value = updatedValue;
this.property.value = this.prepareValueForUpload(this.property, this.editedValue);
this.cardViewUpdateService.update(<CardViewTextItemModel> { ...this.property }, this.property.value);
this.resetErrorMessages();
} else {
this.errors = this.property.getValidationErrors(this.editedValue);
@@ -143,9 +143,10 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
}
removeValueFromList(itemIndex: number) {
if (typeof this.editedValue !== 'string') {
if (Array.isArray(this.editedValue)) {
this.editedValue.splice(itemIndex, 1);
this.update();
this.cd.detectChanges();
}
}