Skip to content

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

Feature/36382 multi selection for project custom fields base (#9164)

Aleix Suauf5d2a7467bee
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index a6e9cc6df8f..be4f6c4e7df 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -196,6 +196,12 @@ class ProjectsController < ApplicationController
end
end
+ ##
+ # Redirect as action as routes can only redirect by full path
+ def settings
+ redirect_to settings_generic_project_path(@project)
+ end
+
private
def find_optional_project
diff --git a/app/views/project_settings/generic.html.erb b/app/views/project_settings/generic.html.erb
index beb3e0512ca..baa38587602 100644
--- a/app/views/project_settings/generic.html.erb
+++ b/app/views/project_settings/generic.html.erb
@@ -26,4 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
-<%= render partial: 'projects/edit' %>
+<%= render partial: 'projects/toolbar' %>
+
+<openproject-base></openproject-base>
\ No newline at end of file
diff --git a/app/views/projects/_edit.html.erb b/app/views/projects/_edit.html.erb
index efdc71f7331..53f8e8fcb25 100644
--- a/app/views/projects/_edit.html.erb
+++ b/app/views/projects/_edit.html.erb
@@ -27,66 +27,7 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
-<%= toolbar title: t(:label_information_plural) do %>
- <% if User.current.allowed_to?(:add_subprojects, @project) %>
- <li class="toolbar-item">
- <%= link_to new_project_path(parent_id: @project.id),
- { class: 'button -alt-highlight',
- aria: {label: t(:label_subproject_new)},
- title: t(:label_subproject_new)} do %>
- <%= op_icon('button--icon icon-add') %>
- <span class="button--text"><%= t(:label_subproject) %></span>
- <% end %>
- </li>
- <% end %>
- <li class="toolbar-item hidden-for-mobile">
- <%= link_to identifier_project_path(@project), class: 'button' do %>
- <%= op_icon('button--icon icon-edit') %>
- <span class="button--text"><%= t('projects.settings.change_identifier') %></span>
- <% end %>
- </li>
- <% if @project.copy_allowed? %>
- <li class="toolbar-item hidden-for-mobile">
- <%= link_to copy_from_project_path(@project, coming_from: :settings), class: 'button copy', accesskey: accesskey(:copy) do %>
- <%= op_icon('button--icon icon-copy') %>
- <span class="button--text"><%= t(:button_copy) %></span>
- <% end %>
- </li>
- <% end %>
- <% if User.current.admin? %>
- <li class="toolbar-item hidden-for-mobile">
- <%= link_to(archive_project_path(@project, status: '', name: @project.name),
- data: { confirm: t('project.archive.are_you_sure', name: @project.name) },
- method: :put,
- title: t(:label_archive_project),
- class: 'button') do %>
- <%= op_icon('button--icon icon-locked') %>
- <span class="button--text"><%= t(:button_archive) %></span>
- <% end %>
- </li>
- <li class="toolbar-item hidden-for-mobile">
- <%= form_for(@project,
- html: { class: 'toolbar-item'},
- url: project_path(@project),
- method: :patch) do |f| %>
- <%= f.hidden_field :templated, value: [email protected] %>
- <% label = @project.templated ? 'remove_from_templates' : 'make_template' %>
- <button class="button" title="<%= t("project.template.#{label}") %>">
- <%= op_icon('button--icon icon-duplicate') unless @project.templated %>
- <span class="button--text"><%= t("project.template.#{label}") %></span>
- </button>
- </li>
- <% end %>
- <li class="toolbar-item">
- <%= link_to confirm_destroy_project_path(@project),
- class: 'button delete',
- title: t(:label_delete_project) do %>
- <%= op_icon('button--icon icon-delete') %>
- <span class="button--text"><%= t(:button_delete) %></span>
- <% end %>
- </li>
- <% end %>
-<% end %>
+<%= render partial: 'toolbar' %>
<%= labelled_tabular_form_for @altered_project, url: project_path(@project) do |f| %>
<%= render partial: '/projects/form',
diff --git a/app/views/projects/_toolbar.html.erb b/app/views/projects/_toolbar.html.erb
new file mode 100644
index 00000000000..40e1965e20a
--- /dev/null
+++ b/app/views/projects/_toolbar.html.erb
@@ -0,0 +1,89 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2021 the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See docs/COPYRIGHT.rdoc for more details.
+
+++#%>
+
+<%= toolbar title: t(:label_information_plural) do %>
+ <% if User.current.allowed_to?(:add_subprojects, @project) %>
+ <li class="toolbar-item">
+ <%= link_to new_project_path(parent_id: @project.id),
+ { class: 'button -alt-highlight',
+ aria: {label: t(:label_subproject_new)},
+ title: t(:label_subproject_new)} do %>
+ <%= op_icon('button--icon icon-add') %>
+ <span class="button--text"><%= t(:label_subproject) %></span>
+ <% end %>
+ </li>
+ <% end %>
+ <li class="toolbar-item hidden-for-mobile">
+ <%= link_to identifier_project_path(@project), class: 'button' do %>
+ <%= op_icon('button--icon icon-edit') %>
+ <span class="button--text"><%= t('projects.settings.change_identifier') %></span>
+ <% end %>
+ </li>
+ <% if @project.copy_allowed? %>
+ <li class="toolbar-item hidden-for-mobile">
+ <%= link_to copy_from_project_path(@project, coming_from: :settings), class: 'button copy', accesskey: accesskey(:copy) do %>
+ <%= op_icon('button--icon icon-copy') %>
+ <span class="button--text"><%= t(:button_copy) %></span>
+ <% end %>
+ </li>
+ <% end %>
+ <% if User.current.admin? %>
+ <li class="toolbar-item hidden-for-mobile">
+ <%= link_to(archive_project_path(@project, status: '', name: @project.name),
+ data: { confirm: t('project.archive.are_you_sure', name: @project.name) },
+ method: :put,
+ title: t(:label_archive_project),
+ class: 'button') do %>
+ <%= op_icon('button--icon icon-locked') %>
+ <span class="button--text"><%= t(:button_archive) %></span>
+ <% end %>
+ </li>
+ <li class="toolbar-item hidden-for-mobile">
+ <%= form_for(@project,
+ html: { class: 'toolbar-item'},
+ url: project_path(@project),
+ method: :patch) do |f| %>
+ <%= f.hidden_field :templated, value: [email protected] %>
+ <% label = @project.templated ? 'remove_from_templates' : 'make_template' %>
+ <button class="button" title="<%= t("project.template.#{label}") %>">
+ <%= op_icon('button--icon icon-duplicate') unless @project.templated %>
+ <span class="button--text"><%= t("project.template.#{label}") %></span>
+ </button>
+ </li>
+ <% end %>
+ <li class="toolbar-item">
+ <%= link_to confirm_destroy_project_path(@project),
+ class: 'button delete',
+ title: t(:label_delete_project) do %>
+ <%= op_icon('button--icon icon-delete') %>
+ <span class="button--text"><%= t(:button_delete) %></span>
+ <% end %>
+ </li>
+ <% end %>
+<% end %>
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index fc7a95dd6de..daf2e758dc8 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -1135,3 +1135,8 @@ en:
placeholder: 'The placeholder can now be used in %{project}. Meanwhile you can already plan with that user and assign work packages for instance.'
group: 'The group is now a part of %{project}. Meanwhile you can already plan with that group and assign work packages for instance.'
next_button: 'Continue'
+
+ forms:
+ submit_success_message: 'The form was successfully submitted'
+ load_error_message: 'There was an error loading the form'
+ validation_error_message: 'Please fix the errors present in the form'
diff --git a/config/routes.rb b/config/routes.rb
index 4536e76e4a3..cc409df161a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -171,7 +171,7 @@ OpenProject::Application.routes.draw do
ProjectSettingsHelper.project_settings_tabs.each do |tab|
get "settings/#{tab[:name]}", controller: "project_settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}"
end
- get "settings", controller: "project_settings/generic", action: 'show', as: "project_settings"
+ get "settings"
get 'identifier', action: 'identifier'
patch 'identifier', action: 'update_identifier'
diff --git a/frontend/package.json b/frontend/package.json
index b2073b6006f..5d6c5e8f0ae 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -51,6 +51,7 @@
"@kolkov/ngx-gallery": "^1.0.11",
"@ng-select/ng-option-highlight": "0.0.5",
"@ng-select/ng-select": "^4.0.4",
+ "@ngx-formly/core": "^6.0.0-next.1",
"@sentry/angular": "^6.2.3",
"@sentry/tracing": "^6.2.3",
"@types/chart.js": "^2.9.20",
diff --git a/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts b/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
index acfa348d20d..ae7148d6d28 100644
--- a/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
+++ b/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
@@ -9,28 +9,21 @@ import { HalResourceSortingService } from 'core-app/modules/hal/services/hal-res
import { NgSelectComponent } from '@ng-select/ng-select';
import { APIV3Service } from 'core-app/modules/apiv3/api-v3.service';
import { DebouncedRequestSwitchmap, errorNotificationHandler } from 'core-app/helpers/rxjs/debounced-input-switchmap';
-import { ValueOption } from 'core-app/modules/fields/edit/field-types/select-edit-field.component';
+import { ValueOption } from 'core-app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component';
import { Observable } from 'rxjs';
import { HalResourceNotificationService } from 'core-app/modules/hal/services/hal-resource-notification.service';
import { CurrentProjectService } from 'core-app/components/projects/current-project.service';
import { ApiV3FilterBuilder, FilterOperator } from 'core-app/components/api/api-v3/api-v3-filter-builder';
import { map } from 'rxjs/operators';
import { APIv3ResourceCollection } from 'core-app/modules/apiv3/paths/apiv3-resource';
-import { UserResource } from 'core-app/modules/hal/resources/user-resource';
-import { APIv3UserPaths } from 'core-app/modules/apiv3/endpoints/users/apiv3-user-paths';
-import { APIV3WorkPackagePaths } from 'core-app/modules/apiv3/endpoints/work_packages/api-v3-work-package-paths';
-import { WorkPackageResource } from 'core-app/modules/hal/resources/work-package-resource';
import { UntilDestroyedMixin } from 'core-app/helpers/angular/until-destroyed.mixin';
import { CachableAPIV3Resource } from "core-app/modules/apiv3/cache/cachable-apiv3-resource";
-export interface FilterConditions {name:string; operator:FilterOperator; values:unknown[]|boolean; }
@Component({
selector: 'filter-searchable-multiselect-value',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl:'./filter-searchable-multiselect-value.component.html'
})
-
-
export class FilterSearchableMultiselectValueComponent extends UntilDestroyedMixin implements OnInit, AfterViewInit {
@Input() public filter:QueryFilterInstanceResource;
@Input() public shouldFocus = false;
diff --git a/frontend/src/app/components/work-packages/work-package-comment/wp-comment-field.component.ts b/frontend/src/app/components/work-packages/work-package-comment/wp-comment-field.component.ts
index 26c2a71764f..df22c757ba6 100644
--- a/frontend/src/app/components/work-packages/work-package-comment/wp-comment-field.component.ts
+++ b/frontend/src/app/components/work-packages/work-package-comment/wp-comment-field.component.ts
@@ -31,7 +31,7 @@ import { Component, OnInit } from "@angular/core";
import {
FormattableEditFieldComponent,
formattableFieldTemplate
-} from "core-app/modules/fields/edit/field-types/formattable-edit-field.component";
+} from "core-app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component";
import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
@Component({
diff --git a/frontend/src/app/core/services/forms/forms.service.ts b/frontend/src/app/core/services/forms/forms.service.ts
new file mode 100644
index 00000000000..380efd61d33
--- /dev/null
+++ b/frontend/src/app/core/services/forms/forms.service.ts
@@ -0,0 +1,149 @@
+import { Injectable } from '@angular/core';
+import { HttpClient, HttpErrorResponse } from "@angular/common/http";
+import { FormGroup } from "@angular/forms";
+import { catchError, map } from "rxjs/operators";
+import { Observable } from "rxjs";
+
+@Injectable({
+ providedIn: 'root'
+})
+export class FormsService {
+
+ constructor(
+ private _httpClient:HttpClient,
+ ) { }
+
+ submit$(form:FormGroup, resourceEndpoint:string, resourceId?:string):Observable<any> {
+ const modelToSubmit = this._formatModelToSubmit(form.value);
+ const httpMethod = resourceId ? 'patch' : 'post';
+ const url = resourceId ? `${resourceEndpoint}/${resourceId}` : resourceEndpoint;
+
+ return this._httpClient
+ [httpMethod](
+ url,
+ modelToSubmit,
+ {
+ withCredentials: true,
+ responseType: 'json'
+ }
+ )
+ .pipe(
+ catchError((error:HttpErrorResponse) => {
+ if (error.status == 422 ) {
+ this._handleBackendFormValidationErrors(error, form);
+ }
+
+ throw error;
+ })
+ );
+ }
+
+ validateForm$(form:FormGroup, resourceEndpoint:string):Observable<any> {
+ const modelToSubmit = this._formatModelToSubmit(form.value);
+
+ return this._httpClient
+ .post(
+ `${resourceEndpoint}/form`,
+ modelToSubmit,
+ {
+ withCredentials: true,
+ responseType: 'json'
+ }
+ )
+ .pipe(
+ map((response: HalSource) => this._getFormattedErrors(Object.values(response?._embedded?.validationErrors))),
+ map((formattedErrors: IFormattedValidationError[]) => this._setFormValidationErrors(formattedErrors, form)),
+ );
+ }
+
+ getFormBackendValidationError$(formValue: {[key:string]: any}, resourceEndpoint:string, limitValidationToKeys?:string | string[]) {
+ const modelToSubmit = this._formatModelToSubmit(formValue);
+
+ return this._httpClient
+ .post(
+ resourceEndpoint,
+ modelToSubmit,
+ {
+ withCredentials: true,
+ responseType: 'json',
+ headers: {
+ 'content-type': 'application/json; charset=utf-8'
+ }
+ }
+ )
+ .pipe(
+ map((response: HalSource) => this._getAllFormValidationErrors(response._embedded.validationErrors, limitValidationToKeys))
+ );
+ }
+
+ private _formatModelToSubmit(formModel:IOPFormModel):IOPFormModel {
+ const resources = formModel?._links || {};
+
+ const formattedResources = Object
+ .keys(resources)
+ .reduce((result, resourceKey) => {
+ const resource = resources[resourceKey];
+ // Form.payload resources have a HalLinkSource interface while
+ // API resource options have a IAllowedValue interface
+ const resourceValue = Array.isArray(resource) ?
+ resource.map(resourceElement => ({ href: resourceElement?.href || resourceElement?._links?.self?.href })) :
+ { href: resource?.href || resource?._links?.self?.href };
+
+ return {
+ ...result,
+ [resourceKey]: resourceValue,
+ };
+ }, {});
+
+ return {
+ ...formModel,
+ _links: formattedResources,
+ }
+ }
+
+ private _handleBackendFormValidationErrors(error:HttpErrorResponse, form:FormGroup):void {
+ const errors:IOPFormError[] = error?.error?._embedded?.errors ?
+ error?.error?._embedded?.errors : [error.error];
+ const formErrors = this._getFormattedErrors(errors);
+
+ this._setFormValidationErrors(formErrors, form);
+ }
+
+ private _setFormValidationErrors(errors:IFormattedValidationError[], form:FormGroup) {
+ errors.forEach((err:any) => {
+ const formControl = form.get(err.key) || form.get('_links')?.get(err.key);
+
+ formControl?.setErrors({[err.key]: {message: err.message}});
+ });
+ }
+
+ private _getAllFormValidationErrors(validationErrors:IOPValidationErrors, formControlKeys?:string | string[]): {[key:string]: {message:string}} {
+ const errors = Object.values(validationErrors);
+ const keysToValidate = Array.isArray(formControlKeys) ? formControlKeys : [formControlKeys];
+ const formErrors = this._getFormattedErrors(errors)
+ .filter(error => {
+ if (!formControlKeys) {
+ return true;
+ } else {
+ return keysToValidate.includes(error.key);
+ }
+ })
+ .reduce((result, { key, message }) => {
+ return {
+ ...result,
+ [key]: {message}
+ }
+ }, {})
+
+ return formErrors
+ }
+
+ private _getFormattedErrors(errors:IOPFormError[]):IFormattedValidationError[] {
+ const formattedErrors = errors.map(err => ({
+ key: err._embedded.details.attribute,
+ message: err.message
+ }));
+
+ return formattedErrors;
+ }
+}
diff --git a/frontend/src/app/core/services/forms/typings.d.ts b/frontend/src/app/core/services/forms/typings.d.ts
new file mode 100644
index 00000000000..37a19fbc5e6
--- /dev/null
+++ b/frontend/src/app/core/services/forms/typings.d.ts
@@ -0,0 +1,135 @@
+interface IOPFormSettings {
+ _type?: "Form";
+ _embedded: {
+ payload: IOPFormModel;
+ schema: IOPFormSchema;
+ validationErrors?: IOPValidationErrors;
+ };
+ _links?: {
+ self: IOPApiCall;
+ validate: IOPApiCall;
+ commit: IOPApiCall;
+ previewMarkup?: IOPApiCall;
+ };
+}
+
+interface IOPFormSchema {
+ _type?: "Schema";
+ _dependencies?: unknown[];
+ _attributeGroups?: IOPAttributeGroup[];
+ lockVersion?: IOPFieldSchema;
+ [fieldKey: string]: IOPFieldSchema | any;
+ _links?: {
+ baseSchema?: {
+ href: string;
+ };
+ };
+}
+
+interface IOPFormModel {
+ [key: string]: string | number | Object | HalLinkSource | null | undefined;
+ _links?: {
+ [key: string]: IOPFieldModel | IOPFieldModel[] | null;
+ };
+}
+
+interface IOPFieldSchema {
+ type: OPFieldType;
+ writable: boolean;
+ allowedValues?: any;
+ required?: boolean;
+ hasDefault: boolean;
+ name?: string;
+ attributeGroup?: string;
+ location?: '_links' | string;
+ options: {
+ [key: string]: any;
+ };
+ _embedded?: {
+ allowedValues?: IOPApiCall | IOPAllowedValue[];
+ };
+ _links?: {
+ allowedValues?: IOPApiCall;
+ };
+}
+
+interface IOPFieldSchemaWithKey extends IOPFieldSchema {
+ key: string;
+}
+
+interface IOPFieldModel extends Partial<HalSource>{
+ name?: string;
+}
+
+type HalSource = {
+ [key:string]:string|number|null|HalSourceLinks,
+ _links:HalSourceLinks
+};
+
+interface IOPApiCall {
+ href: string;
+ method?: string;
+}
+
+interface IOPApiOption {
+ href: string;
+ title?: string;
+}
+
+interface IOPAttributeGroup {
+ _type:
+ | "WorkPackageFormAttributeGroup"
+ | "WorkPackageFormChildrenQueryGroup"
+ | "WorkPackageFormRelationQueryGroup"
+ | unknown;
+ name: string;
+ attributes: string[];
+}
+
+interface IOPAllowedValue {
+ id: string;
+ name: string;
+ [key: string]: unknown;
+ _links: {
+ self: HalSource | IOPApiOption;
+ [key: string]: HalSource;
+ };
+}
+
+type OPFieldType = 'String' | 'Integer' | 'Boolean' | 'Date' | 'DateTime' | 'Formattable' |
+ 'Priority' | 'Status' | 'Type' | 'User' | 'Version' | 'TimeEntriesActivity' | 'Category' |
+ 'CustomOption' | 'Project' | 'ProjectStatus' | 'Password';
+
+interface IOPFormError {
+ errorIdentifier:string;
+ message:string;
+ _type:string;
+ _embedded: IOPFormErrorDetails;
+}
+
+interface IFormattedValidationError {
+ key:string;
+ message:string;
+}
+
+interface IOPFormErrorResponse extends IOPFormError {
+ _embedded: IOPFormErrorDetails | IOPFormErrors;
+}
+
+interface IOPFormErrorDetails {
+ details: {
+ attribute: string;
+ }
+}
+
+interface IOPFormErrors {
+ errors: IOPFormError[];
+}
+
+interface IOPValidationErrors {
+ [key: string]: IOPFormError;
+}
+
+
+
+
diff --git a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
index e63d68588b5..bc7ac5aa621 100644
--- a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
+++ b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
@@ -39,9 +39,8 @@ import { BoardActionService } from "core-app/modules/boards/board/board-actions/
import { HalResource } from "core-app/modules/hal/resources/hal-resource";
import { AngularTrackingHelpers } from "core-components/angular/tracking-functions";
import { CreateAutocompleterComponent } from "core-app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts";
-import { of } from "rxjs";
import { DebouncedRequestSwitchmap, errorNotificationHandler } from "core-app/helpers/rxjs/debounced-input-switchmap";
-import { ValueOption } from "core-app/modules/fields/edit/field-types/select-edit-field.component";
+import { ValueOption } from "core-app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component";
import { HalResourceNotificationService } from "core-app/modules/hal/services/hal-resource-notification.service";
@Component({
diff --git a/frontend/src/app/modules/common/ckeditor/ckeditor-setup.service.ts b/frontend/src/app/modules/common/ckeditor/ckeditor-setup.service.ts
index 6b5efff1315..bc341f2ba8a 100644
--- a/frontend/src/app/modules/common/ckeditor/ckeditor-setup.service.ts
+++ b/frontend/src/app/modules/common/ckeditor/ckeditor-setup.service.ts
@@ -14,6 +14,7 @@ export interface ICKEditorInstance {
config:any;
ui:any;
element:HTMLElement;
+ isReadOnly:boolean;
}
export interface ICKEditorStatic {
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.html
new file mode 100644
index 00000000000..ab9f0957450
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.html
@@ -0,0 +1,7 @@
+<div class="op-field-group-wrapper">
+ <div class="op-field-group-wrapper--header">{{ to.label }}</div>
+
+ <div class="op-field-group-wrapper--body">
+ <ng-container #fieldComponent></ng-container>
+ </div>
+</div>
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.ts
new file mode 100644
index 00000000000..c67ef17f970
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component.ts
@@ -0,0 +1,12 @@
+import { Component, ViewChild, ViewContainerRef } from "@angular/core";
+import { FieldWrapper } from "@ngx-formly/core";
+
+@Component({
+ selector: "op-dynamic-field-group-wrapper",
+ templateUrl: "./dynamic-field-group-wrapper.component.html",
+ styleUrls: ["./dynamic-field-group-wrapper.component.scss"]
+})
+export class DynamicFieldGroupWrapperComponent extends FieldWrapper {
+ @ViewChild("fieldComponent", { read: ViewContainerRef })
+ fieldComponent: ViewContainerRef;
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.html
new file mode 100644
index 00000000000..4c9c86ded56
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.html
@@ -0,0 +1,65 @@
+<div data-qa="op-form--container"
+ *ngIf="form && isStandaloneForm">
+ <form [formGroup]="form"
+ (submit)="submitForm(form)"
+ class="op-form">
+ <formly-form [form]="form"
+ [model]="model"
+ [fields]="fields"
+ (modelChange)="onModelChange($event)"
+ class="op-fieldset">
+ <ng-template formlyTemplate let-field>
+ <op-form-field *ngFor="let field of fields"
+ [label]="field.templateOptions?.label"
+ [noWrapLabel]="field.templateOptions?.noWrapLabel"
+ [required]="field.templateOptions?.required"
+ [attr.data-field-name]="field.property"
+ >
+ <formly-field [field]="field" slot=input></formly-field>
+
+ <formly-validation-message
+ class="op-form-field--error"
+ [field]="field"
+ slot="errors"
+ ></formly-validation-message>
+ </op-form-field>
+ </ng-template>
+ </formly-form>
+
+ <div class="op-form--submit">
+ <button type="submit"
+ class="button -highlight"
+ *ngIf="handleSubmit"
+ [disabled]="inFlight">
+ {{text.save}}
+ </button>
+ </div>
+ </form>
+</div>
+
+<!-- When used as a FormControl, the Dynamic Form doesn't need a wrapping form -->
+<!-- TODO: Issue: sharing the form as an ng-template between this two HTML blocks doesn't work because
+ the nested OpFormFieldComponent don't find the injected FormGroupDirective. --->
+<div data-qa="op-form--container"
+ *ngIf="form && !isStandaloneForm">
+ <formly-form [form]="form"
+ [model]="model"
+ [fields]="fields"
+ (modelChange)="onModelChange($event)"
+ class="op-fieldset">
+ <ng-template formlyTemplate let-field>
+ <op-form-field *ngFor="let field of fields"
+ [label]="field.templateOptions?.label"
+ [noWrapLabel]="field.templateOptions?.noWrapLabel"
+ [required]="field.templateOptions?.required">
+ <formly-field [field]="field" slot=input></formly-field>
+
+ <formly-validation-message [field]="field" slot=errors></formly-validation-message>
+ </op-form-field>
+ </ng-template>
+ </formly-form>
+</div>
+
+
+
+
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
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.ts
new file mode 100644
index 00000000000..0fd8641085e
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts
@@ -0,0 +1,258 @@
+import {
+ Component,
+ Input,
+ OnChanges,
+ Output,
+ ViewChild,
+ EventEmitter,
+ forwardRef,
+} from "@angular/core";
+import { FormlyForm } from "@ngx-formly/core";
+import { DynamicFormService } from "../../services/dynamic-form/dynamic-form.service";
+import {
+ IOPDynamicFormSettings,
+ IOPFormlyFieldSettings,
+} from "../../typings";
+import { I18nService } from "core-app/modules/common/i18n/i18n.service";
+import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
+import { catchError, finalize, take } from "rxjs/operators";
+import { HalSource } from "core-app/modules/hal/resources/hal-resource";
+import { NotificationsService } from "core-app/modules/common/notifications/notifications.service";
+import { DynamicFieldsService } from "core-app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service";
+import { ControlValueAccessor, FormGroup, NG_VALUE_ACCESSOR } from "@angular/forms";
+import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
+import { FormsService } from "core-app/core/services/forms/forms.service";
+
+/*
+* SETTINGS:
+* The DynamicFormComponent can get its settings (payload and fields) in two ways:
+*
+* - @Input settings:
+* Passing down an object that mimics a backend form configuration (IOPFormSettings),
+* with and easier format (not _embedded).
+*
+* <op-dynamic-form [settings]="formSettings">
+* </op-dynamic-form>
+*
+* - Backend settings:
+* In order to fetch its settings from the backend, the DynamicFormComponent will
+* always need the 'resourcePath' @Input and, optionally, the 'resourceId' @Input if
+* we are editing a resource.
+*
+* <op-dynamic-form [resourcePath]="resourcePath">
+* </op-dynamic-form>
+*
+* USE CASES:
+* The DynamicFormComponent can be used in two ways:
+*
+* - Standalone Form:
+* In order to work as an standalone form, handling the submit operation by
+* showing a submit button, the DynamicFormComponent will always need the
+* 'resourcePath' @Input and, optionally, the 'resourceId' @Input if we are
+* editing a single resource.
+*
+* <op-dynamic-form [resourcePath]="projectsPath">
+* </op-dynamic-form>
+*
+* - FormControl:
+* The DynamicFormComponent can be used inside a FormGroup as a FormControl.
+*
+* <op-dynamic-form formControlName="workpackage"
+* [settings]="formSettings">
+* </op-dynamic-form>
+*
+* When used as a FormControl (formControlName), the DynamicFormComponent will set
+* the entire form value as the value of the FormControl. Using it as a FormGroup
+* (formGroupName) would require to pass down the configuration of the form in order
+* to use the DynamicFormComponent, which would make no sense because what this
+* component does is to generate a form automatically from a configuration object.
+*/
+
+@Component({
+ selector: "op-dynamic-form",
+ templateUrl: "./dynamic-form.component.html",
+ styleUrls: ["./dynamic-form.component.scss"],
+ providers: [
+ DynamicFormService,
+ DynamicFieldsService,
+ {
+ provide: NG_VALUE_ACCESSOR,
+ multi: true,
+ useExisting: forwardRef(() => DynamicFormComponent),
+ }
+ ]
+})
+export class DynamicFormComponent extends UntilDestroyedMixin implements ControlValueAccessor, OnChanges {
+ @Input() resourceId:string;
+ @Input() resourcePath:string;
+ @Input() settings:{
+ payload:IOPFormModel,
+ schema:IOPFormSchema,
+ [nonUsedSchemaKeys:string]:any,
+ };
+ // Chance to modify the dynamicFormFields settings before the form is rendered
+ @Input() fieldsSettingsPipe: (dynamicFieldsSettings:IOPFormlyFieldSettings[]) => IOPFormlyFieldSettings[];
+ @Input() showNotifications = true;
+ @Input() showValidationErrorsOn: 'change' | 'blur' | 'submit' | 'never' = 'submit';
+ @Input() handleSubmit = true;
+
+ @Output() modelChange = new EventEmitter<IOPFormModel>();
+ @Output() submitted = new EventEmitter<HalSource>();
+ @Output() errored = new EventEmitter<IOPFormErrorResponse>();
+
+ fields:IOPFormlyFieldSettings[];
+ model:IOPFormModel;
+ form: FormGroup;
+ resourceEndpoint:string | null;
+ inFlight:boolean;
+ text = {
+ save: this._I18n.t('js.button_save'),
+ validation_error_message: this._I18n.t('js.forms.validation_error_message'),
+ load_error_message: this._I18n.t('js.forms.load_error_message'),
+ submit_success_message: this._I18n.t('js.notice_successful_update'),
+ };
+ noSettingsSourceErrorMessage = `DynamicFormComponent needs a settings or resourcePath @Input
+ in order to fetch its setting. Please provide one.`;
+ noPathToSubmitToError = `DynamicForm needs a resourcePath input in order to be submitted
+ and validated. Please provide one.`;
+ onChange:Function;
+ onTouch:Function;
+
+ get isFormControl():boolean {
+ return !!this.onChange && !!this.onTouch;
+ }
+ get isStandaloneForm():boolean {
+ return !this.isFormControl;
+ }
+
+ @ViewChild(FormlyForm)
+ set dynamicForm(dynamicForm: FormlyForm) {
+ this._dynamicFormService.registerForm(dynamicForm);
+ }
+
+ constructor(
+ private _dynamicFormService: DynamicFormService,
+ private _I18n:I18nService,
+ private _pathHelperService:PathHelperService,
+ private _notificationsService:NotificationsService,
+ private _formsService: FormsService,
+ ) {
+ super();
+ }
+
+ writeValue(value:{[key:string]:any}):void {
+ if (value) {
+ this.model = value;
+ }
+ }
+
+ registerOnChange(fn: (_: any) => void): void {
+ this.onChange = fn;
+ }
+
+ registerOnTouched(fn: any): void {
+ this.onTouch = fn;
+ }
+
+ setDisabledState(disabled: boolean): void {
+ disabled ? this.form.disable() : this.form.enable();
+ }
+
+ ngOnChanges() {
+ this._initializeDynamicForm();
+ }
+
+ onModelChange(changes:any) {
+ this.modelChange.emit(changes);
+
+ if (!this.isStandaloneForm) {
+ this.onChange(changes);
+ this.onTouch();
+ }
+ }
+
+ submitForm(form:FormGroup) {
+ if (!(this.isStandaloneForm && this.handleSubmit)) {
+ return;
+ }
+
+ if (!this.resourceEndpoint) {
+ throw new Error(this.noPathToSubmitToError);
+ }
+
+ this.inFlight = true;
+ this._dynamicFormService
+ .submit$(form, this.resourceEndpoint, this.resourceId)
+ .pipe(
+ finalize(() => this.inFlight = false)
+ )
+ .subscribe(
+ (formResource:HalSource) => {
+ this.submitted.emit(formResource);
+ this.showNotifications && this._notificationsService.addSuccess(this.text.submit_success_message);
+ },
+ (error:IOPFormErrorResponse) => {
+ this.errored.emit(error);
+ this.showNotifications && this._notificationsService.addError(this.text.validation_error_message);
+ },
+ );
+ }
+
+ validateForm() {
+ if (!this.resourceEndpoint) {
+ throw new Error(this.noPathToSubmitToError);
+ }
+
+ this._formsService.validateForm$(this.form, this.resourceEndpoint).subscribe();
+ }
+
+ private _initializeDynamicForm() {
+ this.resourceEndpoint = this.resourcePath ?
+ `${this._pathHelperService.api.v3.apiV3Base}${this.resourcePath}` :
+ null;
+
+ if (this.settings) {
+ this._setupDynamicFormFromSettings();
+ } else if (this.resourceEndpoint) {
+ this._setupDynamicFormFromBackend();
+ } else {
+ console.error(this.noSettingsSourceErrorMessage);
+ }
+ }
+
+ private _setupDynamicFormFromBackend() {
+ const url = `${this.resourceEndpoint}/${this.resourceId ? this.resourceId + '/' : ''}form`;
+
+ this._dynamicFormService
+ .getSettingsFromBackend$(url)
+ .pipe(
+ catchError(error => {
+ this._notificationsService.addError(this.text.load_error_message);
+ throw error;
+ })
+ )
+ .subscribe(dynamicFormSettings => this._setupDynamicForm(dynamicFormSettings));
+ }
+
+ private _setupDynamicFormFromSettings() {
+ const formattedSettings:IOPFormSettings = {
+ _embedded: {
+ payload: this.settings.payload,
+ schema: this.settings.schema,
+ }
+ }
+ const dynamicFormSettings = this._dynamicFormService.getSettings(formattedSettings);
+
+ this._setupDynamicForm(dynamicFormSettings);
+ }
+
+ private _setupDynamicForm({fields, model, form}:IOPDynamicFormSettings) {
+ this.form = form;
+ this.fields = this.fieldsSettingsPipe ? this.fieldsSettingsPipe(fields) : fields;
+ this.model = model;
+
+ if (!this.isStandaloneForm) {
+ this.onChange(this.model);
+ }
+ }
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.html
new file mode 100644
index 00000000000..2b167e412cc
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.html
@@ -0,0 +1,5 @@
+<input type="checkbox"
+ [attr.aria-required]="to.required"
+ [attr.required]="to.required"
+ [formControl]="formControl"
+ [formlyAttributes]="field">
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.spec.ts
new file mode 100644
index 00000000000..5b57c7ecffa
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.spec.ts
@@ -0,0 +1,32 @@
+import { fakeAsync } from '@angular/core/testing';
+import {
+ createDynamicInputFixture,
+ testDynamicInputControValueAccessor,
+} from "core-app/modules/common/dynamic-forms/spec/helpers";
+
+describe('BooleanInputComponent', () => {
+ it('should load the field', fakeAsync(() => {
+ const fieldsConfig = [
+ {
+ "type": "booleanInput" as "booleanInput",
+ "className": "op-form--field inline-edit--field",
+ "key": "testControl",
+ "templateOptions": {
+ "required": true,
+ "label": "testControl",
+ },
+ }
+ ];
+ const formModel = {
+ testControl: true,
+ };
+ const testModel = {
+ initialValue: true,
+ changedValue: false,
+ };
+
+ const fixture = createDynamicInputFixture(fieldsConfig, formModel);
+
+ testDynamicInputControValueAccessor(fixture, testModel, 'op-boolean-input input');
+ }));
+});
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.ts
new file mode 100644
index 00000000000..8a6362c7e77
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/boolean-input/boolean-input.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+import { FieldType } from "@ngx-formly/core";
+
+@Component({
+ selector: 'op-boolean-input',
+ templateUrl: './boolean-input.component.html',
+ styleUrls: ['./boolean-input.component.scss']
+})
+export class BooleanInputComponent extends FieldType {
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/components/date-picker-adapter/date-picker-adapter.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/components/date-picker-adapter/date-picker-adapter.component.spec.ts
new file mode 100644
index 00000000000..00ad3236f41
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/components/date-picker-adapter/date-picker-adapter.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { DatePickerAdapterComponent } from './date-picker-adapter.component';
+
+xdescribe('DatePickerAdapterComponent', () => {
+ let component: DatePickerAdapterComponent;
+ let fixture: ComponentFixture<DatePickerAdapterComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ DatePickerAdapterComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(DatePickerAdapterComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/components/date-picker-adapter/date-picker-adapter.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/components/date-picker-adapter/date-picker-adapter.component.ts
new file mode 100644
index 00000000000..ad90e5f9131
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/components/date-picker-adapter/date-picker-adapter.component.ts
@@ -0,0 +1,76 @@
+import { Component, forwardRef } from '@angular/core';
+import { OpDatePickerComponent } from "core-app/modules/common/op-date-picker/op-date-picker.component";
+import { TimezoneService } from "core-components/datetime/timezone.service";
+import * as moment from "moment";
+import { NG_VALUE_ACCESSOR } from "@angular/forms";
+
+@Component({
+ selector: 'op-date-picker-adapter',
+ templateUrl: '../../../../../../op-date-picker/op-date-picker.component.html',
+ providers: [
+ {
+ provide: NG_VALUE_ACCESSOR,
+ useExisting: forwardRef(() => DatePickerAdapterComponent),
+ multi: true
+ }
+ ]
+})
+export class DatePickerAdapterComponent extends OpDatePickerComponent {
+ onControlChange = (_:any) => { }
+ onControlTouch = () => { }
+
+ constructor(
+ timezoneService:TimezoneService,
+ ) {
+ super(timezoneService);
+ }
+
+ writeValue(date:string):void {
+ this.initialDate = this.formatter(date);
+ }
+
+ registerOnChange(fn: (_: any) => void): void {
+ this.onControlChange = fn;
+ }
+
+ registerOnTouched(fn: any): void {
+ this.onControlTouch = fn;
+ }
+
+ setDisabledState(disabled: boolean): void {
+ this.disabled = disabled;
+ }
+
+ onInputChange(_event:KeyboardEvent) {
+ if (this.isEmpty()) {
+ this.datePickerInstance.clear();
+ } else if (this.inputIsValidDate()) {
+ const valueToEmit = this.parser(this.currentValue);
+ this.onControlTouch();
+ this.onControlChange(valueToEmit);
+ }
+ }
+
+ closeOnOutsideClick(event:any) {
+ super.closeOnOutsideClick(event);
+ this.onControlTouch();
+ }
+
+ public parser(data:any) {
+ if (moment(data, 'YYYY-MM-DD', true).isValid()) {
+ return data;
+ } else {
+ return null;
+ }
+ }
+
+ public formatter(data:any):string {
+ if (moment(data, 'YYYY-MM-DD', true).isValid()) {
+ var d = this.timezoneService.parseDate(data);
+
+ return this.timezoneService.formattedISODate(d);
+ } else {
+ return '';
+ }
+ }
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.html
new file mode 100644
index 00000000000..05db6e32b75
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.html
@@ -0,0 +1,5 @@
+<op-date-picker-adapter [required]="to.required"
+ [disabled]="to.disabled"
+ [formControl]="formControl"
+ [formlyAttributes]="field">
+</op-date-picker-adapter>
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.spec.ts
new file mode 100644
index 00000000000..d60a4f59c52
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { DateInputComponent } from './date-input.component';
+
+xdescribe('DateInputComponent', () => {
+ let component: DateInputComponent;
+ let fixture: ComponentFixture<DateInputComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ DateInputComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(DateInputComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.ts
new file mode 100644
index 00000000000..d338716b8b2
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/date-input/date-input.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+import { FieldType } from "@ngx-formly/core";
+
+@Component({
+ selector: 'op-date-input',
+ templateUrl: './date-input.component.html',
+ styleUrls: ['./date-input.component.scss'],
+})
+export class DateInputComponent extends FieldType {
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.html
new file mode 100644
index 00000000000..3c09b5b8992
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.html
@@ -0,0 +1,9 @@
+<div class="op-ckeditor--wrapper op-ckeditor-element">
+ <op-ckeditor [context]="ckEditorContext"
+ [content]="value?.raw"
+ (onContentChange)="onContentChange($event)"
+ (onInitializationFailed)="initializationError = true"
+ (onInitialized)="onCkeditorSetup($event)"
+ [ckEditorType]="templateOptions.editorType">
+ </op-ckeditor>
+</div>
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.spec.ts
new file mode 100644
index 00000000000..ffad2a09055
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { FormattableControlComponent } from './formattable-control.component';
+
+xdescribe('FormattableControlComponent', () => {
+ let component: FormattableControlComponent;
+ let fixture: ComponentFixture<FormattableControlComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ FormattableControlComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(FormattableControlComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts
new file mode 100644
index 00000000000..65a2e4e9f4e
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts
@@ -0,0 +1,98 @@
+import { Component, forwardRef, Input, OnInit, ViewChild } from '@angular/core';
+import { I18nService } from "core-app/modules/common/i18n/i18n.service";
+import { FormlyTemplateOptions } from "@ngx-formly/core";
+import { ICKEditorContext, ICKEditorInstance } from "core-app/modules/common/ckeditor/ckeditor-setup.service";
+import { NG_VALUE_ACCESSOR } from "@angular/forms";
+import { OpCkeditorComponent } from "core-app/modules/common/ckeditor/op-ckeditor.component";
+
+@Component({
+ selector: 'op-formattable-control',
+ templateUrl: './formattable-control.component.html',
+ styleUrls: ['./formattable-control.component.scss'],
+ providers: [
+ {
+ provide: NG_VALUE_ACCESSOR,
+ useExisting: forwardRef(() => FormattableControlComponent),
+ multi: true
+ }
+ ]
+})
+export class FormattableControlComponent implements OnInit {
+ @Input()
+ templateOptions:FormlyTemplateOptions;
+
+ @ViewChild(OpCkeditorComponent, { static: true }) editor:OpCkeditorComponent;
+
+ text:{[key:string]: string};
+ value:{raw:string};
+ disabled = false;
+ touched:boolean;
+ // Detect when inner component could not be initialized
+ initializationError = false;
+ onChange = (_:any) => { }
+ onTouch = () => { }
+
+ public get ckEditorContext():ICKEditorContext {
+ return {
+ // TODO: Can the current editor work without resource??
+ // resource: this.change.pristineResource,
+ macros: 'none' as const,
+ // TODO: Do we need a previewContext
+ // previewContext: this.previewContext,
+ options: { rtl: this.templateOptions?.rtl }
+ };
+ }
+
+ constructor(
+ readonly I18n:I18nService,
+ ) { }
+
+ ngOnInit(): void {
+ this.text = {
+ attachmentLabel: this.I18n.t('js.label_formattable_attachment_hint'),
+ save: this.I18n.t('js.inplace.button_save', { attribute: this.templateOptions?.name }),
+ cancel: this.I18n.t('js.inplace.button_cancel', { attribute: this.templateOptions?.name })
+ };
+ }
+
+ writeValue(value:{raw:string}):void {
+ this.value = value;
+ }
+
+ registerOnChange(fn: (_: any) => void): void {
+ this.onChange = fn;
+ }
+
+ registerOnTouched(fn: any): void {
+ this.onTouch = fn;
+ }
+
+ setDisabledState(disabled: boolean): void {
+ this.disabled = disabled;
+ this.editor.ckEditorInstance.isReadOnly = disabled;
+ }
+
+ onContentChange(value:string) {
+ this.editor
+ .getTransformedContent()
+ .then((val) => {
+ const valueToEmit = {raw: val};
+
+ this.onTouch();
+ this.onChange(valueToEmit);
+ });
+ }
+
+ onCkeditorSetup(editor:ICKEditorInstance) {
+ this.editor.ckEditorInstance.ui.focusTracker.on( 'change:isFocused', ( evt:any, name:any, isFocused:any ) => {
+ if (!isFocused && !this.touched) {
+ this.touched = true;
+ this.onTouch();
+ }
+ } );
+ // TODO: Check if it is new without resource
+ /*if (!this.resource.isNew) {
+ setTimeout(() => editor.editing.view.focus());
+ }*/
+ }
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.html
new file mode 100644
index 00000000000..293e7e41e53
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.html
@@ -0,0 +1,4 @@
+<op-formattable-control [templateOptions]="to"
+ [formControl]="formControl"
+ [formlyAttributes]="field">
+</op-formattable-control>
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.ts
new file mode 100644
index 00000000000..f0f75f1c6b7
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+import { FieldType } from "@ngx-formly/core";
+
+@Component({
+ selector: 'op-formattable-textarea-input',
+ templateUrl: './formattable-textarea-input.component.html',
+ styleUrls: ['./formattable-textarea-input.component.scss']
+})
+export class FormattableTextareaInputComponent extends FieldType {
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.html
new file mode 100644
index 00000000000..809d85d6c10
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.html
@@ -0,0 +1,7 @@
+<input [type]="to.type"
+ [attr.aria-required]="to.required"
+ [attr.required]="to.required"
+ [attr.lang]="to.locale"
+ [formControl]="formControl"
+ [formlyAttributes]="field"
+ class="op-input">
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.spec.ts
new file mode 100644
index 00000000000..f1228666611
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.spec.ts
@@ -0,0 +1,33 @@
+import { fakeAsync } from '@angular/core/testing';
+import {
+ createDynamicInputFixture,
+ testDynamicInputControValueAccessor,
+} from "core-app/modules/common/dynamic-forms/spec/helpers";
+
+describe('IntegerInputComponent', () => {
+ it('should load the field', fakeAsync(() => {
+ const fieldsConfig = [
+ {
+ "type": "integerInput" as "integerInput",
+ "className": "op-form--field inline-edit--field",
+ "key": "testControl",
+ "templateOptions": {
+ "required": true,
+ "label": "testControl",
+ },
+ }
+ ];
+ const formModel = {
+ testControl: 'testValue',
+ };
+ const testModel = {
+ initialValue: formModel.testControl,
+ changedValue: 'testValue2',
+ };
+
+ const fixture = createDynamicInputFixture(fieldsConfig, formModel);
+
+ testDynamicInputControValueAccessor(fixture, testModel, 'op-integer-input input');
+ }));
+});
+
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.ts
new file mode 100644
index 00000000000..c8892eaecdd
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/integer-input/integer-input.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+import { FieldType } from "@ngx-formly/core";
+
+@Component({
+ selector: 'op-integer-input',
+ templateUrl: './integer-input.component.html',
+ styleUrls: ['./integer-input.component.scss']
+})
+export class IntegerInputComponent extends FieldType {
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.html
new file mode 100644
index 00000000000..725d4f3d642
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.html
@@ -0,0 +1,22 @@
+<ng-select [items]="to?.options | async"
+ [formControl]="formControl"
+ [formlyAttributes]="field"
+ [attr.aria-required]="to.required"
+ [attr.required]="to.required"
+ [multiple]="to.multiple"
+ [bindLabel]="to.bindLabel"
+ [searchable]="to.searchable"
+ [virtualScroll]="to.virtualScroll"
+ [clearable]="to.clearable"
+ [typeahead]="to.typeahead"
+ [clearOnBackspace]="false"
+ [clearSearchOnAdd]="false"
+ [hideSelected]="to.hideSelected">
+ <ng-template ng-tag-tmp let-search="searchTerm">
+ <b [textContent]="to.text.add_new_action"></b>: {{search}}
+ </ng-template>
+
+ <ng-template ng-option-tmp let-item="item" let-search="searchTerm">
+ <div [ngOptionHighlight]="search" class="ng-option-label ellipsis">{{ item.name }}</div>
+ </ng-template>
+</ng-select>
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.spec.ts
new file mode 100644
index 00000000000..3e8ce2d812b
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.spec.ts
@@ -0,0 +1,92 @@
+import { fakeAsync, flush } from '@angular/core/testing';
+import {
+ createDynamicInputFixture,
+} from "core-app/modules/common/dynamic-forms/spec/helpers";
+import { By } from "@angular/platform-browser";
+import { of } from "rxjs";
+
+describe('SelectInputComponent', () => {
+ it('should load the field', fakeAsync(() => {
+ const selectOptions = [
+ {
+ name: 'option1',
+ value: 1,
+ },
+ {
+ name: 'option2',
+ value: 2,
+ }
+ ];
+ const fieldsConfig = [
+ {
+ "type": "selectInput" as "selectInput",
+ "className": "op-form--field inline-edit--field",
+ "key": "testControl",
+ "templateOptions": {
+ "required": true,
+ "label": "testControl",
+ "type": "text",
+ "placeholder": "",
+ "disabled": false,
+ "options": of(selectOptions),
+ "bindLabel": 'name',
+ "bindValue": 'value',
+ },
+ }
+ ];
+ const formModel = {
+ testControl: selectOptions[0],
+ };
+ const testModel = {
+ initialValue: selectOptions[0],
+ changedValue: selectOptions[1],
+ };
+ const fixture = createDynamicInputFixture(fieldsConfig, formModel);
+ const dynamicControl = fixture.componentInstance.dynamicControl.field.formControl;
+ const dynamicInput = fixture.debugElement.query(By.css('op-select-input input')).nativeElement;
+ const dynamicDebugElement = fixture.debugElement.query(By.css('ng-select'));
+ const dynamicElement = dynamicDebugElement.nativeElement;
+
+
+ // Test ControlValueAccessor
+ // Write Value
+ expect(dynamicControl.value).toBe(testModel.initialValue);
+ expect(dynamicElement.classList.contains('ng-untouched')).toBeTrue();
+ expect(dynamicElement.classList.contains('ng-valid')).toBeTrue();
+ expect(dynamicElement.classList.contains('ng-pristine')).toBeTrue();
+
+ // Change
+ // Select second option
+ dynamicDebugElement.triggerEventHandler('keydown', {
+ which: 40, // ArrowDown
+ key: '',
+ preventDefault: () => { },
+ });
+ dynamicDebugElement.triggerEventHandler('keydown', {
+ which: 40, // ArrowDown
+ key: '',
+ preventDefault: () => { },
+ });
+ dynamicDebugElement.triggerEventHandler('keydown', {
+ which: 13, // Enter key
+ key: '',
+ preventDefault: () => { },
+ });
+
+ fixture.detectChanges();
+ flush();
+
+ expect(dynamicControl.value).toBe(testModel.changedValue);
+ expect(dynamicElement.classList.contains('ng-dirty')).toBeTrue();
+
+ // Blur
+ dynamicInput.dispatchEvent(new Event('blur'));
+ fixture.detectChanges();
+ expect(dynamicElement.classList.contains('ng-touched')).toBeTrue();
+
+ // Disabled
+ dynamicControl.disable();
+ fixture.detectChanges();
+ expect(dynamicInput.disabled).toBeTrue();
+ }));
+});
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.ts
new file mode 100644
index 00000000000..90fc62f7640
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+import { FieldType } from "@ngx-formly/core";
+
+@Component({
+ selector: 'op-select-input',
+ templateUrl: './select-input.component.html',
+ styleUrls: ['./select-input.component.scss']
+})
+export class SelectInputComponent extends FieldType {
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.html
new file mode 100644
index 00000000000..da0d99c050f
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.html
@@ -0,0 +1,6 @@
+<input [type]="to.type"
+ [attr.aria-required]="to.required"
+ [attr.required]="to.required"
+ [formControl]="formControl"
+ [formlyAttributes]="field"
+ class="op-input">
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.scss b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.spec.ts
new file mode 100644
index 00000000000..6e7d6a3beb1
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.spec.ts
@@ -0,0 +1,35 @@
+import { fakeAsync } from '@angular/core/testing';
+import {
+ createDynamicInputFixture,
+ testDynamicInputControValueAccessor,
+} from "core-app/modules/common/dynamic-forms/spec/helpers";
+
+describe('TextComponent', () => {
+ it('should load the field', fakeAsync(() => {
+ const fieldsConfig = [
+ {
+ "type": "textInput" as "textInput",
+ "className": "op-form--field inline-edit--field",
+ "key": "testControl",
+ "templateOptions": {
+ "required": true,
+ "label": "testControl",
+ "type": "text",
+ "placeholder": "",
+ "disabled": false
+ },
+ }
+ ];
+ const formModel = {
+ testControl: 'testValue',
+ };
+ const testModel = {
+ initialValue: 'testValue',
+ changedValue: 'testValue2',
+ };
+
+ const fixture = createDynamicInputFixture(fieldsConfig, formModel);
+
+ testDynamicInputControValueAccessor(fixture, testModel, 'op-text-input input');
+ }));
+});
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.ts
new file mode 100644
index 00000000000..fe9db09989f
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/text-input/text-input.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+import { FieldType } from '@ngx-formly/core';
+
+@Component({
+ selector: 'op-text-input',
+ templateUrl: './text-input.component.html',
+ styleUrls: ['./text-input.component.scss']
+})
+export class TextInputComponent extends FieldType {
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/dynamic-forms.module.ts b/frontend/src/app/modules/common/dynamic-forms/dynamic-forms.module.ts
new file mode 100644
index 00000000000..e822691c013
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/dynamic-forms.module.ts
@@ -0,0 +1,74 @@
+import { NgModule } from "@angular/core";
+import { CommonModule } from "@angular/common";
+import { ReactiveFormsModule } from "@angular/forms";
+import { FormlyModule } from "@ngx-formly/core";
+import { HTTP_INTERCEPTORS, HttpClientModule } from "@angular/common/http";
+import { NgSelectModule } from "@ng-select/ng-select";
+import { DynamicFieldGroupWrapperComponent } from "./components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component";
+import { DynamicFormComponent } from "./components/dynamic-form/dynamic-form.component";
+import { OpenProjectHeaderInterceptor } from "core-app/modules/hal/http/openproject-header-interceptor";
+import { TextInputComponent } from './components/dynamic-inputs/text-input/text-input.component';
+import { IntegerInputComponent } from './components/dynamic-inputs/integer-input/integer-input.component';
+import { SelectInputComponent } from './components/dynamic-inputs/select-input/select-input.component';
+import { NgOptionHighlightModule } from "@ng-select/ng-option-highlight";
+import { BooleanInputComponent } from './components/dynamic-inputs/boolean-input/boolean-input.component';
+import { DateInputComponent } from './components/dynamic-inputs/date-input/date-input.component';
+import { DatePickerAdapterComponent } from './components/dynamic-inputs/date-input/components/date-picker-adapter/date-picker-adapter.component';
+import { FormattableTextareaInputComponent } from './components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component';
+import { OpenprojectEditorModule } from "core-app/modules/editor/openproject-editor.module";
+import { FormattableControlComponent } from './components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component';
+import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";
+import { FormattableEditFieldModule } from "core-app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.module";
+import { DatePickerModule } from "core-app/modules/common/op-date-picker/date-picker.module";
+
+@NgModule({
+ imports: [
+ CommonModule,
+ ReactiveFormsModule,
+ FormlyModule.forRoot({
+ types: [
+ { name: 'booleanInput', component: BooleanInputComponent },
+ { name: 'integerInput', component: IntegerInputComponent },
+ { name: 'textInput', component: TextInputComponent },
+ { name: 'dateInput', component: DateInputComponent },
+ { name: 'selectInput', component: SelectInputComponent },
+ { name: 'formattableInput', component: FormattableTextareaInputComponent },
+ ],
+ wrappers: [
+ {
+ name: "op-dynamic-field-group-wrapper",
+ component: DynamicFieldGroupWrapperComponent,
+ },
+ ]
+ }),
+ HttpClientModule,
+ OpenprojectCommonModule,
+
+ // Input dependencies
+ DatePickerModule,
+ NgSelectModule,
+ NgOptionHighlightModule,
+ FormattableEditFieldModule,
+ OpenprojectEditorModule,
+ ],
+ declarations: [
+ DynamicFieldGroupWrapperComponent,
+ DynamicFormComponent,
+ // Input Types
+ BooleanInputComponent,
+ IntegerInputComponent,
+ TextInputComponent,
+ DateInputComponent,
+ DatePickerAdapterComponent,
+ SelectInputComponent,
+ FormattableTextareaInputComponent,
+ FormattableControlComponent,
+ ],
+ providers: [
+ { provide: HTTP_INTERCEPTORS, useClass: OpenProjectHeaderInterceptor, multi: true },
+ ],
+ exports: [
+ DynamicFormComponent,
+ ]
+})
+export class DynamicFormsModule {}
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.ts
new file mode 100644
index 00000000000..fb9db2eccf6
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
@@ -0,0 +1,306 @@
+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";
+
+
+@Injectable()
+export class DynamicFieldsService {
+ readonly inputsCatalogue:IOPDynamicInputTypeSettings[] = [
+ {
+ config: {
+ type: 'textInput',
+ className: 'inline-edit--field',
+ templateOptions: {
+ type: 'text',
+ },
+ },
+ useForFields: ['String']
+ },
+ {
+ config: {
+ type: 'textInput',
+ className: 'inline-edit--field',
+ templateOptions: {
+ type: 'password',
+ },
+ },
+ useForFields: ['Password']
+ },
+ {
+ config: {
+ type: 'integerInput',
+ className: `inline-edit--field`,
+ templateOptions: {
+ type: 'number',
+ locale: I18n.locale,
+ },
+ },
+ useForFields: ['Integer']
+ },
+ {
+ config: {
+ type: 'booleanInput',
+ className: `inline-edit--field inline-edit--boolean-field`,
+ templateOptions: {
+ type: 'checkbox',
+ },
+ },
+ useForFields: ['Boolean']
+ },
+ {
+ config: {
+ type: 'dateInput',
+ className: `inline-edit--field`,
+ },
+ useForFields: ['Date', 'DateTime']
+ },
+ {
+ config: {
+ type: 'formattableInput',
+ className: `textarea-wrapper`,
+ templateOptions: {
+ editorType: 'full',
+ noWrapLabel: true,
+ },
+ },
+ useForFields: ['Formattable']
+ },
+ {
+ config: {
+ type: 'selectInput',
+ className: `inline-edit--field`,
+ templateOptions: {
+ type: 'number',
+ locale: I18n.locale,
+ bindLabel: 'name',
+ searchable: false,
+ virtualScroll: true,
+ typeahead: false,
+ clearOnBackspace: false,
+ clearSearchOnAdd: false,
+ hideSelected: false,
+ text: {
+ add_new_action: I18n.t('js.label_create'),
+ },
+ },
+ expressionProperties: {
+ 'templateOptions.clearable': (model:any, formState:any, field:FormlyFieldConfig) => !field.templateOptions?.required,
+ },
+ },
+ useForFields: [
+ 'Priority', 'Status', 'Type', 'User', 'Version', 'TimeEntriesActivity',
+ 'Category', 'CustomOption', 'Project', 'ProjectStatus'
+ ]
+ },
+ ]
+
+ constructor(
+ private _httpClient:HttpClient,
+ ) { }
+
+ getConfig(formSchema:IOPFormSchema, formPayload:IOPFormModel):IOPFormlyFieldSettings[] {
+ const formFieldGroups = formSchema._attributeGroups;
+ const fieldSchemas = this._getFieldsSchemasWithKey(formSchema);
+ const formlyFields = fieldSchemas
+ .map(fieldSchema => this._getFormlyFieldConfig(fieldSchema))
+ .filter(f => f !== null) as IOPFormlyFieldSettings[];
+ const formlyFormWithFieldGroups = this._getFormlyFormWithFieldGroups(formFieldGroups, formlyFields);
+
+ return formlyFormWithFieldGroups;
+ }
+
+ getModel(formSchema:IOPFormSchema, formPayload:IOPFormModel):IOPFormModel {
+ const fieldSchemas = this._getFieldsSchemasWithKey(formSchema);
+ const fieldsModel = this._getFieldsModel(fieldSchemas, formPayload);
+
+ return fieldsModel;
+ }
+
+ private _getFieldsSchemasWithKey(formSchema:IOPFormSchema):IOPFieldSchemaWithKey[] {
+ return Object.keys(formSchema)
+ .map(fieldSchemaKey => {
+ const fieldSchema = {
+ ...formSchema[fieldSchemaKey],
+ key: this._isResourceSchema(formSchema[fieldSchemaKey]) ?
+ `_links.${fieldSchemaKey}` :
+ fieldSchemaKey
+ };
+
+ return fieldSchema;
+ })
+ .filter(fieldSchema => this._isFieldSchema(fieldSchema) && fieldSchema.writable);
+ }
+
+ private _isResourceSchema(fieldSchema: IOPFieldSchema):boolean {
+ return fieldSchema.location === '_links';
+ }
+
+ private _isFieldSchema(schemaValue:IOPFieldSchemaWithKey | any):boolean {
+ return schemaValue?.type;
+ }
+
+ private _getFieldsModel(fieldSchemas:IOPFieldSchemaWithKey[], formModel:IOPFormModel = {}):IOPFormModel {
+ const {_links:resourcesModel, ...otherElementsModel} = formModel;
+ const model = {
+ ...otherElementsModel,
+ _links: this._getFormattedResourcesModel(resourcesModel),
+ }
+
+ return model;
+ }
+
+ private _getFormattedResourcesModel(resourcesModel:IOPFormModel['_links'] = {}): IOPFormModel['_links']{
+ return Object.keys(resourcesModel).reduce((result, resourceKey) => {
+ const resource = resourcesModel[resourceKey];
+ // ng-select needs a 'name' in order to show the label
+ // We need to add it in case of the form payload (HalLinkSource)
+ const resourceModel = Array.isArray(resource) ?
+ resource.map(resourceElement => resourceElement?.href && { ...resourceElement, name: resourceElement?.title }) :
+ resource?.href && { ...resource, name: resource?.title };
+
+ result = {
+ ...result,
+ [resourceKey]: resourceModel,
+ }
+
+ return result;
+ }, {});
+ }
+
+ private _getFormlyFieldConfig(field:IOPFieldSchemaWithKey):IOPFormlyFieldSettings|null {
+ const { key, name:label, required } = field;
+ const fieldTypeConfigSearch = this._getFieldTypeConfig(field);
+ if (!fieldTypeConfigSearch) {
+ return null;
+ }
+ const { templateOptions, ...fieldTypeConfig } = fieldTypeConfigSearch;
+ const fieldOptions = this._getFieldOptions(field);
+ const formlyFieldConfig = {
+ ...fieldTypeConfig,
+ key,
+ property: this.getFieldProperty(key),
+ className: `op-form--field ${fieldTypeConfig.className}`,
+ templateOptions: {
+ required,
+ label,
+ ...templateOptions,
+ ...fieldOptions && {options: fieldOptions},
+ },
+ };
+
+ return formlyFieldConfig;
+ }
+
+ private _getFieldTypeConfig(field:IOPFieldSchemaWithKey):IOPFormlyFieldSettings|null {
+ const fieldType = field.type.replace('[]', '') as OPFieldType;
+ let inputType = this.inputsCatalogue.find(inputType => inputType.useForFields.includes(fieldType))!;
+ if (!inputType) {
+ console.warn(
+ `Could not find a input definition for a field with the folowing type: ${fieldType}.
+ The full field configuration is ${field}`
+ );
+ return null;
+ }
+ let inputConfig = inputType.config;
+ let configCustomizations;
+
+ if (inputConfig.type === 'integerInput' || inputConfig.type === 'selectInput') {
+ configCustomizations = {
+ className: `${inputConfig.className} ${field.name}`,
+ ...field.type.startsWith('[]') && {
+ templateOptions: {
+ ...inputConfig.templateOptions,
+ multiple: true
+ }
+ },
+ };
+ } else if (inputConfig.type === 'formattableInput') {
+ configCustomizations = {
+ templateOptions: {
+ ...inputConfig.templateOptions,
+ rtl: field.options?.rtl,
+ name: field.name,
+ },
+ };
+ }
+
+ return {...inputConfig, ...configCustomizations};
+ }
+
+ private _getFieldOptions(field:IOPFieldSchemaWithKey) {
+ const allowedValues = field._embedded?.allowedValues || field._links?.allowedValues;
+
+ if (!allowedValues) {
+ return;
+ }
+
+ if (Array.isArray(allowedValues)) {
+ const options = allowedValues[0]?._links?.self?.title ?
+ this._formatAllowedValues(allowedValues) :
+ allowedValues;
+
+ return of(options);
+ } else if (allowedValues!.href) {
+ return this._httpClient
+ .get(allowedValues!.href!)
+ .pipe(
+ map((response: api.v3.Result) => response._embedded.elements),
+ map(options => this._formatAllowedValues(options)),
+ );
+ }
+
+ return;
+ }
+
+ // ng-select needs a 'name' in order to show the label
+ // We need to add it in case of the form payload (HalLinkSource)
+ private _formatAllowedValues(options: IOPAllowedValue[]) {
+ return options.map((option:IOPFieldSchema['options']) => ({...option, name: option._links?.self?.title}));
+ }
+
+ // Map a field key that may be a _links.property to the property name
+ private getFieldProperty(key:string) {
+ return key.split('.').pop();
+ }
+
+ private _getFormlyFormWithFieldGroups(fieldGroups:IOPAttributeGroup[] = [], formFields:IOPFormlyFieldSettings[] = []):IOPFormlyFieldSettings[] {
+ const fieldGroupKeys = fieldGroups.reduce((groupKeys, fieldGroup) => [...groupKeys, ...fieldGroup.attributes], []);
+ const fomFieldsWithoutGroup = formFields.filter(formField => {
+ const formFieldKey = formField.key && this.getFieldProperty(formField.key);
+
+ return formFieldKey ?
+ !fieldGroupKeys.includes(formFieldKey) :
+ true;
+ });
+ const formFieldGroups = fieldGroups.reduce((formWithFieldGroups: IOPFormlyFieldSettings[], fieldGroup) => {
+ const newFormFieldGroup = {
+ wrappers: ['op-dynamic-field-group-wrapper'],
+ fieldGroupClassName: 'op-form--field-group',
+ templateOptions: {
+ label: fieldGroup.name,
+ },
+ fieldGroup: formFields.filter(formField => {
+ const formFieldKey = formField.key && this.getFieldProperty(formField.key);
+
+ return formFieldKey ?
+ fieldGroup.attributes.includes(formFieldKey) :
+ false;
+ }),
+ }
+
+ if (newFormFieldGroup.fieldGroup.length) {
+ formWithFieldGroups = [...formWithFieldGroups, newFormFieldGroup];
+ }
+
+ return formWithFieldGroups;
+ }, []);
+
+ return [...fomFieldsWithoutGroup, ...formFieldGroups];
+ }
+}
diff --git a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.ts b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.ts
new file mode 100644
index 00000000000..d1604c9da1a
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.ts
@@ -0,0 +1,58 @@
+import { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import { FormGroup } from "@angular/forms";
+import { FormlyForm } from "@ngx-formly/core";
+import { Observable } from "rxjs";
+import {
+ map,
+} from "rxjs/operators";
+import {
+ IOPDynamicFormSettings,
+} from "../../typings";
+import { DynamicFieldsService } from "core-app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service";
+import { FormsService } from "core-app/core/services/forms/forms.service";
+@Injectable()
+export class DynamicFormService {
+ dynamicForm:FormlyForm;
+
+ constructor(
+ private _httpClient:HttpClient,
+ private _dynamicFieldsService:DynamicFieldsService,
+ private _formsService:FormsService,
+ ) {}
+
+ registerForm(dynamicForm:FormlyForm) {
+ this.dynamicForm = dynamicForm;
+ }
+
+ getSettingsFromBackend$(url:string):Observable<IOPDynamicFormSettings>{
+ return this._httpClient
+ .post<IOPFormSettings>(
+ url,
+ {},
+ {
+ withCredentials: true,
+ responseType: 'json'
+ }
+ )
+ .pipe(
+ map((formConfig => this.getSettings(formConfig))),
+ );
+ }
+
+ getSettings(formConfig:IOPFormSettings):IOPDynamicFormSettings {
+ const formSchema = formConfig._embedded?.schema;
+ const formPayload = formConfig._embedded?.payload;
+ const dynamicForm = {
+ fields: this._dynamicFieldsService.getConfig(formSchema, formPayload),
+ model: this._dynamicFieldsService.getModel(formSchema, formPayload),
+ form: new FormGroup({}),
+ };
+
+ return dynamicForm;
+ }
+
+ submit$(form:FormGroup, resourceEndpoint:string, resourceId?:string) {
+ return this._formsService.submit$(form, resourceEndpoint, resourceId);
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/dynamic-forms/spec/helpers.ts b/frontend/src/app/modules/common/dynamic-forms/spec/helpers.ts
new file mode 100644
index 00000000000..1510a04df2c
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/spec/helpers.ts
@@ -0,0 +1,157 @@
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { Component, forwardRef, ViewChild } from "@angular/core";
+import { FormGroup, NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";
+import { CommonModule } from "@angular/common";
+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 { NgSelectModule } from "@ng-select/ng-select";
+import { NgOptionHighlightModule } from "@ng-select/ng-option-highlight";
+import { FormlyModule } from "@ngx-formly/core";
+import { IOPFormlyFieldSettings } from "core-app/modules/common/dynamic-forms/typings";
+import { FormlyField } from "@ngx-formly/core";
+import { By } from "@angular/platform-browser";
+import { FormattableControlComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component";
+import { OpCkeditorComponent } from "core-app/modules/common/ckeditor/op-ckeditor.component";
+import { ConfigurationService } from "core-app/modules/common/config/configuration.service";
+import { CKEditorSetupService } from "core-app/modules/common/ckeditor/ckeditor-setup.service";
+import { NotificationsService } from "core-app/modules/common/notifications/notifications.service";
+import { OpFormFieldComponent } from "core-app/modules/common/forms/form-field/form-field.component";
+
+export function createDynamicInputFixture(fields: IOPFormlyFieldSettings[], model:any, providers?:any[]): ComponentFixture<any> {
+ @Component({
+ template:`
+ <form [formGroup]="form">
+ <formly-form [form]="form"
+ [model]="model"
+ [fields]="fields">
+ <ng-template formlyTemplate let-field>
+ <op-form-field *ngFor="let field of fields"
+ [label]="field.templateOptions?.label"
+ [noWrapLabel]="field.templateOptions?.noWrapLabel"
+ [required]="field.templateOptions?.required">
+ <formly-field [field]="field" slot=input></formly-field>
+
+ <formly-validation-message [field]="field" slot=errors></formly-validation-message>
+ </op-form-field>
+ </ng-template>
+ </formly-form>
+ </form>
+ `,
+ providers,
+ })
+ class DynamicInputsTestingComponent {
+ form = new FormGroup({});
+ model = model;
+ fields = fields;
+
+ @ViewChild(FormlyField) dynamicControl:FormlyField;
+ }
+
+ const notificationsServiceSpy = jasmine.createSpyObj('NotificationsService', ['addError', 'addSuccess']);
+
+ TestBed
+ .configureTestingModule({
+ imports: [
+ CommonModule,
+ 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: [
+ TextInputComponent,
+ IntegerInputComponent,
+ SelectInputComponent,
+ BooleanInputComponent,
+ OpFormFieldComponent,
+ DateInputComponent,
+ OpCkeditorComponent,
+ FormattableControlComponent,
+ FormattableTextareaInputComponent,
+ DynamicInputsTestingComponent,
+ ],
+ providers: []
+ })
+ .overrideComponent(
+ FormattableControlComponent,
+ {
+ set: {
+ providers: [
+ CKEditorSetupService,
+ { provide: NotificationsService, useValue: notificationsServiceSpy },
+ {
+ provide: NG_VALUE_ACCESSOR,
+ multi: true,
+ useExisting: forwardRef(() => FormattableControlComponent),
+ },
+ {
+ provide: ConfigurationService,
+ useValue: {}
+ },
+ ]
+ }
+ }
+ );
+
+ TestBed.compileComponents();
+
+ const fixture = TestBed.createComponent(DynamicInputsTestingComponent);
+ fixture.detectChanges();
+
+ return fixture;
+}
+
+export function testDynamicInputControValueAccessor(fixture:ComponentFixture<any>, model:any, selector:string) {
+ const dynamicControl = fixture.componentInstance.dynamicControl.field.formControl;
+ const dynamicInput = fixture.debugElement.query(By.css(selector)).nativeElement;
+
+ // Test ControlValueAccessor
+ // Write Value
+ expect(dynamicControl.value).toBe(model.initialValue);
+ expect(dynamicInput.classList.contains('ng-untouched')).toBeTrue();
+ expect(dynamicInput.classList.contains('ng-valid')).toBeTrue();
+ expect(dynamicInput.classList.contains('ng-pristine')).toBeTrue();
+
+ // Change
+ if (dynamicInput.type === 'checkbox') {
+ dynamicInput.click();
+ } else {
+ dynamicInput.value = model.changedValue;
+ dynamicInput.dispatchEvent(new Event('input'));
+ }
+
+ fixture.detectChanges();
+
+ expect(dynamicControl.value).toBe(model.changedValue);
+ expect(dynamicInput.classList.contains('ng-dirty')).toBeTrue();
+
+ // Blur
+ dynamicInput.dispatchEvent(new Event('blur'));
+ fixture.detectChanges();
+ expect(dynamicInput.classList.contains('ng-touched')).toBeTrue();
+
+ // Disabled
+ dynamicControl.disable();
+ fixture.detectChanges();
+ expect(dynamicInput.disabled).toBeTrue();
+}
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/dynamic-forms/typings.d.ts b/frontend/src/app/modules/common/dynamic-forms/typings.d.ts
new file mode 100644
index 00000000000..e0e5ea798bc
--- /dev/null
+++ b/frontend/src/app/modules/common/dynamic-forms/typings.d.ts
@@ -0,0 +1,25 @@
+import { FormlyFieldConfig } from "@ngx-formly/core";
+import { FormGroup } from "@angular/forms";
+
+export interface IOPDynamicFormSettings {
+ fields:IOPFormlyFieldSettings[];
+ model:IOPFormModel;
+ form:FormGroup;
+}
+
+export interface IOPFormlyFieldSettings extends FormlyFieldConfig {
+ key?:string;
+ type?:OPInputType;
+ property?:string;
+}
+
+type OPInputType = 'formattableInput'|'selectInput'|'textInput'|'integerInput'|
+ 'booleanInput'|'dateInput';
+
+export interface IOPDynamicInputTypeSettings {
+ config:IOPFormlyFieldSettings,
+ useForFields:OPFieldType[];
+}
+
+
+
diff --git a/frontend/src/app/modules/common/focus/focus.module.ts b/frontend/src/app/modules/common/focus/focus.module.ts
new file mode 100644
index 00000000000..8623cd4a000
--- /dev/null
+++ b/frontend/src/app/modules/common/focus/focus.module.ts
@@ -0,0 +1,21 @@
+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";
+
+
+
+@NgModule({
+ declarations: [
+ FocusDirective,
+ FocusWithinDirective,
+ ],
+ imports: [
+ CommonModule
+ ],
+ exports: [
+ FocusDirective,
+ FocusWithinDirective,
+ ]
+})
+export class FocusModule { }
diff --git a/frontend/src/app/modules/common/form-field/form-field.component.html b/frontend/src/app/modules/common/form-field/form-field.component.html
deleted file mode 100644
index 2f6e7948d4b..00000000000
--- a/frontend/src/app/modules/common/form-field/form-field.component.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<label class="op-form-field--label-wrap">
- <div
- class="op-form-field--label"
- *ngIf="label"
- >
- {{ label }}
- <span *ngIf="required" class="op-form-field--label-indicator">*</span>
- </div>
- <div class="op-form-field--description">
- <ng-content select="[slot=description]"></ng-content>
- </div>
- <div class="op-form-field--input">
- <ng-content select="[slot=input]"></ng-content>
- </div>
- <div class="op-form-field--help-text">
- <ng-content select="[slot=help-text]"></ng-content>
- </div>
-</label>
-<div
- class="op-form-field--errors"
- *ngIf="isInvalid"
->
- <ng-content select="[slot=errors]"></ng-content>
-</div>
diff --git a/frontend/src/app/modules/common/form-field/form-field.component.ts b/frontend/src/app/modules/common/form-field/form-field.component.ts
deleted file mode 100644
index 651b83d4175..00000000000
--- a/frontend/src/app/modules/common/form-field/form-field.component.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import {
- Component,
- Input,
- HostBinding,
- ContentChild,
-} from "@angular/core";
-import {
- NgControl,
- AbstractControl,
-} from "@angular/forms";
-
-@Component({
- selector: 'op-form-field',
- templateUrl: './form-field.component.html',
-})
-export class OpFormFieldComponent {
- @HostBinding('class.op-form-field') className = true;
- @HostBinding('class.op-form-field_invalid') get errorClassName() {
- return this.isInvalid;
- }
-
- @Input() label = '';
- @Input() required = false;
-
- @ContentChild(NgControl) control:NgControl;
-
- get isDirty() {
- let control:AbstractControl|null = this.control?.control;
- do {
- if (!control) {
- return false;
- }
-
- if (control.dirty) {
- return true;
- }
-
- control = control.parent;
- } while (control);
-
- return false;
- }
-
- get isInvalid() {
- return this.isDirty && this.control?.invalid;
- }
-}
diff --git a/frontend/src/app/modules/common/forms/fieldset.sass b/frontend/src/app/modules/common/forms/fieldset.sass
new file mode 100644
index 00000000000..b2ef9cd0a65
--- /dev/null
+++ b/frontend/src/app/modules/common/forms/fieldset.sass
@@ -0,0 +1,3 @@
+.op-fieldset
+ display: flex
+ flex-direction: column
diff --git a/frontend/src/app/modules/common/form-field/form-binding.directive.ts b/frontend/src/app/modules/common/forms/form-field/form-binding.directive.ts
similarity index 100%
rename from frontend/src/app/modules/common/form-field/form-binding.directive.ts
rename to frontend/src/app/modules/common/forms/form-field/form-binding.directive.ts
diff --git a/frontend/src/app/modules/common/form-field/form-field.children.sass b/frontend/src/app/modules/common/forms/form-field/form-field.children.sass
similarity index 57%
rename from frontend/src/app/modules/common/form-field/form-field.children.sass
rename to frontend/src/app/modules/common/forms/form-field/form-field.children.sass
index 43aeec0d95a..fd467e09b5d 100644
--- a/frontend/src/app/modules/common/form-field/form-field.children.sass
+++ b/frontend/src/app/modules/common/forms/form-field/form-field.children.sass
@@ -1,5 +1,7 @@
.op-form-field_invalid
.ng-select-container,
.op-input,
- .op-option-list--item
+ .op-option-list--item,
+ .document-editor__editable-container,
+ .ck.ck-toolbar
border-color: var(--content-form-error-color)
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.html
new file mode 100644
index 00000000000..3d9b669b7cc
--- /dev/null
+++ b/frontend/src/app/modules/common/forms/form-field/form-field.component.html
@@ -0,0 +1,39 @@
+<ng-container *ngIf="!hidden">
+ <label class="op-form-field--label-wrap">
+ <ng-container *ngTemplateOutlet="inputLabelTemplate"></ng-container>
+
+ <ng-container *ngIf="!noWrapLabel">
+ <ng-container *ngTemplateOutlet="inputTemplate"></ng-container>
+ </ng-container>
+ </label>
+
+ <ng-container *ngIf="noWrapLabel">
+ <ng-container *ngTemplateOutlet="inputTemplate"></ng-container>
+ </ng-container>
+
+ <div class="op-form-field--errors"
+ *ngIf="showErrorMessage">
+ <ng-content select="[slot=errors]"></ng-content>
+ </div>
+</ng-container>
+
+<ng-template #inputTemplate>
+ <div class="op-form-field--description">
+ <ng-content select="[slot=description]"></ng-content>
+ </div>
+
+ <div class="op-form-field--input">
+ <ng-content select="[slot=input]"></ng-content>
+ </div>
+
+ <div class="op-form-field--help-text">
+ <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.ts
new file mode 100644
index 00000000000..596c577f448
--- /dev/null
+++ b/frontend/src/app/modules/common/forms/form-field/form-field.component.ts
@@ -0,0 +1,71 @@
+import {
+ Component,
+ Input,
+ HostBinding,
+ ContentChild,
+ Optional,
+ OnInit,
+} from "@angular/core";
+import {
+ NgControl,
+ AbstractControl,
+ FormGroupDirective,
+} from "@angular/forms";
+import { FormlyField } from "@ngx-formly/core";
+import { DynamicFormComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component";
+
+@Component({
+ selector: 'op-form-field',
+ templateUrl: './form-field.component.html',
+})
+export class OpFormFieldComponent implements OnInit{
+ @HostBinding('class.op-form-field') className = true;
+ @HostBinding('class.op-form-field_invalid') get errorClassName() {
+ return this.showErrorMessage;
+ }
+
+ @Input() label = '';
+ @Input() noWrapLabel = true;
+ @Input() required = false;
+ @Input() showValidationErrorOn: 'change' | 'blur' | 'submit' | 'never';
+
+ @ContentChild(NgControl) ngControl:NgControl;
+ @ContentChild(FormlyField) dynamicControl:FormlyField;
+
+ get formControl ():AbstractControl|undefined|null {
+ return this.ngControl?.control || this.dynamicControl?.field?.formControl;
+ }
+
+ get showErrorMessage():boolean {
+ let showErrorMessage = false;
+
+ if (!this.formControl) {
+ return false;
+ }
+
+ if (this.showValidationErrorOn === 'submit') {
+ showErrorMessage = this.formControl.invalid && this._formGroupDirective?.submitted;
+ } else if (this.showValidationErrorOn === 'blur') {
+ showErrorMessage = this.formControl.invalid && this.formControl.touched;
+ } else if (this.showValidationErrorOn === 'change') {
+ showErrorMessage = this.formControl.invalid && this.formControl.dirty;
+ }
+
+ return showErrorMessage;
+ }
+
+ get hidden () {
+ return this.dynamicControl?.field?.hide;
+ }
+
+ constructor(
+ @Optional() private _formGroupDirective:FormGroupDirective,
+ @Optional() private _dynamicFormComponent:DynamicFormComponent,
+ ) {}
+
+ ngOnInit() {
+ this.showValidationErrorOn = this.showValidationErrorOn ||
+ this._dynamicFormComponent?.showValidationErrorsOn ||
+ 'submit';
+ }
+}
diff --git a/frontend/src/app/modules/common/form-field/form-field.sass b/frontend/src/app/modules/common/forms/form-field/form-field.sass
similarity index 85%
rename from frontend/src/app/modules/common/form-field/form-field.sass
rename to frontend/src/app/modules/common/forms/form-field/form-field.sass
index 19930b0c595..f8dee2fe1e7 100644
--- a/frontend/src/app/modules/common/form-field/form-field.sass
+++ b/frontend/src/app/modules/common/forms/form-field/form-field.sass
@@ -3,6 +3,10 @@
.op-form-field
display: flex
flex-direction: column
+
+ // This is a fix for the formly-forms, which render the wrapper around a non-visible input
+ &:empty
+ display: none
&--label,
&--description,
diff --git a/frontend/src/app/modules/common/forms/form.sass b/frontend/src/app/modules/common/forms/form.sass
new file mode 100644
index 00000000000..3ac05b38a72
--- /dev/null
+++ b/frontend/src/app/modules/common/forms/form.sass
@@ -0,0 +1,27 @@
+.op-form
+ display: flex
+ flex-direction: column
+ align-items: flex-start
+
+ &--submit
+ margin: 1.5rem 0
+ display: flex
+
+ > *
+ max-width: 100%
+ width: 50rem
+
+ // TODO: The selector below is annoying to write, and it's mostly because we cannot use `>` to be more specific.
+ // This has to be fixed in html. The biggest offender right now are the dynamic forms since formly inserts a
+ // <formly-field> and then puts the op-form-fields inside that.
+ .op-form-field + .op-form-field,
+ .op-form-field + .op-fieldset,
+ .op-form-field + .op-button,
+ .op-fieldset + .op-form-field,
+ .op-fieldset + .op-fieldset,
+ .op-fieldset + .button,
+ .button + .op-form-field,
+ .button + .op-fieldset,
+ .button + .button
+ margin-top: 1.5rem
+
diff --git a/frontend/src/app/modules/common/forms/index.sass b/frontend/src/app/modules/common/forms/index.sass
new file mode 100644
index 00000000000..fc92a60931e
--- /dev/null
+++ b/frontend/src/app/modules/common/forms/index.sass
@@ -0,0 +1,3 @@
+@import './form-field/form-field'
+@import './form'
+@import './fieldset'
diff --git a/frontend/src/app/modules/common/input/input.sass b/frontend/src/app/modules/common/input/input.sass
index c54b0ba1b2d..eee049e3d12 100644
--- a/frontend/src/app/modules/common/input/input.sass
+++ b/frontend/src/app/modules/common/input/input.sass
@@ -2,4 +2,5 @@
background: white
border: 1px solid #e2e8f0
border-radius: 2px
+ min-height: 2rem
display: flex
diff --git a/frontend/src/app/modules/common/op-date-picker/date-picker.module.ts b/frontend/src/app/modules/common/op-date-picker/date-picker.module.ts
new file mode 100644
index 00000000000..7efe6b8121d
--- /dev/null
+++ b/frontend/src/app/modules/common/op-date-picker/date-picker.module.ts
@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { OpDatePickerComponent } from "core-app/modules/common/op-date-picker/op-date-picker.component";
+
+
+@NgModule({
+ declarations: [
+ OpDatePickerComponent,
+ ],
+ imports: [
+ CommonModule
+ ],
+ exports: [
+ OpDatePickerComponent,
+ ]
+})
+export class DatePickerModule { }
diff --git a/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.html b/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.html
index 08ea76dfee3..b2c481d33db 100644
--- a/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.html
+++ b/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.html
@@ -2,10 +2,9 @@
[id]="id"
[name]="name"
[value]="initialDate"
- [ngClass]="classes"
+ [ngClass]="classes + ' op-input'"
[size]="size"
[required]="required"
- [focus]="focus"
[disabled]="disabled"
(click)="openOnClick()"
(blur)="closeOnOutsideClick($event)"
diff --git a/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts b/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts
index becd9062c4d..262668173a6 100644
--- a/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts
+++ b/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts
@@ -27,7 +27,6 @@
//++
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnDestroy, Output, ViewChild } from '@angular/core';
-import { ConfigurationService } from 'core-app/modules/common/config/configuration.service';
import { TimezoneService } from 'core-components/datetime/timezone.service';
import { DatePicker } from "core-app/modules/common/op-date-picker/datepicker";
import { DebouncedEventEmitter } from "core-components/angular/debounced-event-emitter";
@@ -51,16 +50,13 @@ export class OpDatePickerComponent extends UntilDestroyedMixin implements OnDest
@Input() public name = '';
@Input() public required = false;
@Input() public size = 20;
- @Input() public focus = false;
@Input() public disabled = false;
@ViewChild('dateInput') dateInput:ElementRef;
- private datePickerInstance:DatePicker;
+ protected datePickerInstance:DatePicker;
- public constructor(private elementRef:ElementRef,
- private ConfigurationService:ConfigurationService,
- private timezoneService:TimezoneService) {
+ public constructor(protected timezoneService:TimezoneService) {
super();
if (!this.id) {
@@ -97,23 +93,23 @@ export class OpDatePickerComponent extends UntilDestroyedMixin implements OnDest
}
}
- private isEmpty():boolean {
+ protected isEmpty():boolean {
return this.currentValue.trim() === '';
}
- private get currentValue():string {
+ protected get currentValue():string {
return this.inputElement?.value || '';
}
- private get inputElement():HTMLInputElement {
- return this.dateInput.nativeElement;
+ protected get inputElement():HTMLInputElement {
+ return this.dateInput?.nativeElement;
}
- private inputIsValidDate():boolean {
+ protected inputIsValidDate():boolean {
return this.currentValue.match(/\d{4}-\d{2}-\d{2}/) !== null;
}
- private initializeDatepicker() {
+ protected initializeDatepicker() {
const options:any = {
allowInput: true,
appendTo: this.appendTo,
diff --git a/frontend/src/app/modules/common/openproject-common.module.sass b/frontend/src/app/modules/common/openproject-common.module.sass
index ceb57d89b77..782133c7aba 100644
--- a/frontend/src/app/modules/common/openproject-common.module.sass
+++ b/frontend/src/app/modules/common/openproject-common.module.sass
@@ -2,6 +2,6 @@
@import './menu/menu'
@import './input/input'
@import './link/link'
-@import './form-field/form-field'
+@import './forms'
@import './option-list/option-list'
@import './export-options/export-options'
diff --git a/frontend/src/app/modules/common/openproject-common.module.ts b/frontend/src/app/modules/common/openproject-common.module.ts
index 5eae4172f28..3072a36808c 100644
--- a/frontend/src/app/modules/common/openproject-common.module.ts
+++ b/frontend/src/app/modules/common/openproject-common.module.ts
@@ -36,12 +36,9 @@ import {NgOptionHighlightModule} from '@ng-select/ng-option-highlight';
import {DragulaModule} from 'ng2-dragula';
import {DynamicModule} from 'ng-dynamic-component';
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 {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';
@@ -52,9 +49,7 @@ import {EnterpriseBannerComponent} from 'core-components/enterprise-banner/enter
import {EnterpriseBannerBootstrapComponent} from 'core-components/enterprise-banner/enterprise-banner-bootstrap.component';
import {HomescreenNewFeaturesBlockComponent} from 'core-components/homescreen/blocks/new-features.component';
import {BoardVideoTeaserModalComponent} from 'core-app/modules/boards/board/board-video-teaser-modal/board-video-teaser-modal.component';
-
import {highlightColBootstrap} from './highlight-col/highlight-col.directive';
-import {FocusDirective} from './focus/focus.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';
@@ -62,8 +57,6 @@ import {OpDateTimeComponent} from './date/op-date-time.component';
import {NotificationComponent} from './notifications/notification.component';
import {NotificationsContainerComponent} from './notifications/notifications-container.component';
import {UploadProgressComponent} from './notifications/upload-progress.component';
-import {OpDatePickerComponent} from './op-date-picker/op-date-picker.component';
-import {FocusWithinDirective} from './focus/focus-within.directive';
import {ResizerComponent} from './resizer/resizer.component';
import {CollapsibleSectionComponent} from './collapsible-section/collapsible-section.component';
import {NoResultsComponent} from './no-results/no-results.component';
@@ -78,11 +71,13 @@ import {AutofocusDirective} from './autofocus/autofocus.directive';
import {ShowSectionDropdownComponent} from './hide-section/show-section-dropdown.component';
import {SlideToggleComponent} from './slide-toggle/slide-toggle.component';
import {DynamicBootstrapModule} from './dynamic-bootstrap/dynamic-bootstrap.module';
-import {OpFormFieldComponent} from './form-field/form-field.component';
-import {OpFormBindingDirective} from './form-field/form-binding.directive';
+import {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";
export function bootstrapModule(injector:Injector) {
// Ensure error reporter is run
@@ -125,6 +120,9 @@ export function bootstrapModule(injector:Injector) {
DynamicBootstrapModule,
OpenprojectPrincipalRenderingModule,
+
+ DatePickerModule,
+ FocusModule,
],
exports: [
// Re-export all commonly used
@@ -140,12 +138,11 @@ export function bootstrapModule(injector:Injector) {
DynamicBootstrapModule,
OpenprojectPrincipalRenderingModule,
- OpDatePickerComponent,
+ DatePickerModule,
+ FocusModule,
OpDateTimeComponent,
AutofocusDirective,
- FocusWithinDirective,
- FocusDirective,
AuthoringComponent,
// Notifications
@@ -188,12 +185,9 @@ export function bootstrapModule(injector:Injector) {
OpIconComponent,
],
declarations: [
- OpDatePickerComponent,
OpDateTimeComponent,
AutofocusDirective,
- FocusWithinDirective,
- FocusDirective,
AuthoringComponent,
// Notifications
diff --git a/frontend/src/app/modules/fields/edit/edit-field.initializer.ts b/frontend/src/app/modules/fields/edit/edit-field.initializer.ts
index 072d3835d1e..bf13cf67687 100644
--- a/frontend/src/app/modules/fields/edit/edit-field.initializer.ts
+++ b/frontend/src/app/modules/fields/edit/edit-field.initializer.ts
@@ -27,18 +27,18 @@
//++
import { EditFieldService } from "core-app/modules/fields/edit/edit-field.service";
-import { TextEditFieldComponent } from "core-app/modules/fields/edit/field-types/text-edit-field.component";
-import { IntegerEditFieldComponent } from "core-app/modules/fields/edit/field-types/integer-edit-field.component";
+import { TextEditFieldComponent } from "core-app/modules/fields/edit/field-types/text-edit-field/text-edit-field.component";
+import { IntegerEditFieldComponent } from "core-app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.component";
import { DurationEditFieldComponent } from "core-app/modules/fields/edit/field-types/duration-edit-field.component";
-import { SelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/select-edit-field.component";
+import { SelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component";
import { MultiSelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/multi-select-edit-field.component";
import { FloatEditFieldComponent } from "core-app/modules/fields/edit/field-types/float-edit-field.component";
-import { BooleanEditFieldComponent } from "core-app/modules/fields/edit/field-types/boolean-edit-field.component";
+import { BooleanEditFieldComponent } from "core-app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.component";
import { WorkPackageEditFieldComponent } from "core-app/modules/fields/edit/field-types/work-package-edit-field.component";
-import { DateEditFieldComponent } from "core-app/modules/fields/edit/field-types/date-edit-field.component";
-import { FormattableEditFieldComponent } from "core-app/modules/fields/edit/field-types/formattable-edit-field.component";
+import { DateEditFieldComponent } from "core-app/modules/fields/edit/field-types/date-edit-field/date-edit-field.component";
+import { FormattableEditFieldComponent } from "core-app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component";
import { WorkPackageCommentFieldComponent } from "core-components/work-packages/work-package-comment/wp-comment-field.component";
-import { SelectAutocompleterRegisterService } from "core-app/modules/fields/edit/field-types/select-autocompleter-register.service";
+import { SelectAutocompleterRegisterService } from "core-app/modules/fields/edit/field-types/select-edit-field/select-autocompleter-register.service";
import { ProjectStatusEditFieldComponent } from "core-app/modules/fields/edit/field-types/project-status-edit-field.component";
import { PlainFormattableEditFieldComponent } from "core-app/modules/fields/edit/field-types/plain-formattable-edit-field.component";
import { TimeEntryWorkPackageEditFieldComponent } from "core-app/modules/fields/edit/field-types/te-work-package-edit-field.component";
diff --git a/frontend/src/app/modules/fields/edit/field-controls/edit-field-controls.module.ts b/frontend/src/app/modules/fields/edit/field-controls/edit-field-controls.module.ts
new file mode 100644
index 00000000000..fdb85e7d57a
--- /dev/null
+++ b/frontend/src/app/modules/fields/edit/field-controls/edit-field-controls.module.ts
@@ -0,0 +1,19 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { EditFieldControlsComponent } from "core-app/modules/fields/edit/field-controls/edit-field-controls.component";
+import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";
+
+
+@NgModule({
+ declarations: [
+ EditFieldControlsComponent,
+ ],
+ imports: [
+ CommonModule,
+ OpenprojectCommonModule,
+ ],
+ exports: [
+ EditFieldControlsComponent,
+ ]
+})
+export class EditFieldControlsModule { }
diff --git a/frontend/src/app/modules/fields/edit/field-types/boolean-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.component.ts
similarity index 100%
rename from frontend/src/app/modules/fields/edit/field-types/boolean-edit-field.component.ts
rename to frontend/src/app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.component.ts
diff --git a/frontend/src/app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.module.ts b/frontend/src/app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.module.ts
new file mode 100644
index 00000000000..481d7c5c1f8
--- /dev/null
+++ b/frontend/src/app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.module.ts
@@ -0,0 +1,18 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { BooleanEditFieldComponent } from "core-app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.component";
+
+
+
+@NgModule({
+ declarations: [
+ BooleanEditFieldComponent,
+ ],
+ imports: [
+ CommonModule
+ ],
+ exports: [
+ BooleanEditFieldComponent,
+ ]
+})
+export class BooleanEditFieldModule { }
diff --git a/frontend/src/app/modules/fields/edit/field-types/combined-date-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/combined-date-edit-field.component.ts
index 756ec5e1c97..fac6412bd89 100644
--- a/frontend/src/app/modules/fields/edit/field-types/combined-date-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/combined-date-edit-field.component.ts
@@ -32,13 +32,14 @@ import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
import { DatePickerModal } from "core-components/datepicker/datepicker.modal";
import { OpModalService } from "core-app/modules/modal/modal.service";
import { take } from "rxjs/operators";
-import { DateEditFieldComponent } from "core-app/modules/fields/edit/field-types/date-edit-field.component";
+import { DateEditFieldComponent } from "core-app/modules/fields/edit/field-types/date-edit-field/date-edit-field.component";
import { OpModalComponent } from "core-app/modules/modal/modal.component";
@Component({
template: `
<input [value]="dates"
(click)="handleClick()"
+ class="op-input"
type="text" />
`
})
diff --git a/frontend/src/app/modules/fields/edit/field-types/date-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
similarity index 100%
rename from frontend/src/app/modules/fields/edit/field-types/date-edit-field.component.ts
rename to frontend/src/app/modules/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
diff --git a/frontend/src/app/modules/fields/edit/field-types/date-edit-field/date-edit-field.module.ts b/frontend/src/app/modules/fields/edit/field-types/date-edit-field/date-edit-field.module.ts
new file mode 100644
index 00000000000..abec9f8a4b9
--- /dev/null
+++ b/frontend/src/app/modules/fields/edit/field-types/date-edit-field/date-edit-field.module.ts
@@ -0,0 +1,21 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { DateEditFieldComponent } from "core-app/modules/fields/edit/field-types/date-edit-field/date-edit-field.component";
+import { DatePickerModule } from "core-app/modules/common/op-date-picker/date-picker.module";
+
+
+
+@NgModule({
+ declarations: [
+ DateEditFieldComponent,
+ ],
+ imports: [
+ CommonModule,
+ DatePickerModule,
+
+ ],
+ exports: [
+ DateEditFieldComponent,
+ ]
+})
+export class DateEditFieldModule { }
diff --git a/frontend/src/app/modules/fields/edit/field-types/duration-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/duration-edit-field.component.ts
index f810296c3d7..ab78f69f8d4 100644
--- a/frontend/src/app/modules/fields/edit/field-types/duration-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/duration-edit-field.component.ts
@@ -36,7 +36,7 @@ import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
template: `
<input type="number"
step="0.01"
- class="inline-edit--field"
+ class="inline-edit--field op-input"
#input
[attr.aria-required]="required"
[ngModel]="formatter(value)"
diff --git a/frontend/src/app/modules/fields/edit/field-types/float-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/float-edit-field.component.ts
index 42a39cfe2ce..bae521a5f57 100644
--- a/frontend/src/app/modules/fields/edit/field-types/float-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/float-edit-field.component.ts
@@ -32,7 +32,7 @@ import { EditFieldComponent } from "core-app/modules/fields/edit/edit-field.comp
template: `
<input type="number"
step="any"
- class="inline-edit--field"
+ class="inline-edit--field op-input"
[attr.aria-required]="required"
[attr.required]="required"
[disabled]="inFlight"
diff --git a/frontend/src/app/modules/fields/edit/field-types/formattable-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.ts
similarity index 100%
rename from frontend/src/app/modules/fields/edit/field-types/formattable-edit-field.component.ts
rename to frontend/src/app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.ts
diff --git a/frontend/src/app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.module.ts b/frontend/src/app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.module.ts
new file mode 100644
index 00000000000..2117825b574
--- /dev/null
+++ b/frontend/src/app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.module.ts
@@ -0,0 +1,22 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormattableEditFieldComponent } from "core-app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component";
+import { OpenprojectEditorModule } from "core-app/modules/editor/openproject-editor.module";
+import { EditFieldControlsComponent } from "core-app/modules/fields/edit/field-controls/edit-field-controls.component";
+import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-controls/edit-field-controls.module";
+
+
+@NgModule({
+ declarations: [
+ FormattableEditFieldComponent,
+ ],
+ imports: [
+ CommonModule,
+ OpenprojectEditorModule,
+ EditFieldControlsModule,
+ ],
+ exports: [
+ FormattableEditFieldComponent,
+ ]
+})
+export class FormattableEditFieldModule { }
diff --git a/frontend/src/app/modules/fields/edit/field-types/integer-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.component.ts
similarity index 97%
rename from frontend/src/app/modules/fields/edit/field-types/integer-edit-field.component.ts
rename to frontend/src/app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.component.ts
index a6761c672bd..0014c0bffa6 100644
--- a/frontend/src/app/modules/fields/edit/field-types/integer-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.component.ts
@@ -31,7 +31,7 @@ import { EditFieldComponent } from "core-app/modules/fields/edit/edit-field.comp
@Component({
template: `
<input type="number"
- class="inline-edit--field"
+ class="inline-edit--field op-input"
[attr.aria-required]="required"
[attr.required]="required"
[disabled]="inFlight"
diff --git a/frontend/src/app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.module.ts b/frontend/src/app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.module.ts
new file mode 100644
index 00000000000..45f10ef5c78
--- /dev/null
+++ b/frontend/src/app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.module.ts
@@ -0,0 +1,20 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { IntegerEditFieldComponent } from "core-app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.component";
+import { FormsModule } from "@angular/forms";
+
+
+
+@NgModule({
+ declarations: [
+ IntegerEditFieldComponent,
+ ],
+ imports: [
+ CommonModule,
+ FormsModule,
+ ],
+ exports: [
+ IntegerEditFieldComponent,
+ ]
+})
+export class IntegerEditFieldModule { }
diff --git a/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts
index 5fdfd3e77fd..1d1c08fb4d7 100644
--- a/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts
@@ -31,7 +31,7 @@ import { HalResource } from 'core-app/modules/hal/resources/hal-resource';
import { I18nService } from 'core-app/modules/common/i18n/i18n.service';
import { Component, OnInit, ViewChild } from "@angular/core";
import { EditFieldComponent } from "core-app/modules/fields/edit/edit-field.component";
-import { ValueOption } from "core-app/modules/fields/edit/field-types/select-edit-field.component";
+import { ValueOption } from "core-app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component";
import { NgSelectComponent } from "@ng-select/ng-select";
import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
diff --git a/frontend/src/app/modules/fields/edit/field-types/select-autocompleter-register.service.ts b/frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-autocompleter-register.service.ts
similarity index 100%
rename from frontend/src/app/modules/fields/edit/field-types/select-autocompleter-register.service.ts
rename to frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-autocompleter-register.service.ts
diff --git a/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.html b/frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component.html
similarity index 100%
rename from frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.html
rename to frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component.html
diff --git a/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component.ts
similarity index 98%
rename from frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
rename to frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component.ts
index 0e0984032c6..6be0712935a 100644
--- a/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component.ts
@@ -30,8 +30,8 @@ import { Component, InjectFlags, OnInit } from '@angular/core';
import { HalResourceSortingService } from 'core-app/modules/hal/services/hal-resource-sorting.service';
import { CollectionResource } from 'core-app/modules/hal/resources/collection-resource';
import { HalResource } from 'core-app/modules/hal/resources/hal-resource';
-import { EditFieldComponent } from '../edit-field.component';
-import { SelectAutocompleterRegisterService } from 'app/modules/fields/edit/field-types/select-autocompleter-register.service';
+import { EditFieldComponent } from '../../edit-field.component';
+import { SelectAutocompleterRegisterService } from 'core-app/modules/fields/edit/field-types/select-edit-field/select-autocompleter-register.service';
import { from } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { HalResourceNotificationService } from 'core-app/modules/hal/services/hal-resource-notification.service';
diff --git a/frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.module.ts b/frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.module.ts
new file mode 100644
index 00000000000..58098189e2f
--- /dev/null
+++ b/frontend/src/app/modules/fields/edit/field-types/select-edit-field/select-edit-field.module.ts
@@ -0,0 +1,20 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { SelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component";
+import { DynamicModule } from 'ng-dynamic-component';
+
+
+
+@NgModule({
+ imports: [
+ CommonModule,
+ DynamicModule,
+ ],
+ declarations: [
+ SelectEditFieldComponent,
+ ],
+ exports: [
+ SelectEditFieldComponent,
+ ]
+})
+export class SelectEditFieldModule { }
diff --git a/frontend/src/app/modules/fields/edit/field-types/text-edit-field.component.html b/frontend/src/app/modules/fields/edit/field-types/text-edit-field.component.html
index e18068f6865..ca94de76c5c 100644
--- a/frontend/src/app/modules/fields/edit/field-types/text-edit-field.component.html
+++ b/frontend/src/app/modules/fields/edit/field-types/text-edit-field.component.html
@@ -1,5 +1,5 @@
<input type="text"
- class="inline-edit--field"
+ class="inline-edit--field op-input"
[focus]="shouldFocus"
[attr.aria-required]="required"
[attr.required]="required"
diff --git a/frontend/src/app/modules/fields/edit/field-types/text-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.component.ts
similarity index 96%
rename from frontend/src/app/modules/fields/edit/field-types/text-edit-field.component.ts
rename to frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.component.ts
index c061d509b1b..091774a6a1d 100644
--- a/frontend/src/app/modules/fields/edit/field-types/text-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.component.ts
@@ -30,7 +30,7 @@ import { Component } from "@angular/core";
import { EditFieldComponent } from "core-app/modules/fields/edit/edit-field.component";
@Component({
- templateUrl: './text-edit-field.component.html'
+ templateUrl: '../text-edit-field.component.html'
})
export class TextEditFieldComponent extends EditFieldComponent {
// ToDo: Work package specific
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.ts
new file mode 100644
index 00000000000..e037d948831
--- /dev/null
+++ b/frontend/src/app/modules/fields/edit/field-types/text-edit-field/text-edit-field.module.ts
@@ -0,0 +1,20 @@
+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";
+
+@NgModule({
+ imports: [
+ CommonModule,
+ FormsModule,
+ FocusModule,
+ ],
+ declarations: [
+ TextEditFieldComponent,
+ ],
+ exports: [
+ TextEditFieldComponent,
+ ]
+})
+export class TextEditFieldModule { }
diff --git a/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts
index 8ed92b73c4e..250cc7b9fdc 100644
--- a/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts
@@ -27,7 +27,7 @@
//++
import { Component } from "@angular/core";
-import { SelectEditFieldComponent, ValueOption } from './select-edit-field.component';
+import { SelectEditFieldComponent, ValueOption } from './select-edit-field/select-edit-field.component';
import { ApiV3FilterBuilder } from "core-components/api/api-v3/api-v3-filter-builder";
import { WorkPackageResource } from "core-app/modules/hal/resources/work-package-resource";
import { DebouncedRequestSwitchmap, errorNotificationHandler } from "core-app/helpers/rxjs/debounced-input-switchmap";
diff --git a/frontend/src/app/modules/fields/openproject-fields.module.ts b/frontend/src/app/modules/fields/openproject-fields.module.ts
index c3caa446a6e..220d289dcd8 100644
--- a/frontend/src/app/modules/fields/openproject-fields.module.ts
+++ b/frontend/src/app/modules/fields/openproject-fields.module.ts
@@ -36,18 +36,11 @@ import { EditFieldService } from "core-app/modules/fields/edit/edit-field.servic
import { DisplayFieldService } from "core-app/modules/fields/display/display-field.service";
import { initializeCoreEditFields } from "core-app/modules/fields/edit/edit-field.initializer";
import { initializeCoreDisplayFields } from "core-app/modules/fields/display/display-field.initializer";
-import { BooleanEditFieldComponent } from "core-app/modules/fields/edit/field-types/boolean-edit-field.component";
-import { DateEditFieldComponent } from "core-app/modules/fields/edit/field-types/date-edit-field.component";
import { DurationEditFieldComponent } from "core-app/modules/fields/edit/field-types/duration-edit-field.component";
import { FloatEditFieldComponent } from "core-app/modules/fields/edit/field-types/float-edit-field.component";
-import { IntegerEditFieldComponent } from "core-app/modules/fields/edit/field-types/integer-edit-field.component";
import { MultiSelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/multi-select-edit-field.component";
-import { SelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/select-edit-field.component";
-import { FormattableEditFieldComponent } from "core-app/modules/fields/edit/field-types/formattable-edit-field.component";
-import { TextEditFieldComponent } from "core-app/modules/fields/edit/field-types/text-edit-field.component";
import { EditFormPortalComponent } from "core-app/modules/fields/edit/editing-portal/edit-form-portal.component";
-import { EditFieldControlsComponent, } from "core-app/modules/fields/edit/field-controls/edit-field-controls.component";
-import { SelectAutocompleterRegisterService } from "core-app/modules/fields/edit/field-types/select-autocompleter-register.service";
+import { SelectAutocompleterRegisterService } from "core-app/modules/fields/edit/field-types/select-edit-field/select-autocompleter-register.service";
import { EditFormComponent } from "core-app/modules/fields/edit/edit-form/edit-form.component";
import { WorkPackageEditFieldComponent } from "core-app/modules/fields/edit/field-types/work-package-edit-field.component";
import { EditableAttributeFieldComponent } from "core-app/modules/fields/edit/field/editable-attribute-field.component";
@@ -61,6 +54,13 @@ import { AttributeHelpTextModal } from "core-app/modules/fields/help-texts/attri
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";
+import { BooleanEditFieldModule } from "core-app/modules/fields/edit/field-types/boolean-edit-field/boolean-edit-field.module";
+import { IntegerEditFieldModule } from "core-app/modules/fields/edit/field-types/integer-edit-field/integer-edit-field.module";
+import { TextEditFieldModule } from "core-app/modules/fields/edit/field-types/text-edit-field/text-edit-field.module";
+import { DateEditFieldModule } from "core-app/modules/fields/edit/field-types/date-edit-field/date-edit-field.module";
+import { SelectEditFieldModule } from "core-app/modules/fields/edit/field-types/select-edit-field/select-edit-field.module";
+import { FormattableEditFieldModule } from "core-app/modules/fields/edit/field-types/formattable-edit-field/formattable-edit-field.module";
+import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-controls/edit-field-controls.module";
@NgModule({
imports: [
@@ -70,9 +70,16 @@ import { OpenprojectAutocompleterModule } from "core-app/modules/autocompleter/o
OpenprojectEditorModule,
OpenprojectModalModule,
OpenprojectAutocompleterModule,
+ // Input Modules
+ BooleanEditFieldModule,
+ IntegerEditFieldModule,
+ TextEditFieldModule,
+ DateEditFieldModule,
+ SelectEditFieldModule,
+ FormattableEditFieldModule,
+ EditFieldControlsModule,
],
exports: [
- EditFieldControlsComponent,
EditFormPortalComponent,
EditFormComponent,
EditableAttributeFieldComponent,
@@ -94,17 +101,10 @@ import { OpenprojectAutocompleterModule } from "core-app/modules/autocompleter/o
],
declarations: [
EditFormPortalComponent,
- BooleanEditFieldComponent,
- DateEditFieldComponent,
DurationEditFieldComponent,
FloatEditFieldComponent,
- IntegerEditFieldComponent,
- FormattableEditFieldComponent,
PlainFormattableEditFieldComponent,
MultiSelectEditFieldComponent,
- SelectEditFieldComponent,
- TextEditFieldComponent,
- EditFieldControlsComponent,
WorkPackageEditFieldComponent,
TimeEntryWorkPackageEditFieldComponent,
EditFormComponent,
diff --git a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts
index f70af385d10..16b66755814 100644
--- a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts
@@ -1,8 +1,8 @@
-import { Component, EventEmitter, Inject, Input, OnInit, Optional } from '@angular/core';
+import { Component, Inject, OnInit, Optional } from '@angular/core';
import { NgSelectComponent } from "@ng-select/ng-select";
import { OpEditingPortalSchemaToken } from "core-app/modules/fields/edit/edit-field.component";
import { IFieldSchema } from "core-app/modules/fields/field.base";
-import { SelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/select-edit-field.component";
+import { SelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/select-edit-field/select-edit-field.component";
import { MultiSelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/multi-select-edit-field.component";
import { I18nService } from "core-app/modules/common/i18n/i18n.service";
import { PermissionsService } from "core-app/core/services/permissions/permissions.service";
diff --git a/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts b/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts
index cd7a96177a0..fbb0c13eb80 100644
--- a/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts
+++ b/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts
@@ -1,7 +1,12 @@
import { APP_INITIALIZER, Injector, NgModule } from "@angular/core";
import { ReactiveFormsModule } from "@angular/forms";
import { TextFieldModule } from '@angular/cdk/text-field';
+import { NgSelectModule } from "@ng-select/ng-select";
import { OpenprojectModalModule } from "core-app/modules/modal/modal.module";
+import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";
+import { InviteUserButtonComponent } from "core-app/modules/invite-user-modal/button/invite-user-button.component";
+import { OpInviteUserModalAugmentService } from "core-app/modules/invite-user-modal/invite-user-modal-augment.service";
+import { OpInviteUserModalService } from "core-app/modules/invite-user-modal/invite-user-modal.service";
import { InviteUserModalComponent } from "./invite-user.component";
import { ProjectSelectionComponent } from "./project-selection/project-selection.component";
import { ProjectSearchComponent } from "./project-selection/project-search.component";
@@ -12,11 +17,6 @@ import { RoleSearchComponent } from "./role/role-search.component";
import { MessageComponent } from "./message/message.component";
import { SummaryComponent } from "./summary/summary.component";
import { SuccessComponent } from "./success/success.component";
-import { NgSelectModule } from "@ng-select/ng-select";
-import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";
-import { InviteUserButtonComponent } from "core-app/modules/invite-user-modal/button/invite-user-button.component";
-import { OpInviteUserModalAugmentService } from "core-app/modules/invite-user-modal/invite-user-modal-augment.service";
-import { OpInviteUserModalService } from "core-app/modules/invite-user-modal/invite-user-modal.service";
export function initializeServices(injector:Injector) {
return function () {
diff --git a/frontend/src/app/modules/invite-user-modal/message/message.component.html b/frontend/src/app/modules/invite-user-modal/message/message.component.html
index 07eff7f4bf0..4b56b6509dd 100644
--- a/frontend/src/app/modules/invite-user-modal/message/message.component.html
+++ b/frontend/src/app/modules/invite-user-modal/message/message.component.html
@@ -14,12 +14,8 @@
[formControl]="messageControl"
slot="input"
#input
- autofocus
- cdkTextareaAutosize
- cdkAutosizeMinRows="1"
- cdkAutosizeMaxrows="3"
- #autosize="cdkTextareaAutosize"
- ></textarea>
+ autofocus>
+ </textarea>
</op-form-field>
</div>
diff --git a/frontend/src/app/modules/invite-user-modal/message/message.component.ts b/frontend/src/app/modules/invite-user-modal/message/message.component.ts
index f7cd86626ef..a70eea6f14e 100644
--- a/frontend/src/app/modules/invite-user-modal/message/message.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/message/message.component.ts
@@ -11,7 +11,6 @@ import {
FormControl,
FormGroup,
} from '@angular/forms';
-import {CdkTextareaAutosize} from '@angular/cdk/text-field';
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {HalResource} from 'core-app/modules/hal/resources/hal-resource';
import {ProjectResource} from 'core-app/modules/hal/resources/project-resource';
@@ -33,7 +32,6 @@ export class MessageComponent implements OnInit {
@Output() save = new EventEmitter<{message:string}>();
@ViewChild('input') input: ElementRef;
- @ViewChild('autosize') autosize: CdkTextareaAutosize;
public text = {
title: () => this.I18n.t('js.invite_user_modal.title.invite_principal_to_project', {
@@ -65,7 +63,6 @@ export class MessageComponent implements OnInit {
ngAfterViewInit() {
this.input.nativeElement.focus();
- this.autosize.resizeToFitContent(true);
}
onSubmit($e:Event) {
diff --git a/frontend/src/app/modules/projects/components/projects/projects.component.html b/frontend/src/app/modules/projects/components/projects/projects.component.html
new file mode 100644
index 00000000000..efe88700cd9
--- /dev/null
+++ b/frontend/src/app/modules/projects/components/projects/projects.component.html
@@ -0,0 +1,5 @@
+<op-dynamic-form [resourcePath]="projectsPath"
+ [resourceId]="resourceId"
+ [fieldsSettingsPipe]="dynamicFieldsSettingsPipe"
+ (submitted)="onSubmitted($event)">
+</op-dynamic-form>
\ No newline at end of file
diff --git a/frontend/src/app/modules/projects/components/projects/projects.component.scss b/frontend/src/app/modules/projects/components/projects/projects.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/frontend/src/app/modules/projects/components/projects/projects.component.spec.ts b/frontend/src/app/modules/projects/components/projects/projects.component.spec.ts
new file mode 100644
index 00000000000..fdf1cfb8219
--- /dev/null
+++ b/frontend/src/app/modules/projects/components/projects/projects.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ProjectsComponent } from './projects.component';
+
+xdescribe('ProjectsComponent', () => {
+ let component: ProjectsComponent;
+ let fixture: ComponentFixture<ProjectsComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ProjectsComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ProjectsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/modules/projects/components/projects/projects.component.ts b/frontend/src/app/modules/projects/components/projects/projects.component.ts
new file mode 100644
index 00000000000..8aa0e8f67a0
--- /dev/null
+++ b/frontend/src/app/modules/projects/components/projects/projects.component.ts
@@ -0,0 +1,51 @@
+import { Component, OnInit } from '@angular/core';
+import { StateService, UIRouterGlobals } from "@uirouter/core";
+import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
+import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
+import { HalSource } from "core-app/modules/hal/resources/hal-resource";
+import { IOPFormlyFieldSettings } from "core-app/modules/common/dynamic-forms/typings";
+
+@Component({
+ selector: 'app-projects',
+ templateUrl: './projects.component.html',
+ styleUrls: ['./projects.component.scss']
+})
+export class ProjectsComponent extends UntilDestroyedMixin implements OnInit {
+ resourceId:string;
+ projectsPath:string;
+ text:{[key:string]:string};
+ dynamicFieldsSettingsPipe:(dynamicFieldsSettings:IOPFormlyFieldSettings[]) => IOPFormlyFieldSettings[];
+
+ constructor(
+ private _uIRouterGlobals:UIRouterGlobals,
+ private _pathHelperService:PathHelperService,
+ private _$state:StateService,
+ ) {
+ super();
+ }
+
+ ngOnInit(): void {
+ this.projectsPath = this._pathHelperService.projectsPath();
+ this.resourceId = this._uIRouterGlobals.params.projectPath;
+ this.dynamicFieldsSettingsPipe = (dynamicFieldsSettings) => {
+ return dynamicFieldsSettings
+ .reduce((formattedDynamicFieldsSettings, dynamicFormField) => {
+ if (dynamicFormField.key === 'identifier') {
+ dynamicFormField = {
+ ...dynamicFormField,
+ hide: true,
+ }
+ }
+
+ return [...formattedDynamicFieldsSettings, dynamicFormField];
+ }, []);
+ }
+ }
+
+ onSubmitted(formResource:HalSource) {
+ // TODO: Filter out if this.resourceId === 'new'?
+ if (!this.resourceId) {
+ this._$state.go('.', { ...this._$state.params, projectPath: formResource.identifier });
+ }
+ }
+}
diff --git a/frontend/src/app/modules/projects/openproject-projects.module.ts b/frontend/src/app/modules/projects/openproject-projects.module.ts
index 32a276d2902..27604986c2b 100644
--- a/frontend/src/app/modules/projects/openproject-projects.module.ts
+++ b/frontend/src/app/modules/projects/openproject-projects.module.ts
@@ -30,6 +30,10 @@ import { OpenprojectCommonModule } from 'core-app/modules/common/openproject-com
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 { 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";
@NgModule({
@@ -39,7 +43,13 @@ import { OpenprojectHalModule } from "core-app/modules/hal/openproject-hal.modul
OpenprojectHalModule,
OpenprojectFieldsModule,
- ]
+ UIRouterModule.forChild({
+ states: PROJECTS_ROUTES,
+ config: uiRouterProjectsConfiguration
+ }),
+ DynamicFormsModule,
+ ],
+ declarations: [ProjectsComponent]
})
export class OpenprojectProjectsModule {
}
diff --git a/frontend/src/app/modules/projects/projects-routes.ts b/frontend/src/app/modules/projects/projects-routes.ts
new file mode 100644
index 00000000000..fe644304337
--- /dev/null
+++ b/frontend/src/app/modules/projects/projects-routes.ts
@@ -0,0 +1,21 @@
+import { Ng2StateDeclaration, UIRouter } from "@uirouter/angular";
+import { ProjectsComponent } from "core-app/modules/projects/components/projects/projects.component";
+
+export const PROJECTS_ROUTES:Ng2StateDeclaration[] = [
+ {
+ name: 'projects',
+ url: '/settings/generic/',
+ parent: 'root',
+ component: ProjectsComponent,
+ },
+];
+
+export function uiRouterProjectsConfiguration(uiRouter:UIRouter) {
+ // Ensure projects/ are being redirected correctly
+ // cf., https://community.openproject.com/wp/29754
+ uiRouter.urlService.rules
+ .when(
+ new RegExp("^/projects/(.*)/settings/generic$"),
+ match => `/projects/${match[1]}/settings/generic/`
+ );
+}
\ No newline at end of file
diff --git a/frontend/src/app/modules/router/openproject.routes.ts b/frontend/src/app/modules/router/openproject.routes.ts
index 7af6bdc49c8..ad7267df1ce 100644
--- a/frontend/src/app/modules/router/openproject.routes.ts
+++ b/frontend/src/app/modules/router/openproject.routes.ts
@@ -87,6 +87,12 @@ export const OPENPROJECT_ROUTES:Ng2StateDeclaration[] = [
url: '/job_statuses',
loadChildren: () => import('../job-status/openproject-job-status.module').then(m => m.OpenProjectJobStatusModule)
},
+ {
+ name: 'projects.**',
+ parent: 'root',
+ url: '/settings/generic',
+ loadChildren: () => import('../projects/openproject-projects.module').then(m => m.OpenprojectProjectsModule)
+ },
];
/**
diff --git a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
index aacea8aaf7f..c44bf89b7bf 100644
--- a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
+++ b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
@@ -171,6 +171,7 @@ import { WorkPackagesTableComponent } from "core-components/wp-table/wp-table.co
import { WorkPackageGroupToggleDropdownMenuDirective } from "core-components/op-context-menu/handlers/wp-group-toggle-dropdown-menu.directive";
import { OpenprojectAutocompleterModule } from "core-app/modules/autocompleter/openproject-autocompleter.module";
import { OpWpTabsModule } from "core-components/wp-tabs/wp-tabs.module";
+import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-controls/edit-field-controls.module";
@NgModule({
imports: [
@@ -192,6 +193,8 @@ import { OpWpTabsModule } from "core-components/wp-tabs/wp-tabs.module";
OpenprojectAutocompleterModule,
OpWpTabsModule,
+
+ EditFieldControlsModule,
],
providers: [
// Notification service
diff --git a/frontend/src/global_styles/vendor/_ngselect.sass b/frontend/src/global_styles/vendor/_ngselect.sass
index 04790c7026b..538e256bb38 100644
--- a/frontend/src/global_styles/vendor/_ngselect.sass
+++ b/frontend/src/global_styles/vendor/_ngselect.sass
@@ -1,2 +1,8 @@
.ng-dropdown-footer
- padding: 0 !important
\ No newline at end of file
+ padding: 0 !important
+
+.ng-select .ng-select-container
+ border-radius: 2px
+
+.ng-select .ng-value-container
+ height: 2rem
\ No newline at end of file
diff --git a/frontend/src/global_styles/vendor/foundation-apps/scss/components/_forms.scss b/frontend/src/global_styles/vendor/foundation-apps/scss/components/_forms.scss
index 968e8217052..ecad4b8be03 100755
--- a/frontend/src/global_styles/vendor/foundation-apps/scss/components/_forms.scss
+++ b/frontend/src/global_styles/vendor/foundation-apps/scss/components/_forms.scss
@@ -87,7 +87,7 @@ $meter-radius: 0 !default;
padding: $form-padding;
margin: 0 0 $global-padding 0;
border: $input-border;
- border-radius: 0;
+ border-radius: 2px;
background: $input-background;
color: $input-color;
font-size: $form-fontsize;
diff --git a/spec/features/menu_items/menu_permissions_spec.rb b/spec/features/menu_items/menu_permissions_spec.rb
index ba84b18124e..ba13b332bbf 100644
--- a/spec/features/menu_items/menu_permissions_spec.rb
+++ b/spec/features/menu_items/menu_permissions_spec.rb
@@ -58,7 +58,7 @@ describe 'menu permissions', type: :feature, js: true do
# Clicking the menu parent item leads to the version page
find('.main-menu--parent-node', text: 'Project settings').click
- expect(page).to have_current_path(settings_generic_project_path(project))
+ expect(page).to have_current_path "/projects/#{project.identifier}/settings/generic/"
end
end
diff --git a/spec/features/projects/copy_spec.rb b/spec/features/projects/copy_spec.rb
index 79f6f498c41..ee763871e84 100644
--- a/spec/features/projects/copy_spec.rb
+++ b/spec/features/projects/copy_spec.rb
@@ -160,13 +160,14 @@ describe 'Projects copy',
copied_settings_page.visit!
# has the parent of the original project
- expect(page)
- .to have_select('Subproject of',
- selected: parent_project.name)
+ page.within('label', text: 'Subproject of') do
+ expect(page)
+ .to have_selector('.ng-value', text: parent_project.name)
+ end
# copies over the value of the custom field
- editor = ::Components::WysiwygEditor.new ".form--field.custom_field_#{project_custom_field.id}"
- editor.expect_value 'some text cf'
+ # has the parent of the original project
+ expect(page).to have_selector('.op-uc-container', text: 'some text cf')
# has wp custom fields of original project active
copied_settings_page.visit_tab!('custom_fields')
diff --git a/spec/features/projects/project_status_administration_spec.rb b/spec/features/projects/project_status_administration_spec.rb
index 1b87705d468..5480761d5c9 100644
--- a/spec/features/projects/project_status_administration_spec.rb
+++ b/spec/features/projects/project_status_administration_spec.rb
@@ -29,6 +29,8 @@
require 'spec_helper'
describe 'Projects status administration', type: :feature, js: true do
+ include_context 'ng-select-autocomplete helpers'
+
let(:current_user) do
FactoryBot.create(:user).tap do |u|
FactoryBot.create(:global_member,
@@ -45,8 +47,8 @@ describe 'Projects status administration', type: :feature, js: true do
.and_return(r.id.to_s)
end
end
+ let(:edit_status_description) { Components::WysiwygEditor.new('[data-field-name="statusExplanation"]') }
let(:create_status_description) { Components::WysiwygEditor.new('.form--field:nth-of-type(4)') }
- let(:edit_status_description) { Components::WysiwygEditor.new('.form--field:nth-of-type(5)') }
before do
login_as current_user
@@ -59,7 +61,9 @@ describe 'Projects status administration', type: :feature, js: true do
click_link 'Advanced settings'
fill_in 'Name', with: 'New project'
+
select 'On track', from: 'Status'
+
create_status_description.set_markdown 'Everything is fine at the start'
create_status_description.expect_supports_no_macros
@@ -71,28 +75,16 @@ describe 'Projects status administration', type: :feature, js: true do
# Check that the status has been set correctly
visit settings_generic_project_path(Project.last)
- expect(page)
- .to have_select('Status', selected: 'On track')
+ expect(page).to have_selector('[data-field-name="status"] .ng-value', text: 'On track')
edit_status_description.expect_value 'Everything is fine at the start'
- select '', from: 'Status'
- edit_status_description.set_markdown 'Now we do not know'
-
- click_button 'Save'
-
- expect(page)
- .to have_select('Status', selected: '')
-
- edit_status_description.expect_value 'Now we do not know'
-
- select 'Off track', from: 'Status'
+ select_autocomplete page.find('[data-field-name="status"]'), query: 'Off track'
edit_status_description.set_markdown 'Oh no'
click_button 'Save'
- expect(page)
- .to have_select('Status', selected: 'Off track')
+ expect(page).to have_selector('[data-field-name="status"] .ng-value', text: 'Off track')
edit_status_description.expect_value 'Oh no'
end
diff --git a/spec/features/projects/projects_custom_fields_spec.rb b/spec/features/projects/projects_custom_fields_spec.rb
index 86567970e74..cdeb6e94248 100644
--- a/spec/features/projects/projects_custom_fields_spec.rb
+++ b/spec/features/projects/projects_custom_fields_spec.rb
@@ -31,7 +31,7 @@ require 'spec_helper'
describe 'Projects custom fields', type: :feature, js: true do
shared_let(:current_user) { FactoryBot.create(:admin) }
shared_let(:project) { FactoryBot.create(:project, name: 'Foo project', identifier: 'foo-project') }
- let(:identifier) { "project_custom_field_values_#{custom_field.id}" }
+ let(:identifier) { "[data-field-name='customField#{custom_field.id}'] input[type=checkbox]" }
before do
login_as current_user
@@ -41,6 +41,7 @@ describe 'Projects custom fields', type: :feature, js: true do
let!(:custom_field) do
FactoryBot.create(:version_project_custom_field)
end
+ let(:identifier) { "project_custom_field_values_#{custom_field.id}" }
scenario 'allows creating a new project (regression #29099)' do
visit new_project_path
@@ -50,7 +51,7 @@ describe 'Projects custom fields', type: :feature, js: true do
expect(page).to have_selector "##{identifier}"
click_on 'Create'
- expect(page).to have_selector('.flash.notice', text: I18n.t(:notice_successful_create))
+ expect(page).to have_text I18n.t(:notice_successful_create)
end
end
@@ -85,14 +86,16 @@ describe 'Projects custom fields', type: :feature, js: true do
created_project = Project.last
- visit project_settings_project_path(created_project)
+ visit settings_project_path(created_project)
- expect(page)
- .to have_field default_int_custom_field.name, with: default_int_custom_field.default_value.to_s
- expect(page)
- .to have_field default_string_custom_field.name, with: 'Overwritten'
- expect(page)
- .to have_field no_default_string_custom_field.name, with: nil
+ int_field = page.find "[data-field-name='customField#{default_int_custom_field.id}'] input"
+ expect(int_field.value).to eq(default_int_custom_field.default_value.to_s)
+
+ string_field = page.find "[data-field-name='customField#{default_string_custom_field.id}'] input"
+ expect(string_field.value).to eq('Overwritten')
+
+ string_field = page.find "[data-field-name='customField#{no_default_string_custom_field.id}'] input"
+ expect(string_field.value).to eq('')
end
end
@@ -100,7 +103,7 @@ describe 'Projects custom fields', type: :feature, js: true do
let!(:custom_field) do
FactoryBot.create(:text_project_custom_field)
end
- let(:editor) { ::Components::WysiwygEditor.new ".form--field.custom_field_#{custom_field.id}" }
+ let(:editor) { ::Components::WysiwygEditor.new "[data-field-name='customField#{custom_field.id}']" }
scenario 'allows settings the project boolean CF (regression #26313)' do
visit settings_generic_project_path(project.id)
@@ -111,16 +114,18 @@ describe 'Projects custom fields', type: :feature, js: true do
# single hash autocomplete
editor.insert_link 'http://example.org/link with spaces'
+ sleep 2
+
# Save project settings
click_on 'Save'
- expect(page).to have_selector('.flash.notice')
+ expect(page).to have_text I18n.t('js.notice_successful_update')
project.reload
cv = project.custom_values.find_by(custom_field_id: custom_field.id).value
expect(cv).to include '[http://example.org/link with spaces](http://example.org/link%20with%20spaces)'
- expect(page).to have_selector('a[href="http://example.org/link%20with%20spaces"]')
+ expect(page).to have_selector('a[href="http://example.org/link with spaces"]')
end
end
@@ -131,12 +136,17 @@ describe 'Projects custom fields', type: :feature, js: true do
scenario 'allows settings the project boolean CF (regression #26313)' do
visit settings_generic_project_path(project.id)
- expect(page).to have_no_checked_field identifier
- check identifier
+ field = page.find(identifier)
+ expect(field).not_to be_checked
+
+ field.check
click_on 'Save'
- expect(page).to have_selector('.flash.notice', text: I18n.t(:notice_successful_update))
- expect(page).to have_checked_field identifier
+ expect(page).to have_text I18n.t(:notice_successful_update)
+
+ field = page.find(identifier)
+ expect(field).to be_checked
+
end
end
end
diff --git a/spec/features/projects/projects_spec.rb b/spec/features/projects/projects_spec.rb
index 071396399df..1f5ea5f115d 100644
--- a/spec/features/projects/projects_spec.rb
+++ b/spec/features/projects/projects_spec.rb
@@ -28,14 +28,14 @@
require 'spec_helper'
-describe 'Projects', type: :feature do
+describe 'Projects', type: :feature, js: true do
let(:current_user) { FactoryBot.create(:admin) }
before do
allow(User).to receive(:current).and_return current_user
end
- describe 'creation', js: true do
+ describe 'creation' do
shared_let(:project) { FactoryBot.create(:project, name: 'Foo project', identifier: 'foo-project') }
before do
@@ -138,7 +138,7 @@ describe 'Projects', type: :feature do
end
end
- describe 'deletion', js: true do
+ describe 'deletion' do
let(:project) { FactoryBot.create(:project) }
let(:projects_page) { Pages::Projects::Destroy.new(project) }
@@ -167,7 +167,7 @@ describe 'Projects', type: :feature do
end
end
- describe 'identifier edit', js: true do
+ describe 'identifier edit' do
let!(:project) { FactoryBot.create(:project, identifier: 'foo') }
it 'updates the project identifier' do
@@ -185,7 +185,7 @@ describe 'Projects', type: :feature do
click_on 'Update'
expect(page).to have_content 'Successful update.'
- expect(current_path).to eq '/projects/foo-bar/settings/generic'
+ expect(current_path).to match '/projects/foo-bar/settings/generic'
expect(Project.first.identifier).to eq 'foo-bar'
end
@@ -200,7 +200,7 @@ describe 'Projects', type: :feature do
end
end
- describe 'form', js: true do
+ describe 'form' do
let(:project) { FactoryBot.build(:project, name: 'Foo project', identifier: 'foo-project') }
let!(:optional_custom_field) do
FactoryBot.create(:custom_field, name: 'Optional Foo',
@@ -256,20 +256,29 @@ describe 'Projects', type: :feature do
fill_in 'Foo', with: '1234'
click_on 'Save'
- expect(page).to have_selector('#errorExplanation', text: 'Foo is too long (maximum is 2 characters)')
+ expect(page).to have_selector('.op-form-field--errors', text: 'Foo is too long (maximum is 2 characters)')
end
end
end
context 'with a multi-select custom field' do
+ include_context 'ng-select-autocomplete helpers'
+
let(:project) { FactoryBot.create(:project, name: 'Foo project', identifier: 'foo-project') }
let!(:list_custom_field) { FactoryBot.create(:list_project_custom_field, name: 'List CF', multi_value: true) }
it 'can create a project' do
visit settings_generic_project_path(project.id)
- select 'A', from: 'List CF'
- select 'B', from: 'List CF'
+ select = page.find("[data-field-name='customField#{list_custom_field.id}']")
+
+ select.find('.ng-select-container').click
+ select.find('.ng-option', text: 'A').click
+
+ sleep 1
+
+ select.find('.ng-select-container').click
+ select.find('.ng-option', text: 'B').click
sleep 1
@@ -277,7 +286,9 @@ describe 'Projects', type: :feature do
expect(page).to have_content 'Successful update.'
- expect(page).to have_select('List CF', selected: %w[A B])
+ select = page.find("[data-field-name='customField#{list_custom_field.id}']")
+ expect(select).to have_selector('.ng-value', text: 'A')
+ expect(select).to have_selector('.ng-value', text: 'B')
cvs = project.reload.custom_value_for(list_custom_field)
expect(cvs.count).to eq 2
diff --git a/spec/routing/project_settings_routing_spec.rb b/spec/routing/project_settings_routing_spec.rb
index 50671babcd0..c2b82b8db68 100644
--- a/spec/routing/project_settings_routing_spec.rb
+++ b/spec/routing/project_settings_routing_spec.rb
@@ -82,7 +82,7 @@ describe ProjectSettingsController, type: :routing do
describe 'miscellaneous' do
it do
expect(get('/projects/123/settings')).to route_to(
- controller: 'project_settings/generic', action: 'show', id: '123'
+ controller: 'projects', action: 'settings', id: '123'
)
end
end
diff --git a/spec/support/components/ng_select_autocomplete_helpers.rb b/spec/support/components/ng_select_autocomplete_helpers.rb
index 64ec1b93b20..4e97c047b1f 100644
--- a/spec/support/components/ng_select_autocomplete_helpers.rb
+++ b/spec/support/components/ng_select_autocomplete_helpers.rb
@@ -6,7 +6,7 @@ module Components
element.click
# Insert the text to find
within(element) do
- page.find('input').set(query)
+ page.find('input', visible: :all).set(query)
end
sleep(0.5)
diff --git a/spec/support/edit_fields/edit_field.rb b/spec/support/edit_fields/edit_field.rb
index f6353286269..ed5f6b727cf 100644
--- a/spec/support/edit_fields/edit_field.rb
+++ b/spec/support/edit_fields/edit_field.rb
@@ -134,7 +134,7 @@ class EditField
def set_value(content)
scroll_to_element(input_element)
if field_type.end_with?('-autocompleter')
- page.find('.ng-dropdown-panel .ng-option', text: content).click
+ page.find('.ng-dropdown-panel .ng-option', visible: :all, text: content).click
else
# A normal fill_in would cause the focus loss on the input for empty strings.
# Thus the form would be submitted.
@@ -151,9 +151,9 @@ class EditField
if field_type.end_with?('-autocompleter')
if multi
- page.find('.ng-value-label', text: content).sibling('.ng-value-icon').click
+ page.find('.ng-value-label', visible: :all, text: content).sibling('.ng-value-icon').click
else
- page.find('.ng-dropdown-panel .ng-option', text: '-').click
+ page.find('.ng-dropdown-panel .ng-option', visible: :all, text: '-').click
end
else
input_element.set('')