mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
[ADF-2786] AOT support for search filter widgets (#3224)
* AOT support for search filter widgets * json schema for search settings
This commit is contained in:
committed by
Eugenio Romano
parent
40b4fc7d66
commit
b580efb7f6
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, ViewChild, ViewContainerRef, OnInit, OnDestroy, Compiler, ModuleWithComponentFactories, ComponentRef } from '@angular/core';
|
||||
import { SearchWidgetsModule } from './search-widgets.module';
|
||||
import { Component, Input, ViewChild, ViewContainerRef, OnInit, OnDestroy, ComponentRef, ComponentFactoryResolver } from '@angular/core';
|
||||
import { SearchQueryBuilderService } from '../../search-query-builder.service';
|
||||
import { SearchFilterService } from '../search-filter/search-filter.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-widget-container',
|
||||
@@ -40,19 +40,23 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
config: any;
|
||||
|
||||
private module: ModuleWithComponentFactories<SearchWidgetsModule>;
|
||||
private componentRef: ComponentRef<any>;
|
||||
|
||||
constructor(compiler: Compiler, private queryBuilder: SearchQueryBuilderService) {
|
||||
this.module = compiler.compileModuleAndAllComponentsSync(SearchWidgetsModule);
|
||||
constructor(
|
||||
private searchFilterService: SearchFilterService,
|
||||
private queryBuilder: SearchQueryBuilderService,
|
||||
private componentFactoryResolver: ComponentFactoryResolver) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const factory = this.module.componentFactories.find(f => f.selector === this.selector);
|
||||
if (factory) {
|
||||
this.content.clear();
|
||||
this.componentRef = this.content.createComponent(factory, 0);
|
||||
this.setupWidget(this.componentRef);
|
||||
const componentType = this.searchFilterService.widgets[this.selector];
|
||||
if (componentType) {
|
||||
const factory = this.componentFactoryResolver.resolveComponentFactory(componentType);
|
||||
if (factory) {
|
||||
this.content.clear();
|
||||
this.componentRef = this.content.createComponent(factory, 0);
|
||||
this.setupWidget(this.componentRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user