[AAE-3115] Content node selector - Ability to select multiple files (#5904)

* Ability to select multiple files

* Fix unit test

* Rename event into NodeSelected

* restrict the typo

Co-authored-by: Denys Vuika <denys.vuika@alfresco.com>

Co-authored-by: Denys Vuika <denys.vuika@alfresco.com>
This commit is contained in:
Maurizio Vitale
2020-07-24 10:12:51 +01:00
committed by GitHub
parent 5a820cbecd
commit 1dde6bb1c5
16 changed files with 120 additions and 88 deletions

View File

@@ -108,17 +108,22 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent
}
openSelectDialog() {
const filesSaved: Node[] = [];
const selectedMode = this.field.params.multiple ? 'multiple' : 'single';
this.contentNodeSelectorService
.openUploadFileDialog(this.field.form.contentHost)
.openUploadFileDialog(this.field.form.contentHost, '-my-', selectedMode)
.subscribe((selections: Node[]) => {
selections.forEach(node => (node['isExternal'] = true));
filesSaved.push(selections[0]);
this.fixIncompatibilityFromPreviousAndNewForm(filesSaved);
const selectionWithoutDuplication = this.removeExistingSelection(selections);
this.fixIncompatibilityFromPreviousAndNewForm(selectionWithoutDuplication);
});
}
removeExistingSelection(selections: Node[]) {
const existingNode: Node[] = [...this.field.value || []];
return selections.filter(opt => !existingNode.some( (node) => node.id === opt.id));
}
isContentSourceSelected(): boolean {
return (
this.field.params &&

View File

@@ -32,7 +32,7 @@ export class ContentCloudNodeSelectorService {
private dialog: MatDialog) {
}
openUploadFileDialog(contentHost: string): Observable<Node[]> {
openUploadFileDialog(contentHost: string, currentFolderId?: string, selectionMode?: string): Observable<Node[]> {
const changedConfig = this.apiService.lastConfig;
changedConfig.provider = 'ALL';
changedConfig.hostEcm = contentHost.replace('/alfresco', '');
@@ -44,8 +44,9 @@ export class ContentCloudNodeSelectorService {
const data = <ContentNodeSelectorComponentData> {
title: 'Select a file',
actionName: 'Choose',
currentFolderId: '-my-',
currentFolderId,
select,
selectionMode,
isSelectionValid: (entry: Node) => entry.isFile,
showFilesInResult: true
};

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { TRANSLATION_PROVIDER, CoreModule, FormRenderingService } from '@alfresco/adf-core';
import { AppListCloudModule } from './app/app-list-cloud.module';
import { TaskCloudModule } from './task/task-cloud.module';
@@ -54,9 +54,7 @@ import { ProcessServicesCloudPipeModule } from './pipes/process-services-cloud-p
}
},
{ provide: PROCESS_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService },
{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService },
FormRenderingService,
{ provide: FormRenderingService, useClass: CloudFormRenderingService }
{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService }
],
exports: [
AppListCloudModule,
@@ -69,4 +67,30 @@ import { ProcessServicesCloudPipeModule } from './pipes/process-services-cloud-p
ProcessServicesCloudPipeModule
]
})
export class ProcessServicesCloudModule { }
export class ProcessServicesCloudModule {
static forRoot(): ModuleWithProviders<ProcessServicesCloudModule> {
return {
ngModule: ProcessServicesCloudModule,
providers: [
{
provide: TRANSLATION_PROVIDER,
multi: true,
useValue: {
name: 'adf-process-services-cloud',
source: 'assets/adf-process-services-cloud'
}
},
{ provide: PROCESS_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService },
{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService },
FormRenderingService,
{ provide: FormRenderingService, useClass: CloudFormRenderingService }
]
};
}
static forChild(): ModuleWithProviders<ProcessServicesCloudModule> {
return {
ngModule: ProcessServicesCloudModule
};
}
}

View File

@@ -31,7 +31,6 @@ import { ProcessDefinitionCloud } from '../models/process-definition-cloud.model
import { Subject, Observable } from 'rxjs';
import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model';
import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
@Component({
selector: 'adf-cloud-start-process',
templateUrl: './start-process-cloud.component.html',