-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(form-builder): refactored save method #77
- Loading branch information
Showing
4 changed files
with
108 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 44 additions & 2 deletions
46
projects/form-builder/src/lib/interfaces/global-state.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,49 @@ | ||
import {FormGroup} from '@angular/forms'; | ||
import {Observable} from 'rxjs'; | ||
import {Parser} from '../utils/parser'; | ||
|
||
export type Process = <T = any>(data: { | ||
pointer: string, | ||
collectionId: string, | ||
documentId: string, | ||
/** | ||
* Value at form initialization. | ||
* This will only be available when | ||
* updating or deleting | ||
*/ | ||
entryValue?: any, | ||
|
||
/** | ||
* This is the value passed on to further | ||
* operations and returned by the form | ||
*/ | ||
outputValue: any | ||
}) => Observable<T>; | ||
|
||
export interface Operation { | ||
priority: number; | ||
save?: Process; | ||
delete?: Process; | ||
}; | ||
|
||
export interface GlobalState { | ||
forms: {[id: string]: FormGroup} | ||
parsers: {[id: string]: Parser} | ||
forms: {[id: string]: FormGroup}; | ||
parsers: {[id: string]: Parser}; | ||
|
||
/** | ||
* Operators are sorted in order of priority | ||
* and executed when the "save" method is called. | ||
* | ||
* They should each mutate the "outputValue" which | ||
* is forwarded along to each subsuqent "save" | ||
* method and returned by the "save" method. | ||
* | ||
* TODO: | ||
* Implement Delete | ||
*/ | ||
operations: { | ||
[id: string]: { | ||
[pointer: string]: Operation | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters