fix undefined body & add loadAll overload
This commit is contained in:
parent
d67d556b68
commit
3ddedbbcf3
@ -46,6 +46,7 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
|
||||
);
|
||||
}
|
||||
|
||||
loadAll(...args: unknown[]): Observable<E[]>;
|
||||
loadAll(modelPath = this._defaultModelPath, queryParams?: List<QueryParam>): Observable<E[]> {
|
||||
return this.getAll(modelPath, queryParams).pipe(
|
||||
mapEach(entity => new this._entityClass(entity)),
|
||||
|
||||
@ -23,15 +23,13 @@ export interface QueryParam {
|
||||
*/
|
||||
export abstract class GenericService<I> {
|
||||
protected readonly _http = this._injector.get(HttpClient);
|
||||
private _lastCheckedForChanges = new Map<string, string>([[ROOT_CHANGES_KEY, '0']]);
|
||||
private readonly _lastCheckedForChanges = new Map<string, string>([[ROOT_CHANGES_KEY, '0']]);
|
||||
|
||||
protected constructor(protected readonly _injector: Injector, protected readonly _defaultModelPath: string) {}
|
||||
|
||||
get<T = I[]>(): Observable<T>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
||||
get<T = I>(id: string, ...args: unknown[]): Observable<T>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
get<T>(id?: string, ...args: unknown[]): Observable<T> {
|
||||
return id ? this._getOne<T>([id]) : this.getAll<T>();
|
||||
@ -86,10 +84,10 @@ export abstract class GenericService<I> {
|
||||
|
||||
hasChanges$(key = ROOT_CHANGES_KEY): Observable<boolean> {
|
||||
const modelPath = key === ROOT_CHANGES_KEY ? '' : `${key}/`;
|
||||
return this._post<{ value: boolean }>(
|
||||
{ value: this._lastCheckedForChanges.get(key) },
|
||||
`${this._defaultModelPath}/${modelPath}changes`,
|
||||
).pipe(map((res: { value: boolean }) => res.value));
|
||||
const body = { value: this._lastCheckedForChanges.get(key) ?? '0' };
|
||||
return this._post<{ value: boolean }>(body, `${this._defaultModelPath}/${modelPath}changes`).pipe(
|
||||
map((res: { value: boolean }) => res.value),
|
||||
);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user