add dmpUser section ui

This commit is contained in:
amentis 2024-02-21 15:18:41 +02:00
parent 38eef575d0
commit cc6359e0fc
4 changed files with 21 additions and 2 deletions

View File

@ -56,6 +56,7 @@ export interface DmpUser extends BaseEntity {
dmp: Dmp; dmp: Dmp;
user: User; user: User;
role: DmpUserRole; role: DmpUserRole;
sectionId: Guid;
} }
export interface DmpDescriptionTemplate extends BaseEntity { export interface DmpDescriptionTemplate extends BaseEntity {
@ -132,6 +133,7 @@ export interface DmpUserPersist {
user: Guid; user: Guid;
role: DmpUserRole; role: DmpUserRole;
email: string; email: string;
sectionId: Guid;
} }
export interface DmpUserRemovePersist { export interface DmpUserRemovePersist {

View File

@ -284,6 +284,18 @@
<mat-error *ngIf="user.get('role').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="user.get('role').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.SECTION' | translate}}</mat-label>
<mat-select [formControl]="user.get('sectionId')">
<mat-option *ngFor="let section of selectedBlueprint.definition.sections" [value]="section.id">
{{ section.label }}
</mat-option>
</mat-select>
<mat-error *ngIf="user.get('sectionId').hasError('backendError')">{{user.get('sectionId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="user.get('sectionId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |translate}}</mat-error>
</mat-form-field>
</div>
</div> </div>
</div> </div>
<div class="col-auto"> <div class="col-auto">

View File

@ -466,6 +466,7 @@ export class DmpUserEditorModel implements DmpUserPersist {
role: DmpUserRole; role: DmpUserRole;
email: string; email: string;
userType: DmpUserType= DmpUserType.Internal; userType: DmpUserType= DmpUserType.Internal;
sectionId: Guid;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -478,6 +479,7 @@ export class DmpUserEditorModel implements DmpUserPersist {
this.role = item.role; this.role = item.role;
// TODO this.email = item.email; // TODO this.email = item.email;
this.userType = (item == null || this.user != null) ? DmpUserType.Internal : DmpUserType.External; this.userType = (item == null || this.user != null) ? DmpUserType.Internal : DmpUserType.External;
this.sectionId = item.sectionId;
return this; return this;
} }
@ -499,6 +501,7 @@ export class DmpUserEditorModel implements DmpUserPersist {
user: [{ value: this.user, disabled: disabled }, context.getValidation('user').validators], user: [{ value: this.user, disabled: disabled }, context.getValidation('user').validators],
role: [{ value: this.role, disabled: disabled }, context.getValidation('role').validators], role: [{ value: this.role, disabled: disabled }, context.getValidation('role').validators],
email: [{ value: this.role, disabled: disabled }, context.getValidation('email').validators], email: [{ value: this.role, disabled: disabled }, context.getValidation('email').validators],
sectionId: [{ value: this.role, disabled: disabled }, context.getValidation('sectionId').validators],
userType: [{ value: this.userType, disabled: disabled }, context.getValidation('userType').validators], userType: [{ value: this.userType, disabled: disabled }, context.getValidation('userType').validators],
}); });
} }
@ -514,6 +517,7 @@ export class DmpUserEditorModel implements DmpUserPersist {
baseValidationArray.push({ key: 'user', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}user`)] }); baseValidationArray.push({ key: 'user', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}user`)] });
baseValidationArray.push({ key: 'role', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}role`)] }); baseValidationArray.push({ key: 'role', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}role`)] });
baseValidationArray.push({ key: 'email', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}email`)] }); baseValidationArray.push({ key: 'email', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}email`)] });
baseValidationArray.push({ key: 'sectionId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sectionId`)] });
baseValidationArray.push({ key: 'userType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}userType`)] }); baseValidationArray.push({ key: 'userType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}userType`)] });
baseContext.validation = baseValidationArray; baseContext.validation = baseValidationArray;
@ -532,7 +536,7 @@ export class DmpUserEditorModel implements DmpUserPersist {
validationErrorModel validationErrorModel
}); });
['user', 'role', 'email'].forEach(keyField => { ['user', 'role', 'email', 'sectionId'].forEach(keyField => {
const control = formGroup?.get(keyField); const control = formGroup?.get(keyField);
control?.clearValidators(); control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators); control?.addValidators(context.getValidation(keyField).validators);

View File

@ -1746,7 +1746,8 @@
"FIRST-NAME": "First Name", "FIRST-NAME": "First Name",
"LAST-NAME": "Last Name", "LAST-NAME": "Last Name",
"EMAIL": "Email", "EMAIL": "Email",
"USER-ROLE": "Role" "USER-ROLE": "Role",
"SECTION": "Specific DMP Section"
}, },
"ACTIONS1": { "ACTIONS1": {
"GO-TO-GRANT": "Go To DMP Grant", "GO-TO-GRANT": "Go To DMP Grant",