moar test
This commit is contained in:
parent
adcbcd589a
commit
dd55aadaf5
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@poweredsoft/data",
|
"name": "@poweredsoft/data",
|
||||||
"version": "0.0.23",
|
"version": "0.0.24",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"rxjs": "^6.5.3"
|
"rxjs": "^6.5.3"
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { Component, OnInit, Pipe } from '@angular/core';
|
import { Component, OnInit, Pipe } from '@angular/core';
|
||||||
import { IDataSource } from 'projects/poweredsoft/data/src/lib/IDataSource';
|
import { IDataSource } from 'projects/poweredsoft/data/src/lib/IDataSource';
|
||||||
import { IDataSourceNotifyMessage } from 'projects/poweredsoft/data/src/lib/IDataSourceNotifyMessage';
|
import { IDataSourceNotifyMessage } from 'projects/poweredsoft/data/src/lib/IDataSourceNotifyMessage';
|
||||||
import { DataSource, IDataSourceTransportOptions, IDataSourceQueryAdapterOptions, IQueryCriteria, IQueryExecutionResult, IQueryExecutionGroupResult, IDataSourceCommandAdapterOptions } from 'projects/poweredsoft/data/src/public-api';
|
import { DataSource, IDataSourceTransportOptions, IDataSourceQueryAdapterOptions, IQueryCriteria, IQueryExecutionResult, IQueryExecutionGroupResult, IDataSourceCommandAdapterOptions, IDataSourceValidationError } from 'projects/poweredsoft/data/src/public-api';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { of } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
|
|
||||||
export interface MyModel {
|
export interface MyModel {
|
||||||
id: number;
|
id: number;
|
||||||
@ -55,7 +55,14 @@ export class AppComponent implements OnInit {
|
|||||||
handle: (command: MyModel) => {
|
handle: (command: MyModel) => {
|
||||||
const key = keyResolver(command);
|
const key = keyResolver(command);
|
||||||
const updateRoute = `${route}/${encodeURIComponent(key as any)}`;
|
const updateRoute = `${route}/${encodeURIComponent(key as any)}`;
|
||||||
return of(command);
|
return throwError(<IDataSourceValidationError>{
|
||||||
|
type: 'validation',
|
||||||
|
errors: {
|
||||||
|
'name': [
|
||||||
|
'David is not unique'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -90,9 +97,21 @@ export class AppComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dataSource.notifyMessage$.subscribe((notifyMessage: IDataSourceNotifyMessage) => {
|
this.dataSource.notifyMessage$.subscribe((notifyMessage) => {
|
||||||
this.handleNotification(notifyMessage);
|
this.handleNotification(notifyMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.dataSource.validationError$.subscribe((t) => {
|
||||||
|
|
||||||
|
let message = '';
|
||||||
|
for (var key in t.errors)
|
||||||
|
t.errors[key].forEach(error => message += `\n${error}`);
|
||||||
|
|
||||||
|
this.handleNotification({
|
||||||
|
type: 'error',
|
||||||
|
message: message
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNotification(notification: IDataSourceNotifyMessage) {
|
handleNotification(notification: IDataSourceNotifyMessage) {
|
||||||
@ -100,8 +119,11 @@ export class AppComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDoSomething() {
|
onDoSomething() {
|
||||||
this.dataSource.executeCommandByName('create', this.createCommand).subscribe(() => {
|
this.dataSource.executeCommandByName('create', {}).subscribe(() => {
|
||||||
console.log('hey we did it!');
|
console.log('hey we did it!');
|
||||||
|
});
|
||||||
|
this.dataSource.executeCommandByName('update', {}).subscribe(() => {
|
||||||
|
|
||||||
});
|
});
|
||||||
//this.dataSource.refresh();
|
//this.dataSource.refresh();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user