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

Working on fixing dynamic form styles, removed a lot of classes (#9246)

Benjamin Bädorf278ca09ea939
diff --git a/frontend/npm-shrinkwrap.json b/frontend/npm-shrinkwrap.json
index 75d005c32ec..6a65a54aa06 100644
--- a/frontend/npm-shrinkwrap.json
+++ b/frontend/npm-shrinkwrap.json
@@ -21787,11 +21787,18 @@
}
},
"@ngx-formly/core": {
- "version": "6.0.0-next.1",
- "resolved": "https://registry.npmjs.org/@ngx-formly/core/-/core-6.0.0-next.1.tgz",
- "integrity": "sha512-YMmLNJyi3UZn1PyvmsF0gKe9t8ihHdhvLyHQn7oxdd96551beVZmylxnlazKV4+5To/SolZSbup3QcmcOj6z8g==",
+ "version": "5.10.19",
+ "resolved": "https://registry.npmjs.org/@ngx-formly/core/-/core-5.10.19.tgz",
+ "integrity": "sha512-vPUBMCGXfOov6h1WC8Yw3pIkOjxHixCmI4v+UJVOk0ThFg9XwAplG0TyE2Gkjp5KBNu4VVPxT6II6meSf0ivXQ==",
"requires": {
- "tslib": "^2.0.0"
+ "tslib": "^1.7.1"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
+ }
}
},
"@nodelib/fs.scandir": {
diff --git a/frontend/package.json b/frontend/package.json
index 98638198b32..2d1c0d0e410 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -51,7 +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",
+ "@ngx-formly/core": "^5.10.19",
"@sentry/angular": "^6.2.3",
"@sentry/tracing": "^6.2.3",
"@types/chart.js": "^2.9.20",
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.html b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.html
index 045f5057ba3..22be0abdc51 100644
--- a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.html
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-field-wrapper/dynamic-field-wrapper.component.html
@@ -1,13 +1,16 @@
-<op-form-field [label]="to?.label"
- [noWrapLabel]="to?.noWrapLabel"
- [required]="to?.required"
- [helpTextAttribute]="to?.property"
- [helpTextAttributeScope]="to?.helpTextAttributeScope"
- [attr.data-qa-field-name]="to?.property">
+<op-form-field
+ [label]="to?.label"
+ [noWrapLabel]="to?.noWrapLabel"
+ [required]="to?.required"
+ [helpTextAttribute]="to?.property"
+ [helpTextAttributeScope]="to?.helpTextAttributeScope"
+ [attr.data-qa-field-name]="to?.property"
+ [ngClass]="{ 'op-form-field_checkbox': field.type === 'booleanInput' }"
+>
<ng-container #fieldComponent slot="input"></ng-container>
-
- <formly-validation-message class="op-form-field--error"
- [field]="field"
- slot="errors">
- </formly-validation-message>
+ <formly-validation-message
+ class="op-form-field--error"
+ [field]="field"
+ slot="errors"
+ ></formly-validation-message>
</op-form-field>
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
index 2cf0de65c91..4642a4fb8c5 100644
--- 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
@@ -1,39 +1,37 @@
-<div data-qa="op-form--container"
- *ngIf="form && handleSubmit">
- <form [formGroup]="form"
- (submit)="submitForm(form)"
- class="op-form">
- <formly-form [form]="form"
- [model]="innerModel"
- [fields]="fields"
- (modelChange)="onModelChange($event)"
- class="op-fieldset">
- </formly-form>
+<form
+ *ngIf="form && handleSubmit"
+ data-qa="op-form--container"
+ class="op-form"
+ [formGroup]="form"
+ (submit)="submitForm(form)"
+>
+ <formly-form
+ [form]="form"
+ [model]="innerModel"
+ [fields]="fields"
+ (modelChange)="onModelChange($event)"
+ class="op-form--fieldset"
+ ></formly-form>
- <div class="op-form--submit"
- *ngIf="handleSubmit">
- <button type="submit"
- class="button -highlight"
- [disabled]="inFlight">
- {{text.save}}
- </button>
- </div>
- </form>
-</div>
+ <div class="op-form--submit"
+ *ngIf="handleSubmit">
+ <button type="submit"
+ class="button -highlight"
+ [disabled]="inFlight">
+ {{text.save}}
+ </button>
+ </div>
+</form>
<!-- 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 doesn't find the injected FormGroupDirective. --->
-<div data-qa="op-form--container"
- *ngIf="form && !handleSubmit">
- <formly-form [form]="form"
- [model]="innerModel"
- [fields]="fields"
- (modelChange)="onModelChange($event)"
- class="op-fieldset">
- </formly-form>
-</div>
-
-
-
-
+<formly-form
+ data-qa="op-form--container"
+ class="op-form--fieldset"
+ *ngIf="form && !handleSubmit"
+ [form]="form"
+ [model]="innerModel"
+ [fields]="fields"
+ (modelChange)="onModelChange($event)"
+></formly-form>
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.spec.ts
index 0882660b507..a91085db18a 100644
--- a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.spec.ts
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.spec.ts
@@ -98,7 +98,6 @@ describe('DynamicFormComponent', () => {
fields: [
{
"type": "textInput",
- "className": "op-form--field inline-edit--field",
"key": "name",
"templateOptions": {
"required": true,
@@ -110,7 +109,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "integerInput",
- "className": "op-form--field inline-edit--field",
"key": "quantity",
"templateOptions": {
"required": true,
@@ -122,7 +120,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "textInput",
- "className": "op-form--field inline-edit--field",
"key": "identifier",
"templateOptions": {
"required": true,
@@ -134,7 +131,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "formattableInput",
- "className": "op-form--field textarea-wrapper",
"key": "description",
"templateOptions": {
"required": false,
@@ -147,7 +143,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "booleanInput",
- "className": "op-form--field inline-edit--field inline-edit--boolean-field",
"key": "public",
"templateOptions": {
"required": true,
@@ -159,7 +154,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "booleanInput",
- "className": "op-form--field inline-edit--field inline-edit--boolean-field",
"key": "active",
"templateOptions": {
"required": true,
@@ -171,7 +165,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "selectInput",
- "className": "op-form--field inline-edit--field Status",
"expressionProperties": {},
"key": "status",
"templateOptions": {
@@ -197,7 +190,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "formattableInput",
- "className": "op-form--field textarea-wrapper",
"key": "statusExplanation",
"templateOptions": {
"required": false,
@@ -210,7 +202,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "selectInput",
- "className": "op-form--field inline-edit--field Subproject of",
"expressionProperties": {},
"key": "_links.parent",
"templateOptions": {
@@ -233,7 +224,6 @@ describe('DynamicFormComponent', () => {
},
{
"type": "dateInput",
- "className": "op-form--field inline-edit--field",
"key": "customField12",
"templateOptions": {
"required": false,
@@ -372,7 +362,7 @@ describe('DynamicFormComponent', () => {
expect(fixture.debugElement.query(By.css('[data-qa="op-form--container"]'))).toBeTruthy();
expect(fixture.debugElement.queryAll(By.css('formly-form')).length).toEqual(1);
- expect(fixture.debugElement.queryAll(By.css('formly-field')).length).toEqual(11);
+ expect(fixture.debugElement.queryAll(By.css('formly-field')).length).toEqual(10);
expect(fixture.debugElement.queryAll(By.css('op-text-input')).length).toEqual(2);
expect(fixture.debugElement.queryAll(By.css('op-formattable-textarea-input')).length).toEqual(2);
expect(fixture.debugElement.queryAll(By.css('op-select-input')).length).toEqual(2);
@@ -400,7 +390,7 @@ describe('DynamicFormComponent', () => {
expect(fixture.debugElement.query(By.css('[data-qa="op-form--container"]'))).toBeTruthy();
expect(fixture.debugElement.queryAll(By.css('formly-form')).length).toEqual(1);
- expect(fixture.debugElement.queryAll(By.css('formly-field')).length).toEqual(11);
+ expect(fixture.debugElement.queryAll(By.css('formly-field')).length).toEqual(10);
expect(fixture.debugElement.queryAll(By.css('op-text-input')).length).toEqual(2);
expect(fixture.debugElement.queryAll(By.css('op-formattable-textarea-input')).length).toEqual(2);
expect(fixture.debugElement.queryAll(By.css('op-select-input')).length).toEqual(2);
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
index 5b57c7ecffa..233098b561d 100644
--- 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
@@ -9,7 +9,6 @@ describe('BooleanInputComponent', () => {
const fieldsConfig = [
{
"type": "booleanInput" as "booleanInput",
- "className": "op-form--field inline-edit--field",
"key": "testControl",
"templateOptions": {
"required": true,
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.spec.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.spec.ts
index 3febf58e4c1..e0c3a6a4e17 100644
--- a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.spec.ts
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/formattable-textarea-input.component.spec.ts
@@ -11,7 +11,6 @@ describe('FormattableTextareaInputComponent', () => {
const fieldsConfig = [
{
"type": "formattableInput" as "formattableInput",
- "className": "op-form--field inline-edit--field",
"key": "testControl",
"templateOptions": {
"required": true,
@@ -43,7 +42,7 @@ describe('FormattableTextareaInputComponent', () => {
// Test ControlValueAccessor
// Write Value
- expect(dynamicControl.value).toEqual(testModel.initialValue);
+ expect(dynamicControl.value.testControl).toEqual(testModel.initialValue);
expect(dynamicElement.classList.contains('ng-untouched')).toBeTrue();
expect(dynamicElement.classList.contains('ng-valid')).toBeTrue();
expect(dynamicElement.classList.contains('ng-pristine')).toBeTrue();
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
index f1228666611..d01f864a78d 100644
--- 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
@@ -9,7 +9,6 @@ describe('IntegerInputComponent', () => {
const fieldsConfig = [
{
"type": "integerInput" as "integerInput",
- "className": "op-form--field inline-edit--field",
"key": "testControl",
"templateOptions": {
"required": true,
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
index 3e8ce2d812b..99a1b10dc98 100644
--- 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
@@ -20,7 +20,6 @@ describe('SelectInputComponent', () => {
const fieldsConfig = [
{
"type": "selectInput" as "selectInput",
- "className": "op-form--field inline-edit--field",
"key": "testControl",
"templateOptions": {
"required": true,
@@ -47,10 +46,9 @@ describe('SelectInputComponent', () => {
const dynamicDebugElement = fixture.debugElement.query(By.css('ng-select'));
const dynamicElement = dynamicDebugElement.nativeElement;
-
// Test ControlValueAccessor
// Write Value
- expect(dynamicControl.value).toBe(testModel.initialValue);
+ expect(dynamicControl.value.testControl).toBe(testModel.initialValue);
expect(dynamicElement.classList.contains('ng-untouched')).toBeTrue();
expect(dynamicElement.classList.contains('ng-valid')).toBeTrue();
expect(dynamicElement.classList.contains('ng-pristine')).toBeTrue();
@@ -76,7 +74,7 @@ describe('SelectInputComponent', () => {
fixture.detectChanges();
flush();
- expect(dynamicControl.value).toBe(testModel.changedValue);
+ expect(dynamicControl.value.testControl).toBe(testModel.changedValue);
expect(dynamicElement.classList.contains('ng-dirty')).toBeTrue();
// Blur
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
index 6e7d6a3beb1..807c1a1d65b 100644
--- 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
@@ -9,7 +9,6 @@ describe('TextComponent', () => {
const fieldsConfig = [
{
"type": "textInput" as "textInput",
- "className": "op-form--field inline-edit--field",
"key": "testControl",
"templateOptions": {
"required": true,
diff --git a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts
index 65c52bb4589..ab61f9b1734 100644
--- a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts
+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts
@@ -200,18 +200,13 @@ describe('DynamicFieldsService', () => {
return formlyField.fieldGroup ? [...result, ...formlyField.fieldGroup] : [...result, formlyField];
}, []);
const formGroup = formlyConfig[1];
- const everyFieldHasCSSClass = formlyFields.every(formlyField => formlyField.className!.startsWith('op-form--field'));
- expect(everyFieldHasCSSClass).toBeTruthy('should place the op-form--field class on every field');
- expect(formlyFields[1].templateOptions!.required).toBe(true, 'should set the required attribute');
expect(formlyFields[1].templateOptions!.label).toBe('Name', 'should set the correct label');
expect(isObservable(formlyFields[0].templateOptions!.options)).toBeTruthy('should add options as observables');
expect(formlyFields[0].className).toContain('Subproject of', 'should add the specific input type properties');
expect(formlyFields[0].templateOptions!.locale).toBeTruthy('should add the specific input templateOptions');
expect(formGroup).toBeTruthy();
- expect(formGroup.wrappers![0]).toEqual('op-dynamic-field-group-wrapper', 'should add the form field group wrapper');
- expect(formGroup.fieldGroupClassName).toEqual('op-form-group', 'should add the CSS class to the field group wrapper');
expect(formGroup.templateOptions!.label).toEqual('People', 'should add the correct label to the field group wrapper');
expect(formGroup.fieldGroup![0].key).toEqual('name', 'should add the correct key to the field group wrapper');
});
diff --git a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
index e41533682d2..53ae9d1a459 100644
--- a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
@@ -15,7 +15,6 @@ export class DynamicFieldsService {
{
config: {
type: 'textInput',
- className: 'inline-edit--field',
templateOptions: {
type: 'text',
},
@@ -25,7 +24,6 @@ export class DynamicFieldsService {
{
config: {
type: 'textInput',
- className: 'inline-edit--field',
templateOptions: {
type: 'password',
},
@@ -35,7 +33,6 @@ export class DynamicFieldsService {
{
config: {
type: 'integerInput',
- className: `inline-edit--field`,
templateOptions: {
type: 'number',
locale: I18n.locale,
@@ -46,7 +43,6 @@ export class DynamicFieldsService {
{
config: {
type: 'booleanInput',
- className: `inline-edit--field inline-edit--boolean-field`,
templateOptions: {
type: 'checkbox',
},
@@ -56,7 +52,6 @@ export class DynamicFieldsService {
{
config: {
type: 'dateInput',
- className: `inline-edit--field`,
},
useForFields: ['Date', 'DateTime']
},
@@ -74,7 +69,6 @@ export class DynamicFieldsService {
{
config: {
type: 'selectInput',
- className: `inline-edit--field`,
templateOptions: {
type: 'number',
locale: I18n.locale,
@@ -100,7 +94,6 @@ export class DynamicFieldsService {
{
config: {
type: 'selectProjectStatusInput',
- className: `inline-edit--field`,
templateOptions: {
type: 'number',
locale: I18n.locale,
@@ -210,8 +203,8 @@ export class DynamicFieldsService {
const formlyFieldConfig = {
...fieldTypeConfig,
key,
- className: `op-form--field ${fieldTypeConfig.className}`,
- wrappers: [`op-dynamic-field-wrapper`],
+ wrappers: ['op-dynamic-field-wrapper'],
+ className: `op-form--field ${fieldTypeConfig?.className || ''}`,
templateOptions: {
property,
required,
@@ -240,9 +233,9 @@ export class DynamicFieldsService {
let inputConfig = inputType.config;
let configCustomizations;
- if (inputConfig.type === 'integerInput' || inputConfig.type === 'selectInput') {
+ if (inputConfig.type === 'integerInput' || inputConfig.type === 'selectInput' || inputConfig.type === 'selectProjectStatusInput') {
configCustomizations = {
- className: `${inputConfig.className} ${field.name}`,
+ className: field.name,
...field.type.startsWith('[]') && {
templateOptions: {
...inputConfig.templateOptions,
@@ -301,17 +294,17 @@ export class DynamicFieldsService {
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);
+ const formFieldsWithoutGroup = formFields
+ .filter(formField => {
+ const formFieldKey = formField.key && this.getFieldProperty(formField.key);
+
+ return formFieldKey ?
+ !fieldGroupKeys.includes(formFieldKey) :
+ true;
+ });
- return formFieldKey ?
- !fieldGroupKeys.includes(formFieldKey) :
- true;
- });
const formFieldGroups = fieldGroups.reduce((formWithFieldGroups:IOPFormlyFieldSettings[], fieldGroup) => {
const newFormFieldGroup = {
- wrappers: ['op-dynamic-field-group-wrapper'],
- fieldGroupClassName: 'op-form-group',
templateOptions: {
label: fieldGroup.name,
isFieldGroup: true,
@@ -353,6 +346,6 @@ export class DynamicFieldsService {
return formWithFieldGroups;
}, []);
- return [...fomFieldsWithoutGroup, ...formFieldGroups];
+ return [...formFieldsWithoutGroup, ...formFieldGroups];
}
}
diff --git a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts
index 457b91bf53a..3814055ae52 100644
--- a/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts
+++ b/frontend/src/app/modules/common/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts
@@ -74,7 +74,6 @@ describe('DynamicFormService', () => {
"fields": [
{
"type": "textInput",
- "className": "op-form--field inline-edit--field",
"key": "name",
"templateOptions": {
"required": true,
@@ -84,7 +83,6 @@ describe('DynamicFormService', () => {
},
{
"type": "selectInput",
- "className": "op-form--field inline-edit--field Subproject of",
"expressionProperties": {},
"key": "_links.parent",
"templateOptions": {
diff --git a/frontend/src/app/modules/common/dynamic-forms/spec/helpers.ts b/frontend/src/app/modules/common/dynamic-forms/spec/helpers.ts
index 0956a01aa32..f889b766df7 100644
--- a/frontend/src/app/modules/common/dynamic-forms/spec/helpers.ts
+++ b/frontend/src/app/modules/common/dynamic-forms/spec/helpers.ts
@@ -14,7 +14,7 @@ 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 { FormlyForm } 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";
@@ -30,16 +30,6 @@ export function createDynamicInputFixture(fields: IOPFormlyFieldSettings[], mode
<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>
`,
@@ -50,7 +40,7 @@ export function createDynamicInputFixture(fields: IOPFormlyFieldSettings[], mode
model = model;
fields = fields;
- @ViewChild(FormlyField) dynamicControl:FormlyField;
+ @ViewChild(FormlyForm) dynamicControl:FormlyForm;
}
const notificationsServiceSpy = jasmine.createSpyObj('NotificationsService', ['addError', 'addSuccess']);
@@ -125,12 +115,12 @@ export function createDynamicInputFixture(fields: IOPFormlyFieldSettings[], mode
}
export function testDynamicInputControValueAccessor(fixture:ComponentFixture<any>, model:any, selector:string) {
- const dynamicControl = fixture.componentInstance.dynamicControl.field.formControl;
+ const dynamicControl: FormGroup = fixture.componentInstance.dynamicControl.form;
const dynamicInput = fixture.debugElement.query(By.css(selector)).nativeElement;
// Test ControlValueAccessor
// Write Value
- expect(dynamicControl.value).toBe(model.initialValue);
+ expect(dynamicControl.value.testControl).toBe(model.initialValue);
expect(dynamicInput.classList.contains('ng-untouched')).toBeTrue();
expect(dynamicInput.classList.contains('ng-valid')).toBeTrue();
expect(dynamicInput.classList.contains('ng-pristine')).toBeTrue();
@@ -145,7 +135,7 @@ export function testDynamicInputControValueAccessor(fixture:ComponentFixture<any
fixture.detectChanges();
- expect(dynamicControl.value).toBe(model.changedValue);
+ expect(dynamicControl.value.testControl).toBe(model.changedValue);
expect(dynamicInput.classList.contains('ng-dirty')).toBeTrue();
// Blur
diff --git a/frontend/src/app/modules/common/forms/fieldset.sass b/frontend/src/app/modules/common/forms/fieldset.sass
deleted file mode 100644
index b2ef9cd0a65..00000000000
--- a/frontend/src/app/modules/common/forms/fieldset.sass
+++ /dev/null
@@ -1,3 +0,0 @@
-.op-fieldset
- display: flex
- flex-direction: column
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
index 35c42b679dd..f02dc85ccf2 100644
--- a/frontend/src/app/modules/common/forms/form-field/form-field.component.html
+++ b/frontend/src/app/modules/common/forms/form-field/form-field.component.html
@@ -18,6 +18,10 @@
<ng-container *ngTemplateOutlet="inputTemplate"></ng-container>
</ng-container>
+ <div class="op-form-field--help-text">
+ <ng-content select="[slot=help-text]"></ng-content>
+ </div>
+
<div class="op-form-field--errors"
*ngIf="showErrorMessage">
<ng-content select="[slot=errors]"></ng-content>
@@ -32,8 +36,4 @@
<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>
diff --git a/frontend/src/app/modules/common/forms/form-field/form-field.sass b/frontend/src/app/modules/common/forms/form-field/form-field.sass
index f8dee2fe1e7..e106d186bfa 100644
--- a/frontend/src/app/modules/common/forms/form-field/form-field.sass
+++ b/frontend/src/app/modules/common/forms/form-field/form-field.sass
@@ -48,3 +48,19 @@
&--errors
&:empty
display: none
+
+ // Checkbox mode
+ $off: &
+ &_checkbox
+ #{$off}--label-wrap
+ flex-direction: row
+ flex-wrap: wrap
+
+ #{$off}--input
+ order: 1
+ margin-right: 1rem
+ #{$off}--label
+ order: 2
+ #{$off}--description
+ order: 3
+
diff --git a/frontend/src/app/modules/common/forms/form.sass b/frontend/src/app/modules/common/forms/form.sass
index bf2ad2b787c..ecaed217748 100644
--- a/frontend/src/app/modules/common/forms/form.sass
+++ b/frontend/src/app/modules/common/forms/form.sass
@@ -1,34 +1,23 @@
.op-form
- display: flex
- flex-direction: column
- align-items: flex-start
-
&--submit
margin: 1.5rem 0
display: flex
- > *
- max-width: 100%
- width: 50rem
+ &,
+ &--fieldset
+ display: flex
+ flex-direction: column
+ align-items: flex-start
+
+ > *
+ 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-form-field + .op-highlighted-input,
- .op-fieldset + .op-form-field,
- .op-fieldset + .op-fieldset,
- .op-fieldset + .button,
- .op-fieldset + .op-highlighted-input,
- .op-highlighted-input + .op-form-field,
- .op-highlighted-input + .op-fieldset,
- .op-highlighted-input + .op-button,
- .op-highlighted-input + .op-highlighted-input,
- .button + .op-form-field,
- .button + .op-fieldset,
- .button + .button,
- .button + .op-highlighted-input
- margin-top: 1.5rem
-
+ > .op-form--fieldset,
+ > .op-form--field,
+ > .op-form-field,
+ > .op-option-list,
+ > .op-highlighted-input,
+ > .button
+ &:not(:last-child)
+ margin-bottom: 1rem
diff --git a/frontend/src/app/modules/common/forms/index.sass b/frontend/src/app/modules/common/forms/index.sass
index f67b666db2d..3cbe43cf5ac 100644
--- a/frontend/src/app/modules/common/forms/index.sass
+++ b/frontend/src/app/modules/common/forms/index.sass
@@ -1,4 +1,3 @@
@import './form-field/form-field'
@import './form'
-@import './fieldset'
@import './highlighted-input'
diff --git a/frontend/src/app/modules/invite-user-modal/principal/principal-search.component.ts b/frontend/src/app/modules/invite-user-modal/principal/principal-search.component.ts
index e5f695d3c92..35fb94ca5f1 100644
--- a/frontend/src/app/modules/invite-user-modal/principal/principal-search.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/principal/principal-search.component.ts
@@ -119,6 +119,7 @@ export class PrincipalSearchComponent extends UntilDestroyedMixin implements OnI
public createNewFromInput() {
this.createNew.emit({ name: this.input });
}
+
private loadPrincipalData(searchTerm:string) {
const nonMemberFilter = new ApiV3FilterBuilder();
if (searchTerm) {
diff --git a/frontend/src/app/modules/projects/form-helpers/form-attribute-groups.ts b/frontend/src/app/modules/projects/form-helpers/form-attribute-groups.ts
index 164a7c9a802..22913bdffe2 100644
--- a/frontend/src/app/modules/projects/form-helpers/form-attribute-groups.ts
+++ b/frontend/src/app/modules/projects/form-helpers/form-attribute-groups.ts
@@ -14,7 +14,7 @@ export namespace ProjectFormAttributeGroups {
):IOPFormlyFieldSettings {
return {
fieldGroup: fields,
- fieldGroupClassName: "op-form--field-group",
+ fieldGroupClassName: "op-form--fieldset",
templateOptions: {
label: label,
isFieldGroup: true,