diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml index 5316684176..6932cb9450 100644 --- a/config/locales/js-en.yml +++ b/config/locales/js-en.yml @@ -417,6 +417,7 @@ en: label_in_more_than: "in more than" label_incoming_emails: "Incoming emails" label_information_plural: "Information" + label_invalid: "Invalid" label_import: "Import" label_latest_activity: "Latest activity" label_last_updated_on: "Last updated on" diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts index 6a346080ff..22907972e8 100644 --- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts +++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts @@ -21,6 +21,7 @@ import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destr import { ConfirmDialogService } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.service'; import { IDynamicFieldGroupConfig, IOPDynamicFormSettings, IOPFormlyFieldSettings } from '../../typings'; import { DynamicFormService } from '../../services/dynamic-form/dynamic-form.service'; +import idFromLink from 'core-app/features/hal/helpers/id-from-link'; /** * SETTINGS: @@ -379,6 +380,9 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang fields = this.dynamicFieldsService.getFormlyFormWithFieldGroups(this.fieldGroups, fields); } + const id = this.resourceId || idFromLink(this.resourcePath || null); + model.id = id; + this.fields = fields; this.innerModel = model; this.form = this.dynamicFormGroup || form; diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts index 4830156255..86594e6158 100644 --- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts +++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/project-input/project-input.component.ts @@ -1,16 +1,13 @@ -import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, +} from '@angular/core'; import { FieldType } from '@ngx-formly/core'; -import idFromLink from 'core-app/features/hal/helpers/id-from-link'; @Component({ selector: 'op-project-input', templateUrl: './project-input.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class ProjectInputComponent extends FieldType implements OnInit { - projectId:string|undefined; - - public ngOnInit():void { - this.projectId = idFromLink(this.model?.project?.href); - } +export class ProjectInputComponent extends FieldType { } diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.html b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.html index a1dc144f50..eed0cf914f 100644 --- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.html +++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.html @@ -21,11 +21,4 @@
{{ item.name }}
- - - - - \ No newline at end of file + diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.ts index 1c8afa4ba8..06561eb5c3 100644 --- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.ts +++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/select-input/select-input.component.ts @@ -7,12 +7,5 @@ import idFromLink from 'core-app/features/hal/helpers/id-from-link'; templateUrl: './select-input.component.html', styleUrls: ['./select-input.component.scss'], }) -export class SelectInputComponent extends FieldType implements OnInit { - projectId:string|undefined; - - public ngOnInit():void { - if (this.model?.project) { - this.projectId = idFromLink(this.model.project?.href); - } - } +export class SelectInputComponent extends FieldType { } diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/user-input/user-input.component.html b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/user-input/user-input.component.html new file mode 100644 index 0000000000..f75f435d38 --- /dev/null +++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/user-input/user-input.component.html @@ -0,0 +1,9 @@ + + diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/user-input/user-input.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/user-input/user-input.component.ts new file mode 100644 index 0000000000..94e1941d07 --- /dev/null +++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/user-input/user-input.component.ts @@ -0,0 +1,19 @@ +import { + ChangeDetectionStrategy, + Component, + OnInit, +} from '@angular/core'; +import { FieldType } from '@ngx-formly/core'; + +@Component({ + selector: 'op-user-input', + templateUrl: './user-input.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class UserInputComponent extends FieldType implements OnInit { + projectId:string|undefined; + + public ngOnInit():void { + this.projectId = this.model?.id; + } +} diff --git a/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts b/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts index f44106fc60..a2a424226d 100644 --- a/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts +++ b/frontend/src/app/shared/components/dynamic-forms/dynamic-forms.module.ts @@ -20,6 +20,7 @@ import { DateInputComponent } from 'core-app/shared/components/dynamic-forms/com import { DynamicFieldGroupWrapperComponent } from 'core-app/shared/components/dynamic-forms/components/dynamic-field-group-wrapper/dynamic-field-group-wrapper.component'; import { FormattableControlModule } from 'core-app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.module'; import { OPSharedModule } from 'core-app/shared/shared.module'; +import { UserInputComponent } from 'core-app/shared/components/dynamic-forms/components/dynamic-inputs/user-input/user-input.component'; @NgModule({ imports: [ @@ -35,6 +36,7 @@ import { OPSharedModule } from 'core-app/shared/shared.module'; { name: 'projectInput', component: ProjectInputComponent }, { name: 'selectProjectStatusInput', component: SelectProjectStatusInputComponent }, { name: 'formattableInput', component: FormattableTextareaInputComponent }, + { name: 'userInput', component: UserInputComponent }, ], wrappers: [ { @@ -70,6 +72,7 @@ import { OPSharedModule } from 'core-app/shared/shared.module'; SelectProjectStatusInputComponent, DateInputComponent, FormattableTextareaInputComponent, + UserInputComponent, ], exports: [ DynamicFormComponent, diff --git a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts index 23558ba482..8ae7766711 100644 --- a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts +++ b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts @@ -57,6 +57,12 @@ export class DynamicFieldsService { }, useForFields: ['Date', 'DateTime'], }, + { + config: { + type: 'userInput', + }, + useForFields: ['User'], + }, { config: { type: 'formattableInput', @@ -89,7 +95,7 @@ export class DynamicFieldsService { }, }, useForFields: [ - 'Priority', 'Status', 'Type', 'User', 'Version', 'TimeEntriesActivity', + 'Priority', 'Status', 'Type', 'Version', 'TimeEntriesActivity', 'Category', 'CustomOption', ], }, @@ -236,13 +242,17 @@ export class DynamicFieldsService { const inputConfig = inputType.config; let configCustomizations; - if (inputConfig.type === 'integerInput' || inputConfig.type === 'selectInput' || inputConfig.type === 'selectProjectStatusInput') { + if ( + inputConfig.type === 'integerInput' + || inputConfig.type === 'selectInput' + || inputConfig.type === 'selectProjectStatusInput' + || inputConfig.type === 'userInput' + ) { configCustomizations = { className: field.name, templateOptions: { ...inputConfig.templateOptions, ...(this.isMultiSelectField(field) && { multiple: true }), - ...(fieldType === 'User' && { showAddNewUserButton: true }), }, }; } else if (inputConfig.type === 'formattableInput') { diff --git a/frontend/src/app/shared/components/dynamic-forms/typings.d.ts b/frontend/src/app/shared/components/dynamic-forms/typings.d.ts index 987e01762b..e499e2f1c6 100644 --- a/frontend/src/app/shared/components/dynamic-forms/typings.d.ts +++ b/frontend/src/app/shared/components/dynamic-forms/typings.d.ts @@ -25,11 +25,10 @@ export interface IOPFormlyTemplateOptions extends FormlyTemplateOptions { collapsibleFieldGroupsCollapsed?:boolean; helpTextAttributeScope?:string; showValidationErrorOn?:'change' | 'blur' | 'submit' | 'never'; - showAddNewUserButton?:boolean; } type OPInputType = 'formattableInput'|'selectInput'|'textInput'|'integerInput'| -'booleanInput'|'dateInput'|'formly-group'|'projectInput'|'selectProjectStatusInput'; +'booleanInput'|'dateInput'|'formly-group'|'projectInput'|'selectProjectStatusInput'|'userInput'; export interface IOPDynamicInputTypeSettings { config:IOPFormlyFieldSettings, diff --git a/frontend/src/app/shared/components/forms/form-field/form-field.component.html b/frontend/src/app/shared/components/forms/form-field/form-field.component.html index 7126dc90ea..eb10206571 100644 --- a/frontend/src/app/shared/components/forms/form-field/form-field.component.html +++ b/frontend/src/app/shared/components/forms/form-field/form-field.component.html @@ -3,10 +3,14 @@
+ class="hidden-for-sighted" + > + {{ text.invalid }} + {{ label }} + * +