|
|
@ -29,7 +29,13 @@ import { |
|
|
import cssjs from '@core/css/css'; |
|
|
import cssjs from '@core/css/css'; |
|
|
import { UtilsService } from '@core/services/utils.service'; |
|
|
import { UtilsService } from '@core/services/utils.service'; |
|
|
import { ModulesWithFactories, ResourcesService } from '@core/services/resources.service'; |
|
|
import { ModulesWithFactories, ResourcesService } from '@core/services/resources.service'; |
|
|
import { Widget, widgetActionSources, WidgetControllerDescriptor, WidgetType } from '@shared/models/widget.models'; |
|
|
import { |
|
|
|
|
|
IWidgetSettingsComponent, |
|
|
|
|
|
Widget, |
|
|
|
|
|
widgetActionSources, |
|
|
|
|
|
WidgetControllerDescriptor, |
|
|
|
|
|
WidgetType |
|
|
|
|
|
} from '@shared/models/widget.models'; |
|
|
import { catchError, map, mergeMap, switchMap, tap } from 'rxjs/operators'; |
|
|
import { catchError, map, mergeMap, switchMap, tap } from 'rxjs/operators'; |
|
|
import { isFunction, isUndefined } from '@core/utils'; |
|
|
import { isFunction, isUndefined } from '@core/utils'; |
|
|
import { TranslateService } from '@ngx-translate/core'; |
|
|
import { TranslateService } from '@ngx-translate/core'; |
|
|
@ -47,6 +53,8 @@ import moment from 'moment'; |
|
|
import { IModulesMap } from '@modules/common/modules-map.models'; |
|
|
import { IModulesMap } from '@modules/common/modules-map.models'; |
|
|
import { HOME_COMPONENTS_MODULE_TOKEN } from '@home/components/tokens'; |
|
|
import { HOME_COMPONENTS_MODULE_TOKEN } from '@home/components/tokens'; |
|
|
import { widgetSettingsComponentsMap } from '@home/components/widget/lib/settings/widget-settings.module'; |
|
|
import { widgetSettingsComponentsMap } from '@home/components/widget/lib/settings/widget-settings.module'; |
|
|
|
|
|
import { basicWidgetConfigComponentsMap } from '@home/components/widget/config/basic/basic-widget-config.module'; |
|
|
|
|
|
import { IBasicWidgetConfigComponent } from '@home/components/widget/config/widget-config.component.models'; |
|
|
|
|
|
|
|
|
@Injectable() |
|
|
@Injectable() |
|
|
export class WidgetComponentService { |
|
|
export class WidgetComponentService { |
|
|
@ -397,6 +405,7 @@ export class WidgetComponentService { |
|
|
|
|
|
|
|
|
private registerWidgetSettingsForms(widgetInfo: WidgetInfo, factories: ComponentFactory<any>[]) { |
|
|
private registerWidgetSettingsForms(widgetInfo: WidgetInfo, factories: ComponentFactory<any>[]) { |
|
|
const directives: string[] = []; |
|
|
const directives: string[] = []; |
|
|
|
|
|
const basicDirectives: string[] = []; |
|
|
if (widgetInfo.settingsDirective && widgetInfo.settingsDirective.length) { |
|
|
if (widgetInfo.settingsDirective && widgetInfo.settingsDirective.length) { |
|
|
directives.push(widgetInfo.settingsDirective); |
|
|
directives.push(widgetInfo.settingsDirective); |
|
|
} |
|
|
} |
|
|
@ -407,12 +416,19 @@ export class WidgetComponentService { |
|
|
directives.push(widgetInfo.latestDataKeySettingsDirective); |
|
|
directives.push(widgetInfo.latestDataKeySettingsDirective); |
|
|
} |
|
|
} |
|
|
if (widgetInfo.basicModeDirective && widgetInfo.basicModeDirective.length) { |
|
|
if (widgetInfo.basicModeDirective && widgetInfo.basicModeDirective.length) { |
|
|
directives.push(widgetInfo.basicModeDirective); |
|
|
basicDirectives.push(widgetInfo.basicModeDirective); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.expandSettingComponentMap(widgetSettingsComponentsMap, directives, factories); |
|
|
|
|
|
this.expandSettingComponentMap(basicWidgetConfigComponentsMap, basicDirectives, factories); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private expandSettingComponentMap(settingsComponentsMap: {[key: string]: Type<IWidgetSettingsComponent | IBasicWidgetConfigComponent>}, |
|
|
|
|
|
directives: string[], factories: ComponentFactory<any>[]): void { |
|
|
if (directives.length) { |
|
|
if (directives.length) { |
|
|
factories.filter((factory) => directives.includes(factory.selector)) |
|
|
factories.filter((factory) => directives.includes(factory.selector)) |
|
|
.forEach((foundFactory) => { |
|
|
.forEach((foundFactory) => { |
|
|
widgetSettingsComponentsMap[foundFactory.selector] = foundFactory.componentType; |
|
|
settingsComponentsMap[foundFactory.selector] = foundFactory.componentType; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|