moar test

This commit is contained in:
David Lebee 2019-09-13 10:39:33 -05:00
parent adcbcd589a
commit dd55aadaf5
2 changed files with 107 additions and 85 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@poweredsoft/data",
"version": "0.0.23",
"version": "0.0.24",
"peerDependencies": {
"rxjs": "^6.5.3"
}

View File

@ -1,9 +1,9 @@
import { Component, OnInit, Pipe } from '@angular/core';
import { IDataSource } from 'projects/poweredsoft/data/src/lib/IDataSource';
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 { of } from 'rxjs';
import { of, throwError } from 'rxjs';
export interface MyModel {
id: number;
@ -55,7 +55,14 @@ export class AppComponent implements OnInit {
handle: (command: MyModel) => {
const key = keyResolver(command);
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.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) {
@ -100,8 +119,11 @@ export class AppComponent implements OnInit {
}
onDoSomething() {
this.dataSource.executeCommandByName('create', this.createCommand).subscribe(() => {
this.dataSource.executeCommandByName('create', {}).subscribe(() => {
console.log('hey we did it!');
});
this.dataSource.executeCommandByName('update', {}).subscribe(() => {
});
//this.dataSource.refresh();
}