44 CrudDefinition ,
55 Edit ,
66 List ,
7+ New ,
78 TextField ,
89 UrlAction ,
910 type RequestParameters ,
@@ -17,7 +18,7 @@ import {
1718 getBankAccounts ,
1819 updateBankAccount
1920} from '$lib/db/bank_accounts' ;
20- import type BankAccount from '$lib/entities/BankAccount' ;
21+ import BankAccount from '$lib/entities/BankAccount' ;
2122import { goto } from '$app/navigation' ;
2223import { success } from '$lib/utils/message' ;
2324
@@ -34,8 +35,11 @@ export default new CrudDefinition<BankAccount>({
3435 // minStateLoadingTimeMs: 0,
3536
3637 operations : [
37- new List ( [ ...baseFields ] , [ new UrlAction ( 'Edit' , '/crud/bank-accounts/edit' ) ] ) ,
38- new Edit ( baseFields )
38+ new List ( [ ...baseFields ] , [ new UrlAction ( 'Edit' , '/crud/bank-accounts/edit' ) ] , {
39+ globalActions : [ new UrlAction ( 'New' , '/crud/bank-accounts/new' ) ]
40+ } ) ,
41+ new Edit ( baseFields ) ,
42+ new New ( baseFields ) ,
3943 ] ,
4044
4145 stateProvider : new CallbackStateProvider < BankAccount > (
@@ -67,11 +71,10 @@ export default new CrudDefinition<BankAccount>({
6771 if ( ! data ) {
6872 throw new Error ( 'Cannot create new object: empty data.' ) ;
6973 }
70- if ( Array . isArray ( data ) ) {
71- throw new Error ( 'Cannot update data as array for this action.' ) ;
72- }
7374
74- return createBankAccount ( data ) ;
75+ await createBankAccount ( BankAccount . fromObject ( data ) ) ;
76+ success ( 'Success!' ) ;
77+ await goto ( '/crud/bank-accounts/list' ) ;
7578 }
7679
7780 if ( operation . name === 'edit' ) {
0 commit comments