data source
This commit is contained in:
parent
bd8d1d611a
commit
a304fc48e9
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "data",
|
||||
"version": "0.0.27",
|
||||
"version": "0.0.28",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@poweredsoft/data",
|
||||
"version": "0.0.28",
|
||||
"version": "0.0.29",
|
||||
"peerDependencies": {
|
||||
"rxjs": "^6.5.3"
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
||||
protected _loading$: Observable<boolean>;
|
||||
protected _validationError$: Observable<IDataSourceValidationError>;
|
||||
protected _notifyMessage$: Observable<IDataSourceNotifyMessage>;
|
||||
public manageNotificationMessage: boolean;
|
||||
|
||||
|
||||
protected _criteria: IQueryCriteria = {
|
||||
page: null,
|
||||
pageSize: null,
|
||||
@ -67,9 +66,7 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
||||
protected _initCriteria() {
|
||||
if (!this.options.defaultCriteria)
|
||||
return;
|
||||
|
||||
this.manageNotificationMessage = (null == this.options.manageNotificationMessage || !this.options.manageNotificationMessage) ? false : true;
|
||||
|
||||
|
||||
const copy: IQueryCriteria = JSON.parse(JSON.stringify(this.options.defaultCriteria));
|
||||
this._criteria.page = copy.page || this._criteria.page;
|
||||
this._criteria.pageSize = copy.pageSize || this._criteria.pageSize;
|
||||
@ -111,13 +108,12 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
||||
|
||||
return this.options.transport.commands[name].adapter.handle(command).pipe(
|
||||
map(t => {
|
||||
let message = `{command} was executed successfully..`;
|
||||
if (this.manageNotificationMessage)
|
||||
message = message.replace('{command}', name);
|
||||
|
||||
this._notifyMessageSubject.next({
|
||||
type: 'success',
|
||||
message: message
|
||||
message: 'COMMAND_EXECUTED_SUCCESFULLY',
|
||||
messageParams: {
|
||||
command: name
|
||||
}
|
||||
});
|
||||
return t;
|
||||
}),
|
||||
@ -151,14 +147,14 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
||||
o.next(result);
|
||||
this._dataSubject.next(this.data);
|
||||
this._notifyMessageSubject.next({
|
||||
message: 'New data has been read succesfully..',
|
||||
message: 'NEW_DATA_READ_SUCCESFULLY',
|
||||
type: 'info'
|
||||
});
|
||||
},
|
||||
err => {
|
||||
o.error(err);
|
||||
this._notifyMessageSubject.next({
|
||||
message: 'Something unexpected as occured during the query',
|
||||
message: 'UNEXPECTED_ERROR_OCCURED',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ export interface IDataSource<TModel>
|
||||
resolveCommandModelByName<T extends any>(event: IResolveCommandModelEvent<TModel>) : Observable<T>;
|
||||
executeCommandByName<TCommand, TResult>(name: string, command: TCommand) : Observable<TResult>;
|
||||
query<TQuery extends IQueryCriteria>(query: TQuery);
|
||||
excuteQuery<TQuery extends IQueryCriteria>(query: TQuery): Observable<IQueryExecutionGroupResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
||||
refresh();
|
||||
resolveIdField<TKeyType extends any>(model: TModel) : TKeyType;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
export interface IDataSourceNotifyMessage {
|
||||
type: 'warning' | 'info' | 'success' | 'error';
|
||||
message: string;
|
||||
messageParams?: any;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ export interface IDataSourceOptions<TModel> {
|
||||
idField?: string;
|
||||
resolveIdField?: (model: TModel) => any;
|
||||
defaultCriteria: IQueryCriteria;
|
||||
manageNotificationMessage?: boolean;
|
||||
}
|
||||
|
||||
export interface IDataSourceTransportOptions<TModel> {
|
||||
|
Loading…
Reference in New Issue
Block a user