mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[AAE-3886] Cleanup the customModels when the attach file widget component gets destroyed (#6275)
This commit is contained in:
@@ -34,7 +34,7 @@ import {
|
||||
} from '@alfresco/adf-core';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ContentModule } from '@alfresco/adf-content-services';
|
||||
import { ContentModule, ContentNodeSelectorPanelService } from '@alfresco/adf-content-services';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
@@ -51,6 +51,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
let formService: FormService;
|
||||
let downloadService: DownloadService;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
let contentNodeSelectorPanelService: ContentNodeSelectorPanelService;
|
||||
let apiServiceSpy: jasmine.Spy;
|
||||
let contentModelFormFileHandlerSpy: jasmine.Spy;
|
||||
let updateFormSpy: jasmine.Spy;
|
||||
@@ -208,6 +209,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
);
|
||||
formService = TestBed.inject(FormService);
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService);
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
@@ -326,6 +328,13 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should reset the custom models when the component gets destroyed', () => {
|
||||
contentNodeSelectorPanelService.customModels = ['mock-value'];
|
||||
widget.ngOnDestroy();
|
||||
|
||||
expect(contentNodeSelectorPanelService.customModels).toEqual([]);
|
||||
});
|
||||
|
||||
describe('destinationFolderPath', () => {
|
||||
let openUploadFileDialogSpy: jasmine.Spy;
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
/* tslint:disable:component-selector */
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
FormService,
|
||||
LogService,
|
||||
@@ -53,7 +53,7 @@ import { ContentNodeSelectorPanelService } from '@alfresco/adf-content-services'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit {
|
||||
export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit, OnDestroy {
|
||||
|
||||
static ALIAS_ROOT_FOLDER = '-root-';
|
||||
static ALIAS_USER_FOLDER = '-my-';
|
||||
@@ -217,4 +217,8 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
||||
isValidAlias(alias: string): boolean {
|
||||
return alias && AttachFileCloudWidgetComponent.VALID_ALIAS.includes(alias);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.contentNodeSelectorPanelService.customModels = [];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user