This commit is contained in:
Diamantis Tziotzios 2019-12-11 11:15:36 +02:00
commit 79069ed64b
6 changed files with 23 additions and 8 deletions

View File

@ -138,7 +138,7 @@ public class RemoteFetcher {
private void ifFunderQueryExist(UrlConfiguration urlConfiguration, ExternalUrlCriteria externalUrlCriteria) {
if (urlConfiguration.getFunderQuery() != null) {
if (externalUrlCriteria.getFunderId() != null && urlConfiguration.getFunderQuery().startsWith("dmp:")) {
if (externalUrlCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
urlConfiguration.setUrl(urlConfiguration.getUrl().replace("{funderQuery}", urlConfiguration.getFunderQuery()));
}
else {

View File

@ -74,10 +74,10 @@ public class Researcher implements DataModel<eu.eudat.data.entities.Researcher,
@Override
public eu.eudat.data.entities.Researcher toDataModel() {
eu.eudat.data.entities.Researcher researcher = new eu.eudat.data.entities.Researcher();
if (this.tag.equals("Internal") || this.tag.equals(this.id.substring(0, this.tag.length()))) {
if (this.tag.toLowerCase().equals("internal") || this.tag.equals(this.id.substring(0, this.tag.length()))) {
researcher.setReference(this.id);
} else {
researcher.setReference(this.tag + ":" + this.id);
researcher.setReference(this.tag.toLowerCase() + ":" + this.id);
}
researcher.setLabel(this.name);
researcher.setUri(this.label);

View File

@ -12,7 +12,7 @@
<div class="col-12">
<div class="row">
<div class="ml-auto col-auto"><button mat-raised-button mat-dialog-close type="button">Cancel</button></div>
<div class="col-auto"><button mat-raised-button color="primary" (click)="addResearcher()" type="button">Save</button></div>
<div class="col-auto"><button mat-raised-button [disabled]="!isFormValid()" color="primary" (click)="addResearcher()" type="button">Save</button></div>
</div>
</div>
</div>

View File

@ -37,4 +37,8 @@ export class AddResearcherComponent extends BaseComponent implements OnInit {
addResearcher() {
this.dialogRef.close(this.formGroup.value);
}
isFormValid() {
return this.formGroup.valid;
}
}

View File

@ -1,5 +1,8 @@
import { FormBuilder, FormGroup } from '@angular/forms';
import { ResearcherModel } from '../../../../core/model/researcher/researcher';
import { ValidationContext } from "../../../../common/forms/validation/validation-context";
import { BackendErrorValidator } from "../../../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../../../common/forms/validation/error-model/validation-error-model";
export class ResearcherEditorModel {
public id: String;
@ -7,6 +10,7 @@ export class ResearcherEditorModel {
public lastName: String;
public uri: String;
public email: String;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModel(item: ResearcherModel): ResearcherEditorModel {
this.id = item.id;
@ -17,13 +21,20 @@ export class ResearcherEditorModel {
return this;
}
buildForm(): FormGroup {
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({
firstName: [this.name],
lastName: [this.lastName]
firstName: [{ value: this.name, disabled: disabled }, context.getValidation('firstName').validators],
lastName: [{ value: this.lastName, disabled: disabled }, context.getValidation('lastName').validators]
});
return formGroup;
}
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'firstName', validators: [BackendErrorValidator(this.validationErrorModel, 'firstName')] });
baseContext.validation.push({ key: 'lastName', validators: [BackendErrorValidator(this.validationErrorModel, 'lastName')] });
return baseContext;
}
}

View File

@ -154,7 +154,7 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
name: fullName,
id: "dmp:" + fullName,
status: 0,
tag: null,
tag: "Internal",
});
}
});