Add language column on the DMP quick wizard Editor (ref #273)

This commit is contained in:
George Kalampokis 2020-06-18 15:55:15 +03:00
parent ac43dc8bd9
commit a4e21003c8
5 changed files with 40 additions and 5 deletions

View File

@ -6,10 +6,7 @@ import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.userinfo.UserListingModel;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.*;
public class DmpQuickWizardModel {
@ -19,6 +16,7 @@ public class DmpQuickWizardModel {
private AssociatedProfile datasetProfile;
private String description;
private eu.eudat.models.data.grant.Grant grant;
private String language;
public UUID getId() {
@ -65,6 +63,14 @@ public class DmpQuickWizardModel {
this.grant = grant;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Grant grant, Project project, Principal principal) {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
@ -93,6 +99,8 @@ public class DmpQuickWizardModel {
eu.eudat.models.data.userinfo.UserInfo userInfo = new eu.eudat.models.data.userinfo.UserInfo();
userInfo.setId(principal.getId());
dataManagementPlanEntity.setAssociatedUsers(user);
dataManagementPlanEntity.setExtraProperties(new HashMap<>());
dataManagementPlanEntity.getExtraProperties().put("language", this.language);
return dataManagementPlanEntity;
}

View File

@ -36,4 +36,5 @@ export interface DmpModel {
dynamicFields: Array<DmpDynamicField>;
modified: Date;
extraProperties: Map<String, any>;
language: String;
}

View File

@ -17,6 +17,7 @@ export class DmpEditorWizardModel {
public datasetProfile: DatasetProfileModel;
public definition: DmpProfileDefinition;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
public language: String;
fromModel(item: DmpModel): DmpEditorWizardModel {
this.id = item.id;
@ -24,6 +25,7 @@ export class DmpEditorWizardModel {
this.status = item.status;
this.description = item.description;
this.datasetProfile = item.profiles[0];
this.language = item.language;
return this;
}
@ -35,6 +37,7 @@ export class DmpEditorWizardModel {
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
datasetProfile: [{ value: this.datasetProfile, disabled: disabled }, context.getValidation('datasetProfile').validators],
language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators],
});
return formGroup;
}
@ -46,6 +49,7 @@ export class DmpEditorWizardModel {
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
baseContext.validation.push({ key: 'datasetProfile', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'datasetProfile')] });
baseContext.validation.push({ key: 'language', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'language')] });
return baseContext;
}
}

View File

@ -43,6 +43,20 @@
<mat-error *ngIf="formGroup.get('datasetProfile').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-12 mt-3">
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete> -->
<mat-select [formControl]="formGroup.get('language')" placeholder="{{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}">
<mat-option *ngFor="let lang of getLanguageInfos()" [value]="lang.code">
{{ lang.name }}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('language').hasError('backendError')">
{{formGroup.get('language').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('language').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
<div class="col-md-12 help">
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.HELP' | translate}}
</div>

View File

@ -18,6 +18,9 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable, of as observableOf } from 'rxjs';
import { DmpEditorWizardModel } from './dmp-editor-wizard-model';
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
import { LanguageInfo } from '@app/core/model/language-info';
import { LanguageService } from '@app/core/services/language/language.service';
import { LanguageInfoService } from '@app/core/services/culture/language-info-service';
@Component({
@ -47,7 +50,8 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
private route: ActivatedRoute,
private _service: DmpService,
public language: TranslateService,
private formService: FormService
private formService: FormService,
private languageInfoService: LanguageInfoService
) {
super();
}
@ -130,4 +134,8 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
}
return false;
}
getLanguageInfos(): LanguageInfo[] {
return this.languageInfoService.getLanguageInfoValues();
}
}