dmp user field filter sections changes

This commit is contained in:
amentis 2024-05-21 11:22:33 +03:00
parent 6facf9f7d4
commit 91556cb6b6
3 changed files with 11 additions and 3 deletions

View File

@ -113,6 +113,7 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
// // rootPath: `descriptionTemplates[${index}].` // // rootPath: `descriptionTemplates[${index}].`
// })), //context.getValidation('descriptionTemplates') // })), //context.getValidation('descriptionTemplates')
// )) // ))
if (disabled) descriptionTemplatesFormGroup.disable();
formGroup.addControl('descriptionTemplates', descriptionTemplatesFormGroup); formGroup.addControl('descriptionTemplates', descriptionTemplatesFormGroup);
return formGroup; return formGroup;

View File

@ -67,15 +67,21 @@
<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-12 col-xl mt-3" *ngIf="sections && (user.get('role').value == dmpUserRoleEnum.DescriptionContributor || user.get('role').value == dmpUserRoleEnum.Reviewer)"> <div class="col-12 col-xl mt-3" *ngIf="sections || hasTemplatesSections">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.SECTIONS' | translate}}</mat-label> <mat-label>{{'DMP-EDITOR.FIELDS.SECTIONS' | translate}}</mat-label>
<mat-select [formControl]="user.get('sectionId')"> <mat-select *ngIf="user.get('role').value != dmpUserRoleEnum.DescriptionContributor && sections" [formControl]="user.get('sectionId')">
<mat-option value="">{{'DMP-EDITOR.FIELDS.ALL-SECTIONS' | translate}}</mat-option> <mat-option value="">{{'DMP-EDITOR.FIELDS.ALL-SECTIONS' | translate}}</mat-option>
<mat-option *ngFor="let section of sections" [value]="section.id"> <mat-option *ngFor="let section of sections" [value]="section.id">
{{ section.label }} {{ section.label }}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-select *ngIf="user.get('role').value === dmpUserRoleEnum.DescriptionContributor && hasTemplatesSections" [formControl]="user.get('sectionId')">
<mat-option value="">{{'DMP-EDITOR.FIELDS.ALL-SECTIONS' | translate}}</mat-option>
<mat-option *ngFor="let section of hasTemplatesSections" [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('backendError')">{{user.get('sectionId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="user.get('sectionId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |translate}}</mat-error> <mat-error *ngIf="user.get('sectionId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |translate}}</mat-error>
</mat-form-field> </mat-form-field>

View File

@ -28,6 +28,7 @@ export class DmpUserFieldComponent extends BaseComponent implements OnInit {
@Input() enableSorting: boolean = true; @Input() enableSorting: boolean = true;
hoveredUser:number = -1; hoveredUser:number = -1;
hasTemplatesSections: DmpBlueprintDefinitionSection[] = null;
dmpUserTypeEnum = DmpUserType; dmpUserTypeEnum = DmpUserType;
dmpUserTypeEnumValues = this.enumUtils.getEnumValues<DmpUserType>(DmpUserType); dmpUserTypeEnumValues = this.enumUtils.getEnumValues<DmpUserType>(DmpUserType);
@ -43,7 +44,7 @@ export class DmpUserFieldComponent extends BaseComponent implements OnInit {
) { super(); } ) { super(); }
ngOnInit() { ngOnInit() {
this.sections = this.sections?.filter(x => x.hasTemplates) || null; this.hasTemplatesSections = this.sections?.filter(x => x.hasTemplates) || null;
console.log('sorting mode: ', this.enableSorting); console.log('sorting mode: ', this.enableSorting);
if(this.initializeUsers) { if(this.initializeUsers) {
this.addUser(); this.addUser();