replace multiple entities once

This commit is contained in:
Dan Percic 2021-11-17 18:03:31 +02:00
parent 74fcbf080b
commit 17c65675b9
2 changed files with 6 additions and 6 deletions

View File

@ -79,10 +79,10 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
return this.all.some(entity => entity.id === id);
}
replace(newEntity: E): void {
const all = this.all.filter(item => item.id !== newEntity.id);
all.push(newEntity);
this.setEntities(all);
this.entityChanged$.next(newEntity);
replace(newEntities: E[]): void {
const ids = newEntities.map(entity => entity.id);
const all = this.all.filter(item => !ids.includes(item.id));
this.setEntities([...all, ...newEntities]);
newEntities.forEach(entity => this.entityChanged$.next(entity));
}
}

View File

@ -29,7 +29,7 @@ export class SortingService<T extends IListable> {
return order === SortingOrders.asc ? result : result.reverse();
}
return orderBy<T>(values, [column], [order]) as T[];
return orderBy<T>(values, [column], [order]) ;
}
setSortingOption(value: SortingOption<T>): void {