[AAE-10773] Make Form core process agonostic (#8032)

* move form list in a component

* move things in the right place

* move last pice in the right place

* move things in the right place

* move people and group in the right place

* move radio and typehead
form service start remove responsibilities

* remove model service and editor service from formService

* move dropdwon in process-service
finish remove service from form service

* fix some wrong import

* move activiti

* fix double quote imports

* move dynamic table

* fix shell

* move unit test

* [ci:force] fix lint issues

* fix build and some unit test

* fix process spec type spy problems [ci:foce]

* fix

* fix broken tests

* fix lint issues

* fix cloud dropdown test

* cleanup process-service-cloud tests

* fix people process

* improve e2e test

Co-authored-by: Kasia Biernat <kasia.biernat@hyland.com>
This commit is contained in:
Eugenio Romano
2022-12-21 15:12:38 +00:00
committed by GitHub
parent eb27d38eba
commit a535af667b
180 changed files with 1971 additions and 3260 deletions

View File

@@ -0,0 +1,124 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MatDialog } from '@angular/material/dialog';
import { EventEmitter, Injectable, Output } from '@angular/core';
import { AlfrescoApiService, TranslationService } from '@alfresco/adf-core';
import { Observable, of, Subject } from 'rxjs';
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
import { AlfrescoEndpointRepresentation, Node, ContentApi } from '@alfresco/js-api';
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
import { switchMap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
// eslint-disable-next-line @angular-eslint/directive-class-suffix
export class AttachFileWidgetDialogService {
/** Emitted when an error occurs. */
@Output()
error = new EventEmitter<any>();
private externalApis: { [key: string]: AlfrescoApiService } = {};
constructor(private dialog: MatDialog,
private translation: TranslationService) {
}
/**
* Opens a dialog to choose a file to upload.
*
* @param repository Alfresco endpoint that represents the content service
* @param currentFolderId Upload file from specific folder
* @returns Information about the chosen file(s)
*/
openLogin(repository: AlfrescoEndpointRepresentation, currentFolderId = '-my-', accountIdentifier?: string): Observable<Node[]> {
const { title, ecmHost, selected, registerExternalHost } = this.constructPayload(repository);
const data: AttachFileWidgetDialogComponentData = {
title,
selected,
ecmHost,
currentFolderId,
isSelectionValid: (entry: Node) => entry.isFile,
showFilesInResult: true,
registerExternalHost,
accountIdentifier
};
this.openLoginDialog(data, 'adf-attach-file-widget-dialog', '630px');
return selected;
}
downloadURL(repository: AlfrescoEndpointRepresentation, sourceId: string): Observable<string> {
const { accountIdentifier } = this.constructPayload(repository);
if (this.externalApis[accountIdentifier]?.getInstance()) {
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());
if (this.externalApis[accountIdentifier].getInstance().isLoggedIn()) {
return of(contentApi.getContentUrl(sourceId));
}
}
return this.showExternalHostLoginDialog(repository).pipe(
switchMap(() => {
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());
return of(contentApi.getContentUrl(sourceId));
})
);
}
addService(accountIdentifier: string, apiService: AlfrescoApiService) {
if (!this.externalApis[accountIdentifier]) {
this.externalApis[accountIdentifier] = apiService;
}
}
/** Closes the currently open dialog. */
close() {
this.dialog.closeAll();
}
private openLoginDialog(data: AttachFileWidgetDialogComponentData, currentPanelClass: string, chosenWidth: string) {
this.dialog.open(AttachFileWidgetDialogComponent, { data, panelClass: currentPanelClass, width: chosenWidth });
}
private showExternalHostLoginDialog(repository: AlfrescoEndpointRepresentation): Observable<AlfrescoApiService> {
const data = {
...this.constructPayload(repository),
loginOnly: true
};
return this.dialog.open(AttachFileWidgetDialogComponent, { data, panelClass: 'adf-attach-file-widget-dialog', width: '630px' })
.afterClosed();
}
private constructPayload(repository: AlfrescoEndpointRepresentation) {
const accountIdentifier = 'alfresco-' + repository.id + '-' + repository.name;
const ecmHost = repository.repositoryUrl.replace('/alfresco', '');
const selected = new Subject<Node[]>();
selected.subscribe({
complete: this.close.bind(this)
});
const title = this.getLoginTitleTranslation(ecmHost);
const registerExternalHost = this.addService.bind(this);
return { ecmHost, accountIdentifier, selected, title, registerExternalHost };
}
private getLoginTitleTranslation(ecmHost: string): string {
return this.translation.instant(`ATTACH-FILE.DIALOG.LOGIN`, { ecmHost });
}
}