context-dashboard/widget-config.service.ts
Properties |
Methods |
Accessors |
constructor(widgetConfigSectionService: WidgetConfigSectionService)
|
||||||
|
Parameters :
|
| addOnBeforeSave | ||||||
addOnBeforeSave(callback: (config: ContextWidgetConfig) => void)
|
||||||
|
Adds a callback which can check the configuration before saving.
Parameters :
Returns :
void
|
| canSave |
canSave()
|
|
Returns true if the configuration can be saved.
Returns :
Promise<boolean>
|
| deselectWidget |
deselectWidget()
|
|
Deselect the currently selected.
Returns :
void
|
| initConfig | ||||||||
initConfig(config: ContextWidgetConfig)
|
||||||||
|
Used to initialize the configuration of the selected widget.
Parameters :
Returns :
void
|
| selectWidget | ||||||||||||||||||||
selectWidget(selected: DynamicComponentDefinition, identifier: string, isDeviceTypeDashboard: unknown)
|
||||||||||||||||||||
|
Select a widget
Parameters :
Returns :
void
|
| setPreview | ||||||||
setPreview(preview: unknown | DynamicComponentDefinition | TemplateRef<any>)
|
||||||||
|
Enables a preview. If set to a DynamicComponentDefinition, the preview will be rendered with the given component. If set to a TemplateRef, the preview will be rendered with the given template.
Parameters :
Returns :
void
|
| updateConfig | |||||||||||||||
updateConfig(change: Partial<ContextWidgetConfig>, force: unknown)
|
|||||||||||||||
|
Updates the configuration of the selected widget. Also concurrency checks are ignored and no change is emitted on the component. Use with caution and only if you want to reset the configuration to some default.
Parameters :
Returns :
void
|
| currentSections$ |
Type : Observable<WidgetConfigSection[]>
|
Default value : this.selected$.pipe(
tap(() => (this.beforeSaveCallbacks = [])),
withLatestFrom(this._currentConfig$),
mergeMap(([selectedWidget, config]) =>
selectedWidget === null
? of([])
: this.widgetConfigSectionService.items$.pipe(
map(sections => [
...this.getWidgetDefaultSections(selectedWidget, config),
...sections.filter(section => section.widgetId === selectedWidget.id)
])
)
),
mergeMap((sections: WidgetConfigSectionDefinition[]) => {
if (sections.length === 0) {
return Promise.resolve([]);
}
return Promise.all(
sections.map(async section => ({
component: await section.loadComponent(),
label: section.label,
priority: section.priority || 0,
expanded: section.expanded || false,
initialState: section.initialState,
validators: section.validators || [],
validationErrors: section.validationErrors || {},
injector: section.injector,
providers: Array.isArray(section.providers)
? section.providers
: section.providers
? await section.providers()
: []
}))
);
}),
map(sections => sortByPriority(sections)),
shareReplay(1)
)
|
|
Returns all the current sections. A configuration section is a component that can be used to configure a widget.
Sections should be added via the |
| hasConfig$ |
Type : unknown
|
Default value : this.currentSections$.pipe(map(sections => sections.length > 0))
|
|
Indicates if the current selected widget has a configuration or not. |
| instanceId$ |
Type : unknown
|
Default value : this._instanceId$.asObservable()
|
|
The unique identifier of the current widget instance. |
| isDeviceTypeDashboard$ |
Type : unknown
|
Default value : this._isDeviceTypeDashboard$.asObservable()
|
|
Indicates if the selected widget is placed on a device type dashboard. |
| notify$ |
Type : unknown
|
Default value : new Subject<WidgetConfigNotification>()
|
|
A bus for broadcasting WidgetConfigNotification events between independent widget config sections during an active configuration session. Who emits: Any config section component (or its service) that needs to
inform other sections about a state change — for example,
Who subscribes: Config section components that hold references to data owned
by other sections. Subscribers should filter by Subscription management: Each subscriber is responsible for unsubscribing
(e.g. via Unknown notification types: Because |
| selected$ |
Type : unknown
|
Default value : new BehaviorSubject<DynamicComponentDefinition>(null)
|
|
The currently selected widget definition. |
| selectedComponent$ |
Type : unknown
|
Default value : new BehaviorSubject<DynamicComponentComponent>(null)
|
|
The currently selected widget component. |
| currentConfig |
getcurrentConfig()
|
|
The current configuration of the selected widget.
Only to read the value. Use |