-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(admin-ui): Co-locate ui extension code
- Loading branch information
1 parent
97ba022
commit 5f26a1e
Showing
27 changed files
with
318 additions
and
281 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
39 changes: 39 additions & 0 deletions
39
packages/admin-ui/src/lib/core/src/extension/add-action-bar-item.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { APP_INITIALIZER, Provider } from '@angular/core'; | ||
import { ActionBarItem } from '../providers/nav-builder/nav-builder-types'; | ||
import { NavBuilderService } from '../providers/nav-builder/nav-builder.service'; | ||
|
||
/** | ||
* @description | ||
* Adds a button to the ActionBar at the top right of each list or detail view. The locationId can | ||
* be determined by inspecting the DOM and finding the <vdr-action-bar> element and its | ||
* `data-location-id` attribute. | ||
* | ||
* This should be used in the NgModule `providers` array of your ui extension module. | ||
* | ||
* @example | ||
* ```TypeScript | ||
* \@NgModule({ | ||
* imports: [SharedModule], | ||
* providers: [ | ||
* addActionBarItem({ | ||
* id: 'print-invoice' | ||
* label: 'Print Invoice', | ||
* locationId: 'order-detail', | ||
* routerLink: ['/extensions/invoicing'], | ||
* }), | ||
* ], | ||
* }) | ||
* export class MyUiExtensionModule {} | ||
* ``` | ||
* @docsCategory action-bar | ||
*/ | ||
export function addActionBarItem(config: ActionBarItem): Provider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (navBuilderService: NavBuilderService) => () => { | ||
navBuilderService.addActionBarItem(config); | ||
}, | ||
deps: [NavBuilderService], | ||
}; | ||
} |
81 changes: 81 additions & 0 deletions
81
packages/admin-ui/src/lib/core/src/extension/add-nav-menu-item.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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { APP_INITIALIZER, Provider } from '@angular/core'; | ||
import { NavMenuItem, NavMenuSection } from '../providers/nav-builder/nav-builder-types'; | ||
import { NavBuilderService } from '../providers/nav-builder/nav-builder.service'; | ||
|
||
/** | ||
* @description | ||
* Add a section to the main nav menu. Providing the `before` argument will | ||
* move the section before any existing section with the specified id. If | ||
* omitted (or if the id is not found) the section will be appended to the | ||
* existing set of sections. | ||
* This should be used in the NgModule `providers` array of your ui extension module. | ||
* | ||
* @example | ||
* ```TypeScript | ||
* \@NgModule({ | ||
* imports: [SharedModule], | ||
* providers: [ | ||
* addNavMenuSection({ | ||
* id: 'reports', | ||
* label: 'Reports', | ||
* items: [{ | ||
* // ... | ||
* }], | ||
* }, | ||
* 'settings'), | ||
* ], | ||
* }) | ||
* export class MyUiExtensionModule {} | ||
* ``` | ||
* @docsCategory nav-menu | ||
*/ | ||
export function addNavMenuSection(config: NavMenuSection, before?: string): Provider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (navBuilderService: NavBuilderService) => () => { | ||
navBuilderService.addNavMenuSection(config, before); | ||
}, | ||
deps: [NavBuilderService], | ||
}; | ||
} | ||
|
||
/** | ||
* @description | ||
* Add a menu item to an existing section specified by `sectionId`. The id of the section | ||
* can be found by inspecting the DOM and finding the `data-section-id` attribute. | ||
* Providing the `before` argument will move the item before any existing item with the specified id. | ||
* If omitted (or if the name is not found) the item will be appended to the | ||
* end of the section. | ||
* | ||
* This should be used in the NgModule `providers` array of your ui extension module. | ||
* | ||
* @example | ||
* ```TypeScript | ||
* \@NgModule({ | ||
* imports: [SharedModule], | ||
* providers: [ | ||
* addNavMenuItem({ | ||
* id: 'reviews', | ||
* label: 'Product Reviews', | ||
* routerLink: ['/extensions/reviews'], | ||
* icon: 'star', | ||
* }, | ||
* 'marketing'), | ||
* ], | ||
* }) | ||
* export class MyUiExtensionModule {} | ||
* `` | ||
* | ||
* @docsCategory nav-menu | ||
*/ | ||
export function addNavMenuItem(config: NavMenuItem, sectionId: string, before?: string): Provider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (navBuilderService: NavBuilderService) => () => { | ||
navBuilderService.addNavMenuItem(config, sectionId, before); | ||
}, | ||
deps: [NavBuilderService], | ||
}; | ||
} |
4 changes: 2 additions & 2 deletions
4
...k-action-registry/register-bulk-action.ts → ...ore/src/extension/register-bulk-action.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
21 changes: 21 additions & 0 deletions
21
packages/admin-ui/src/lib/core/src/extension/register-custom-detail-component.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { APP_INITIALIZER, Provider } from '@angular/core'; | ||
import { CustomDetailComponentConfig } from '../providers/custom-detail-component/custom-detail-component-types'; | ||
import { CustomDetailComponentService } from '../providers/custom-detail-component/custom-detail-component.service'; | ||
|
||
/** | ||
* @description | ||
* Registers a {@link CustomDetailComponent} to be placed in a given location. This allows you | ||
* to embed any type of custom Angular component in the entity detail pages of the Admin UI. | ||
* | ||
* @docsCategory custom-detail-components | ||
*/ | ||
export function registerCustomDetailComponent(config: CustomDetailComponentConfig): Provider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (customDetailComponentService: CustomDetailComponentService) => () => { | ||
customDetailComponentService.registerCustomDetailComponent(config); | ||
}, | ||
deps: [CustomDetailComponentService], | ||
}; | ||
} |
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
61 changes: 61 additions & 0 deletions
61
packages/admin-ui/src/lib/core/src/extension/register-form-input-component.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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { APP_INITIALIZER, FactoryProvider, Type } from '@angular/core'; | ||
import { FormInputComponent } from '../common/component-registry-types'; | ||
import { ComponentRegistryService } from '../providers/component-registry/component-registry.service'; | ||
|
||
/** | ||
* @description | ||
* Registers a custom FormInputComponent which can be used to control the argument inputs | ||
* of a {@link ConfigurableOperationDef} (e.g. CollectionFilter, ShippingMethod etc) or for | ||
* a custom field. | ||
* | ||
* @example | ||
* ```TypeScript | ||
* \@NgModule({ | ||
* imports: [SharedModule], | ||
* declarations: [MyCustomFieldControl], | ||
* providers: [ | ||
* registerFormInputComponent('my-custom-input', MyCustomFieldControl), | ||
* ], | ||
* }) | ||
* export class MyUiExtensionModule {} | ||
* ``` | ||
* | ||
* This input component can then be used in a custom field: | ||
* | ||
* @example | ||
* ```TypeScript | ||
* const config = { | ||
* // ... | ||
* customFields: { | ||
* ProductVariant: [ | ||
* { | ||
* name: 'rrp', | ||
* type: 'int', | ||
* ui: { component: 'my-custom-input' }, | ||
* }, | ||
* ] | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* or with an argument of a {@link ConfigurableOperationDef}: | ||
* | ||
* @example | ||
* ```TypeScript | ||
* args: { | ||
* rrp: { type: 'int', ui: { component: 'my-custom-input' } }, | ||
* } | ||
* ``` | ||
* | ||
* @docsCategory custom-input-components | ||
*/ | ||
export function registerFormInputComponent(id: string, component: Type<FormInputComponent>): FactoryProvider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (registry: ComponentRegistryService) => () => { | ||
registry.registerInputComponent(id, component); | ||
}, | ||
deps: [ComponentRegistryService], | ||
}; | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/admin-ui/src/lib/core/src/extension/register-history-entry-component.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { APP_INITIALIZER, Provider } from '@angular/core'; | ||
import { HistoryEntryConfig } from '../providers/custom-history-entry-component/history-entry-component-types'; | ||
import { HistoryEntryComponentService } from '../providers/custom-history-entry-component/history-entry-component.service'; | ||
|
||
/** | ||
* @description | ||
* Registers a {@link HistoryEntryComponent} for displaying history entries in the Order/Customer | ||
* history timeline. | ||
* | ||
* @since 1.9.0 | ||
* @docsCategory custom-history-entry-components | ||
*/ | ||
export function registerHistoryEntryComponent(config: HistoryEntryConfig): Provider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (customHistoryEntryComponentService: HistoryEntryComponentService) => () => { | ||
customHistoryEntryComponentService.registerComponent(config); | ||
}, | ||
deps: [HistoryEntryComponentService], | ||
}; | ||
} |
20 changes: 1 addition & 19 deletions
20
...-ui/src/lib/core/src/providers/custom-detail-component/custom-detail-component.service.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
21 changes: 1 addition & 20 deletions
21
.../lib/core/src/providers/custom-history-entry-component/history-entry-component.service.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
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
Oops, something went wrong.