Added support of custom basic settings
This commit is contained in:
		
							parent
							
								
									49f5931f1b
								
							
						
					
					
						commit
						805feab1cf
					
				@ -15,3 +15,5 @@
 | 
			
		||||
///
 | 
			
		||||
 | 
			
		||||
export * from './home-components.module';
 | 
			
		||||
 | 
			
		||||
export * from './widget/config/widget-config.component.models';
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,13 @@ import {
 | 
			
		||||
import cssjs from '@core/css/css';
 | 
			
		||||
import { UtilsService } from '@core/services/utils.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 { isFunction, isUndefined } from '@core/utils';
 | 
			
		||||
import { TranslateService } from '@ngx-translate/core';
 | 
			
		||||
@ -47,6 +53,8 @@ import moment from 'moment';
 | 
			
		||||
import { IModulesMap } from '@modules/common/modules-map.models';
 | 
			
		||||
import { HOME_COMPONENTS_MODULE_TOKEN } from '@home/components/tokens';
 | 
			
		||||
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()
 | 
			
		||||
export class WidgetComponentService {
 | 
			
		||||
@ -397,6 +405,7 @@ export class WidgetComponentService {
 | 
			
		||||
 | 
			
		||||
  private registerWidgetSettingsForms(widgetInfo: WidgetInfo, factories: ComponentFactory<any>[]) {
 | 
			
		||||
    const directives: string[] = [];
 | 
			
		||||
    const basicDirectives: string[] = [];
 | 
			
		||||
    if (widgetInfo.settingsDirective && widgetInfo.settingsDirective.length) {
 | 
			
		||||
      directives.push(widgetInfo.settingsDirective);
 | 
			
		||||
    }
 | 
			
		||||
@ -407,12 +416,19 @@ export class WidgetComponentService {
 | 
			
		||||
      directives.push(widgetInfo.latestDataKeySettingsDirective);
 | 
			
		||||
    }
 | 
			
		||||
    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) {
 | 
			
		||||
      factories.filter((factory) => directives.includes(factory.selector))
 | 
			
		||||
        .forEach((foundFactory) => {
 | 
			
		||||
          widgetSettingsComponentsMap[foundFactory.selector] = foundFactory.componentType;
 | 
			
		||||
          settingsComponentsMap[foundFactory.selector] = foundFactory.componentType;
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user