mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge branch 'memory-leak-fixes_contribute-7.6' into generify-component-loaders_contribute-main
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Component, ComponentFactoryResolver, ElementRef, OnInit, ViewChild } from '@angular/core';
|
import { Component, ComponentRef, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import {
|
import {
|
||||||
@@ -14,6 +14,7 @@ import { GenericConstructor } from '../../../../../core/shared/generic-construct
|
|||||||
import { DynamicComponentLoaderDirective } from '../../../../../shared/abstract-component-loader/dynamic-component-loader.directive';
|
import { DynamicComponentLoaderDirective } from '../../../../../shared/abstract-component-loader/dynamic-component-loader.directive';
|
||||||
import { ThemeService } from '../../../../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../../../../shared/theme-support/theme.service';
|
||||||
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { hasValue } from '../../../../../shared/empty.util';
|
||||||
|
|
||||||
@listableObjectComponent(ItemSearchResult, ViewMode.GridElement, Context.AdminSearch)
|
@listableObjectComponent(ItemSearchResult, ViewMode.GridElement, Context.AdminSearch)
|
||||||
@Component({
|
@Component({
|
||||||
@@ -24,17 +25,18 @@ import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service
|
|||||||
/**
|
/**
|
||||||
* The component for displaying a list element for an item search result on the admin search page
|
* The component for displaying a list element for an item search result on the admin search page
|
||||||
*/
|
*/
|
||||||
export class ItemAdminSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> implements OnInit {
|
export class ItemAdminSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> implements OnDestroy, OnInit {
|
||||||
@ViewChild(DynamicComponentLoaderDirective, { static: true }) dynamicComponentLoaderDirective: DynamicComponentLoaderDirective;
|
@ViewChild(DynamicComponentLoaderDirective, { static: true }) dynamicComponentLoaderDirective: DynamicComponentLoaderDirective;
|
||||||
@ViewChild('badges', { static: true }) badges: ElementRef;
|
@ViewChild('badges', { static: true }) badges: ElementRef;
|
||||||
@ViewChild('buttons', { static: true }) buttons: ElementRef;
|
@ViewChild('buttons', { static: true }) buttons: ElementRef;
|
||||||
|
|
||||||
|
protected compRef: ComponentRef<Component>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
protected truncatableService: TruncatableService,
|
protected truncatableService: TruncatableService,
|
||||||
protected bitstreamDataService: BitstreamDataService,
|
protected bitstreamDataService: BitstreamDataService,
|
||||||
private themeService: ThemeService,
|
private themeService: ThemeService,
|
||||||
private componentFactoryResolver: ComponentFactoryResolver,
|
|
||||||
) {
|
) {
|
||||||
super(dsoNameService, truncatableService, bitstreamDataService);
|
super(dsoNameService, truncatableService, bitstreamDataService);
|
||||||
}
|
}
|
||||||
@@ -44,23 +46,32 @@ export class ItemAdminSearchResultGridElementComponent extends SearchResultGridE
|
|||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent());
|
const component: GenericConstructor<Component> = this.getComponent();
|
||||||
|
|
||||||
const viewContainerRef = this.dynamicComponentLoaderDirective.viewContainerRef;
|
const viewContainerRef = this.dynamicComponentLoaderDirective.viewContainerRef;
|
||||||
viewContainerRef.clear();
|
viewContainerRef.clear();
|
||||||
|
|
||||||
const componentRef = viewContainerRef.createComponent(
|
this.compRef = viewContainerRef.createComponent(
|
||||||
componentFactory,
|
component, {
|
||||||
0,
|
index: 0,
|
||||||
undefined,
|
injector: undefined,
|
||||||
[
|
projectableNodes: [
|
||||||
[this.badges.nativeElement],
|
[this.badges.nativeElement],
|
||||||
[this.buttons.nativeElement]
|
[this.buttons.nativeElement],
|
||||||
]);
|
],
|
||||||
(componentRef.instance as any).object = this.object;
|
},
|
||||||
(componentRef.instance as any).index = this.index;
|
);
|
||||||
(componentRef.instance as any).linkType = this.linkType;
|
this.compRef.setInput('object',this.object);
|
||||||
(componentRef.instance as any).listID = this.listID;
|
this.compRef.setInput('index', this.index);
|
||||||
|
this.compRef.setInput('linkType', this.linkType);
|
||||||
|
this.compRef.setInput('listID', this.listID);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (hasValue(this.compRef)) {
|
||||||
|
this.compRef.destroy();
|
||||||
|
this.compRef = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, ComponentFactoryResolver, ElementRef, ViewChild } from '@angular/core';
|
import { Component, ElementRef, ViewChild, ComponentRef, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import {
|
import {
|
||||||
@@ -24,6 +24,7 @@ import { take } from 'rxjs/operators';
|
|||||||
import { WorkflowItemSearchResult } from '../../../../../shared/object-collection/shared/workflow-item-search-result.model';
|
import { WorkflowItemSearchResult } from '../../../../../shared/object-collection/shared/workflow-item-search-result.model';
|
||||||
import { ThemeService } from '../../../../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../../../../shared/theme-support/theme.service';
|
||||||
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { hasValue } from '../../../../../shared/empty.util';
|
||||||
|
|
||||||
@listableObjectComponent(WorkflowItemSearchResult, ViewMode.GridElement, Context.AdminWorkflowSearch)
|
@listableObjectComponent(WorkflowItemSearchResult, ViewMode.GridElement, Context.AdminWorkflowSearch)
|
||||||
@Component({
|
@Component({
|
||||||
@@ -34,7 +35,7 @@ import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service
|
|||||||
/**
|
/**
|
||||||
* The component for displaying a grid element for an workflow item on the admin workflow search page
|
* The component for displaying a grid element for an workflow item on the admin workflow search page
|
||||||
*/
|
*/
|
||||||
export class WorkflowItemSearchResultAdminWorkflowGridElementComponent extends SearchResultGridElementComponent<WorkflowItemSearchResult, WorkflowItem> {
|
export class WorkflowItemSearchResultAdminWorkflowGridElementComponent extends SearchResultGridElementComponent<WorkflowItemSearchResult, WorkflowItem> implements OnDestroy, OnInit {
|
||||||
/**
|
/**
|
||||||
* Directive used to render the dynamic component in
|
* Directive used to render the dynamic component in
|
||||||
*/
|
*/
|
||||||
@@ -55,9 +56,10 @@ export class WorkflowItemSearchResultAdminWorkflowGridElementComponent extends S
|
|||||||
*/
|
*/
|
||||||
public item$: Observable<Item>;
|
public item$: Observable<Item>;
|
||||||
|
|
||||||
|
protected compRef: ComponentRef<Component>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
private componentFactoryResolver: ComponentFactoryResolver,
|
|
||||||
private linkService: LinkService,
|
private linkService: LinkService,
|
||||||
protected truncatableService: TruncatableService,
|
protected truncatableService: TruncatableService,
|
||||||
private themeService: ThemeService,
|
private themeService: ThemeService,
|
||||||
@@ -75,26 +77,34 @@ export class WorkflowItemSearchResultAdminWorkflowGridElementComponent extends S
|
|||||||
this.dso = this.linkService.resolveLink(this.dso, followLink('item'));
|
this.dso = this.linkService.resolveLink(this.dso, followLink('item'));
|
||||||
this.item$ = (this.dso.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
|
this.item$ = (this.dso.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
|
||||||
this.item$.pipe(take(1)).subscribe((item: Item) => {
|
this.item$.pipe(take(1)).subscribe((item: Item) => {
|
||||||
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent(item));
|
const component: GenericConstructor<Component> = this.getComponent(item);
|
||||||
|
|
||||||
const viewContainerRef = this.dynamicComponentLoaderDirective.viewContainerRef;
|
const viewContainerRef = this.dynamicComponentLoaderDirective.viewContainerRef;
|
||||||
viewContainerRef.clear();
|
viewContainerRef.clear();
|
||||||
|
|
||||||
const componentRef = viewContainerRef.createComponent(
|
this.compRef = viewContainerRef.createComponent(
|
||||||
componentFactory,
|
component, {
|
||||||
0,
|
index: 0,
|
||||||
undefined,
|
injector: undefined,
|
||||||
[
|
projectableNodes: [
|
||||||
[this.badges.nativeElement],
|
[this.badges.nativeElement],
|
||||||
[this.buttons.nativeElement]
|
[this.buttons.nativeElement],
|
||||||
]);
|
],
|
||||||
(componentRef.instance as any).object = item;
|
},
|
||||||
(componentRef.instance as any).index = this.index;
|
);
|
||||||
(componentRef.instance as any).linkType = this.linkType;
|
this.compRef.setInput('object', item);
|
||||||
(componentRef.instance as any).listID = this.listID;
|
this.compRef.setInput('index', this.index);
|
||||||
componentRef.changeDetectorRef.detectChanges();
|
this.compRef.setInput('linkType', this.linkType);
|
||||||
}
|
this.compRef.setInput('listID', this.listID);
|
||||||
);
|
this.compRef.changeDetectorRef.detectChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (hasValue(this.compRef)) {
|
||||||
|
this.compRef.destroy();
|
||||||
|
this.compRef = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, ComponentFactoryResolver, ElementRef, ViewChild, OnInit } from '@angular/core';
|
import { Component, ElementRef, ViewChild, OnInit, OnDestroy, ComponentRef } from '@angular/core';
|
||||||
|
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { map, mergeMap, take, tap } from 'rxjs/operators';
|
import { map, mergeMap, take, tap } from 'rxjs/operators';
|
||||||
@@ -35,6 +35,7 @@ import { SupervisionOrder } from '../../../../../core/supervision-order/models/s
|
|||||||
import { PaginatedList } from '../../../../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../../../../core/data/paginated-list.model';
|
||||||
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
|
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
|
||||||
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { hasValue } from '../../../../../shared/empty.util';
|
||||||
|
|
||||||
@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.GridElement, Context.AdminWorkflowSearch)
|
@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.GridElement, Context.AdminWorkflowSearch)
|
||||||
@Component({
|
@Component({
|
||||||
@@ -45,7 +46,7 @@ import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service
|
|||||||
/**
|
/**
|
||||||
* The component for displaying a grid element for an workflow item on the admin workflow search page
|
* The component for displaying a grid element for an workflow item on the admin workflow search page
|
||||||
*/
|
*/
|
||||||
export class WorkspaceItemSearchResultAdminWorkflowGridElementComponent extends SearchResultGridElementComponent<WorkspaceItemSearchResult, WorkspaceItem> implements OnInit {
|
export class WorkspaceItemSearchResultAdminWorkflowGridElementComponent extends SearchResultGridElementComponent<WorkspaceItemSearchResult, WorkspaceItem> implements OnDestroy, OnInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The item linked to the workspace item
|
* The item linked to the workspace item
|
||||||
@@ -77,9 +78,13 @@ export class WorkspaceItemSearchResultAdminWorkflowGridElementComponent extends
|
|||||||
*/
|
*/
|
||||||
@ViewChild('buttons', { static: true }) buttons: ElementRef;
|
@ViewChild('buttons', { static: true }) buttons: ElementRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reference to the dynamic component
|
||||||
|
*/
|
||||||
|
protected compRef: ComponentRef<Component>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
private componentFactoryResolver: ComponentFactoryResolver,
|
|
||||||
private linkService: LinkService,
|
private linkService: LinkService,
|
||||||
protected truncatableService: TruncatableService,
|
protected truncatableService: TruncatableService,
|
||||||
private themeService: ThemeService,
|
private themeService: ThemeService,
|
||||||
@@ -98,24 +103,24 @@ export class WorkspaceItemSearchResultAdminWorkflowGridElementComponent extends
|
|||||||
this.dso = this.linkService.resolveLink(this.dso, followLink('item'));
|
this.dso = this.linkService.resolveLink(this.dso, followLink('item'));
|
||||||
this.item$ = (this.dso.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
|
this.item$ = (this.dso.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
|
||||||
this.item$.pipe(take(1)).subscribe((item: Item) => {
|
this.item$.pipe(take(1)).subscribe((item: Item) => {
|
||||||
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent(item));
|
const component: GenericConstructor<Component> = this.getComponent(item);
|
||||||
|
|
||||||
const viewContainerRef = this.dynamicComponentLoaderDirective.viewContainerRef;
|
const viewContainerRef = this.dynamicComponentLoaderDirective.viewContainerRef;
|
||||||
viewContainerRef.clear();
|
viewContainerRef.clear();
|
||||||
|
|
||||||
const componentRef = viewContainerRef.createComponent(
|
this.compRef = viewContainerRef.createComponent(
|
||||||
componentFactory,
|
component, {
|
||||||
0,
|
index: 0,
|
||||||
undefined,
|
projectableNodes: [
|
||||||
[
|
|
||||||
[this.badges.nativeElement],
|
[this.badges.nativeElement],
|
||||||
[this.buttons.nativeElement]
|
[this.buttons.nativeElement]
|
||||||
]);
|
],
|
||||||
(componentRef.instance as any).object = item;
|
});
|
||||||
(componentRef.instance as any).index = this.index;
|
this.compRef.setInput('object', item);
|
||||||
(componentRef.instance as any).linkType = this.linkType;
|
this.compRef.setInput('index', this.index);
|
||||||
(componentRef.instance as any).listID = this.listID;
|
this.compRef.setInput('linkType', this.linkType);
|
||||||
componentRef.changeDetectorRef.detectChanges();
|
this.compRef.setInput('listID', this.listID);
|
||||||
|
this.compRef.changeDetectorRef.detectChanges();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -128,6 +133,13 @@ export class WorkspaceItemSearchResultAdminWorkflowGridElementComponent extends
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (hasValue(this.compRef)) {
|
||||||
|
this.compRef.destroy();
|
||||||
|
this.compRef = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the component depending on the item's entity type, view mode and context
|
* Fetch the component depending on the item's entity type, view mode and context
|
||||||
* @returns {GenericConstructor<Component>}
|
* @returns {GenericConstructor<Component>}
|
||||||
|
@@ -85,6 +85,7 @@ export abstract class AbstractComponentLoaderComponent<T> implements OnInit, OnC
|
|||||||
this.subs
|
this.subs
|
||||||
.filter((subscription: Subscription) => hasValue(subscription))
|
.filter((subscription: Subscription) => hasValue(subscription))
|
||||||
.forEach((subscription: Subscription) => subscription.unsubscribe());
|
.forEach((subscription: Subscription) => subscription.unsubscribe());
|
||||||
|
this.destroyComponentInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
ComponentFactoryResolver,
|
|
||||||
ComponentRef,
|
ComponentRef,
|
||||||
Directive,
|
Directive,
|
||||||
Input,
|
Input,
|
||||||
@@ -12,6 +11,7 @@ import { PlacementArray } from '@ng-bootstrap/ng-bootstrap/util/positioning';
|
|||||||
import { ContextHelpWrapperComponent } from './context-help-wrapper/context-help-wrapper.component';
|
import { ContextHelpWrapperComponent } from './context-help-wrapper/context-help-wrapper.component';
|
||||||
import { PlacementDir } from './context-help-wrapper/placement-dir.model';
|
import { PlacementDir } from './context-help-wrapper/placement-dir.model';
|
||||||
import { ContextHelpService } from './context-help.service';
|
import { ContextHelpService } from './context-help.service';
|
||||||
|
import { hasValue } from './empty.util';
|
||||||
|
|
||||||
export interface ContextHelpDirectiveInput {
|
export interface ContextHelpDirectiveInput {
|
||||||
content: string;
|
content: string;
|
||||||
@@ -43,7 +43,6 @@ export class ContextHelpDirective implements OnChanges, OnDestroy {
|
|||||||
constructor(
|
constructor(
|
||||||
private templateRef: TemplateRef<any>,
|
private templateRef: TemplateRef<any>,
|
||||||
private viewContainerRef: ViewContainerRef,
|
private viewContainerRef: ViewContainerRef,
|
||||||
private componentFactoryResolver: ComponentFactoryResolver,
|
|
||||||
private contextHelpService: ContextHelpService
|
private contextHelpService: ContextHelpService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -53,19 +52,21 @@ export class ContextHelpDirective implements OnChanges, OnDestroy {
|
|||||||
this.contextHelpService.add({id: this.dsContextHelp.id, isTooltipVisible: false});
|
this.contextHelpService.add({id: this.dsContextHelp.id, isTooltipVisible: false});
|
||||||
|
|
||||||
if (this.wrapper === undefined) {
|
if (this.wrapper === undefined) {
|
||||||
const factory
|
this.wrapper = this.viewContainerRef.createComponent(ContextHelpWrapperComponent);
|
||||||
= this.componentFactoryResolver.resolveComponentFactory(ContextHelpWrapperComponent);
|
|
||||||
this.wrapper = this.viewContainerRef.createComponent(factory);
|
|
||||||
}
|
}
|
||||||
this.wrapper.instance.templateRef = this.templateRef;
|
this.wrapper.setInput('templateRef', this.templateRef);
|
||||||
this.wrapper.instance.content = this.dsContextHelp.content;
|
this.wrapper.setInput('content', this.dsContextHelp.content);
|
||||||
this.wrapper.instance.id = this.dsContextHelp.id;
|
this.wrapper.setInput('id', this.dsContextHelp.id);
|
||||||
this.wrapper.instance.tooltipPlacement = this.dsContextHelp.tooltipPlacement;
|
this.wrapper.setInput('tooltipPlacement', this.dsContextHelp.tooltipPlacement);
|
||||||
this.wrapper.instance.iconPlacement = this.dsContextHelp.iconPlacement;
|
this.wrapper.setInput('iconPlacement', this.dsContextHelp.iconPlacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.clearMostRecentId();
|
this.clearMostRecentId();
|
||||||
|
if (hasValue(this.wrapper)) {
|
||||||
|
this.wrapper.destroy();
|
||||||
|
this.wrapper = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearMostRecentId(): void {
|
private clearMostRecentId(): void {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, ComponentFactoryResolver, ChangeDetectorRef } from '@angular/core';
|
import { Component, Input, ChangeDetectorRef } from '@angular/core';
|
||||||
import { ThemedComponent } from '../theme-support/themed.component';
|
import { ThemedComponent } from '../theme-support/themed.component';
|
||||||
import { LoadingComponent } from './loading.component';
|
import { LoadingComponent } from './loading.component';
|
||||||
import { ThemeService } from '../theme-support/theme.service';
|
import { ThemeService } from '../theme-support/theme.service';
|
||||||
@@ -20,11 +20,10 @@ export class ThemedLoadingComponent extends ThemedComponent<LoadingComponent> {
|
|||||||
protected inAndOutputNames: (keyof LoadingComponent & keyof this)[] = ['message', 'showMessage', 'spinner'];
|
protected inAndOutputNames: (keyof LoadingComponent & keyof this)[] = ['message', 'showMessage', 'spinner'];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected resolver: ComponentFactoryResolver,
|
|
||||||
protected cdr: ChangeDetectorRef,
|
protected cdr: ChangeDetectorRef,
|
||||||
protected themeService: ThemeService
|
protected themeService: ThemeService
|
||||||
) {
|
) {
|
||||||
super(resolver, cdr, themeService);
|
super(cdr, themeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getComponentName(): string {
|
protected getComponentName(): string {
|
||||||
|
@@ -6,7 +6,6 @@ import {
|
|||||||
ComponentRef,
|
ComponentRef,
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
ComponentFactoryResolver,
|
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
HostBinding,
|
HostBinding,
|
||||||
@@ -47,7 +46,6 @@ export abstract class ThemedComponent<T> implements AfterViewInit, OnDestroy, On
|
|||||||
@HostBinding('attr.data-used-theme') usedTheme: string;
|
@HostBinding('attr.data-used-theme') usedTheme: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected resolver: ComponentFactoryResolver,
|
|
||||||
protected cdr: ChangeDetectorRef,
|
protected cdr: ChangeDetectorRef,
|
||||||
protected themeService: ThemeService,
|
protected themeService: ThemeService,
|
||||||
) {
|
) {
|
||||||
@@ -118,8 +116,9 @@ export abstract class ThemedComponent<T> implements AfterViewInit, OnDestroy, On
|
|||||||
|
|
||||||
this.lazyLoadSub = this.lazyLoadObs.subscribe(([simpleChanges, constructor]: [SimpleChanges, GenericConstructor<T>]) => {
|
this.lazyLoadSub = this.lazyLoadObs.subscribe(([simpleChanges, constructor]: [SimpleChanges, GenericConstructor<T>]) => {
|
||||||
this.destroyComponentInstance();
|
this.destroyComponentInstance();
|
||||||
const factory = this.resolver.resolveComponentFactory(constructor);
|
this.compRef = this.vcr.createComponent(constructor, {
|
||||||
this.compRef = this.vcr.createComponent(factory, undefined, undefined, [this.themedElementContent.nativeElement.childNodes]);
|
projectableNodes: [this.themedElementContent.nativeElement.childNodes],
|
||||||
|
});
|
||||||
if (hasValue(simpleChanges)) {
|
if (hasValue(simpleChanges)) {
|
||||||
this.ngOnChanges(simpleChanges);
|
this.ngOnChanges(simpleChanges);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user