From f8c1b0f6cc103e94960380c0f91afa13da4a9874 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 19 Sep 2024 15:07:15 -0400 Subject: [PATCH] migrate cloud components --- .../display-rich-text.widget.spec.ts | 4 +-- .../display-rich-text.widget.ts | 1 + .../file-viewer/file-viewer.widget.spec.ts | 6 ++-- .../widgets/file-viewer/file-viewer.widget.ts | 7 ++++- .../widgets/group/group-cloud.widget.spec.ts | 3 +- .../widgets/group/group-cloud.widget.ts | 29 ++++++++++--------- .../src/lib/form/form-cloud.module.ts | 10 +++---- .../components/group-cloud.component.spec.ts | 2 +- .../group/components/group-cloud.component.ts | 26 ++++++++++++++++- .../src/lib/group/group-cloud.module.ts | 9 +----- .../src/lib/group/pipe/group-initial.pipe.ts | 6 ++-- 11 files changed, 63 insertions(+), 40 deletions(-) diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.spec.ts index cf72fb7d03..a7c11dde26 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.spec.ts @@ -81,7 +81,7 @@ describe('DisplayRichTextWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [CoreTestingModule] + imports: [CoreTestingModule, DisplayRichTextWidgetComponent] }); fixture = TestBed.createComponent(DisplayRichTextWidgetComponent); widget = fixture.componentInstance; @@ -94,7 +94,7 @@ describe('DisplayRichTextWidgetComponent', () => { expect(widget).toBeTruthy(); }); - it('should parse editorjs data to html', async () => { + it('should parse editor.js data to html', async () => { const expectedHtml = '

Editor.js

Display some formatted text

'; diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts index dbef7784d5..fa42b58968 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts @@ -24,6 +24,7 @@ import { DomSanitizer } from '@angular/platform-browser'; @Component({ selector: 'display-rich-text', + standalone: true, templateUrl: './display-rich-text.widget.html', styleUrls: ['./display-rich-text.widget.scss'], host: { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.spec.ts index 63bc504ba0..323c638d41 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.spec.ts @@ -15,10 +15,9 @@ * limitations under the License. */ -import { TranslateModule } from '@ngx-translate/core'; import { FileViewerWidgetComponent } from './file-viewer.widget'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormModel, FormService, FormFieldModel } from '@alfresco/adf-core'; +import { FormModel, FormService, FormFieldModel, NoopTranslateModule } from '@alfresco/adf-core'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; describe('FileViewerWidgetComponent', () => { @@ -44,8 +43,7 @@ describe('FileViewerWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot()], - declarations: [FileViewerWidgetComponent], + imports: [NoopTranslateModule, FileViewerWidgetComponent], providers: [{ provide: FormService, useValue: formServiceStub }], schemas: [CUSTOM_ELEMENTS_SCHEMA] }); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts index 146067c3a2..f8cb32b785 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts @@ -16,12 +16,17 @@ */ import { Component, ViewEncapsulation } from '@angular/core'; -import { FormService, BaseViewerWidgetComponent } from '@alfresco/adf-core'; +import { FormService, BaseViewerWidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { AlfrescoViewerComponent } from '@alfresco/adf-content-services'; /* eslint-disable @angular-eslint/component-selector */ @Component({ selector: 'file-viewer-widget', + standalone: true, + imports: [CommonModule, TranslateModule, AlfrescoViewerComponent, ErrorWidgetComponent], templateUrl: './file-viewer.widget.html', styleUrls: ['./file-viewer.widget.scss'], host: { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.spec.ts index 2b31b57d84..0ecfe81892 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.spec.ts @@ -33,8 +33,7 @@ describe('GroupCloudWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], - declarations: [GroupCloudWidgetComponent], + imports: [ProcessServiceCloudTestingModule, GroupCloudWidgetComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA] }); fixture = TestBed.createComponent(GroupCloudWidgetComponent); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts index d022b94271..9f4a150404 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts @@ -16,17 +16,22 @@ */ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; -import { WidgetComponent, FormService } from '@alfresco/adf-core'; +import { WidgetComponent, FormService, ErrorWidgetComponent } from '@alfresco/adf-core'; import { UntypedFormControl } from '@angular/forms'; import { filter, takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; import { ComponentSelectionMode } from '../../../../types'; import { IdentityGroupModel } from '../../../../group/models/identity-group.model'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { GroupCloudComponent } from '../../../../group/components/group-cloud.component'; /* eslint-disable @angular-eslint/component-selector */ @Component({ selector: 'group-cloud-widget', + standalone: true, + imports: [CommonModule, TranslateModule, ErrorWidgetComponent, GroupCloudComponent], templateUrl: './group-cloud.widget.html', host: { '(click)': 'event($event)', @@ -42,7 +47,6 @@ import { IdentityGroupModel } from '../../../../group/models/identity-group.mode encapsulation: ViewEncapsulation.None }) export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy { - private onDestroy$ = new Subject(); typeId = 'GroupCloudWidgetComponent'; @@ -66,17 +70,16 @@ export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit this.validate = this.field.readOnly ? false : true; } // eslint-disable-next-line @typescript-eslint/no-unused-expressions - this.search = new UntypedFormControl({value: '', disabled: this.field.readOnly}, []), - - this.search.statusChanges - .pipe( - filter((value: string) => value === 'INVALID'), - takeUntil(this.onDestroy$) - ) - .subscribe(() => { - this.field.markAsInvalid(); - this.field.form.markAsInvalid(); - }); + (this.search = new UntypedFormControl({ value: '', disabled: this.field.readOnly }, [])), + this.search.statusChanges + .pipe( + filter((value: string) => value === 'INVALID'), + takeUntil(this.onDestroy$) + ) + .subscribe(() => { + this.field.markAsInvalid(); + this.field.form.markAsInvalid(); + }); this.search.statusChanges .pipe( diff --git a/lib/process-services-cloud/src/lib/form/form-cloud.module.ts b/lib/process-services-cloud/src/lib/form/form-cloud.module.ts index 70245e7b6e..77b00e15fb 100644 --- a/lib/process-services-cloud/src/lib/form/form-cloud.module.ts +++ b/lib/process-services-cloud/src/lib/form/form-cloud.module.ts @@ -69,7 +69,10 @@ import { FormSpinnerComponent } from './components/spinner/form-spinner.componen FormSpinnerComponent, UploadCloudWidgetComponent, AttachFileCloudWidgetComponent, - FilePropertiesTableCloudComponent + FilePropertiesTableCloudComponent, + DisplayRichTextWidgetComponent, + FileViewerWidgetComponent, + GroupCloudWidgetComponent ], declarations: [ FormCloudComponent, @@ -77,11 +80,8 @@ import { FormSpinnerComponent } from './components/spinner/form-spinner.componen FormCustomOutcomesComponent, RadioButtonsCloudWidgetComponent, PeopleCloudWidgetComponent, - GroupCloudWidgetComponent, PropertiesViewerWrapperComponent, - PropertiesViewerWidgetComponent, - FileViewerWidgetComponent, - DisplayRichTextWidgetComponent + PropertiesViewerWidgetComponent ], exports: [ FormCloudComponent, diff --git a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts index 34164b9cd6..c7b3798a97 100644 --- a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts @@ -72,7 +72,7 @@ describe('GroupCloudComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [CoreTestingModule, GroupCloudModule] + imports: [CoreTestingModule, GroupCloudModule, GroupCloudComponent] }); fixture = TestBed.createComponent(GroupCloudComponent); component = fixture.componentInstance; diff --git a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts index 6284142fa7..99058c07f7 100644 --- a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts @@ -29,7 +29,7 @@ import { OnDestroy, Inject } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; +import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms'; import { trigger, state, style, transition, animate } from '@angular/animations'; import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { distinctUntilChanged, switchMap, mergeMap, filter, tap, takeUntil, debounceTime } from 'rxjs/operators'; @@ -37,9 +37,33 @@ import { ComponentSelectionMode } from '../../types'; import { IdentityGroupModel } from '../models/identity-group.model'; import { IdentityGroupServiceInterface } from '../services/identity-group.service.interface'; import { IDENTITY_GROUP_SERVICE_TOKEN } from '../services/identity-group-service.token'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatIconModule } from '@angular/material/icon'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; +import { MatSelectModule } from '@angular/material/select'; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; +import { MatChipsModule } from '@angular/material/chips'; +import { MatInputModule } from '@angular/material/input'; +import { MatButtonModule } from '@angular/material/button'; @Component({ selector: 'adf-cloud-group', + standalone: true, + imports: [ + CommonModule, + TranslateModule, + MatIconModule, + MatFormFieldModule, + MatProgressBarModule, + MatSelectModule, + MatAutocompleteModule, + MatChipsModule, + MatInputModule, + ReactiveFormsModule, + MatButtonModule + ], templateUrl: './group-cloud.component.html', styleUrls: ['./group-cloud.component.scss'], animations: [ diff --git a/lib/process-services-cloud/src/lib/group/group-cloud.module.ts b/lib/process-services-cloud/src/lib/group/group-cloud.module.ts index 60f1885408..bceb27055b 100644 --- a/lib/process-services-cloud/src/lib/group/group-cloud.module.ts +++ b/lib/process-services-cloud/src/lib/group/group-cloud.module.ts @@ -16,20 +16,13 @@ */ import { NgModule } from '@angular/core'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { CommonModule } from '@angular/common'; - -import { CoreModule } from '@alfresco/adf-core'; -import { MaterialModule } from '../material.module'; import { GroupCloudComponent } from './components/group-cloud.component'; import { InitialGroupNamePipe } from './pipe/group-initial.pipe'; import { IDENTITY_GROUP_SERVICE_TOKEN } from './services/identity-group-service.token'; import { IdentityGroupService } from './services/identity-group.service'; -import { MatProgressBarModule } from '@angular/material/progress-bar'; @NgModule({ - imports: [CommonModule, MaterialModule, FormsModule, ReactiveFormsModule, CoreModule, MatProgressBarModule], - declarations: [GroupCloudComponent, InitialGroupNamePipe], + imports: [GroupCloudComponent, InitialGroupNamePipe], providers: [{ provide: IDENTITY_GROUP_SERVICE_TOKEN, useExisting: IdentityGroupService }], exports: [GroupCloudComponent, InitialGroupNamePipe] }) diff --git a/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.ts b/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.ts index cb9e83a2f0..4719ea7f32 100644 --- a/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.ts +++ b/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.ts @@ -19,10 +19,10 @@ import { Pipe, PipeTransform } from '@angular/core'; import { IdentityGroupModel } from '../models/identity-group.model'; @Pipe({ - name: 'groupNameInitial' + name: 'groupNameInitial', + standalone: true }) export class InitialGroupNamePipe implements PipeTransform { - transform(group: IdentityGroupModel): string { let result = ''; if (group) { @@ -32,7 +32,7 @@ export class InitialGroupNamePipe implements PipeTransform { } getInitialGroupName(groupName: string) { - groupName = (groupName ? groupName[0] : ''); + groupName = groupName ? groupName[0] : ''; return groupName; } }