update listing and entities map services

This commit is contained in:
Dan Percic 2023-01-09 21:47:55 +02:00
parent 64d1cb8be6
commit b638c5f074
2 changed files with 5 additions and 5 deletions

View File

@ -15,11 +15,11 @@ export class ListingService<Class extends IListable<PrimaryKey>, PrimaryKey exte
readonly areAllSelected$: Observable<boolean>; readonly areAllSelected$: Observable<boolean>;
readonly areSomeSelected$: Observable<boolean>; readonly areSomeSelected$: Observable<boolean>;
readonly notAllSelected$: Observable<boolean>; readonly notAllSelected$: Observable<boolean>;
readonly selected$: Observable<(string | number)[]>; readonly selected$: Observable<PrimaryKey[]>;
readonly selectedEntities$: Observable<Class[]>; readonly selectedEntities$: Observable<Class[]>;
readonly selectedLength$: Observable<number>; readonly selectedLength$: Observable<number>;
private _displayed: Class[] = []; private _displayed: Class[] = [];
private readonly _selected$ = new BehaviorSubject<(string | number)[]>([]); private readonly _selected$ = new BehaviorSubject<PrimaryKey[]>([]);
constructor( constructor(
protected readonly _filterService: FilterService, protected readonly _filterService: FilterService,
@ -46,7 +46,7 @@ export class ListingService<Class extends IListable<PrimaryKey>, PrimaryKey exte
return this._entitiesService.all.filter(a => selectedIds.includes(a.id)); return this._entitiesService.all.filter(a => selectedIds.includes(a.id));
} }
get selectedIds(): (string | number)[] { get selectedIds(): PrimaryKey[] {
return this._selected$.getValue(); return this._selected$.getValue();
} }

View File

@ -20,7 +20,7 @@ export abstract class EntitiesMapService<Interface, Class extends Entity<Interfa
} }
delete(keys: List<Id>): void; delete(keys: List<Id>): void;
delete(key: Id, entity: PrimaryKey | Class): void; delete(key: Id, entityId: PrimaryKey | Class): void;
delete(keys: List<Id> | Id, entity?: PrimaryKey | Class): void { delete(keys: List<Id> | Id, entity?: PrimaryKey | Class): void {
if (isArray(keys)) { if (isArray(keys)) {
return keys.forEach(key => this._map.delete(key)); return keys.forEach(key => this._map.delete(key));
@ -29,7 +29,7 @@ export abstract class EntitiesMapService<Interface, Class extends Entity<Interfa
if (entity) { if (entity) {
const entityId = typeof entity === 'string' || typeof entity === 'number' ? entity : entity.id; const entityId = typeof entity === 'string' || typeof entity === 'number' ? entity : entity.id;
const entities = this.get(keys).filter(entity => entity.id !== entityId); const entities = this.get(keys).filter(entity => entity.id !== entityId);
this.set(keys, entities); return this.set(keys, entities);
} }
console.error('entityId is null when deleting from EntitiesMapService'); console.error('entityId is null when deleting from EntitiesMapService');