-
Notifications
You must be signed in to change notification settings - Fork 4
[NAE-1497] Frontend actions #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
809f732
[NAE-1497] Frontend Actions
renczesstefan de7a4fe
[NAE-1497] Frontend Actions
renczesstefan 5a84374
Merge branch 'NAE-1906' into NAE-1497
renczesstefan 42aa345
[NAE-1497] Frontend Actions
renczesstefan 253476b
[NAE-1497] Frontend Actions
renczesstefan 632c399
[NAE-1497] Frontend Actions
renczesstefan 2b50219
[NAE-1497] Frontend Actions
renczesstefan c051e5d
[NAE-1497] Frontend Actions
renczesstefan 0ec1a25
[NAE-1497] Frontend Actions
renczesstefan 2f08b7c
[NAE-1497] Frontend Actions
renczesstefan 60cbbab
[NAE-1497] Frontend Actions
renczesstefan 64659ac
[NAE-1497] Frontend Actions
renczesstefan d90c2bf
[NAE-1497] Frontend Actions
renczesstefan b0eae3a
[NAE-1497] Frontend Actions
renczesstefan 1067d2e
[NAE-1497] Frontend Actions
renczesstefan b3bc5f6
[NAE-1497] Frontend Actions
renczesstefan 62b924c
[NAE-1497] Frontend Actions
renczesstefan ba3bc5a
[NAE-1497] Frontend Actions
renczesstefan e4831c7
[NAE-1497] Frontend Actions
renczesstefan 22ed681
[NAE-1497] Frontend Actions
renczesstefan bbfc953
[NAE-1497] Frontend Actions
renczesstefan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Frontend Actions | ||
| Frontend actions are type of actions that are executed on frontend. The action implementation is done as part of | ||
| frontend code and they can be called from inside data or transition events. | ||
|
|
||
| ## Definition of action on frontend | ||
|
|
||
| A frontend action can be defined anywhere in frontend code, but it is suggested to make a separate file | ||
| for it. When defining action, we should follow these steps: | ||
|
|
||
| 1. Create a file with any name, e.g. ``example-action.ts``, this will be the file, where we define our action | ||
| 2. To define an action we should create and export a constant. Type of this constant has to be `FrontendActionDefinition`. The value of this constant will be the actual action definition | ||
| ``` | ||
| export const redirectAction: FrontActionDefinition | ||
| ``` | ||
| 3. The ``FrontActionDefinition`` interface has an argument called ``fn`` which has a type of anonymous function with two arguments: ``injector: Injector``, ``frontAction: FrontAction``. | ||
| ``Injector`` is classic Angular injector, ``FrontAction`` contains the ID/name of the frontend action and the arguments. The content of this object is got from backend frontend action call. The frontend | ||
| action definition should look like as follows: | ||
| ``` | ||
| export const redirectAction: FrontActionDefinition = { | ||
| fn: (injector: Injector, frontAction: FrontAction) => { | ||
| const router = injector.get(Router); | ||
| router.navigate([frontAction.args[0]]) | ||
| } | ||
| } | ||
| ``` | ||
| 4. The final step to register our new frontend function into ``FrontActionsRegisterService``. This can be done in any module of our frontend application, | ||
| but it is suggested to do it in ``app.module.ts``. This can be done via calling the ``FrontActionsRegistryService.register(actionId: string, actionDefintion: FrontActionDefinition)``. The first argument, ``actionId`` | ||
| should be the same, that it is called on backend. | ||
| ``` | ||
| export class AppModule { | ||
| constructor(frontActionsRegistryService: FrontActionsRegistryService) { | ||
| frontActionsRegistryService.register('redirect', redirectAction); | ||
| } | ||
| } | ||
| ``` |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.