OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add attribute help texts to dynamic forms (#9215)
Benjamin Bädorf831921a79a69
diff --git a/frontend/package.json b/frontend/package.jsonindex 04fe667a08e..0da6c3ff4b9 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -125,6 +125,7 @@"serve-test": "node --max_old_space_size=8096 ./node_modules/@angular/cli/bin/ng serve --host 0.0.0.0 --disable-host-check --public-host http://frontend-test:4200","pretest": "./scripts/link_plugin_placeholder.js","test": "ng test --watch=false",+ "test-watch": "ng test --watch=true","lint": "eslint -c .eslintrc.js --ext .ts src/app/","generate-typings": "tsc -d -p src/tsconfig.app.json"}diff --git a/frontend/src/app/components/op-context-menu/op-context-menu.service.ts b/frontend/src/app/components/op-context-menu/op-context-menu.service.tsindex 75f81bd74a8..6ea8377c2c3 100644--- a/frontend/src/app/components/op-context-menu/op-context-menu.service.ts+++ b/frontend/src/app/components/op-context-menu/op-context-menu.service.ts@@ -5,7 +5,7 @@ import { OpContextMenuHandler } from "core-components/op-context-menu/op-contextimport { OpContextMenuLocalsMap, OpContextMenuLocalsToken } from "core-components/op-context-menu/op-context-menu.types";import { OPContextMenuComponent } from "core-components/op-context-menu/op-context-menu.component";import { keyCodes } from 'core-app/modules/common/keyCodes.enum';-import { FocusHelperService } from 'core-app/modules/common/focus/focus-helper';+import { FocusHelperService } from 'core-app/modules/focus/focus-helper';@Injectable({ providedIn: 'root' })export class OPContextMenuService {diff --git a/frontend/src/app/components/wp-edit-form/table-edit-form.ts b/frontend/src/app/components/wp-edit-form/table-edit-form.tsindex 2953809334c..e27f54ed11a 100644--- a/frontend/src/app/components/wp-edit-form/table-edit-form.ts+++ b/frontend/src/app/components/wp-edit-form/table-edit-form.ts@@ -33,7 +33,7 @@ import { IFieldSchema } from "core-app/modules/fields/field.base";import { EditFieldHandler } from "core-app/modules/fields/edit/editing-portal/edit-field-handler";import { WorkPackageViewColumnsService } from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-columns.service";-import { FocusHelperService } from "core-app/modules/common/focus/focus-helper";+import { FocusHelperService } from "core-app/modules/focus/focus-helper";import { EditingPortalService } from "core-app/modules/fields/edit/editing-portal/editing-portal-service";import { CellBuilder, editCellContainer, tdClassName } from "core-components/wp-fast-table/builders/cell-builder";import { WorkPackageTable } from "core-components/wp-fast-table/wp-fast-table";diff --git a/frontend/src/app/components/wp-fast-table/handlers/state/selection-transformer.ts b/frontend/src/app/components/wp-fast-table/handlers/state/selection-transformer.tsindex fcbf497e561..f4b6d7a7132 100644--- a/frontend/src/app/components/wp-fast-table/handlers/state/selection-transformer.ts+++ b/frontend/src/app/components/wp-fast-table/handlers/state/selection-transformer.ts@@ -6,7 +6,7 @@ import { checkedClassName } from '../../builders/ui-state-link-builder';import { locateTableRow, scrollTableRowIntoView } from '../../helpers/wp-table-row-helpers';import { WorkPackageTable } from '../../wp-fast-table';import { IsolatedQuerySpace } from "core-app/modules/work_packages/query-space/isolated-query-space";-import { FocusHelperService } from 'core-app/modules/common/focus/focus-helper';+import { FocusHelperService } from 'core-app/modules/focus/focus-helper';import {WorkPackageViewSelectionService,WorkPackageViewSelectionStatediff --git a/frontend/src/app/components/wp-table/external-configuration/external-query-configuration.service.ts b/frontend/src/app/components/wp-table/external-configuration/external-query-configuration.service.tsindex 01237af6b9c..3b0e139ca01 100644--- a/frontend/src/app/components/wp-table/external-configuration/external-query-configuration.service.ts+++ b/frontend/src/app/components/wp-table/external-configuration/external-query-configuration.service.ts@@ -1,7 +1,7 @@import { ApplicationRef, ComponentFactoryResolver, Injectable, Injector } from '@angular/core';import { ComponentPortal, DomPortalOutlet, PortalInjector } from '@angular/cdk/portal';import { TransitionService } from '@uirouter/core';-import { FocusHelperService } from 'core-app/modules/common/focus/focus-helper';+import { FocusHelperService } from 'core-app/modules/focus/focus-helper';import {ExternalQueryConfigurationComponent,QueryConfigurationLocalsdiff --git a/frontend/src/app/components/wp-table/table-pagination/wp-table-pagination.component.spec.ts b/frontend/src/app/components/wp-table/table-pagination/wp-table-pagination.component.spec.tsindex 1000a564435..ed9f2e00b45 100644--- a/frontend/src/app/components/wp-table/table-pagination/wp-table-pagination.component.spec.ts+++ b/frontend/src/app/components/wp-table/table-pagination/wp-table-pagination.component.spec.ts@@ -41,7 +41,7 @@ import { I18nService } from "core-app/modules/common/i18n/i18n.service";import { OpenProject } from "core-app/globals/openproject";import { WorkPackageViewSortByService } from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-sort-by.service";import { ConfigurationService } from "core-app/modules/common/config/configuration.service";-import { OpIconComponent } from "core-app/modules/common/icon/icon.component";+import { OpIconComponent } from "core-app/modules/icon/icon.component";function setupMocks(paginationService:PaginationService) {const options:IPaginationOptions = {diff --git a/frontend/src/app/core/services/forms/forms.service.spec.ts b/frontend/src/app/core/services/forms/forms.service.spec.tsnew file mode 100644index 00000000000..6b3393b47dc--- /dev/null+++ b/frontend/src/app/core/services/forms/forms.service.spec.ts@@ -0,0 +1,139 @@+import { TestBed } from '@angular/core/testing';+import { FormsService } from './forms.service';+import { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";+import { HttpClient } from "@angular/common/http";+import { FormBuilder } from "@angular/forms";++describe('FormsService', () => {+ let service:FormsService;+ let httpClient:HttpClient;+ let httpTestingController:HttpTestingController;+ const testFormUrl = 'http://op.com/form';+ const formModel = {+ "name": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ "title": "Parent project",+ "name": "Parent project"+ },+ "users": [+ {+ "href": "/api/v3/users/26",+ "title": "User 1",+ "name": "User 1"+ }+ ]+ }+ };+ const formBuilder = new FormBuilder();++ beforeEach(() => {+ TestBed.configureTestingModule({+ imports: [+ HttpClientTestingModule,+ ],+ });+ httpClient = TestBed.inject(HttpClient);+ httpTestingController = TestBed.inject(HttpTestingController);+ service = TestBed.inject(FormsService);+ });++ it('should be created', () => {+ expect(service).toBeTruthy();+ });++ it('should submit the dynamic form value', () => {+ const form = formBuilder.group(formModel);+ const resourceId = '123';++ service+ .submit$(form, testFormUrl)+ .subscribe();++ const postReq = httpTestingController.expectOne(testFormUrl);++ expect(postReq.request.method).toEqual('POST', 'should create a new resource when no id is provided');+ expect(postReq.request.body.name).toEqual('Project 1', 'should upload the primitive values as they are');+ expect(postReq.request.body._links.parent).toEqual({ href: '/api/v3/projects/26' }, 'should format the resource values to only contain the href');++ postReq.flush('ok response');+ httpTestingController.verify();++ service+ .submit$(form, testFormUrl, resourceId)+ .subscribe();++ const patchReq = httpTestingController.expectOne(`${testFormUrl}/${resourceId}`);++ expect(patchReq.request.method).toEqual('PATCH', 'should update the resource when an id is provided');++ patchReq.flush('ok response');+ httpTestingController.verify();+ });++ it('should format the model to fit the backend expectation', () => {+ // @ts-ignore+ const formattedModel = service._formatModelToSubmit(formModel);+ const expectedResult = {+ "name": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ },+ "users": [+ {+ "href": "/api/v3/users/26",+ }+ ]+ }+ };++ expect(formattedModel).toEqual(expectedResult);+ });++ it('should set the backend errors in the FormGroup', () => {+ const form= formBuilder.group({+ ...formModel,+ _links: formBuilder.group(formModel._links),+ });+ const backEndErrorResponse = {+ error: {+ "_type": "Error",+ "errorIdentifier": "urn:openproject-org:api:v3:errors:MultipleErrors",+ "message": "Multiple field constraints have been violated.",+ "_embedded": {+ "errors": [+ {+ "_type": "Error",+ "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",+ "message": "Name can't be blank.",+ "_embedded": {+ "details": {+ "attribute": "name"+ }+ }+ },+ {+ "_type": "Error",+ "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",+ "message": "Identifier can't be blank.",+ "_embedded": {+ "details": {+ "attribute": "parent"+ }+ }+ },+ ]+ }+ }, status: 422+ };++ // @ts-ignore+ service._handleBackendFormValidationErrors(backEndErrorResponse, form);++ expect(form.get('name')!.invalid).toBe(true);+ expect(form.get('_links')!.get('parent')!.invalid).toBe(true);+ expect(form.get('_links')!.get('users')!.valid).toBe(true);+ });+});diff --git a/frontend/src/app/global-dynamic-components.const.ts b/frontend/src/app/global-dynamic-components.const.tsindex 09aaaaede73..7ae4a8f368e 100644--- a/frontend/src/app/global-dynamic-components.const.ts+++ b/frontend/src/app/global-dynamic-components.const.ts@@ -145,7 +145,7 @@ import {import {AttributeHelpTextComponent,attributeHelpTextSelector-} from "core-app/modules/fields/help-texts/attribute-help-text.component";+} from "core-app/modules/attribute-help-texts/attribute-help-text.component";import {quickInfoMacroSelector,WorkPackageQuickinfoMacroComponentdiff --git a/frontend/src/app/modules/a11y/keyboard-shortcut-service.ts b/frontend/src/app/modules/a11y/keyboard-shortcut-service.tsindex c25b835fab2..738b196d4a7 100644--- a/frontend/src/app/modules/a11y/keyboard-shortcut-service.ts+++ b/frontend/src/app/modules/a11y/keyboard-shortcut-service.ts@@ -27,9 +27,10 @@//++import { Injectable } from "@angular/core";-import { PathHelperService } from "../common/path-helper/path-helper.service";-import { CurrentProjectService } from "../../components/projects/current-project.service";-import { FocusHelperService } from "../common/focus/focus-helper";+import { FocusHelperService } from "core-app/modules/focus/focus-helper";+import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";+import { CurrentProjectService } from "core-app/components/projects/current-project.service";+const accessKeys = {preview: 1,diff --git a/frontend/src/app/modules/a11y/openproject-a11y.module.ts b/frontend/src/app/modules/a11y/openproject-a11y.module.tsindex 601a344e47b..6805e8ae8be 100644--- a/frontend/src/app/modules/a11y/openproject-a11y.module.ts+++ b/frontend/src/app/modules/a11y/openproject-a11y.module.ts@@ -27,11 +27,11 @@//++ Ng1FieldControlsWrapper,-import { FormsModule } from "@angular/forms";import { NgModule } from "@angular/core";+import { FormsModule } from "@angular/forms";+import { CommonModule } from "@angular/common";import { AccessibleClickDirective } from "core-app/modules/a11y/accessible-click.directive";import { AccessibleByKeyboardComponent } from "core-app/modules/a11y/accessible-by-keyboard.component";-import { CommonModule } from "@angular/common";import { DoubleClickOrTapDirective } from "core-app/modules/a11y/double-click-or-tap.directive";@NgModule({@@ -46,8 +46,8 @@ import { DoubleClickOrTapDirective } from "core-app/modules/a11y/double-click-or],declarations: [AccessibleClickDirective,- AccessibleByKeyboardComponent,DoubleClickOrTapDirective,+ AccessibleByKeyboardComponent,]})export class OpenprojectAccessibilityModule {diff --git a/frontend/src/app/modules/common/authoring/authoring.html b/frontend/src/app/modules/attachments/authoring/authoring.component.htmlsimilarity index 100%rename from frontend/src/app/modules/common/authoring/authoring.htmlrename to frontend/src/app/modules/attachments/authoring/authoring.component.htmldiff --git a/frontend/src/app/modules/common/authoring/authoring.sass b/frontend/src/app/modules/attachments/authoring/authoring.component.sasssimilarity index 100%rename from frontend/src/app/modules/common/authoring/authoring.sassrename to frontend/src/app/modules/attachments/authoring/authoring.component.sassdiff --git a/frontend/src/app/modules/common/authoring/authoring.component.ts b/frontend/src/app/modules/attachments/authoring/authoring.component.tssimilarity index 96%rename from frontend/src/app/modules/common/authoring/authoring.component.tsrename to frontend/src/app/modules/attachments/authoring/authoring.component.tsindex 22bc4165c26..dec5bf2637b 100644--- a/frontend/src/app/modules/common/authoring/authoring.component.ts+++ b/frontend/src/app/modules/attachments/authoring/authoring.component.ts@@ -33,8 +33,8 @@ import { HalResource } from 'core-app/modules/hal/resources/hal-resource';import { TimezoneService } from 'core-components/datetime/timezone.service';@Component({- templateUrl: './authoring.html',- styleUrls: ['./authoring.sass'],+ templateUrl: './authoring.component.html',+ styleUrls: ['./authoring.component.sass'],selector: 'authoring',})export class AuthoringComponent implements OnInit {diff --git a/frontend/src/app/modules/attachments/openproject-attachments.module.ts b/frontend/src/app/modules/attachments/openproject-attachments.module.tsindex 18c4467a0e3..5656dcf033b 100644--- a/frontend/src/app/modules/attachments/openproject-attachments.module.ts+++ b/frontend/src/app/modules/attachments/openproject-attachments.module.ts@@ -27,27 +27,37 @@//++import { NgModule } from '@angular/core';+import { CommonModule } from "@angular/common";-import { OpenprojectCommonModule } from 'core-app/modules/common/openproject-common.module';-import { AttachmentsComponent } from "core-app/modules/attachments/attachments.component";-import { AttachmentListComponent } from "core-app/modules/attachments/attachment-list/attachment-list.component";-import { AttachmentListItemComponent } from "core-app/modules/attachments/attachment-list/attachment-list-item.component";-import { AttachmentsUploadComponent } from "core-app/modules/attachments/attachments-upload/attachments-upload.component";+import { IconModule } from 'core-app/modules/icon/icon.module';+import { OpenprojectAccessibilityModule } from 'core-app/modules/a11y/openproject-a11y.module';++import { AttachmentsComponent } from "./attachments.component";+import { AttachmentListComponent } from "./attachment-list/attachment-list.component";+import { AttachmentListItemComponent } from "./attachment-list/attachment-list-item.component";+import { AttachmentsUploadComponent } from "./attachments-upload/attachments-upload.component";+import { AuthoringComponent } from './authoring/authoring.component';@NgModule({imports: [- OpenprojectCommonModule,+ CommonModule,+ IconModule,+ OpenprojectAccessibilityModule,],declarations: [AttachmentsComponent,AttachmentListComponent,AttachmentListItemComponent,AttachmentsUploadComponent,++ AuthoringComponent,],exports: [AttachmentsUploadComponent,AttachmentListComponent,AttachmentsComponent,++ AuthoringComponent,]})export class OpenprojectAttachmentsModule {diff --git a/frontend/src/app/modules/fields/help-texts/attribute-help-text.component.html b/frontend/src/app/modules/attribute-help-texts/attribute-help-text.component.htmlsimilarity index 100%rename from frontend/src/app/modules/fields/help-texts/attribute-help-text.component.htmlrename to frontend/src/app/modules/attribute-help-texts/attribute-help-text.component.htmldiff --git a/frontend/src/app/modules/fields/help-texts/attribute-help-text.component.ts b/frontend/src/app/modules/attribute-help-texts/attribute-help-text.component.tssimilarity index 97%rename from frontend/src/app/modules/fields/help-texts/attribute-help-text.component.tsrename to frontend/src/app/modules/attribute-help-texts/attribute-help-text.component.tsindex a3fc0f28bc6..9704540d5b1 100644--- a/frontend/src/app/modules/fields/help-texts/attribute-help-text.component.ts+++ b/frontend/src/app/modules/attribute-help-texts/attribute-help-text.component.ts@@ -26,7 +26,6 @@// See docs/COPYRIGHT.rdoc for more details.//++-import { AttributeHelpTextsService } from './attribute-help-text.service';import {ChangeDetectionStrategy,ChangeDetectorRef,@@ -38,7 +37,8 @@ import {} from '@angular/core';import { I18nService } from 'core-app/modules/common/i18n/i18n.service';import { OpModalService } from 'core-app/modules/modal/modal.service';-import { AttributeHelpTextModal } from "core-app/modules/fields/help-texts/attribute-help-text.modal";+import { AttributeHelpTextsService } from './attribute-help-text.service';+import { AttributeHelpTextModal } from "./attribute-help-text.modal";export const attributeHelpTextSelector = 'attribute-help-text';diff --git a/frontend/src/app/modules/fields/help-texts/attribute-help-text.modal.ts b/frontend/src/app/modules/attribute-help-texts/attribute-help-text.modal.tssimilarity index 100%rename from frontend/src/app/modules/fields/help-texts/attribute-help-text.modal.tsrename to frontend/src/app/modules/attribute-help-texts/attribute-help-text.modal.tsdiff --git a/frontend/src/app/modules/attribute-help-texts/attribute-help-text.module.ts b/frontend/src/app/modules/attribute-help-texts/attribute-help-text.module.tsnew file mode 100644index 00000000000..7991a2d1baa--- /dev/null+++ b/frontend/src/app/modules/attribute-help-texts/attribute-help-text.module.ts@@ -0,0 +1,29 @@+import { NgModule } from "@angular/core";+import { CommonModule } from "@angular/common";+import { OpenprojectModalModule } from "core-app/modules/modal/modal.module";+import { OpenprojectAttachmentsModule } from "core-app/modules/attachments/openproject-attachments.module";+import { OpenprojectAccessibilityModule } from "core-app/modules/a11y/openproject-a11y.module";+import { IconModule } from "core-app/modules/icon/icon.module";++import { AttributeHelpTextComponent } from "./attribute-help-text.component";+import { AttributeHelpTextModal } from "./attribute-help-text.modal";++@NgModule({+ imports: [+ CommonModule,+ OpenprojectModalModule,+ OpenprojectAttachmentsModule,+ OpenprojectAccessibilityModule,+ IconModule,+ ],+ declarations: [+ AttributeHelpTextComponent,+ AttributeHelpTextModal,+ ],+ providers: [+ ],+ exports: [+ AttributeHelpTextComponent,+ ]+})+export class AttributeHelpTextModule {}diff --git a/frontend/src/app/modules/fields/help-texts/attribute-help-text.service.ts b/frontend/src/app/modules/attribute-help-texts/attribute-help-text.service.tssimilarity index 100%rename from frontend/src/app/modules/fields/help-texts/attribute-help-text.service.tsrename to frontend/src/app/modules/attribute-help-texts/attribute-help-text.service.tsdiff --git a/frontend/src/app/modules/fields/help-texts/help-text.modal.html b/frontend/src/app/modules/attribute-help-texts/help-text.modal.htmlsimilarity index 100%rename from frontend/src/app/modules/fields/help-texts/help-text.modal.htmlrename to frontend/src/app/modules/attribute-help-texts/help-text.modal.htmldiff --git a/frontend/src/app/modules/common/autofocus/autofocus.directive.ts b/frontend/src/app/modules/common/autofocus/autofocus.directive.tsindex 9ecd969e2e7..0615513fda7 100644--- a/frontend/src/app/modules/common/autofocus/autofocus.directive.ts+++ b/frontend/src/app/modules/common/autofocus/autofocus.directive.ts@@ -1,5 +1,5 @@import { AfterContentInit, Directive, ElementRef, Input } from '@angular/core';-import { FocusHelperService } from "core-app/modules/common/focus/focus-helper";+import { FocusHelperService } from "core-app/modules/focus/focus-helper";@Directive({selector: '[autoFocus]'diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.htmlindex e5e81d98d9a..045f5057ba3 100644--- a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.html+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.html@@ -1,8 +1,10 @@<op-form-field [label]="to?.label"[noWrapLabel]="to?.noWrapLabel"[required]="to?.required"+ [helpTextAttribute]="to?.property"+ [helpTextAttributeScope]="to?.helpTextAttributeScope"[attr.data-qa-field-name]="to?.property">- <ng-container #fieldComponent slot=input></ng-container>+ <ng-container #fieldComponent slot="input"></ng-container><formly-validation-message class="op-form-field--error"[field]="field"diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.spec.tsnew file mode 100644index 00000000000..9f6fb6e01b7--- /dev/null+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.spec.ts@@ -0,0 +1,460 @@+import { NgSelectModule } from "@ng-select/ng-select";+import { NgOptionHighlightModule } from "@ng-select/ng-option-highlight";+import { Component, forwardRef, ViewChild } from "@angular/core";+import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';+import { By } from "@angular/platform-browser";+import { defer, of } from "rxjs";+import { FormControl, FormGroup, NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";+import { CommonModule } from "@angular/common";+import { FormlyModule } from "@ngx-formly/core";++import { DynamicFormComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component";+import { DynamicFormService } from "core-app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service";+import { DynamicFieldsService } from "core-app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service";+import { I18nService } from "core-app/modules/common/i18n/i18n.service";+import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";+import { NotificationsService } from "core-app/modules/common/notifications/notifications.service";+import { TextInputComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component";+import { IntegerInputComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component";+import { SelectInputComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component";+import { BooleanInputComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component";+import { DateInputComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component";+import { FormattableTextareaInputComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component";+import { DynamicFieldGroupWrapperComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component";+import { OpFormFieldComponent } from "core-app/modules/common/forms/form-field/form-field.component";+import { HttpClientTestingModule } from "@angular/common/http/testing";++@Component({+ template: `+ <op-dynamic-form [formControl]="control"></op-dynamic-form>`,+ providers: []+})+class DynamicFormsTestingComponent {+ control = new FormControl('');++ @ViewChild(DynamicFormComponent) dynamicFormControl:DynamicFormComponent;+}++describe('DynamicFormComponent', () => {+ let component:DynamicFormComponent;+ let fixture:ComponentFixture<DynamicFormComponent>;+ const formSchema:any = {+ "_type": "Form",+ "_embedded": {+ "payload": {+ "name": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ "title": "Parent project"+ }+ }+ },+ "schema": {+ "_type": "Schema",+ "_dependencies": [],+ "name": {+ "type": "String",+ "name": "Name",+ "required": true,+ "hasDefault": false,+ "writable": true,+ "minLength": 1,+ "maxLength": 255,+ "options": {}+ },+ "parent": {+ "type": "Project",+ "name": "Subproject of",+ "required": false,+ "hasDefault": false,+ "writable": true,+ "_links": {+ "allowedValues": {+ "href": "/api/v3/projects/available_parent_projects?of=25"+ }+ }+ },+ "_links": {}+ },+ "validationErrors": {}+ },+ "_links": {+ "self": {+ "href": "/api/v3/projects/25/form",+ "method": "post"+ },+ "validate": {+ "href": "/api/v3/projects/25/form",+ "method": "post"+ },+ "commit": {+ "href": "/api/v3/projects/25",+ "method": "patch"+ }+ }+ };+ const dynamicFormSettings:any = {+ fields: [+ {+ "type": "textInput",+ "className": "op-form--field inline-edit--field",+ "key": "name",+ "templateOptions": {+ "required": true,+ "label": "Name",+ "type": "text",+ "placeholder": "",+ "disabled": false+ },+ },+ {+ "type": "integerInput",+ "className": "op-form--field inline-edit--field",+ "key": "quantity",+ "templateOptions": {+ "required": true,+ "label": "Quantity",+ "type": "number",+ "placeholder": "",+ "disabled": false+ },+ },+ {+ "type": "textInput",+ "className": "op-form--field inline-edit--field",+ "key": "identifier",+ "templateOptions": {+ "required": true,+ "label": "Identifier",+ "type": "text",+ "placeholder": "",+ "disabled": false+ },+ },+ {+ "type": "formattableInput",+ "className": "op-form--field textarea-wrapper",+ "key": "description",+ "templateOptions": {+ "required": false,+ "label": "Description",+ "editorType": "full",+ "inlineLabel": true,+ "placeholder": "",+ "disabled": false+ },+ },+ {+ "type": "booleanInput",+ "className": "op-form--field inline-edit--field inline-edit--boolean-field",+ "key": "public",+ "templateOptions": {+ "required": true,+ "label": "Public",+ "type": "checkbox",+ "placeholder": "",+ "disabled": false+ },+ },+ {+ "type": "booleanInput",+ "className": "op-form--field inline-edit--field inline-edit--boolean-field",+ "key": "active",+ "templateOptions": {+ "required": true,+ "label": "Active",+ "type": "checkbox",+ "placeholder": "",+ "disabled": false+ },+ },+ {+ "type": "selectInput",+ "className": "op-form--field inline-edit--field Status",+ "expressionProperties": {},+ "key": "status",+ "templateOptions": {+ "required": false,+ "label": "Status",+ "type": "number",+ "locale": "en",+ "bindLabel": "title",+ "searchable": false,+ "virtualScroll": true,+ "typeahead": false,+ "clearOnBackspace": false,+ "clearSearchOnAdd": false,+ "hideSelected": false,+ "text": {+ "add_new_action": "Create"+ },+ "placeholder": "",+ "disabled": false,+ "clearable": true,+ "multiple": false+ },+ },+ {+ "type": "formattableInput",+ "className": "op-form--field textarea-wrapper",+ "key": "statusExplanation",+ "templateOptions": {+ "required": false,+ "label": "Status description",+ "editorType": "full",+ "inlineLabel": true,+ "placeholder": "",+ "disabled": false+ },+ },+ {+ "type": "selectInput",+ "className": "op-form--field inline-edit--field Subproject of",+ "expressionProperties": {},+ "key": "_links.parent",+ "templateOptions": {+ "required": false,+ "label": "Subproject of",+ "type": "number",+ "locale": "en",+ "bindLabel": "title",+ "searchable": false,+ "virtualScroll": true,+ "typeahead": false,+ "clearOnBackspace": false,+ "clearSearchOnAdd": false,+ "hideSelected": false,+ "text": {+ "add_new_action": "Create"+ },+ "options": of([])+ },+ },+ {+ "type": "dateInput",+ "className": "op-form--field inline-edit--field",+ "key": "customField12",+ "templateOptions": {+ "required": false,+ "label": "Date",+ "placeholder": "",+ "disabled": false+ },+ }+ ],+ model: {+ "identifier": "test11",+ "name": "qwe",+ "active": true,+ "public": false,+ "description": {+ "format": "markdown",+ "raw": "asdadsad",+ "html": "<p class=\"op-uc-p\">asdadsad</p>"+ },+ "status": null,+ "statusExplanation": {+ "format": "markdown",+ "raw": null,+ "html": ""+ },+ "customField12": null,+ "_links": {+ "parent": {+ "href": "/api/v3/projects/23",+ "title": "qweqwe",+ "name": "qweqwe"+ }+ }+ },+ form: new FormGroup({}),+ };+ const I18nServiceStub = {+ t: function(key:string) {+ return 'test translation';+ }+ };+ const apiV3Base = 'http://www.openproject.com/api/v3/';+ const IPathHelperServiceStub = { api: { v3: { apiV3Base } } };+ let notificationsService:jasmine.SpyObj<NotificationsService>;+ let dynamicFormService:jasmine.SpyObj<DynamicFormService>;++ beforeEach(async () => {+ const notificationsServiceSpy = jasmine.createSpyObj('NotificationsService', ['addError', 'addSuccess']);+ const dynamicFormServiceSpy = jasmine.createSpyObj('DynamicFormService', ['getSettings', 'getSettingsFromBackend$', 'registerForm', 'submit$']);++ await TestBed+ .configureTestingModule({+ imports: [+ CommonModule,+ HttpClientTestingModule,+ ReactiveFormsModule,+ FormlyModule.forRoot({+ types: [+ { name: 'textInput', component: TextInputComponent },+ { name: 'integerInput', component: IntegerInputComponent },+ { name: 'selectInput', component: SelectInputComponent },+ { name: 'booleanInput', component: BooleanInputComponent },+ { name: 'dateInput', component: DateInputComponent },+ { name: 'formattableInput', component: FormattableTextareaInputComponent },+ ],+ wrappers: [+ {+ name: "op-dynamic-field-group-wrapper",+ component: DynamicFieldGroupWrapperComponent,+ },+ ]+ }),+ NgSelectModule,+ NgOptionHighlightModule,+ ],+ declarations: [+ DynamicFormComponent,+ OpFormFieldComponent,+ TextInputComponent,+ IntegerInputComponent,+ SelectInputComponent,+ BooleanInputComponent,+ DynamicFormsTestingComponent,+ // Skip adding DateInputComponent and FormattableTextareaInputComponent+ // to keep it simple (inheritance test issues).+ ],+ providers: [+ DynamicFieldsService,+ { provide: I18nService, useValue: I18nServiceStub },+ { provide: PathHelperService, useValue: IPathHelperServiceStub },+ { provide: NotificationsService, useValue: notificationsServiceSpy },+ ]+ })+ // Set component providers+ .overrideComponent(+ DynamicFormComponent,+ {+ set: {+ providers: [+ {+ provide: DynamicFormService,+ useValue: dynamicFormServiceSpy+ },+ {+ provide: NG_VALUE_ACCESSOR,+ multi: true,+ useExisting: forwardRef(() => DynamicFormComponent),+ }+ ]+ }+ }+ )+ .compileComponents();++ fixture = TestBed.createComponent(DynamicFormComponent);+ component = fixture.componentInstance;+ notificationsService = fixture.debugElement.injector.get(NotificationsService) as jasmine.SpyObj<NotificationsService>;+ dynamicFormService = fixture.debugElement.injector.get(DynamicFormService) as jasmine.SpyObj<DynamicFormService>;+ });++ it('should create', () => {+ expect(component).toBeTruthy();+ });++ it('sould get the form schema from the backend when no @Input settings', fakeAsync(() => {+ // @ts-ignore+ dynamicFormService.getSettingsFromBackend$.and.returnValue(defer(() => Promise.resolve(dynamicFormSettings)));++ component.resourcePath = '/api/v3/projects/1234/form';+ component.ngOnChanges({});++ expect(dynamicFormService.getSettingsFromBackend$).toHaveBeenCalled();++ fixture.detectChanges();+ flush();++ expect(fixture.debugElement.query(By.css('[data-qa="op-form--container"]'))).toBeTruthy();+ expect(fixture.debugElement.queryAll(By.css('formly-form')).length).toEqual(1);+ expect(fixture.debugElement.queryAll(By.css('formly-field')).length).toEqual(11);+ expect(fixture.debugElement.queryAll(By.css('op-text-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-formattable-textarea-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-select-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-date-input')).length).toEqual(1);+ expect(fixture.debugElement.queryAll(By.css('op-boolean-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-integer-input')).length).toEqual(1);+ expect(fixture.debugElement.query(By.css('button[type=submit]'))).toBeTruthy();+ }));++ it('should get the form schema from @Input settings when present', fakeAsync(() => {+ // @ts-ignore+ dynamicFormService.getSettings.and.returnValue(dynamicFormSettings);++ component.resourcePath = '/api/v3/projects/1234/form';+ component.settings = {+ payload: formSchema._embedded.payload,+ schema: formSchema._embedded.schema,+ };++ component.ngOnChanges({ settings: { currentValue: component.settings } } as any);++ expect(dynamicFormService.getSettings).toHaveBeenCalled();++ fixture.detectChanges();++ expect(fixture.debugElement.query(By.css('[data-qa="op-form--container"]'))).toBeTruthy();+ expect(fixture.debugElement.queryAll(By.css('formly-form')).length).toEqual(1);+ expect(fixture.debugElement.queryAll(By.css('formly-field')).length).toEqual(11);+ expect(fixture.debugElement.queryAll(By.css('op-text-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-formattable-textarea-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-select-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-date-input')).length).toEqual(1);+ expect(fixture.debugElement.queryAll(By.css('op-boolean-input')).length).toEqual(2);+ expect(fixture.debugElement.queryAll(By.css('op-integer-input')).length).toEqual(1);+ expect(fixture.debugElement.query(By.css('button[type=submit]'))).toBeTruthy();+ }));++ it('should submit the form and notify the user', fakeAsync(() => {+ // @ts-ignore+ dynamicFormService.getSettingsFromBackend$.and.returnValue(defer(() => Promise.resolve(dynamicFormSettings)));+ dynamicFormService.submit$.and.returnValue(defer(() => Promise.resolve('ok')));+ let submitButton;++ // Should not show notifications when showNotifications === false+ component.showNotifications = false;++ component.resourcePath = '/api/v3/projects/1234/form';+ component.ngOnChanges({});+ flush();+ fixture.detectChanges();+ submitButton = fixture.debugElement.query(By.css('button[type=submit]'));+ submitButton.nativeElement.click();++ flush();++ expect(dynamicFormService.submit$).toHaveBeenCalled();+ expect(notificationsService.addSuccess).not.toHaveBeenCalled();++ // Should not show notifications when showNotifications === true+ component.showNotifications = true;++ fixture.detectChanges();++ submitButton = fixture.debugElement.query(By.css('button[type=submit]'));+ submitButton.nativeElement.click();++ flush();++ expect(dynamicFormService.submit$).toHaveBeenCalled();+ expect(notificationsService.addSuccess).toHaveBeenCalled();++ dynamicFormService.submit$.and.returnValue(defer(() => {+ throw 'Error'+ }));++ submitButton.nativeElement.click();++ flush();++ expect(notificationsService.addError).toHaveBeenCalled();++ dynamicFormService.submit$.and.returnValue(defer(() => Promise.resolve('ok')));+ }));+});+diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.tsindex b433ca33ab5..1b6f72d74a9 100644--- a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts@@ -92,6 +92,7 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang@Input() showNotifications = true;@Input() showValidationErrorsOn:'change'|'blur'|'submit'|'never' = 'submit';@Input() handleSubmit = true;+ @Input() helpTextAttributeScope:string|undefined;@Input('dynamicFormGroup') form:FormGroup = new FormGroup({});@Input() set model(payload:IOPFormModel) {@@ -105,7 +106,6 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang/** Initial payload to POST to the form */@Input() initialPayload:Object = {};-@Output() modelChange = new EventEmitter<IOPFormModel>();@Output() submitted = new EventEmitter<HalSource>();@Output() errored = new EventEmitter<IOPFormErrorResponse>();@@ -272,7 +272,14 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang}private _setupDynamicForm({ fields, model }:IOPDynamicFormSettings) {- this.fields = this.fieldsSettingsPipe ? this.fieldsSettingsPipe(fields) : fields;+ const scopedFields = fields.map(field => ({+ ...field,+ templateOptions: {+ ...field.templateOptions,+ helpTextAttributeScope: this.helpTextAttributeScope,+ },+ }));+ this.fields = this.fieldsSettingsPipe ? this.fieldsSettingsPipe(scopedFields) : scopedFields;this.innerModel = model;this._changeDetectorRef.detectChanges();diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.spec.tsnew file mode 100644index 00000000000..3febf58e4c1--- /dev/null+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.spec.ts@@ -0,0 +1,59 @@+import { discardPeriodicTasks, fakeAsync, flush, tick } from '@angular/core/testing';+import {+ createDynamicInputFixture,+} from "core-app/modules/common/dynamic-forms/spec/helpers";+import { By } from "@angular/platform-browser";+// @ts-ignore+import(/* webpackChunkName: "ckeditor" */ 'core-vendor/ckeditor/ckeditor.js');++describe('FormattableTextareaInputComponent', () => {+ it('should load the field', fakeAsync(() => {+ const fieldsConfig = [+ {+ "type": "formattableInput" as "formattableInput",+ "className": "op-form--field inline-edit--field",+ "key": "testControl",+ "templateOptions": {+ "required": true,+ "label": "testControl",+ "type": "text",+ "placeholder": "",+ "disabled": false,+ "bindLabel": 'name',+ "bindValue": 'value',+ "noWrapLabel": true+ },+ }+ ];+ const formModel = {+ testControl: {+ html: '<p>tesValue</p>',+ raw: 'tesValue'+ },+ };+ const testModel = {+ initialValue: formModel.testControl,+ changedValue: 'testValue2',+ };+ const fixture = createDynamicInputFixture(fieldsConfig, formModel);+ const dynamicInput = fixture.debugElement.query(By.css('.document-editor__editable-container')).nativeElement;+ const dynamicControl = fixture.componentInstance.dynamicControl.field.formControl;+ const dynamicDebugElement = fixture.debugElement.query(By.css('op-formattable-control'));+ const dynamicElement = dynamicDebugElement.nativeElement;++ // Test ControlValueAccessor+ // Write Value+ expect(dynamicControl.value).toEqual(testModel.initialValue);+ expect(dynamicElement.classList.contains('ng-untouched')).toBeTrue();+ expect(dynamicElement.classList.contains('ng-valid')).toBeTrue();+ expect(dynamicElement.classList.contains('ng-pristine')).toBeTrue();++ fixture.detectChanges();+ tick(1000);+ flush();++ // Discard any editor intervals+ discardPeriodicTasks();+ }));+});+diff --git a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.tsnew file mode 100644index 00000000000..65c52bb4589--- /dev/null+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts@@ -0,0 +1,218 @@+import { TestBed } from '@angular/core/testing';+import { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";+import { HttpClient } from "@angular/common/http";+import { DynamicFieldsService } from "core-app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service";+import { isObservable } from "rxjs";++describe('DynamicFieldsService', () => {+ let httpClient: HttpClient;+ let httpTestingController: HttpTestingController;+ let service:DynamicFieldsService;++ beforeEach(() => {+ TestBed.configureTestingModule({+ imports: [+ HttpClientTestingModule,+ ],+ providers: [+ DynamicFieldsService,+ ]+ });+ httpClient = TestBed.inject(HttpClient);+ httpTestingController = TestBed.inject(HttpTestingController);+ service = TestBed.inject(DynamicFieldsService);+ });++ it('should be created', () => {+ expect(service).toBeTruthy();+ });++ it('should generate a proper dynamic form schema', () => {+ const formPayload = {+ "name": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ "title": "Parent project"+ }+ }+ };+ const formSchema = {+ "name": {+ "type": "String",+ "name": "Name",+ "required": true,+ "hasDefault": false,+ "writable": true,+ "minLength": 1,+ "maxLength": 255,+ "options": {}+ },+ "parent": {+ "type": "Project",+ "name": "Subproject of",+ "required": false,+ "hasDefault": false,+ "location": "_links",+ "writable": true,+ "_links": {+ "allowedValues": {+ "href": "/api/v3/projects/available_parent_projects?of=25"+ }+ }+ },+ "id": {+ "type": "Integer",+ "name": "ID",+ "required": true,+ "hasDefault": false,+ "writable": false,+ "options": {}+ },+ _dependencies: [],+ };++ // @ts-ignore+ const fieldsSchemas = service._getFieldsSchemasWithKey(formSchema, formPayload);++ expect(fieldsSchemas.length).toBe(2, 'should return only writable field schemas');+ expect(fieldsSchemas[0].key).toBe('name', 'should place the correct key on primitives');+ expect(fieldsSchemas[1].key).toBe('_links.parent', 'should place the correct key on resources');+ });++ it('should format the form model (add the name property to resources (_links: single and multiple))', () => {+ const formPayload = {+ "title": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ "title": "Parent project"+ },+ "children": [+ {+ "href": "/api/v3/projects/27",+ "title": "Child project 1"+ },+ {+ "href": "/api/v3/projects/28",+ "title": "Child project 2"+ }+ ]+ },+ };+ const formSchema = {+ "title": {+ "type": "String",+ "name": "Name",+ "required": true,+ "hasDefault": false,+ "writable": true,+ "minLength": 1,+ "maxLength": 255,+ "options": {}+ },+ "parent": {+ "type": "Project",+ "name": "Subproject of",+ "required": false,+ "hasDefault": false,+ "writable": true,+ "location": "_links",+ "_links": {+ "allowedValues": {+ "href": "/api/v3/projects/available_parent_projects?of=25"+ }+ }+ },+ "children": {+ "type": "Project",+ "name": "Project's children",+ "required": false,+ "hasDefault": false,+ "writable": true,+ "_links": {+ "allowedValues": {+ "href": "/api/v3/projects/available_parent_projects?of=25"+ }+ }+ },+ _dependencies: [],+ };++ // @ts-ignore+ const formModel = service.getModel(formPayload);+ const titleName = formModel.title;+ const parentProjectName = !Array.isArray(formModel._links!.parent) && formModel._links!.parent!.name;+ const childrenProjectsNames = Array.isArray(formModel._links!.children) && formModel._links!.children!.map((childProject: IOPFieldModel) => childProject.name);++ expect(titleName).toBe('Project 1', 'should add the payload value on primitives');+ expect(parentProjectName).toEqual('Parent project', 'should add a name property on resources');+ expect(childrenProjectsNames).toEqual(['Child project 1', 'Child project 2'], 'should add a name property on resources with multiple values');+ });++ it('should generate a proper dynamic form config', () => {+ const formPayload = {+ "name": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ "title": "Parent project"+ },+ }+ };+ const formSchema = {+ "parent": {+ "type": "Project",+ "name": "Subproject of",+ "required": false,+ "hasDefault": false,+ "writable": true,+ "_links": {+ "allowedValues": {+ "href": "/api/v3/projects/available_parent_projects?of=25"+ }+ }+ },+ "name": {+ "type": "String",+ "name": "Name",+ "required": true,+ "hasDefault": false,+ "writable": true,+ "minLength": 1,+ "maxLength": 255,+ "options": {},+ "attributeGroup": "People"+ },+ _attributeGroups: [+ {+ "_type": "WorkPackageFormAttributeGroup",+ "name": "People",+ "attributes": [+ "name",+ ]+ },+ ]+ };+ // @ts-ignore+ const formlyConfig = service.getConfig(formSchema, formPayload);+ const formlyFields = formlyConfig.reduce((result, formlyField) => {+ return formlyField.fieldGroup ? [...result, ...formlyField.fieldGroup] : [...result, formlyField];+ }, []);+ const formGroup = formlyConfig[1];+ const everyFieldHasCSSClass = formlyFields.every(formlyField => formlyField.className!.startsWith('op-form--field'));++ expect(everyFieldHasCSSClass).toBeTruthy('should place the op-form--field class on every field');+ expect(formlyFields[1].templateOptions!.required).toBe(true, 'should set the required attribute');+ expect(formlyFields[1].templateOptions!.label).toBe('Name', 'should set the correct label');+ expect(isObservable(formlyFields[0].templateOptions!.options)).toBeTruthy('should add options as observables');+ expect(formlyFields[0].className).toContain('Subproject of', 'should add the specific input type properties');+ expect(formlyFields[0].templateOptions!.locale).toBeTruthy('should add the specific input templateOptions');++ expect(formGroup).toBeTruthy();+ expect(formGroup.wrappers![0]).toEqual('op-dynamic-field-group-wrapper', 'should add the form field group wrapper');+ expect(formGroup.fieldGroupClassName).toEqual('op-form-group', 'should add the CSS class to the field group wrapper');+ expect(formGroup.templateOptions!.label).toEqual('People', 'should add the correct label to the field group wrapper');+ expect(formGroup.fieldGroup![0].key).toEqual('name', 'should add the correct key to the field group wrapper');+ });+});diff --git a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.tsindex f0f8dcc2778..b7ba05ef473 100644--- a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts@@ -1,12 +1,12 @@-import {Injectable} from '@angular/core';+import { Injectable } from '@angular/core';import {IOPDynamicInputTypeSettings,IOPFormlyFieldSettings,} from "../../typings";-import {FormlyFieldConfig} from "@ngx-formly/core";-import {of} from "rxjs";-import {map} from "rxjs/operators";-import {HttpClient} from "@angular/common/http";+import { FormlyFieldConfig } from "@ngx-formly/core";+import { of } from "rxjs";+import { map } from "rxjs/operators";+import { HttpClient } from "@angular/common/http";@Injectable()@@ -121,11 +121,12 @@ export class DynamicFieldsService {getFormattedFieldsModel(formModel:IOPFormModel = {}):IOPFormModel {const { _links: resourcesModel, _meta: metaModel, ...otherElementsModel } = formModel;+const model = {...otherElementsModel,_meta: metaModel,_links: this._getFormattedResourcesModel(resourcesModel),- }+ };return model;}@@ -172,7 +173,7 @@ export class DynamicFieldsService {result = {...result,[resourceKey]: resourceModel,- }+ };return result;}, {});diff --git a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.tsindex e69de29bb2d..457b91bf53a 100644--- a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts@@ -0,0 +1,176 @@+import { TestBed } from '@angular/core/testing';+import { DynamicFormService } from "core-app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service";+import { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";+import { HttpClient } from "@angular/common/http";+import { IOPDynamicFormSettings } from "core-app/modules/common/dynamic-forms/typings";+import { DynamicFieldsService } from "core-app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service";+import { FormGroup } from "@angular/forms";+import { of } from "rxjs";+import { FormsService } from "core-app/core/services/forms/forms.service";++describe('DynamicFormService', () => {+ let httpClient:HttpClient;+ let httpTestingController:HttpTestingController;+ let dynamicFormService:DynamicFormService;+ let formsService:jasmine.SpyObj<FormsService>;+ const testFormUrl = 'http://op.com/form';+ const formSchema = {+ "_type": "Form",+ "_embedded": {+ "payload": {+ "name": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ "title": "Parent project"+ }+ }+ },+ "schema": {+ "_type": "Schema",+ "_dependencies": [],+ "name": {+ "type": "String",+ "name": "Name",+ "required": true,+ "hasDefault": false,+ "writable": true,+ "minLength": 1,+ "maxLength": 255,+ "options": {}+ },+ "parent": {+ "type": "Project",+ "name": "Subproject of",+ "required": false,+ "hasDefault": false,+ "writable": true,+ "_links": {+ "allowedValues": {+ "href": "/api/v3/projects/available_parent_projects?of=25"+ }+ }+ },+ "_links": {}+ },+ "validationErrors": {}+ },+ "_links": {+ "self": {+ "href": "/api/v3/projects/25/form",+ "method": "post"+ },+ "validate": {+ "href": "/api/v3/projects/25/form",+ "method": "post"+ },+ "commit": {+ "href": "/api/v3/projects/25",+ "method": "patch"+ }+ }+ };+ const dynamicFormConfig = {+ "fields": [+ {+ "type": "textInput",+ "className": "op-form--field inline-edit--field",+ "key": "name",+ "templateOptions": {+ "required": true,+ "label": "Name",+ "type": "text"+ }+ },+ {+ "type": "selectInput",+ "className": "op-form--field inline-edit--field Subproject of",+ "expressionProperties": {},+ "key": "_links.parent",+ "templateOptions": {+ "required": false,+ "label": "Subproject of",+ "type": "number",+ "locale": "en",+ "bindLabel": "title",+ "searchable": false,+ "virtualScroll": true,+ "typeahead": false,+ "clearOnBackspace": false,+ "clearSearchOnAdd": false,+ "hideSelected": false,+ "text": {+ "add_new_action": "Create"+ },+ "options": of([]),+ }+ }+ ],+ "model": {+ "name": "Project 1",+ "_links": {+ "parent": {+ "href": "/api/v3/projects/26",+ "title": "Parent project",+ "name": "Parent project"+ }+ },+ "_meta": undefined+ },+ "form": new FormGroup({}),+ };++ beforeEach(() => {+ const formServiceSpy = jasmine.createSpyObj('FormsService', ['submit$']);++ TestBed.configureTestingModule({+ imports: [+ HttpClientTestingModule,+ ],+ providers: [+ DynamicFormService,+ DynamicFieldsService,+ { provide: FormsService, useValue: formServiceSpy }+ ]+ });+ httpClient = TestBed.inject(HttpClient);+ httpTestingController = TestBed.inject(HttpTestingController);+ dynamicFormService = TestBed.inject(DynamicFormService);+ formsService = TestBed.inject(FormsService) as jasmine.SpyObj<FormsService>;+ });++ it('should be created', () => {+ expect(dynamicFormService).toBeTruthy();+ });++ it('should return the dynamic form config from the backend response', () => {+ dynamicFormService+ .getSettingsFromBackend$(testFormUrl)+ .subscribe(dynamicFormConfigResponse => {+ expect(dynamicFormConfigResponse.fields.length).toEqual(dynamicFormConfig.fields.length, 'should return one dynamic field per schema field');+ expect(+ dynamicFormConfigResponse.fields.every((field, index) => field.type === dynamicFormConfig.fields[index].type)+ )+ .toBe(true, 'should return the dynamic fields in the schema order');+ expect(dynamicFormConfigResponse.model).toEqual(dynamicFormConfig.model, 'should return the form model formatted');+ });++ const req = httpTestingController.expectOne(testFormUrl);++ expect(req.request.method).toEqual('POST');+ req.flush(formSchema);+ httpTestingController.verify();+ });++ it('should submit the dynamic form value', () => {+ const dynamicForm = dynamicFormConfig.form;++ formsService.submit$.and.returnValue(of('ok response'));++ dynamicFormService+ .submit$(dynamicForm, testFormUrl)+ .subscribe();++ expect(formsService.submit$).toHaveBeenCalledWith(dynamicForm, testFormUrl, undefined, undefined);+ });+});diff --git a/frontend/src/app/modules/common/dynamic-forms/typings.d.ts b/frontend/src/app/modules/common/dynamic-forms/typings.d.tsindex 89b26cb0fc5..8b04a638265 100644--- a/frontend/src/app/modules/common/dynamic-forms/typings.d.ts+++ b/frontend/src/app/modules/common/dynamic-forms/typings.d.ts@@ -19,6 +19,7 @@ export interface IOPFormlyTemplateOptions extends FormlyTemplateOptions {isFieldGroup?:boolean;collapsibleFieldGroups?:boolean;collapsibleFieldGroupsCollapsed?:boolean;+ helpTextAttributeScope?:string;}type OPInputType = 'formattableInput'|'selectInput'|'textInput'|'integerInput'|diff --git a/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.component.ts b/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.component.tsindex 5db2d848e08..b2c8299caad 100644--- a/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.component.ts+++ b/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.component.ts@@ -38,7 +38,7 @@ import {ViewChild} from "@angular/core";import { I18nService } from "core-app/modules/common/i18n/i18n.service";-import { ContainHelpers } from "core-app/modules/common/focus/contain-helpers";+import { ContainHelpers } from "core-app/modules/focus/contain-helpers";import { InjectField } from "core-app/helpers/angular/inject-field.decorator";export const triggerEditingEvent = 'op:selectableTitle:trigger';diff --git a/frontend/src/app/modules/common/forms/form-field/form-field.component.html b/frontend/src/app/modules/common/forms/form-field/form-field.component.htmlindex 3d9b669b7cc..35c42b679dd 100644--- a/frontend/src/app/modules/common/forms/form-field/form-field.component.html+++ b/frontend/src/app/modules/common/forms/form-field/form-field.component.html@@ -1,6 +1,13 @@<ng-container *ngIf="!hidden"><label class="op-form-field--label-wrap">- <ng-container *ngTemplateOutlet="inputLabelTemplate"></ng-container>+ <div class="op-form-field--label">+ {{ label }}+ <span *ngIf="required" class="op-form-field--label-indicator">*</span>+ <attribute-help-text+ [attribute]="helpTextAttribute"+ [attributeScope]="helpTextAttributeScope"+ ></attribute-help-text>+ </div><ng-container *ngIf="!noWrapLabel"><ng-container *ngTemplateOutlet="inputTemplate"></ng-container>@@ -30,10 +37,3 @@<ng-content select="[slot=help-text]"></ng-content></div></ng-template>--<ng-template #inputLabelTemplate>- <div class="op-form-field--label">- {{ label }}- <span *ngIf="required" class="op-form-field--label-indicator">*</span>- </div>-</ng-template>diff --git a/frontend/src/app/modules/common/forms/form-field/form-field.component.ts b/frontend/src/app/modules/common/forms/form-field/form-field.component.tsindex 1e5ea302812..b3d804b2632 100644--- a/frontend/src/app/modules/common/forms/form-field/form-field.component.ts+++ b/frontend/src/app/modules/common/forms/form-field/form-field.component.ts@@ -25,6 +25,12 @@ export class OpFormFieldComponent implements OnInit{}@Input() label = '';+ @Input() set helpTextAttribute(helpTextAttribute:string|undefined) {+ this._helpTextAttribute = helpTextAttribute;+ };+ @Input() set helpTextAttributeScope(helpTextAttributeScope:string|undefined) {+ this._helpTextAttributeScope = helpTextAttributeScope;+ };@Input() noWrapLabel = true;@Input() required = false;@Input() showValidationErrorOn: 'change' | 'blur' | 'submit' | 'never';@@ -57,10 +63,21 @@ export class OpFormFieldComponent implements OnInit{return this._dynamicControl?.field?.hide;}+ get helpTextAttribute() {+ return this._helpTextAttribute || this._dynamicControl?.field?.templateOptions?.property;+ }++ get helpTextAttributeScope() {+ return this._helpTextAttributeScope || this._dynamicFormComponent?.helpTextAttributeScope;+ }++ private _helpTextAttribute:string|undefined;+ private _helpTextAttributeScope:string|undefined;+constructor(- @Optional() private _dynamicControl: FormlyField,@Optional() private _formGroupDirective:FormGroupDirective,@Optional() private _dynamicFormComponent:DynamicFormComponent,+ @Optional() private _dynamicControl:FormlyField,) {}ngOnInit() {diff --git a/frontend/src/app/modules/common/op-date-picker/datepicker.ts b/frontend/src/app/modules/common/op-date-picker/datepicker.tsindex 797b4b12db8..eb58d557c62 100644--- a/frontend/src/app/modules/common/op-date-picker/datepicker.ts+++ b/frontend/src/app/modules/common/op-date-picker/datepicker.ts@@ -121,7 +121,7 @@ export class DatePicker {// multiple scrolls event when it is openconst target = event.target! as HTMLInputElement;- if (target.classList.contains('flatpickr-monthDropdown-months')) {+ if (target?.classList?.contains('flatpickr-monthDropdown-months')) {return;}diff --git a/frontend/src/app/modules/common/openproject-common.module.ts b/frontend/src/app/modules/common/openproject-common.module.tsindex f8b30b750f4..482f0f0a217 100644--- a/frontend/src/app/modules/common/openproject-common.module.ts+++ b/frontend/src/app/modules/common/openproject-common.module.ts@@ -38,6 +38,9 @@ import {StateService, UIRouterModule} from '@uirouter/angular';import {HookService} from '../plugins/hook-service';import {OpenprojectAccessibilityModule} from 'core-app/modules/a11y/openproject-a11y.module';import {CurrentUserModule} from 'core-app/modules/current-user/current-user.module';+import {IconModule} from 'core-app/modules/icon/icon.module';+import {AttributeHelpTextModule} from 'core-app/modules/attribute-help-texts/attribute-help-text.module';+import {IconTriggeredContextMenuComponent} from 'core-components/op-context-menu/icon-triggered-context-menu/icon-triggered-context-menu.component';import {CurrentProjectService} from 'core-components/projects/current-project.service';import {TablePaginationComponent} from 'core-components/table-pagination/table-pagination.component';@@ -51,7 +54,6 @@ import {BoardVideoTeaserModalComponent} from 'core-app/modules/boards/board/boarimport {highlightColBootstrap} from './highlight-col/highlight-col.directive';import {HighlightColDirective} from './highlight-col/highlight-col.directive';import {CopyToClipboardDirective} from './copy-to-clipboard/copy-to-clipboard.directive';-import {AuthoringComponent} from './authoring/authoring.component';import {OpDateTimeComponent} from './date/op-date-time.component';import {NotificationComponent} from './notifications/notification.component';import {NotificationsContainerComponent} from './notifications/notifications-container.component';@@ -73,10 +75,9 @@ import {DynamicBootstrapModule} from './dynamic-bootstrap/dynamic-bootstrap.moduimport {OpFormFieldComponent} from './forms/form-field/form-field.component';import {OpFormBindingDirective} from './forms/form-field/form-binding.directive';import {OpOptionListComponent} from './option-list/option-list.component';-import {OpIconComponent} from './icon/icon.component';import {OpenprojectPrincipalRenderingModule} from "core-app/modules/principal/principal-rendering.module";import { DatePickerModule } from "core-app/modules/common/op-date-picker/date-picker.module";-import { FocusModule } from "core-app/modules/common/focus/focus.module";+import { FocusModule } from "core-app/modules/focus/focus.module";export function bootstrapModule(injector:Injector) {@@ -123,6 +124,8 @@ export function bootstrapModule(injector:Injector) {DatePickerModule,FocusModule,+ IconModule,+ AttributeHelpTextModule,],exports: [// Re-export all commonly used@@ -132,6 +135,8 @@ export function bootstrapModule(injector:Injector) {FormsModule,PortalModule,DragDropModule,+ IconModule,+ AttributeHelpTextModule,OpenprojectAccessibilityModule,NgSelectModule,NgOptionHighlightModule,@@ -143,8 +148,6 @@ export function bootstrapModule(injector:Injector) {OpDateTimeComponent,AutofocusDirective,- AuthoringComponent,-// NotificationsNotificationsContainerComponent,NotificationComponent,@@ -183,14 +186,11 @@ export function bootstrapModule(injector:Injector) {OpFormFieldComponent,OpFormBindingDirective,OpOptionListComponent,- OpIconComponent,],declarations: [OpDateTimeComponent,AutofocusDirective,- AuthoringComponent,-// NotificationsNotificationsContainerComponent,NotificationComponent,@@ -242,7 +242,6 @@ export function bootstrapModule(injector:Injector) {OpFormFieldComponent,OpFormBindingDirective,OpOptionListComponent,- OpIconComponent,]})export class OpenprojectCommonModule {diff --git a/frontend/src/app/modules/fields/edit/field-handler/hal-resource-edit-field-handler.ts b/frontend/src/app/modules/fields/edit/field-handler/hal-resource-edit-field-handler.tsindex 72986f00c0c..3ee4a536e6e 100644--- a/frontend/src/app/modules/fields/edit/field-handler/hal-resource-edit-field-handler.ts+++ b/frontend/src/app/modules/fields/edit/field-handler/hal-resource-edit-field-handler.ts@@ -30,7 +30,7 @@ import { keyCodes } from 'core-app/modules/common/keyCodes.enum';import { I18nService } from 'core-app/modules/common/i18n/i18n.service';import { ConfigurationService } from 'core-app/modules/common/config/configuration.service';import { Injector } from '@angular/core';-import { FocusHelperService } from 'core-app/modules/common/focus/focus-helper';+import { FocusHelperService } from 'core-app/modules/focus/focus-helper';import { EditFieldHandler } from "core-app/modules/fields/edit/editing-portal/edit-field-handler";import { ClickPositionMapper } from "core-app/modules/common/set-click-position/set-click-position";import { debugLog } from "core-app/helpers/debug_output";diff --git a/frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.module.ts b/frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.module.tsindex e037d948831..3b85c47faef 100644--- a/frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.module.ts+++ b/frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.module.ts@@ -1,8 +1,8 @@import { NgModule } from '@angular/core';import { CommonModule } from '@angular/common';-import { TextEditFieldComponent } from "core-app/modules/fields/edit/field-types/text-edit-field/text-edit-field.component";import { FormsModule } from "@angular/forms";-import { FocusModule } from "core-app/modules/common/focus/focus.module";+import { TextEditFieldComponent } from "core-app/modules/fields/edit/field-types/text-edit-field/text-edit-field.component";+import { FocusModule } from "core-app/modules/focus/focus.module";@NgModule({imports: [diff --git a/frontend/src/app/modules/fields/openproject-fields.module.ts b/frontend/src/app/modules/fields/openproject-fields.module.tsindex 220d289dcd8..8f15853331a 100644--- a/frontend/src/app/modules/fields/openproject-fields.module.ts+++ b/frontend/src/app/modules/fields/openproject-fields.module.ts@@ -27,11 +27,13 @@//++import { APP_INITIALIZER, NgModule } from '@angular/core';+import { CommonModule } from "@angular/common";import { OpenprojectAccessibilityModule } from "core-app/modules/a11y/openproject-a11y.module";import { OpenprojectModalModule } from "core-app/modules/modal/modal.module";import { OpenprojectEditorModule } from 'core-app/modules/editor/openproject-editor.module';import { OpenprojectAttachmentsModule } from "core-app/modules/attachments/openproject-attachments.module";import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";+import { AttributeHelpTextModule } from "core-app/modules/attribute-help-texts/attribute-help-text.module";import { EditFieldService } from "core-app/modules/fields/edit/edit-field.service";import { DisplayFieldService } from "core-app/modules/fields/display/display-field.service";import { initializeCoreEditFields } from "core-app/modules/fields/edit/edit-field.initializer";@@ -49,8 +51,6 @@ import { PlainFormattableEditFieldComponent } from "core-app/modules/fields/editimport { TimeEntryWorkPackageEditFieldComponent } from "core-app/modules/fields/edit/field-types/te-work-package-edit-field.component";import { AttributeValueMacroComponent } from "core-app/modules/fields/macros/attribute-value-macro.component";import { AttributeLabelMacroComponent } from "core-app/modules/fields/macros/attribute-label-macro.component";-import { AttributeHelpTextComponent } from "core-app/modules/fields/help-texts/attribute-help-text.component";-import { AttributeHelpTextModal } from "core-app/modules/fields/help-texts/attribute-help-text.modal";import { WorkPackageQuickinfoMacroComponent } from "core-app/modules/fields/macros/work-package-quickinfo-macro.component";import { DisplayFieldComponent } from "core-app/modules/fields/display/display-field.component";import { OpenprojectAutocompleterModule } from "core-app/modules/autocompleter/openproject-autocompleter.module";@@ -64,12 +64,14 @@ import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-cont@NgModule({imports: [+ CommonModule,OpenprojectCommonModule,OpenprojectAttachmentsModule,OpenprojectAccessibilityModule,OpenprojectEditorModule,OpenprojectModalModule,OpenprojectAutocompleterModule,+ AttributeHelpTextModule,// Input ModulesBooleanEditFieldModule,IntegerEditFieldModule,@@ -83,7 +85,6 @@ import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-contEditFormPortalComponent,EditFormComponent,EditableAttributeFieldComponent,- AttributeHelpTextComponent,],providers: [{@@ -114,9 +115,6 @@ import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-contAttributeValueMacroComponent,AttributeLabelMacroComponent,- // Help texts- AttributeHelpTextComponent,- AttributeHelpTextModal,WorkPackageQuickinfoMacroComponent,]})diff --git a/frontend/src/app/modules/common/focus/contain-helpers.ts b/frontend/src/app/modules/focus/contain-helpers.tssimilarity index 100%rename from frontend/src/app/modules/common/focus/contain-helpers.tsrename to frontend/src/app/modules/focus/contain-helpers.tsdiff --git a/frontend/src/app/modules/common/focus/focus-helper.ts b/frontend/src/app/modules/focus/focus-helper.tssimilarity index 100%rename from frontend/src/app/modules/common/focus/focus-helper.tsrename to frontend/src/app/modules/focus/focus-helper.tsdiff --git a/frontend/src/app/modules/common/focus/focus-within.directive.ts b/frontend/src/app/modules/focus/focus-within.directive.tssimilarity index 100%rename from frontend/src/app/modules/common/focus/focus-within.directive.tsrename to frontend/src/app/modules/focus/focus-within.directive.tsdiff --git a/frontend/src/app/modules/common/focus/focus.directive.ts b/frontend/src/app/modules/focus/focus.directive.tssimilarity index 95%rename from frontend/src/app/modules/common/focus/focus.directive.tsrename to frontend/src/app/modules/focus/focus.directive.tsindex b11c46def8c..e324ea12847 100644--- a/frontend/src/app/modules/common/focus/focus.directive.ts+++ b/frontend/src/app/modules/focus/focus.directive.ts@@ -27,7 +27,7 @@//++import { AfterViewInit, Directive, ElementRef, Input } from "@angular/core";-import { FocusHelperService } from "core-app/modules/common/focus/focus-helper";+import { FocusHelperService } from "core-app/modules/focus/focus-helper";@Directive({selector: '[focus]'diff --git a/frontend/src/app/modules/common/focus/focus.module.ts b/frontend/src/app/modules/focus/focus.module.tssimilarity index 63%rename from frontend/src/app/modules/common/focus/focus.module.tsrename to frontend/src/app/modules/focus/focus.module.tsindex 8623cd4a000..33fb0090b3d 100644--- a/frontend/src/app/modules/common/focus/focus.module.ts+++ b/frontend/src/app/modules/focus/focus.module.ts@@ -1,7 +1,8 @@import { NgModule } from '@angular/core';import { CommonModule } from '@angular/common';-import { FocusWithinDirective } from "core-app/modules/common/focus/focus-within.directive";-import { FocusDirective } from "core-app/modules/common/focus/focus.directive";++import { FocusWithinDirective } from "./focus-within.directive";+import { FocusDirective } from "./focus.directive";diff --git a/frontend/src/app/modules/global_search/global-search-work-packages.component.ts b/frontend/src/app/modules/global_search/global-search-work-packages.component.tsindex 2f44e7e259d..2c55bb919fb 100644--- a/frontend/src/app/modules/global_search/global-search-work-packages.component.ts+++ b/frontend/src/app/modules/global_search/global-search-work-packages.component.ts@@ -27,7 +27,7 @@//++import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, Renderer2 } from '@angular/core';-import { FocusHelperService } from 'app/modules/common/focus/focus-helper';+import { FocusHelperService } from 'app/modules/focus/focus-helper';import { I18nService } from 'app/modules/common/i18n/i18n.service';import { HalResourceService } from "app/modules/hal/services/hal-resource.service";import { GlobalSearchService } from "core-app/modules/global_search/services/global-search.service";diff --git a/frontend/src/app/modules/global_search/input/global-search-input.component.ts b/frontend/src/app/modules/global_search/input/global-search-input.component.tsindex 20acf4c4e61..c999d193ad7 100644--- a/frontend/src/app/modules/global_search/input/global-search-input.component.ts+++ b/frontend/src/app/modules/global_search/input/global-search-input.component.ts@@ -37,7 +37,7 @@ import {ViewChild,ViewEncapsulation} from '@angular/core';-import { ContainHelpers } from 'core-app/modules/common/focus/contain-helpers';+import { ContainHelpers } from 'core-app/modules/focus/contain-helpers';import { I18nService } from 'core-app/modules/common/i18n/i18n.service';import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";import { HalResourceService } from "core-app/modules/hal/services/hal-resource.service";diff --git a/frontend/src/app/modules/common/icon/icon.component.ts b/frontend/src/app/modules/icon/icon.component.tssimilarity index 100%rename from frontend/src/app/modules/common/icon/icon.component.tsrename to frontend/src/app/modules/icon/icon.component.tsdiff --git a/frontend/src/app/modules/icon/icon.module.ts b/frontend/src/app/modules/icon/icon.module.tsnew file mode 100644index 00000000000..ad5169d41d1--- /dev/null+++ b/frontend/src/app/modules/icon/icon.module.ts@@ -0,0 +1,18 @@+import { NgModule } from "@angular/core";+import { CommonModule } from "@angular/common";+import { OpIconComponent } from './icon.component';++@NgModule({+ imports: [+ CommonModule,+ ],+ declarations: [+ OpIconComponent,+ ],+ providers: [+ ],+ exports: [+ OpIconComponent,+ ]+})+export class IconModule {}diff --git a/frontend/src/app/modules/common/icon/op-icon.spec.ts b/frontend/src/app/modules/icon/op-icon.spec.tssimilarity index 97%rename from frontend/src/app/modules/common/icon/op-icon.spec.tsrename to frontend/src/app/modules/icon/op-icon.spec.tsindex e0a70203afe..6e6f9aafcd9 100644--- a/frontend/src/app/modules/common/icon/op-icon.spec.ts+++ b/frontend/src/app/modules/icon/op-icon.spec.ts@@ -29,7 +29,7 @@import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";import { By } from "@angular/platform-browser";import { DebugElement } from "@angular/core";-import { OpIconComponent } from "core-app/modules/common/icon/icon.component";+import { OpIconComponent } from "./icon.component";describe('opIcon Directive', function() {let app:OpIconComponent;diff --git a/frontend/src/app/modules/modal/modal.module.ts b/frontend/src/app/modules/modal/modal.module.tsindex 82cfd6b7e33..3691fd9a4ea 100644--- a/frontend/src/app/modules/modal/modal.module.ts+++ b/frontend/src/app/modules/modal/modal.module.ts@@ -1,11 +1,17 @@import { NgModule } from "@angular/core";-import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";+import { CommonModule } from "@angular/common";+import { FocusModule } from "core-app/modules/focus/focus.module";+import { IconModule } from "core-app/modules/icon/icon.module";import { OpModalService } from "./modal.service";import { OpModalWrapperAugmentService } from "./modal-wrapper-augment.service";import { OpModalHeaderComponent } from "./modal-header.component";@NgModule({- imports: [ OpenprojectCommonModule ],+ imports: [+ CommonModule,+ FocusModule,+ IconModule,+ ],exports: [ OpModalHeaderComponent ],providers: [OpModalService,diff --git a/frontend/src/app/modules/modal/modal.service.ts b/frontend/src/app/modules/modal/modal.service.tsindex 50f3c8c2afd..f2e6fea381a 100644--- a/frontend/src/app/modules/modal/modal.service.ts+++ b/frontend/src/app/modules/modal/modal.service.ts@@ -10,7 +10,7 @@ import { ComponentPortal, ComponentType, DomPortalOutlet, PortalInjector } fromimport { TransitionService } from '@uirouter/core';import { OpModalComponent } from 'core-app/modules/modal/modal.component';import { keyCodes } from 'core-app/modules/common/keyCodes.enum';-import { FocusHelperService } from 'core-app/modules/common/focus/focus-helper';+import { FocusHelperService } from 'core-app/modules/focus/focus-helper';export const OpModalLocalsToken = new InjectionToken<any>('OP_MODAL_LOCALS');diff --git a/frontend/src/app/modules/projects/components/copy-project/copy-project.component.html b/frontend/src/app/modules/projects/components/copy-project/copy-project.component.htmlindex 0df7d9f2194..387cb774823 100644--- a/frontend/src/app/modules/projects/components/copy-project/copy-project.component.html+++ b/frontend/src/app/modules/projects/components/copy-project/copy-project.component.html@@ -2,5 +2,5 @@[formUrl]="formUrl"[fieldsSettingsPipe]="dynamicFieldsSettingsPipe"(submitted)="onSubmitted($event)"->-</op-dynamic-form>\ No newline at end of file+ helpTextAttributeScope="Project"+></op-dynamic-form>\ No newline at end of filediff --git a/frontend/src/app/modules/projects/components/new-project/new-project.component.html b/frontend/src/app/modules/projects/components/new-project/new-project.component.htmlindex 90475cae95c..4e571cf81e8 100644--- a/frontend/src/app/modules/projects/components/new-project/new-project.component.html+++ b/frontend/src/app/modules/projects/components/new-project/new-project.component.html@@ -23,5 +23,5 @@[initialPayload]="initialPayload"[fieldsSettingsPipe]="dynamicFieldsSettingsPipe"(submitted)="onSubmitted($event)"->-</op-dynamic-form>\ No newline at end of file+ helpTextAttributeScope="Project"+></op-dynamic-form>\ No newline at end of filediff --git a/frontend/src/app/modules/projects/components/projects/projects.component.html b/frontend/src/app/modules/projects/components/projects/projects.component.htmlindex a1175266131..298deb5b645 100644--- a/frontend/src/app/modules/projects/components/projects/projects.component.html+++ b/frontend/src/app/modules/projects/components/projects/projects.component.html@@ -1,4 +1,6 @@-<op-dynamic-form [resourceId]="resourceId"- [resourcePath]="projectsPath"- [fieldsSettingsPipe]="dynamicFieldsSettingsPipe">-</op-dynamic-form>\ No newline at end of file+<op-dynamic-form+ [resourceId]="resourceId"+ [resourcePath]="projectsPath"+ [fieldsSettingsPipe]="dynamicFieldsSettingsPipe"+ helpTextAttributeScope="Project"+></op-dynamic-form>\ No newline at end of filediff --git a/frontend/src/app/modules/projects/openproject-projects.module.ts b/frontend/src/app/modules/projects/openproject-projects.module.tsindex 5c7b80987bc..d0a2f45f738 100644--- a/frontend/src/app/modules/projects/openproject-projects.module.ts+++ b/frontend/src/app/modules/projects/openproject-projects.module.ts@@ -26,17 +26,17 @@// See docs/COPYRIGHT.rdoc for more details.//++-import { OpenprojectFieldsModule } from 'core-app/modules/fields/openproject-fields.module';import { NgModule } from '@angular/core';import { OpenprojectHalModule } from "core-app/modules/hal/openproject-hal.module";import { UIRouterModule } from "@uirouter/angular";+import { OpenprojectFieldsModule } from 'core-app/modules/fields/openproject-fields.module';import { PROJECTS_ROUTES, uiRouterProjectsConfiguration } from "core-app/modules/projects/projects-routes";import { ProjectsComponent } from './components/projects/projects.component';import { DynamicFormsModule } from "core-app/modules/common/dynamic-forms/dynamic-forms.module";import { NewProjectComponent } from "core-app/modules/projects/components/new-project/new-project.component";import { ReactiveFormsModule } from "@angular/forms";import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";-import {CopyProjectComponent} from "core-app/modules/projects/components/copy-project/copy-project.component";+import { CopyProjectComponent } from "core-app/modules/projects/components/copy-project/copy-project.component";@NgModule({imports: [diff --git a/spec/features/projects/attribute_help_texts_spec.rb b/spec/features/projects/attribute_help_texts_spec.rbindex 151db89eada..0a3a7d580c7 100644--- a/spec/features/projects/attribute_help_texts_spec.rb+++ b/spec/features/projects/attribute_help_texts_spec.rb@@ -35,6 +35,9 @@ describe 'Project attribute help texts', type: :feature, js: true doFactoryBot.create :project_help_text,attribute_name: :status,help_text: 'Some **help text** for status.'+ FactoryBot.create :project_help_text,+ attribute_name: :description,+ help_text: 'Some **help text** for description.'endlet(:grid) do@@ -81,13 +84,11 @@ describe 'Project attribute help texts', type: :feature, js: true doit_behaves_like 'allows to view help texts'it 'shows the help text on the project create form' do- skip 'Attribute help texts are not working yet on dynamic forms'-visit new_project_pathpage.find('.form--fieldset-legend', text: 'ADVANCED SETTINGS').click- expect(page).to have_selector('.form--label attribute-help-text', wait: 10)+ expect(page).to have_selector('.op-form-field--label attribute-help-text', wait: 10)# Open help text modalmodal.open!