|
9 | 9 |
|
10 | 10 | Additional UI extensibility points ([Entity action extensions](../angular/entity-action-extensions.md), [data table column extensions](../angular/data-table-column-extensions.md), [page toolbar extensions](../angular/page-toolbar-extensions.md) and others) are used in ABP pages to allow to control entity actions, table columns and page toolbar of a page. If you replace a page, you need to apply some configurations to be able to work extension components in your component. Let's see how to do this by replacing the roles page. |
11 | 11 |
|
12 | | -Create a new module called `MyRolesModule`: |
13 | | - |
14 | | -```bash |
15 | | -yarn ng generate module my-roles --module app |
16 | | -``` |
17 | | - |
18 | 12 | Create a new component called `MyRolesComponent`: |
19 | 13 |
|
20 | 14 | ```bash |
21 | | -yarn ng generate component my-roles/my-roles --flat --export |
| 15 | +yarn ng generate component my-roles/my-roles --flat |
22 | 16 | ``` |
23 | 17 |
|
24 | 18 | Open the generated `src/app/my-roles/my-roles.component.ts` file and replace its content with the following: |
25 | 19 |
|
26 | 20 | ```js |
27 | 21 | import { Component, Injector, inject, OnInit } from '@angular/core'; |
28 | | -import { FormGroup } from '@angular/forms'; |
| 22 | +import { FormGroup, ReactiveFormsModule } from '@angular/forms'; |
29 | 23 | import { finalize } from 'rxjs/operators'; |
30 | 24 |
|
31 | | -import { ListService, PagedAndSortedResultRequestDto, PagedResultDto } from '@abp/ng.core'; |
| 25 | +import { ListService, PagedAndSortedResultRequestDto, PagedResultDto, LocalizationPipe } from '@abp/ng.core'; |
32 | 26 | import { eIdentityComponents, RolesComponent } from '@abp/ng.identity'; |
33 | 27 | import { IdentityRoleDto, IdentityRoleService } from '@abp/ng.identity/proxy'; |
34 | | -import { ePermissionManagementComponents } from '@abp/ng.permission-management'; |
35 | | -import { Confirmation, ConfirmationService } from '@abp/ng.theme.shared'; |
| 28 | +import { ePermissionManagementComponents, PermissionManagementComponent } from '@abp/ng.permission-management'; |
| 29 | +import { Confirmation, ConfirmationService, ModalComponent, ButtonComponent } from '@abp/ng.theme.shared'; |
36 | 30 | import { |
37 | 31 | EXTENSIONS_IDENTIFIER, |
38 | 32 | FormPropData, |
39 | | - generateFormFromProps |
| 33 | + generateFormFromProps, |
| 34 | + PageToolbarComponent, |
| 35 | + ExtensibleTableComponent, |
| 36 | + ExtensibleFormComponent |
40 | 37 | } from '@abp/ng.components/extensible'; |
41 | 38 |
|
42 | 39 | @Component({ |
43 | 40 | selector: 'app-my-roles', |
| 41 | + imports: [ |
| 42 | + ReactiveFormsModule, |
| 43 | + LocalizationPipe, |
| 44 | + ModalComponent, |
| 45 | + ButtonComponent, |
| 46 | + PageToolbarComponent, |
| 47 | + ExtensibleTableComponent, |
| 48 | + ExtensibleFormComponent, |
| 49 | + PermissionManagementComponent |
| 50 | + ], |
44 | 51 | templateUrl: './my-roles.component.html', |
45 | 52 | providers: [ |
46 | 53 | ListService, |
@@ -236,25 +243,12 @@ Open the generated `src/app/my-role/my-role.component.html` file and replace its |
236 | 243 |
|
237 | 244 | We have added the `abp-page-toolbar`, `abp-extensible-table`, and `abp-extensible-form` extension components to template of the `MyRolesComponent`. |
238 | 245 |
|
239 | | -You should import the required modules for the `MyRolesComponent` to `MyRolesModule`. Open the `src/my-roles/my-roles.module.ts` file and replace the content with the following: |
240 | | - |
241 | | -```js |
242 | | -import { ExtensibleModule } from '@abp/ng.components/extensible'; |
243 | | -import { NgModule } from '@angular/core'; |
244 | | -import { SharedModule } from '../shared/shared.module'; |
245 | | -import { MyRolesComponent } from './my-roles.component'; |
246 | | -import { PermissionManagementModule } from '@abp/ng.permission-management'; |
247 | | - |
248 | | -@NgModule({ |
249 | | - declarations: [MyRolesComponent], |
250 | | - imports: [SharedModule, ExtensibleModule, PermissionManagementModule], |
251 | | - exports: [MyRolesComponent], |
252 | | -}) |
253 | | -export class MyRolesModule {} |
254 | | -``` |
255 | | - |
256 | | -- `ExtensionsModule` imported to be able to use the extension components in your component. |
257 | | -- `PermissionManagementModule` imported to be able to use the `abp-permission-*management` in your component. |
| 246 | +Since we are using standalone components, all required imports are already defined in the component's `imports` array: |
| 247 | +- `PageToolbarComponent`, `ExtensibleTableComponent`, `ExtensibleFormComponent` - Extension components |
| 248 | +- `PermissionManagementComponent` - Permission management component |
| 249 | +- `ModalComponent`, `ButtonComponent` - Theme shared components |
| 250 | +- `LocalizationPipe` - For localization |
| 251 | +- `ReactiveFormsModule` - For form handling |
258 | 252 |
|
259 | 253 | As the last step, it is needs to be replaced the `RolesComponent` with the `MyRolesComponent`. Open the `app.component.ts` and modify its content as shown below: |
260 | 254 |
|
|
0 commit comments