Skip to content

Commit 55f7c2a

Browse files
committed
add before hooks
1 parent ed639c6 commit 55f7c2a

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

projects/fusio-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-fusio-sdk",
3-
"version": "6.0.4",
3+
"version": "6.0.5",
44
"description": "SDK to integrate Fusio into an Angular app",
55
"keywords": [
66
"Fusio",

projects/fusio-sdk/src/lib/abstract/form.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export abstract class Form<T> implements OnInit {
4747

4848
async doCreate(entity: T) {
4949
try {
50-
this.response = await this.getService().create(entity);
50+
this.response = await this.getService().create(this.beforeCreate(entity));
5151

5252
this.onSubmit();
5353
} catch (error) {
@@ -57,7 +57,7 @@ export abstract class Form<T> implements OnInit {
5757

5858
async doUpdate(entity: T) {
5959
try {
60-
this.response = await this.getService().update(entity);
60+
this.response = await this.getService().update(this.beforeUpdate(entity));
6161

6262
this.onSubmit();
6363
} catch (error) {
@@ -67,7 +67,7 @@ export abstract class Form<T> implements OnInit {
6767

6868
async doDelete(entity: T) {
6969
try {
70-
this.response = await this.getService().delete(entity);
70+
this.response = await this.getService().delete(this.beforeDelete(entity));
7171

7272
this.onSubmit();
7373
} catch (error) {
@@ -89,6 +89,21 @@ export abstract class Form<T> implements OnInit {
8989
protected onSubmit(): void
9090
{
9191
}
92+
93+
protected beforeCreate(entity: T): T
94+
{
95+
return entity;
96+
}
97+
98+
protected beforeUpdate(entity: T): T
99+
{
100+
return entity;
101+
}
102+
103+
protected beforeDelete(entity: T): T
104+
{
105+
return entity;
106+
}
92107
}
93108

94109
export enum Mode {

0 commit comments

Comments
 (0)