diff --git a/lib/core/src/lib/avatar/avatar.component.spec.ts b/lib/core/src/lib/avatar/avatar.component.spec.ts index 7fa3b41e87..edebb3205f 100644 --- a/lib/core/src/lib/avatar/avatar.component.spec.ts +++ b/lib/core/src/lib/avatar/avatar.component.spec.ts @@ -34,10 +34,6 @@ describe('AvatarComponent', () => { const getAvatarImageElement = (): HTMLImageElement => fixture.nativeElement.querySelector('.adf-avatar__image'); - it('should create', () => { - expect(component).toBeTruthy(); - }); - it('should display initials when src is not provided', () => { component.src = ''; fixture.detectChanges(); diff --git a/lib/core/src/lib/form/components/form-base.component.ts b/lib/core/src/lib/form/components/form-base.component.ts index 3e90bb04db..22e6051083 100644 --- a/lib/core/src/lib/form/components/form-base.component.ts +++ b/lib/core/src/lib/form/components/form-base.component.ts @@ -24,6 +24,8 @@ import { FormFieldModel, FormFieldValidator, FormModel, FormOutcomeEvent, FormOu }) // eslint-disable-next-line @angular-eslint/directive-class-suffix export abstract class FormBaseComponent { + protected _form: FormModel; + static SAVE_OUTCOME_ID: string = '$save'; static COMPLETE_OUTCOME_ID: string = '$complete'; static START_PROCESS_OUTCOME_ID: string = '$startProcess'; @@ -96,7 +98,27 @@ export abstract class FormBaseComponent { @Output() error = new EventEmitter(); - form: FormModel; + /** + * Custom style that is backed by the form.theme. + */ + formStyle: string = ''; + + get form(): FormModel { + return this._form; + } + + /** Underlying form model instance. */ + @Input() + set form(form: FormModel) { + this._form = form; + + if (form) { + const theme = form.theme?.form; + this.formStyle = theme ? this.flattenStyles(theme) : ''; + } else { + this.formStyle = ''; + } + } getParsedFormDefinition(): FormBaseComponent { return this; @@ -226,4 +248,10 @@ export abstract class FormBaseComponent { protected abstract storeFormAsMetadata(): void; protected abstract onExecuteOutcome(outcome: FormOutcomeModel): boolean; + + private flattenStyles(styles: { [key: string]: string }): string { + return Object.entries(styles) + .map(([key, value]) => `${key}: ${value}`) + .join(';'); + } } diff --git a/lib/core/src/lib/form/components/widgets/core/index.ts b/lib/core/src/lib/form/components/widgets/core/index.ts index ac251bf4c0..c6ca497270 100644 --- a/lib/core/src/lib/form/components/widgets/core/index.ts +++ b/lib/core/src/lib/form/components/widgets/core/index.ts @@ -47,3 +47,4 @@ export * from './form-field-variable-options'; export * from './widget-schema.model'; export * from './theme.model'; export * from './predefined-theme'; +export * from './displayable-cm-properties.model'; diff --git a/lib/core/src/lib/form/components/widgets/index.ts b/lib/core/src/lib/form/components/widgets/index.ts index 417902f9f7..230570782e 100644 --- a/lib/core/src/lib/form/components/widgets/index.ts +++ b/lib/core/src/lib/form/components/widgets/index.ts @@ -57,7 +57,7 @@ export * from './text/text-mask.component'; export * from './display-text'; export * from './header'; -export const WIDGET_DIRECTIVES: any[] = [ +export const WIDGET_DIRECTIVES = [ UnknownWidgetComponent, TextWidgetComponent, NumberWidgetComponent, @@ -72,6 +72,6 @@ export const WIDGET_DIRECTIVES: any[] = [ DateTimeWidgetComponent, JsonWidgetComponent, BaseViewerWidgetComponent -]; +] as const; -export const MASK_DIRECTIVE: any[] = [InputMaskDirective]; +export const MASK_DIRECTIVE = [InputMaskDirective] as const; diff --git a/lib/core/src/lib/form/pipes/form-style.pipe.spec.ts b/lib/core/src/lib/form/pipes/form-style.pipe.spec.ts deleted file mode 100644 index e2c844bb02..0000000000 --- a/lib/core/src/lib/form/pipes/form-style.pipe.spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -/*! - * @license - * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * 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 { FormStylePipe } from './form-style.pipe'; -import { ThemeModel } from '../components/widgets/core/theme.model'; - -describe('FormStylePipe', () => { - let pipe: FormStylePipe; - - beforeEach(() => { - pipe = new FormStylePipe(); - }); - - it('should transform form theme into styles', () => { - const formTheme: ThemeModel = { - form: { - '--adf-form-label-font-size': '16px', - '--adf-form-label-color': 'black', - '--adf-form-label-font-weight': 'bold' - } - }; - - const result = pipe.transform(formTheme); - - expect(result).toEqual('--adf-form-label-font-size: 16px;--adf-form-label-color: black;--adf-form-label-font-weight: bold'); - }); - - it('should return an empty string if form theme is undefined', () => { - const result = pipe.transform(undefined); - - expect(result).toEqual(''); - }); -}); diff --git a/lib/core/src/lib/form/pipes/form-style.pipe.ts b/lib/core/src/lib/form/pipes/form-style.pipe.ts deleted file mode 100644 index c11445cffa..0000000000 --- a/lib/core/src/lib/form/pipes/form-style.pipe.ts +++ /dev/null @@ -1,36 +0,0 @@ -/*! - * @license - * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * 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 { Pipe, PipeTransform } from '@angular/core'; -import { ThemeModel } from '../components/widgets/core/theme.model'; - -@Pipe({ - name: 'adfFormStyle', - standalone: true -}) -export class FormStylePipe implements PipeTransform { - transform(formTheme?: ThemeModel): string { - const theme = formTheme?.form; - return theme ? this.flattenStyles(theme) : ''; - } - - private flattenStyles(styles: { [key: string]: string }): string { - return Object.entries(styles) - .map(([key, value]) => `${key}: ${value}`) - .join(';'); - } -} diff --git a/lib/core/src/lib/form/pipes/index.ts b/lib/core/src/lib/form/pipes/index.ts index f109368968..cbbf53bca5 100644 --- a/lib/core/src/lib/form/pipes/index.ts +++ b/lib/core/src/lib/form/pipes/index.ts @@ -16,4 +16,3 @@ */ export * from './field-style.pipe'; -export * from './form-style.pipe'; diff --git a/lib/core/src/lib/header/navbar/navbar-item.component.spec.ts b/lib/core/src/lib/header/navbar/navbar-item.component.spec.ts index 760e4076a3..07032ab223 100644 --- a/lib/core/src/lib/header/navbar/navbar-item.component.spec.ts +++ b/lib/core/src/lib/header/navbar/navbar-item.component.spec.ts @@ -38,10 +38,6 @@ describe('NavbarItemComponent', () => { button = fixture.nativeElement.querySelector('.adf-navbar-item-btn'); }); - it('should create', () => { - expect(component).toBeTruthy(); - }); - it('should display label', () => { fixture.detectChanges(); expect(button.textContent).toContain('Test Label'); diff --git a/lib/core/src/lib/progress/progress.component.spec.ts b/lib/core/src/lib/progress/progress.component.spec.ts index f65046b7e1..b5f755f55d 100644 --- a/lib/core/src/lib/progress/progress.component.spec.ts +++ b/lib/core/src/lib/progress/progress.component.spec.ts @@ -40,10 +40,6 @@ describe('ProgressComponent', () => { fixture.detectChanges(); }); - it('should create', () => { - expect(component).toBeTruthy(); - }); - it('should default to bar variant and indeterminate mode', () => { expect(component.variant).toBe('bar'); expect(component.mode).toBe('indeterminate'); diff --git a/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts b/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts index 05cf2177a6..8697e2263d 100644 --- a/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts +++ b/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts @@ -36,18 +36,21 @@ export class CloudFormRenderingService extends FormRenderingService { constructor() { super(); - this.register({ - [FormFieldTypes.UPLOAD]: () => AttachFileCloudWidgetComponent, - [FormFieldTypes.DROPDOWN]: () => DropdownCloudWidgetComponent, - [FormFieldTypes.DATE]: () => DateCloudWidgetComponent, - [FormFieldTypes.PEOPLE]: () => PeopleCloudWidgetComponent, - [FormFieldTypes.FUNCTIONAL_GROUP]: () => GroupCloudWidgetComponent, - [FormFieldTypes.PROPERTIES_VIEWER]: () => PropertiesViewerWidgetComponent, - [FormFieldTypes.RADIO_BUTTONS]: () => RadioButtonsCloudWidgetComponent, - [FormFieldTypes.ALFRESCO_FILE_VIEWER]: () => FileViewerWidgetComponent, - [FormFieldTypes.DISPLAY_RICH_TEXT]: () => DisplayRichTextWidgetComponent, - [FormFieldTypes.DATA_TABLE]: () => DataTableWidgetComponent, - [FormFieldTypes.DISPLAY_EXTERNAL_PROPERTY]: () => DisplayExternalPropertyWidgetComponent - }, true); + this.register( + { + [FormFieldTypes.UPLOAD]: () => AttachFileCloudWidgetComponent, + [FormFieldTypes.DROPDOWN]: () => DropdownCloudWidgetComponent, + [FormFieldTypes.DATE]: () => DateCloudWidgetComponent, + [FormFieldTypes.PEOPLE]: () => PeopleCloudWidgetComponent, + [FormFieldTypes.FUNCTIONAL_GROUP]: () => GroupCloudWidgetComponent, + [FormFieldTypes.PROPERTIES_VIEWER]: () => PropertiesViewerWidgetComponent, + [FormFieldTypes.RADIO_BUTTONS]: () => RadioButtonsCloudWidgetComponent, + [FormFieldTypes.ALFRESCO_FILE_VIEWER]: () => FileViewerWidgetComponent, + [FormFieldTypes.DISPLAY_RICH_TEXT]: () => DisplayRichTextWidgetComponent, + [FormFieldTypes.DATA_TABLE]: () => DataTableWidgetComponent, + [FormFieldTypes.DISPLAY_EXTERNAL_PROPERTY]: () => DisplayExternalPropertyWidgetComponent + }, + true + ); } } diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.spec.ts index 22b9717794..ce575597fa 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.spec.ts @@ -21,10 +21,14 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module'; import { FormCloudComponent } from './form-cloud.component'; +import { FormCustomOutcomesComponent } from './form-cloud-custom-outcomes.component'; +import { MatButtonModule } from '@angular/material/button'; @Component({ selector: 'adf-cloud-form-with-custom-outcomes', - template: ` + standalone: true, + imports: [FormCustomOutcomesComponent, FormCloudComponent, MatButtonModule], + template: ` @@ -36,7 +40,6 @@ class FormCloudWithCustomOutComesComponent { adfCloudForm: FormCloudComponent; onCustomButtonOneClick() {} - onCustomButtonTwoClick() {} } @@ -47,8 +50,7 @@ describe('FormCloudWithCustomOutComesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], - declarations: [FormCloudWithCustomOutComesComponent] + imports: [ProcessServiceCloudTestingModule, FormCloudWithCustomOutComesComponent] }); fixture = TestBed.createComponent(FormCloudWithCustomOutComesComponent); customComponent = fixture.componentInstance; @@ -58,8 +60,7 @@ describe('FormCloudWithCustomOutComesComponent', () => { outcomes: [{ id: 'outcome-1', name: 'outcome 1' }] }; - const form = new FormModel(formRepresentation); - customComponent.adfCloudForm.form = form; + customComponent.adfCloudForm.form = new FormModel(formRepresentation); fixture.detectChanges(); }); diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.ts index 9307736778..a01e18b9b9 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud-custom-outcomes.component.ts @@ -19,6 +19,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'adf-cloud-form-custom-outcomes', + standalone: true, template: '' }) export class FormCustomOutcomesComponent {} diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html index 52af230b34..8b3a76d0e4 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html @@ -6,7 +6,7 @@
+ [style]="formStyle">
@@ -22,78 +22,75 @@
- + -
- - -

-
- check_circle - - error - -
-
- -
-
- -
- {{form.taskName}} - - {{'FORM.FORM_RENDERER.NAMELESS_TASK' | translate}} - - -

-
-
- - - - - - - - - + + +

+
+ check_circle + + error + +
+
+ +
+
+ +
+ {{form.taskName}} + + {{'FORM.FORM_RENDERER.NAMELESS_TASK' | translate}} + + +

+
+
+ + + + + + + + +
- \ No newline at end of file + diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts index f3f84be0e6..f8d3635a43 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts @@ -32,7 +32,8 @@ import { WidgetVisibilityService, provideTranslations, AuthModule, - FormFieldEvent + FormFieldEvent, + NoopTranslateModule } from '@alfresco/adf-core'; import { Node } from '@alfresco/js-api'; import { ESCAPE } from '@angular/cdk/keycodes'; @@ -46,7 +47,6 @@ import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { Observable, of, throwError } from 'rxjs'; -import { FormCloudModule } from '../form-cloud.module'; import { cloudFormMock, conditionalUploadWidgetsMock, @@ -98,7 +98,7 @@ describe('FormCloudComponent', () => { const resolver = formRenderingService.getComponentTypeResolver(type); const widgetType = resolver(null); - const factoryResolver: ComponentFactoryResolver = TestBed.inject(ComponentFactoryResolver); + const factoryResolver = TestBed.inject(ComponentFactoryResolver); const factory = factoryResolver.resolveComponentFactory(widgetType); const componentRef = factory.create(injector); @@ -107,7 +107,7 @@ describe('FormCloudComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], + imports: [ProcessServiceCloudTestingModule, FormCloudComponent], providers: [ { provide: VersionCompatibilityService, @@ -1539,7 +1539,7 @@ describe('retrieve metadata on submit', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [AuthModule.forRoot({ useHash: true }), NoopAnimationsModule, TranslateModule.forRoot(), CoreModule.forRoot(), FormCloudModule], + imports: [AuthModule.forRoot({ useHash: true }), NoopAnimationsModule, NoopTranslateModule, CoreModule.forRoot(), FormCloudComponent], providers: [ provideTranslations('app', 'resources'), { diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts index e5054d83e4..5b9609a6b0 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts @@ -34,6 +34,7 @@ import { ConfirmDialogComponent, ContentLinkModel, FORM_FIELD_VALIDATORS, + FormatSpacePipe, FormBaseComponent, FormEvent, FormFieldModel, @@ -41,8 +42,11 @@ import { FormModel, FormOutcomeEvent, FormOutcomeModel, + FormRendererComponent, FormService, FormValues, + ToolbarComponent, + ToolbarDividerComponent, UploadWidgetContentLinkModel, WidgetVisibilityService } from '@alfresco/adf-core'; @@ -55,9 +59,29 @@ import { FormCloudDisplayMode, FormCloudDisplayModeConfiguration } from '../../s import { FormCloudSpinnerService } from '../services/spinner/form-cloud-spinner.service'; import { DisplayModeService } from '../services/display-mode.service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatButtonModule } from '@angular/material/button'; +import { MatCardModule } from '@angular/material/card'; +import { MatIconModule } from '@angular/material/icon'; +import { A11yModule } from '@angular/cdk/a11y'; @Component({ selector: 'adf-cloud-form', + standalone: true, + imports: [ + CommonModule, + TranslateModule, + FormatSpacePipe, + MatButtonModule, + MatCardModule, + FormRendererComponent, + MatIconModule, + ToolbarDividerComponent, + ToolbarComponent, + A11yModule + ], + providers: [FormCloudSpinnerService], templateUrl: './form-cloud.component.html', styleUrls: ['./form-cloud.component.scss'] }) @@ -78,10 +102,6 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, @Input() processInstanceId: string; - /** Underlying form model instance. */ - @Input() - form: FormModel; - /** Task id to fetch corresponding form and values. */ @Input() taskId: string; diff --git a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.html b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.html index 09c16fcf82..a65729f038 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.html +++ b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.html @@ -1,7 +1,7 @@ - {{'ADF_CLOUD_TASK_LIST.START_TASK.FORM.LABEL.FORM'|translate}} + {{'ADF_CLOUD_TASK_LIST.START_TASK.FORM.LABEL.FORM' | translate}} - {{'ADF_CLOUD_TASK_LIST.START_TASK.FORM.LABEL.NONE'|translate}} + {{'ADF_CLOUD_TASK_LIST.START_TASK.FORM.LABEL.NONE' | translate}} {{ form.name }} diff --git a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.spec.ts index c06b0e6c41..46090847c9 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.spec.ts @@ -17,7 +17,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { FormDefinitionSelectorCloudComponent } from './form-definition-selector-cloud.component'; import { of } from 'rxjs'; import { FormDefinitionSelectorCloudService } from '../services/form-definition-selector-cloud.service'; @@ -33,8 +32,7 @@ describe('FormDefinitionCloudComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], - schemas: [CUSTOM_ELEMENTS_SCHEMA] + imports: [ProcessServiceCloudTestingModule, FormDefinitionSelectorCloudComponent] }); fixture = TestBed.createComponent(FormDefinitionSelectorCloudComponent); service = TestBed.inject(FormDefinitionSelectorCloudService); diff --git a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.stories.ts b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.stories.ts index b20513e9dd..8f1420c21b 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.stories.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.stories.ts @@ -16,7 +16,6 @@ */ import { applicationConfig, Meta, moduleMetadata, StoryFn } from '@storybook/angular'; -import { FormCloudModule } from '../form-cloud.module'; import { FormDefinitionSelectorCloudComponent } from './form-definition-selector-cloud.component'; import { ProcessServicesCloudStoryModule } from '../../testing/process-services-cloud-story.module'; import { FormDefinitionSelectorCloudService } from '../services/form-definition-selector-cloud.service'; @@ -28,7 +27,7 @@ export default { title: 'Process Services Cloud/Form Cloud/Form Definition Selector Cloud', decorators: [ moduleMetadata({ - imports: [FormCloudModule], + imports: [FormDefinitionSelectorCloudComponent], providers: [{ provide: FormDefinitionSelectorCloudService, useClass: FormDefinitionSelectorCloudServiceMock }] }), applicationConfig({ diff --git a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts index 6b89404893..2fde126b2d 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts @@ -18,17 +18,19 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Observable } from 'rxjs'; import { FormDefinitionSelectorCloudService } from '../services/form-definition-selector-cloud.service'; -import { MatSelectChange } from '@angular/material/select'; +import { MatSelectChange, MatSelectModule } from '@angular/material/select'; import { FormRepresentation } from '../../services/form-fields.interfaces'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; @Component({ selector: 'adf-cloud-form-definition-selector', + standalone: true, + imports: [CommonModule, TranslateModule, MatSelectModule], templateUrl: './form-definition-selector-cloud.component.html', styleUrls: ['./form-definition-selector-cloud.component.scss'] }) - export class FormDefinitionSelectorCloudComponent implements OnInit { - /** Name of the application. If specified, this shows the users who have access to the app. */ @Input() appName: string = ''; @@ -39,8 +41,7 @@ export class FormDefinitionSelectorCloudComponent implements OnInit { forms$: Observable; - constructor(private formDefinitionCloudService: FormDefinitionSelectorCloudService) { - } + constructor(private formDefinitionCloudService: FormDefinitionSelectorCloudService) {} ngOnInit(): void { this.forms$ = this.formDefinitionCloudService.getStandAloneTaskForms(this.appName); @@ -49,5 +50,4 @@ export class FormDefinitionSelectorCloudComponent implements OnInit { onSelect(event: MatSelectChange) { this.selectForm.emit(event.value); } - } diff --git a/lib/process-services-cloud/src/lib/form/components/spinner/form-spinner.component.ts b/lib/process-services-cloud/src/lib/form/components/spinner/form-spinner.component.ts index ab80e1afcf..e991ab4345 100644 --- a/lib/process-services-cloud/src/lib/form/components/spinner/form-spinner.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/spinner/form-spinner.component.ts @@ -16,8 +16,12 @@ */ import { Component, Input } from '@angular/core'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; @Component({ + standalone: true, + imports: [TranslateModule, MatProgressSpinnerModule], templateUrl: './form-spinner.component.html', styleUrls: ['./form-spinner.component.scss'] }) diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts index 1c6fc7ad22..6c7ba3e0dc 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts @@ -16,7 +16,6 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { ContentCloudNodeSelectorService } from '../../../services/content-cloud-node-selector.service'; import { ProcessCloudContentService } from '../../../services/process-cloud-content.service'; import { AttachFileCloudWidgetComponent } from './attach-file-cloud-widget.component'; @@ -61,16 +60,10 @@ import { processVariables } from '../../../mocks/attach-file-cloud-widget.mock'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; -import { CUSTOM_ELEMENTS_SCHEMA, Injector, runInInjectionContext } from '@angular/core'; -import { - ContentModule, - ContentNodeSelectorPanelService, - NewVersionUploaderDataAction, - NewVersionUploaderService -} from '@alfresco/adf-content-services'; +import { Injector, runInInjectionContext } from '@angular/core'; +import { ContentNodeSelectorPanelService, NewVersionUploaderDataAction, NewVersionUploaderService } from '@alfresco/adf-content-services'; import { By } from '@angular/platform-browser'; import { of, throwError } from 'rxjs'; -import { FormCloudModule } from '../../../form-cloud.module'; const mockNodeToBeVersioned: any = { isFile: true, @@ -150,8 +143,7 @@ describe('AttachFileCloudWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule, FormCloudModule, ContentModule.forRoot()], - schemas: [CUSTOM_ELEMENTS_SCHEMA] + imports: [ProcessServiceCloudTestingModule, AttachFileCloudWidgetComponent] }); notificationService = TestBed.inject(NotificationService); downloadService = TestBed.inject(DownloadService); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts index 7ad47c3fbf..04178f0969 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts @@ -17,21 +17,19 @@ /* eslint-disable @angular-eslint/component-selector */ -import { Component, EventEmitter, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, inject, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { FormService, - ThumbnailService, - NotificationService, FormValues, ContentLinkModel, AppConfigService, UploadWidgetContentLinkModel, - DestinationFolderPath + DestinationFolderPath, + ErrorWidgetComponent } from '@alfresco/adf-core'; import { Node, NodesApi, RelatedContentRepresentation } from '@alfresco/js-api'; import { ContentCloudNodeSelectorService } from '../../../services/content-cloud-node-selector.service'; -import { ProcessCloudContentService } from '../../../services/process-cloud-content.service'; -import { UploadCloudWidgetComponent } from './upload-cloud.widget'; +import { UploadCloudWidgetComponent } from '../upload/upload-cloud.widget'; import { DestinationFolderPathModel, DestinationFolderPathType } from '../../../models/form-cloud-representation.model'; import { AlfrescoApiService, @@ -41,15 +39,22 @@ import { NewVersionUploaderService, VersionManagerUploadData } from '@alfresco/adf-content-services'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatIconModule } from '@angular/material/icon'; +import { FilePropertiesTableCloudComponent } from './file-properties-table/file-properties-table-cloud.component'; +import { MatButtonModule } from '@angular/material/button'; -export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; -export const ALIAS_ROOT_FOLDER = '-root-'; -export const ALIAS_USER_FOLDER = '-my-'; -export const APP_NAME = '-appname-'; -export const VALID_ALIAS = [ALIAS_ROOT_FOLDER, ALIAS_USER_FOLDER, '-shared-']; +const RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; +const ALIAS_ROOT_FOLDER = '-root-'; +const ALIAS_USER_FOLDER = '-my-'; +const APP_NAME = '-appname-'; +const VALID_ALIAS = [ALIAS_ROOT_FOLDER, ALIAS_USER_FOLDER, '-shared-']; @Component({ selector: 'adf-cloud-attach-file-cloud-widget', + standalone: true, + imports: [CommonModule, ErrorWidgetComponent, TranslateModule, MatIconModule, FilePropertiesTableCloudComponent, MatButtonModule], templateUrl: './attach-file-cloud-widget.component.html', styleUrls: ['./attach-file-cloud-widget.component.scss'], host: { @@ -66,6 +71,12 @@ export const VALID_ALIAS = [ALIAS_ROOT_FOLDER, ALIAS_USER_FOLDER, '-shared-']; encapsulation: ViewEncapsulation.None }) export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit, OnDestroy { + private contentNodeSelectorService = inject(ContentCloudNodeSelectorService); + private appConfigService = inject(AppConfigService); + private apiService = inject(AlfrescoApiService); + private contentNodeSelectorPanelService = inject(ContentNodeSelectorPanelService); + private newVersionUploaderService = inject(NewVersionUploaderService); + typeId = 'AttachFileCloudWidgetComponent'; rootNodeId = ALIAS_USER_FOLDER; selectedNode: Node; @@ -81,18 +92,8 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i } displayedColumns = ['icon', 'fileName', 'action']; - constructor( - formService: FormService, - thumbnails: ThumbnailService, - processCloudContentService: ProcessCloudContentService, - notificationService: NotificationService, - private contentNodeSelectorService: ContentCloudNodeSelectorService, - private appConfigService: AppConfigService, - private apiService: AlfrescoApiService, - private contentNodeSelectorPanelService: ContentNodeSelectorPanelService, - private newVersionUploaderService: NewVersionUploaderService - ) { - super(formService, thumbnails, processCloudContentService, notificationService); + constructor(formService: FormService) { + super(formService); } ngOnInit() { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.html b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.html similarity index 93% rename from lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.html rename to lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.html index 4a31426483..d308ee176c 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.html +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.html @@ -29,16 +29,12 @@ - - {{ - columnName.title ? columnName.title : columnName.name | titlecase - }} - + + {{prop.title ? prop.title : prop.name | titlecase }} - {{ getColumnValue(row, columnName) }} + (click)="onRowClicked(row)">{{ getColumnValue(row, prop) }} @@ -89,6 +85,5 @@ - diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.scss b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.scss similarity index 100% rename from lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.scss rename to lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.scss diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.spec.ts similarity index 85% rename from lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.spec.ts rename to lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.spec.ts index 979019d010..9e2c7e6288 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.spec.ts @@ -17,21 +17,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; +import { ProcessServiceCloudTestingModule } from '../../../../../testing/process-service-cloud.testing.module'; import { FilePropertiesTableCloudComponent } from './file-properties-table-cloud.component'; import { By } from '@angular/platform-browser'; -import { MatTableModule } from '@angular/material/table'; -import { MatIconModule } from '@angular/material/icon'; describe('FilePropertiesTableCloudComponent', () => { let widget: FilePropertiesTableCloudComponent; let fixture: ComponentFixture; - beforeEach(async () => { + beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule, MatTableModule, MatIconModule], - declarations: [FilePropertiesTableCloudComponent] - }).compileComponents(); + imports: [ProcessServiceCloudTestingModule, FilePropertiesTableCloudComponent] + }); }); beforeEach(() => { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.ts similarity index 63% rename from lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.ts rename to lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.ts index 0f830c629f..552ac567aa 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table/file-properties-table-cloud.component.ts @@ -17,19 +17,43 @@ /* eslint-disable @angular-eslint/component-selector */ -import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { LocalizedDatePipe, ThumbnailService } from '@alfresco/adf-core'; +import { Component, EventEmitter, inject, Input, Output } from '@angular/core'; +import { LocalizedDatePipe, ThumbnailService, UploadDirective, DisplayableCMProperties } from '@alfresco/adf-core'; import { Node } from '@alfresco/js-api'; import { NewVersionUploaderDialogData } from '@alfresco/adf-content-services'; +import { CommonModule } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatMenuModule } from '@angular/material/menu'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTableModule } from '@angular/material/table'; +import { MatLineModule } from '@angular/material/core'; +import { MatListModule } from '@angular/material/list'; -export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; +const RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; @Component({ selector: 'adf-cloud-file-properties-table', + standalone: true, + imports: [ + CommonModule, + MatIconModule, + TranslateModule, + MatMenuModule, + UploadDirective, + MatButtonModule, + MatTableModule, + MatLineModule, + MatListModule + ], + providers: [LocalizedDatePipe], templateUrl: './file-properties-table-cloud.component.html', styleUrls: ['./file-properties-table-cloud.component.scss'] }) export class FilePropertiesTableCloudComponent { + private localizedDatePipe = inject(LocalizedDatePipe); + private thumbnailService = inject(ThumbnailService); + @Input() uploadedFiles; @@ -61,12 +85,10 @@ export class FilePropertiesTableCloudComponent { uploadNewFileVersion = new EventEmitter(); @Output() - contentModelFileHandler: EventEmitter = new EventEmitter(); + contentModelFileHandler = new EventEmitter(); @Output() - removeAttachFile: EventEmitter = new EventEmitter(); - - constructor(private localizedDatePipe: LocalizedDatePipe, private thumbnailService: ThumbnailService) {} + removeAttachFile = new EventEmitter(); onRowClicked(file?: Node) { this.rowClick.emit(file); @@ -90,11 +112,11 @@ export class FilePropertiesTableCloudComponent { this.uploadNewFileVersion.emit(newVersionUploaderDialogData); } - contentModelFormFileHandler(file?: any) { + contentModelFormFileHandler(file?: Node) { this.contentModelFileHandler.emit(file); } - onRemoveAttachFile(file: any) { + onRemoveAttachFile(file: Node) { this.removeAttachFile.emit(file); } @@ -102,17 +124,15 @@ export class FilePropertiesTableCloudComponent { return this.thumbnailService.getMimeTypeIcon(mimeType); } - getColumnValue(file, displayableCMProperty): string { - if (!file.properties[displayableCMProperty.prefixedName]) { - const fieldProperty = this.field.params.displayableCMProperties?.find((property) => property.name === displayableCMProperty.name); - return fieldProperty.defaultValue ? this.checkDateTypeAndTransform(displayableCMProperty.dataType, fieldProperty.defaultValue) : '--'; + getColumnValue(file, prop: DisplayableCMProperties): string { + if (!file.properties[prop.prefixedName]) { + const fieldProperty = this.field.params.displayableCMProperties?.find((property) => property.name === prop.name); + return fieldProperty.defaultValue ? this.checkDateTypeAndTransform(prop.dataType, fieldProperty.defaultValue) : '--'; } - return file.properties[displayableCMProperty.prefixedName] - ? this.checkDateTypeAndTransform(displayableCMProperty.dataType, file.properties[displayableCMProperty.prefixedName]) - : '--'; + return file.properties[prop.prefixedName] ? this.checkDateTypeAndTransform(prop.dataType, file.properties[prop.prefixedName]) : '--'; } - checkDateTypeAndTransform(dataType, value): string { + private checkDateTypeAndTransform(dataType: string, value: any): string { if (dataType === 'd:date') { return this.localizedDatePipe.transform(value); } else if (dataType === 'd:datetime') { 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..a7923ca66c 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; @@ -89,11 +89,6 @@ describe('DisplayRichTextWidgetComponent', () => { widget.field = fakeFormField; }); - it('should create', () => { - fixture.detectChanges(); - expect(widget).toBeTruthy(); - }); - it('should parse editorjs 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..10fd4a20e5 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,11 +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 { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { FormFieldModel, FormModel, FormService, NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core'; describe('FileViewerWidgetComponent', () => { const fakeForm = new FormModel(); @@ -44,10 +42,8 @@ describe('FileViewerWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot()], - declarations: [FileViewerWidgetComponent], - providers: [{ provide: FormService, useValue: formServiceStub }], - schemas: [CUSTOM_ELEMENTS_SCHEMA] + imports: [NoopTranslateModule, NoopAuthModule, FileViewerWidgetComponent], + providers: [{ provide: FormService, useValue: formServiceStub }] }); formServiceStub = TestBed.inject(FormService); @@ -55,27 +51,21 @@ describe('FileViewerWidgetComponent', () => { widget = fixture.componentInstance; }); - it('should set the file id corretly when the field value is an array', (done) => { - const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: [fakePngAnswer] }); - widget.field = fakeField; + it('should set the file id corretly when the field value is an array', async () => { + widget.field = new FormFieldModel(fakeForm, { id: 'fakeField', value: [fakePngAnswer] }); fixture.detectChanges(); + await fixture.whenStable(); - fixture.whenStable().then(() => { - expect(widget.field.value).toBe('1933'); - done(); - }); + expect(widget.field.value).toBe('1933'); }); - it('should set the file id corretly when the field value is a string', (done) => { - const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' }); - widget.field = fakeField; + it('should set the file id corretly when the field value is a string', async () => { + widget.field = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' }); fixture.detectChanges(); + await fixture.whenStable(); - fixture.whenStable().then(() => { - expect(widget.field.value).toBe('fakeValue'); - done(); - }); + expect(widget.field.value).toBe('fakeValue'); }); }); 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..cf4085fffc 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,16 @@ */ import { Component, ViewEncapsulation } from '@angular/core'; -import { FormService, BaseViewerWidgetComponent } from '@alfresco/adf-core'; +import { FormService, BaseViewerWidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; +import { AlfrescoViewerComponent } from '@alfresco/adf-content-services'; +import { TranslateModule } from '@ngx-translate/core'; /* eslint-disable @angular-eslint/component-selector */ @Component({ selector: 'file-viewer-widget', + standalone: true, + imports: [ErrorWidgetComponent, AlfrescoViewerComponent, TranslateModule], 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.html b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.html index 5104114847..d26eeec4a3 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.html +++ b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.html @@ -18,8 +18,9 @@ - + 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 e42a94e14d..d7b6706a20 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 @@ -19,7 +19,6 @@ import { FormFieldModel, FormFieldTypes, FormModel, IdentityGroupModel } from '@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { GroupCloudWidgetComponent } from './group-cloud.widget'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HarnessLoader } from '@angular/cdk/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatChipHarness } from '@angular/material/chips/testing'; @@ -32,9 +31,7 @@ describe('GroupCloudWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], - declarations: [GroupCloudWidgetComponent], - schemas: [CUSTOM_ELEMENTS_SCHEMA] + imports: [ProcessServiceCloudTestingModule, GroupCloudWidgetComponent] }); fixture = TestBed.createComponent(GroupCloudWidgetComponent); widget = fixture.componentInstance; 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 1284df4ba3..9b66e3f4c2 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, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core'; -import { FormService, WidgetComponent } from '@alfresco/adf-core'; +import { ErrorWidgetComponent, FormService, WidgetComponent } from '@alfresco/adf-core'; import { UntypedFormControl } from '@angular/forms'; import { filter } from 'rxjs/operators'; import { ComponentSelectionMode } from '../../../../types'; import { IdentityGroupModel } from '../../../../group/models/identity-group.model'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { GroupCloudModule } from '../../../../group/group-cloud.module'; /* eslint-disable @angular-eslint/component-selector */ @Component({ selector: 'group-cloud-widget', + standalone: true, + imports: [CommonModule, TranslateModule, ErrorWidgetComponent, GroupCloudModule], templateUrl: './group-cloud.widget.html', host: { '(click)': 'event($event)', @@ -42,7 +47,6 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; encapsulation: ViewEncapsulation.None }) export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit { - typeId = 'GroupCloudWidgetComponent'; roles: string[]; mode: ComponentSelectionMode; @@ -65,9 +69,7 @@ export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit this.preSelectGroup = this.field.value ? this.field.value : []; 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 = new UntypedFormControl({ value: '', disabled: this.field.readOnly }, []); this.search.statusChanges .pipe( filter((value: string) => value === 'INVALID'), diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.html b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.html index 3891e85b89..01cd6e1bdf 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.html +++ b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.html @@ -1,5 +1,7 @@
+ [class.adf-invalid]="!field.isValid && isTouched()" + [class.adf-readonly]="field.readOnly" + [class.adf-left-label-input-container]="field.leftLabels">
@@ -18,11 +20,16 @@ (blur)="markAsTouched()" [attr.title]="field.tooltip" > - + - +
diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.spec.ts index 669088ab7a..1a142cfb7d 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.spec.ts @@ -18,7 +18,6 @@ import { FormFieldModel, FormFieldTypes, FormModel, IdentityUserModel } from '@alfresco/adf-core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { PeopleCloudWidgetComponent } from './people-cloud.widget'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; import { IdentityUserService } from '../../../../people/services/identity-user.service'; import { mockShepherdsPie, mockYorkshirePudding } from '../../../../people/mock/people-cloud.mock'; @@ -35,9 +34,7 @@ describe('PeopleCloudWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], - declarations: [PeopleCloudWidgetComponent], - schemas: [CUSTOM_ELEMENTS_SCHEMA] + imports: [ProcessServiceCloudTestingModule, PeopleCloudWidgetComponent] }); identityUserService = TestBed.inject(IdentityUserService); fixture = TestBed.createComponent(PeopleCloudWidgetComponent); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts index d68a89a3a0..fcb24027de 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts @@ -16,18 +16,23 @@ */ import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core'; -import { FormService, WidgetComponent } from '@alfresco/adf-core'; +import { ErrorWidgetComponent, FormService, WidgetComponent } from '@alfresco/adf-core'; import { UntypedFormControl } from '@angular/forms'; import { filter } from 'rxjs/operators'; import { ComponentSelectionMode } from '../../../../types'; import { IdentityUserModel } from '../../../../people/models/identity-user.model'; import { IdentityUserService } from '../../../../people/services/identity-user.service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { CommonModule } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { PeopleCloudModule } from '../../../../people/people-cloud.module'; /* eslint-disable @angular-eslint/component-selector */ @Component({ selector: 'people-cloud-widget', + standalone: true, + imports: [CommonModule, TranslateModule, ErrorWidgetComponent, PeopleCloudModule], templateUrl: './people-cloud.widget.html', host: { '(click)': 'event($event)', @@ -43,6 +48,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; encapsulation: ViewEncapsulation.None }) export class PeopleCloudWidgetComponent extends WidgetComponent implements OnInit { + private identityUserService = inject(IdentityUserService); typeId = 'PeopleCloudWidgetComponent'; appName: string; @@ -56,7 +62,7 @@ export class PeopleCloudWidgetComponent extends WidgetComponent implements OnIni private readonly destroyRef = inject(DestroyRef); - constructor(formService: FormService, private identityUserService: IdentityUserService) { + constructor(formService: FormService) { super(formService); } @@ -70,7 +76,7 @@ export class PeopleCloudWidgetComponent extends WidgetComponent implements OnIni this.validate = this.field.readOnly ? false : true; } - this.search = new UntypedFormControl({value: '', disabled: this.field.readOnly}, []); + this.search = new UntypedFormControl({ value: '', disabled: this.field.readOnly }, []); this.search.statusChanges .pipe( @@ -94,7 +100,7 @@ export class PeopleCloudWidgetComponent extends WidgetComponent implements OnIni if (this.field.selectLoggedUser && !this.field.value) { const userInfo = this.identityUserService.getCurrentUserInfo(); - this.preSelectUsers = [ userInfo ]; + this.preSelectUsers = [userInfo]; this.onChangedUser(this.preSelectUsers); } } diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer-wrapper.component.ts b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer-wrapper.component.ts index c8a293cb14..8fbf058bd4 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer-wrapper.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer-wrapper.component.ts @@ -16,13 +16,17 @@ */ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation } from '@angular/core'; -import { PresetConfig, NodesApiService } from '@alfresco/adf-content-services'; +import { PresetConfig, NodesApiService, ContentMetadataComponent } from '@alfresco/adf-content-services'; import { Node } from '@alfresco/js-api'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; +import { CommonModule } from '@angular/common'; /* eslint-disable @angular-eslint/component-selector */ @Component({ selector: 'adf-properties-viewer-wrapper', + standalone: true, + imports: [CommonModule, MatProgressSpinnerModule, ContentMetadataComponent], templateUrl: './properties-viewer-wrapper.component.html', encapsulation: ViewEncapsulation.None }) diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer.widget.spec.ts index 4bb0210d25..fe7beada65 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer-wrapper/properties-viewer.widget.spec.ts @@ -29,7 +29,7 @@ describe('PropertiesViewerWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], + imports: [ProcessServiceCloudTestingModule, PropertiesViewerWrapperComponent], providers: [NodesApiService, { provide: BasicPropertiesService, useValue: { getProperties: () => [] } }] }); fixture = TestBed.createComponent(PropertiesViewerWrapperComponent); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.spec.ts index 51e3318537..6049c27997 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.spec.ts @@ -20,7 +20,6 @@ import { FormFieldModel, FormModel } from '@alfresco/adf-core'; import { PropertiesViewerWidgetComponent } from './properties-viewer.widget'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; import { fakeNodeWithProperties } from '../../../mocks/attach-file-cloud-widget.mock'; -import { PropertiesViewerWrapperComponent } from './properties-viewer-wrapper/properties-viewer-wrapper.component'; import { NodesApiService, BasicPropertiesService } from '@alfresco/adf-content-services'; import { of } from 'rxjs'; @@ -47,8 +46,7 @@ describe('PropertiesViewerWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], - declarations: [PropertiesViewerWrapperComponent], + imports: [ProcessServiceCloudTestingModule, PropertiesViewerWidgetComponent], providers: [NodesApiService, { provide: BasicPropertiesService, useValue: { getProperties: () => [] } }] }); fixture = TestBed.createComponent(PropertiesViewerWidgetComponent); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts index e26401af4b..d738a388e1 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts @@ -16,13 +16,18 @@ */ import { Component, EventEmitter, Output, ViewEncapsulation } from '@angular/core'; -import { BaseViewerWidgetComponent, FormService } from '@alfresco/adf-core'; +import { BaseViewerWidgetComponent, ErrorWidgetComponent, FormService } from '@alfresco/adf-core'; import { Node } from '@alfresco/js-api'; +import { PropertiesViewerWrapperComponent } from './properties-viewer-wrapper/properties-viewer-wrapper.component'; +import { TranslateModule } from '@ngx-translate/core'; +import { CommonModule } from '@angular/common'; /* eslint-disable @angular-eslint/component-selector */ @Component({ selector: 'adf-properties-viewer-widget', + standalone: true, + imports: [CommonModule, ErrorWidgetComponent, PropertiesViewerWrapperComponent, TranslateModule], templateUrl: './properties-viewer.widget.html', styleUrls: ['./properties-viewer.widget.scss'], host: { @@ -39,7 +44,6 @@ import { Node } from '@alfresco/js-api'; encapsulation: ViewEncapsulation.None }) export class PropertiesViewerWidgetComponent extends BaseViewerWidgetComponent { - @Output() nodeContentLoaded: EventEmitter = new EventEmitter(); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/index.ts b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/index.ts deleted file mode 100644 index f921cedd55..0000000000 --- a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * @license - * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * 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. - */ - -export * from './radio-buttons-cloud.schema'; -export * from './radio-buttons-cloud.widget'; diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.html b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.html index 52094cfcb6..06c50cfe8e 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.html +++ b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.html @@ -1,8 +1,14 @@
- - + + { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule] + imports: [ProcessServiceCloudTestingModule, RadioButtonsCloudWidgetComponent] }); formCloudService = TestBed.inject(FormCloudService); formUtilsService = TestBed.inject(FormUtilsService); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts index 25757598a2..512c07c9e4 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts @@ -18,14 +18,19 @@ /* eslint-disable @angular-eslint/component-selector */ import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core'; -import { ErrorMessageModel, FormFieldOption, FormService, WidgetComponent } from '@alfresco/adf-core'; +import { ErrorMessageModel, ErrorWidgetComponent, FormFieldOption, FormService, WidgetComponent } from '@alfresco/adf-core'; import { FormCloudService } from '../../../services/form-cloud.service'; -import { TranslateService } from '@ngx-translate/core'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormUtilsService } from '../../../services/form-utils.service'; +import { MatRadioModule } from '@angular/material/radio'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; @Component({ selector: 'radio-buttons-cloud-widget', + standalone: true, + imports: [CommonModule, ErrorWidgetComponent, MatRadioModule, TranslateModule, FormsModule], templateUrl: './radio-buttons-cloud.widget.html', styleUrls: ['./radio-buttons-cloud.widget.scss'], host: { @@ -42,17 +47,16 @@ import { FormUtilsService } from '../../../services/form-utils.service'; encapsulation: ViewEncapsulation.None }) export class RadioButtonsCloudWidgetComponent extends WidgetComponent implements OnInit { + private formCloudService = inject(FormCloudService); + private translateService = inject(TranslateService); + private formUtilsService = inject(FormUtilsService); + typeId = 'RadioButtonsCloudWidgetComponent'; restApiError: ErrorMessageModel; private readonly destroyRef = inject(DestroyRef); - constructor( - public formService: FormService, - private readonly formCloudService: FormCloudService, - private readonly translateService: TranslateService, - private readonly formUtilsService: FormUtilsService - ) { + constructor(formService: FormService) { super(formService); } @@ -68,16 +72,16 @@ export class RadioButtonsCloudWidgetComponent extends WidgetComponent implements this.formCloudService .getRestWidgetData(this.field.form.id, this.field.id, body) .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe( - (result: FormFieldOption[]) => { + .subscribe({ + next: (result) => { this.field.options = result; this.field.updateForm(); }, - (err) => { + error: (err) => { this.resetRestApiOptions(); this.handleError(err); } - ); + }); } onOptionClick(optionSelected: any) { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/upload-cloud.widget.html b/lib/process-services-cloud/src/lib/form/components/widgets/upload/upload-cloud.widget.html similarity index 88% rename from lib/process-services-cloud/src/lib/form/components/widgets/attach-file/upload-cloud.widget.html rename to lib/process-services-cloud/src/lib/form/components/widgets/upload/upload-cloud.widget.html index af79d6eac7..c51ea71028 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/upload-cloud.widget.html +++ b/lib/process-services-cloud/src/lib/form/components/widgets/upload/upload-cloud.widget.html @@ -9,8 +9,8 @@ - {{file.name}} + {{file.name}}