more methods in IDataSource
This commit is contained in:
parent
a770f3898a
commit
71a4d01930
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@poweredsoft/data",
|
"name": "@poweredsoft/data",
|
||||||
"version": "0.0.32",
|
"version": "0.0.33",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"rxjs": "^6.5.3"
|
"rxjs": "^6.5.3"
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,38 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
this._initCriteria();
|
this._initCriteria();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.data = null;
|
||||||
|
this._dataSubject.next(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateData(value: IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>) {
|
||||||
|
this.data = value;
|
||||||
|
this._dataSubject.next(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceDataWithArray(items: TModel[]) {
|
||||||
|
this.data = {
|
||||||
|
totalRecords: items.length,
|
||||||
|
numberOfPages: null,
|
||||||
|
groups: null,
|
||||||
|
aggregates: null,
|
||||||
|
data: items
|
||||||
|
};
|
||||||
|
this._dataSubject.next(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceDataWithSingle(item: TModel) {
|
||||||
|
this.data = {
|
||||||
|
totalRecords: 1,
|
||||||
|
numberOfPages: null,
|
||||||
|
groups: null,
|
||||||
|
aggregates: null,
|
||||||
|
data: [item]
|
||||||
|
};
|
||||||
|
this._dataSubject.next(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
protected _initCriteria() {
|
protected _initCriteria() {
|
||||||
if (!this.options.defaultCriteria)
|
if (!this.options.defaultCriteria)
|
||||||
return;
|
return;
|
||||||
|
@ -12,6 +12,10 @@ export interface IDataSource<TModel>
|
|||||||
excuteQuery<TQuery extends IQueryCriteria>(query: TQuery): Observable<IQueryExecutionGroupResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
excuteQuery<TQuery extends IQueryCriteria>(query: TQuery): Observable<IQueryExecutionGroupResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
||||||
refresh();
|
refresh();
|
||||||
resolveIdField<TKeyType extends any>(model: TModel) : TKeyType;
|
resolveIdField<TKeyType extends any>(model: TModel) : TKeyType;
|
||||||
|
clear();
|
||||||
|
updateData(value: IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>);
|
||||||
|
replaceDataWithArray(items: TModel[]);
|
||||||
|
replaceDataWithSingle(item: TModel);
|
||||||
|
|
||||||
data$: Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
data$: Observable<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
||||||
loading$: Observable<boolean>;
|
loading$: Observable<boolean>;
|
||||||
|
Loading…
Reference in New Issue
Block a user