chore: remove deprecated Angular api (#9516)

This commit is contained in:
Denys Vuika
2024-04-09 09:12:58 -04:00
committed by GitHub
parent 3bfadae286
commit d45a02042e
14 changed files with 101 additions and 270 deletions

View File

@@ -15,27 +15,22 @@
* limitations under the License.
*/
import { Directive, Input, Component, OnInit, OnChanges, ComponentFactoryResolver, ViewContainerRef } from '@angular/core';
import { Directive, Input, Component, OnInit, OnChanges, ViewContainerRef } from '@angular/core';
@Directive({
selector: '[adf-node-counter]'
})
export class NodeCounterDirective implements OnInit, OnChanges {
/** Number to display in the counter badge */
@Input('adf-node-counter')
counter: number;
componentRef: NodeCounterComponent;
constructor(
private resolver: ComponentFactoryResolver,
public viewContainerRef: ViewContainerRef
) {}
constructor(private viewContainerRef: ViewContainerRef) {}
ngOnInit() {
const componentFactory = this.resolver.resolveComponentFactory(NodeCounterComponent);
this.componentRef = this.viewContainerRef.createComponent(componentFactory).instance;
this.componentRef = this.viewContainerRef.createComponent(NodeCounterComponent).instance;
this.componentRef.counter = this.counter;
}
@@ -48,9 +43,7 @@ export class NodeCounterDirective implements OnInit, OnChanges {
@Component({
selector: 'adf-node-counter',
template: `
<div>{{ 'NODE_COUNTER.SELECTED_COUNT' | translate: { count: counter } }}</div>
`
template: ` <div>{{ 'NODE_COUNTER.SELECTED_COUNT' | translate : { count: counter } }}</div> `
})
export class NodeCounterComponent {
counter: number;

View File

@@ -15,18 +15,7 @@
* limitations under the License.
*/
import {
Component,
Input,
ViewChild,
ViewContainerRef,
OnInit,
OnDestroy,
ComponentRef,
ComponentFactoryResolver,
SimpleChanges,
OnChanges
} from '@angular/core';
import { Component, Input, ViewChild, ViewContainerRef, OnInit, OnDestroy, ComponentRef, SimpleChanges, OnChanges } from '@angular/core';
import { SearchFilterService } from '../../services/search-filter.service';
import { Observable } from 'rxjs';
import { SearchQueryBuilderService } from '../../services';
@@ -56,21 +45,14 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan
componentRef: ComponentRef<any>;
constructor(
private searchFilterService: SearchFilterService,
private queryBuilder: SearchQueryBuilderService,
private componentFactoryResolver: ComponentFactoryResolver
) {}
constructor(private searchFilterService: SearchFilterService, private queryBuilder: SearchQueryBuilderService) {}
ngOnInit() {
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);
}
this.content.clear();
this.componentRef = this.content.createComponent(componentType, { index: 0 });
this.setupWidget(this.componentRef);
}
}