mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-11205] Add LazyApi decorator (#11711)
* [ACS-11205] Add LazyApi decorator * [ACS-11205] Add unit tests and CR fixes * [ACS-11259] Storybook build fix
This commit is contained in:
+5
-6
@@ -27,7 +27,7 @@ import {
|
||||
ErrorWidgetComponent,
|
||||
IconModule
|
||||
} from '@alfresco/adf-core';
|
||||
import { Node, NodesApi, RelatedContentRepresentation } from '@alfresco/js-api';
|
||||
import { LazyApi, Node, NodesApi, RelatedContentRepresentation } from '@alfresco/js-api';
|
||||
import { ContentCloudNodeSelectorService } from '../../../services/content-cloud-node-selector.service';
|
||||
import { UploadCloudWidgetComponent } from '../upload/upload-cloud.widget';
|
||||
import { DestinationFolderPathModel, DestinationFolderPathType } from '../../../models/form-cloud-representation.model';
|
||||
@@ -72,11 +72,10 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
||||
error = new EventEmitter<any>();
|
||||
|
||||
private previewState = false;
|
||||
private _nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
@LazyApi((self: AttachFileCloudWidgetComponent) => new NodesApi(self.apiService.getInstance()))
|
||||
declare readonly nodesApi: NodesApi;
|
||||
|
||||
displayedColumns = ['icon', 'fileName', 'title', 'action'];
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
+3
-6
@@ -19,7 +19,7 @@ import { Injectable, inject } from '@angular/core';
|
||||
import { NotificationService } from '@alfresco/adf-core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ContentNodeSelectorComponent, ContentNodeSelectorComponentData, NodeAction, AlfrescoApiService } from '@alfresco/adf-content-services';
|
||||
import { Node, NodeEntry, NodesApi } from '@alfresco/js-api';
|
||||
import { LazyApi, Node, NodeEntry, NodesApi } from '@alfresco/js-api';
|
||||
import { firstValueFrom, from, Observable, Subject, throwError } from 'rxjs';
|
||||
import { catchError, map, mapTo } from 'rxjs/operators';
|
||||
import { DestinationFolderPathModel } from '../models/form-cloud-representation.model';
|
||||
@@ -32,11 +32,8 @@ export class ContentCloudNodeSelectorService {
|
||||
private readonly notificationService = inject(NotificationService);
|
||||
private readonly dialog = inject(MatDialog);
|
||||
|
||||
private _nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
@LazyApi((self: ContentCloudNodeSelectorService) => new NodesApi(self.apiService.getInstance()))
|
||||
declare readonly nodesApi: NodesApi;
|
||||
|
||||
sourceNodeNotFound = false;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import { FormValues, FormModel, FormFieldOption, FormFieldValidator, FormService
|
||||
import { Observable, from, EMPTY } from 'rxjs';
|
||||
import { expand, map, reduce, switchMap } from 'rxjs/operators';
|
||||
import { TaskDetailsCloudModel } from '../../task/models/task-details-cloud.model';
|
||||
import { CompleteFormRepresentation, UploadApi } from '@alfresco/js-api';
|
||||
import { CompleteFormRepresentation, LazyApi, UploadApi } from '@alfresco/js-api';
|
||||
import { TaskVariableCloud } from '../models/task-variable-cloud.model';
|
||||
import { BaseCloudService } from '../../services/base-cloud.service';
|
||||
import { FormContent } from '../../services/form-fields.interfaces';
|
||||
@@ -32,13 +32,11 @@ export const FORM_CLOUD_SERVICE_FIELD_VALIDATORS_TOKEN = new InjectionToken<Form
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FormCloudService extends BaseCloudService implements FormCloudServiceInterface {
|
||||
private _uploadApi: UploadApi;
|
||||
private readonly fieldValidators: FormFieldValidator[] = inject(FORM_CLOUD_SERVICE_FIELD_VALIDATORS_TOKEN, { optional: true }) ?? [];
|
||||
private readonly formService = inject(FormService);
|
||||
get uploadApi(): UploadApi {
|
||||
this._uploadApi = this._uploadApi ?? new UploadApi(this.apiService.getInstance());
|
||||
return this._uploadApi;
|
||||
}
|
||||
|
||||
@LazyApi((self: FormCloudService) => new UploadApi(self.apiService.getInstance()))
|
||||
declare readonly uploadApi: UploadApi;
|
||||
|
||||
/**
|
||||
* Gets the form definition of a task.
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Observable, from } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DownloadService } from '@alfresco/adf-core';
|
||||
import { ContentService, NodesApiService, AlfrescoApiService } from '@alfresco/adf-content-services';
|
||||
import { AuthenticationApi, Node, UploadApi } from '@alfresco/js-api';
|
||||
import { AuthenticationApi, LazyApi, Node, UploadApi } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -31,17 +31,11 @@ export class ProcessCloudContentService {
|
||||
private readonly contentService = inject(ContentService);
|
||||
private readonly downloadService = inject(DownloadService);
|
||||
|
||||
private _uploadApi: UploadApi;
|
||||
get uploadApi(): UploadApi {
|
||||
this._uploadApi = this._uploadApi ?? new UploadApi(this.apiService.getInstance());
|
||||
return this._uploadApi;
|
||||
}
|
||||
@LazyApi((self: ProcessCloudContentService) => new UploadApi(self.apiService.getInstance()))
|
||||
uploadApi: UploadApi;
|
||||
|
||||
private _authenticationApi: AuthenticationApi;
|
||||
get authenticationApi(): AuthenticationApi {
|
||||
this._authenticationApi = this._authenticationApi ?? new AuthenticationApi(this.apiService.getInstance());
|
||||
return this._authenticationApi;
|
||||
}
|
||||
@LazyApi((self: ProcessCloudContentService) => new AuthenticationApi(self.apiService.getInstance()))
|
||||
authenticationApi: AuthenticationApi;
|
||||
|
||||
createTemporaryRawRelatedContent(file: File, nodeId: string): Observable<Node> {
|
||||
return from(this.uploadApi.uploadFile(file, '', nodeId, null, { overwrite: true })).pipe(
|
||||
|
||||
Reference in New Issue
Block a user