mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3603] Destination picker is not opening on My Files when clicking on Attach file widget (#5865)
* [ACA-3603] Destination picker is not opening on My Files when clicking on Attach file widget * * * * Fixed failing unit tests * * Used openFileBrowseDialogByFolderId
This commit is contained in:
@@ -102,6 +102,15 @@ export class ContentNodeDialogService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a file browser at a default myFile location.
|
||||||
|
* shows files and folders in the dialog search result.
|
||||||
|
* @returns Information about the selected file(s)
|
||||||
|
*/
|
||||||
|
openFileBrowseDialogByDefaultLocation(): Observable<Node[]> {
|
||||||
|
return this.openFileBrowseDialogByFolderId('-my-');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a folder browser at a chosen site location.
|
* Opens a folder browser at a chosen site location.
|
||||||
* @returns Information about the selected folder(s)
|
* @returns Information about the selected folder(s)
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation, OnDestroy } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||||
import { SitesService, LogService } from '@alfresco/adf-core';
|
import { SitesService, LogService } from '@alfresco/adf-core';
|
||||||
import { SitePaging, SiteEntry } from '@alfresco/js-api';
|
import { SitePaging, SiteEntry } from '@alfresco/js-api';
|
||||||
import { MatSelect } from '@angular/material/select';
|
import { MatSelect, MatSelectChange } from '@angular/material/select';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ export class DropdownSitesComponent implements OnInit, OnDestroy {
|
|||||||
return event.target.scrollTop >= (event.target.scrollHeight - event.target.offsetHeight - this.ITEM_HEIGHT_TO_WAIT_BEFORE_LOAD_NEXT);
|
return event.target.scrollTop >= (event.target.scrollHeight - event.target.offsetHeight - this.ITEM_HEIGHT_TO_WAIT_BEFORE_LOAD_NEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedSite(event: any) {
|
selectedSite(event: MatSelectChange) {
|
||||||
this.change.emit(event.value);
|
this.change.emit(event.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ export interface AttachFileWidgetDialogComponentData {
|
|||||||
title: string;
|
title: string;
|
||||||
actionName?: string;
|
actionName?: string;
|
||||||
selected: Subject<Node[]>;
|
selected: Subject<Node[]>;
|
||||||
|
currentFolderId: string;
|
||||||
ecmHost: string;
|
ecmHost: string;
|
||||||
context?: string;
|
context?: string;
|
||||||
isSelectionValid?: (entry: Node) => boolean;
|
isSelectionValid?: (entry: Node) => boolean;
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
</adf-login-dialog-panel>
|
</adf-login-dialog-panel>
|
||||||
<adf-content-node-selector-panel *ngIf="isLoggedIn()"
|
<adf-content-node-selector-panel *ngIf="isLoggedIn()"
|
||||||
id="attach-file-content-node"
|
id="attach-file-content-node"
|
||||||
|
[currentFolderId]="data?.currentFolderId"
|
||||||
[isSelectionValid]="data?.isSelectionValid"
|
[isSelectionValid]="data?.isSelectionValid"
|
||||||
[showFilesInResult]="data?.showFilesInResult"
|
[showFilesInResult]="data?.showFilesInResult"
|
||||||
(select)="onSelect($event)"
|
(select)="onSelect($event)"
|
||||||
|
@@ -17,15 +17,15 @@
|
|||||||
|
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
import { ContentModule, ContentNodeSelectorPanelComponent } from '@alfresco/adf-content-services';
|
import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService } from '@alfresco/adf-content-services';
|
||||||
import { EventEmitter } from '@angular/core';
|
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||||
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
||||||
import { setupTestBed, AuthenticationService, SitesService } from '@alfresco/adf-core';
|
import { setupTestBed, AuthenticationService, SitesService, AlfrescoApiService, AlfrescoApiServiceMock, NodesApiService } from '@alfresco/adf-core';
|
||||||
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
||||||
import { of } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node, SiteEntry, NodeEntry } from '@alfresco/js-api';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
describe('AttachFileWidgetDialogComponent', () => {
|
describe('AttachFileWidgetDialogComponent', () => {
|
||||||
@@ -35,14 +35,18 @@ describe('AttachFileWidgetDialogComponent', () => {
|
|||||||
const data: AttachFileWidgetDialogComponentData = {
|
const data: AttachFileWidgetDialogComponentData = {
|
||||||
title: 'Choose along citizen...',
|
title: 'Choose along citizen...',
|
||||||
actionName: 'Choose',
|
actionName: 'Choose',
|
||||||
|
currentFolderId: '-my-',
|
||||||
selected: new EventEmitter<any>(),
|
selected: new EventEmitter<any>(),
|
||||||
ecmHost: 'http://fakeUrl.com/'
|
ecmHost: 'http://fakeUrl.com'
|
||||||
};
|
};
|
||||||
let element: HTMLInputElement;
|
let element: HTMLInputElement;
|
||||||
let authService: AuthenticationService;
|
let authService: AuthenticationService;
|
||||||
let siteService: SitesService;
|
let siteService: SitesService;
|
||||||
|
let nodeService: NodesApiService;
|
||||||
|
let documentListService: DocumentListService;
|
||||||
|
|
||||||
let isLogged = false;
|
let isLogged = false;
|
||||||
|
const fakeSite = new SiteEntry({ entry: { id: 'fake-site', guid: 'fake-site', title: 'fake-site', visibility: 'visible' } });
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -51,8 +55,10 @@ describe('AttachFileWidgetDialogComponent', () => {
|
|||||||
ContentModule.forRoot()
|
ContentModule.forRoot()
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: MAT_DIALOG_DATA, useValue: data }
|
{ provide: MAT_DIALOG_DATA, useValue: data },
|
||||||
]
|
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
@@ -61,6 +67,14 @@ describe('AttachFileWidgetDialogComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
authService = fixture.debugElement.injector.get(AuthenticationService);
|
authService = fixture.debugElement.injector.get(AuthenticationService);
|
||||||
siteService = fixture.debugElement.injector.get(SitesService);
|
siteService = fixture.debugElement.injector.get(SitesService);
|
||||||
|
nodeService = fixture.debugElement.injector.get(NodesApiService);
|
||||||
|
documentListService = fixture.debugElement.injector.get(DocumentListService);
|
||||||
|
|
||||||
|
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
|
||||||
|
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
||||||
|
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } }));
|
||||||
|
|
||||||
|
spyOn(siteService, 'getSite').and.returnValue(of(fakeSite));
|
||||||
spyOn(siteService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
spyOn(siteService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||||
spyOn(widget, 'isLoggedIn').and.callFake(() => {
|
spyOn(widget, 'isLoggedIn').and.callFake(() => {
|
||||||
return isLogged;
|
return isLogged;
|
||||||
|
@@ -54,6 +54,7 @@ export class AttachFileWidgetDialogService {
|
|||||||
actionName,
|
actionName,
|
||||||
selected,
|
selected,
|
||||||
ecmHost,
|
ecmHost,
|
||||||
|
currentFolderId: '-my-',
|
||||||
context,
|
context,
|
||||||
isSelectionValid: (entry: Node) => entry.isFile,
|
isSelectionValid: (entry: Node) => entry.isFile,
|
||||||
showFilesInResult: true
|
showFilesInResult: true
|
||||||
|
@@ -241,7 +241,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
it('should isLink property of the selected node become true when the widget has link enabled', async (done) => {
|
it('should isLink property of the selected node become true when the widget has link enabled', async (done) => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@@ -267,7 +267,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
it('should isLink property of the selected node become false when the widget has link disabled', async (done) => {
|
it('should isLink property of the selected node become false when the widget has link disabled', async (done) => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@@ -293,7 +293,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
it('should be able to upload files coming from content node selector', async(() => {
|
it('should be able to upload files coming from content node selector', async(() => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@@ -323,7 +323,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
};
|
};
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValues(of(fakePngAnswer), of(fakePngUpload));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValues(of(fakePngAnswer), of(fakePngUpload));
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
|
@@ -215,7 +215,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
this.uploadFileFromCS(selections, accountIdentifier);
|
this.uploadFileFromCS(selections, accountIdentifier);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.contentDialog.openFileBrowseDialogBySite().subscribe(
|
this.contentDialog.openFileBrowseDialogByDefaultLocation().subscribe(
|
||||||
(selections: Node[]) => {
|
(selections: Node[]) => {
|
||||||
this.tempFilesList.push(...selections);
|
this.tempFilesList.push(...selections);
|
||||||
this.uploadFileFromCS(selections, accountIdentifier);
|
this.uploadFileFromCS(selections, accountIdentifier);
|
||||||
|
Reference in New Issue
Block a user