bug fixes
This commit is contained in:
parent
c99267d6cc
commit
2f4e123ac9
|
@ -3,4 +3,14 @@ package eu.eudat.data.dao.criteria;
|
|||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
||||
public class DataManagementPlanBlueprintCriteria extends Criteria<DMPProfile> {
|
||||
|
||||
private Integer status;
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,13 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
|
|||
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||
if (criteria.getStatus() != null) {
|
||||
if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue()));
|
||||
} else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue()));
|
||||
}
|
||||
}
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,19 @@ public class DmpRDAMapper {
|
|||
rda.getCost().add(CostRDAMapper.toRDA((Map)costl));
|
||||
});
|
||||
}
|
||||
UserInfo contact = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String) extraProperties.get("contact")));
|
||||
UserInfo contactDb = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String) extraProperties.get("contact")));
|
||||
UserInfo contact = new UserInfo();
|
||||
contact.setId(contactDb.getId());
|
||||
contact.setName(contactDb.getName());
|
||||
contact.setEmail(contactDb.getEmail());
|
||||
if(contact.getEmail() == null){
|
||||
for(UserDMP userDMP: dmp.getUsers()){
|
||||
if(userDMP.getDmp().getId() == dmp.getId() && userDMP.getUser().getEmail() != null){
|
||||
contact.setEmail(userDMP.getUser().getEmail());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rda.setContact(ContactRDAMapper.toRDA(contact));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { BaseCriteria } from "../base-criteria";
|
||||
|
||||
export class DmpBlueprintCriteria extends BaseCriteria {
|
||||
|
||||
public status?: number;
|
||||
}
|
|
@ -402,8 +402,18 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
|||
formSubmit(): void {
|
||||
this.formService.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) { return; }
|
||||
let errorMessages = [];
|
||||
if(!this.hasTitle()) {
|
||||
errorMessages.push("Title should be set.");
|
||||
}
|
||||
if(!this.hasDescription()) {
|
||||
errorMessages.push("Description should be set.");
|
||||
}
|
||||
if(!this.hasDescriptionTemplates()) {
|
||||
this.showValidationErrorsDialog(undefined, ["At least one section should have description templates."]);
|
||||
errorMessages.push("At least one section should have description templates.");
|
||||
}
|
||||
if(errorMessages.length > 0) {
|
||||
this.showValidationErrorsDialog(undefined, errorMessages);
|
||||
return;
|
||||
}
|
||||
this.onSubmit();
|
||||
|
@ -413,9 +423,19 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
|||
return this.formGroup.valid;
|
||||
}
|
||||
|
||||
hasTitle(): boolean {
|
||||
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
|
||||
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category === FieldCategory.SYSTEM && field.type === SystemFieldType.TEXT));
|
||||
}
|
||||
|
||||
hasDescription(): boolean {
|
||||
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
|
||||
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category === FieldCategory.SYSTEM && field.type === SystemFieldType.HTML_TEXT));
|
||||
}
|
||||
|
||||
hasDescriptionTemplates(): boolean {
|
||||
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
|
||||
return (dmpBlueprint.definition.sections.filter(s => s.hasTemplates == true).length > 0) ? true : false;
|
||||
return dmpBlueprint.definition.sections.some(section => section.hasTemplates == true);
|
||||
}
|
||||
|
||||
private showValidationErrorsDialog(projectOnly?: boolean, errmess?: string[]) {
|
||||
|
@ -515,7 +535,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
|||
confirmed =>{
|
||||
if(confirmed){
|
||||
this.formGroup.get('status').setValue(DmpProfileStatus.Deleted);
|
||||
this.dmpProfileService.createDmp(this.formGroup.value)
|
||||
this.dmpProfileService.createBlueprint(this.formGroup.value)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
|
|
|
@ -143,15 +143,15 @@
|
|||
<div *ngIf="field.type == 0">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" [formControl]="formGroup.get('label')" required>
|
||||
<!-- <mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
||||
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> -->
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div *ngIf="field.type == 1">
|
||||
<rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'description'"
|
||||
[placeholder]="'DMP-EDITOR.PLACEHOLDER.DESCRIPTION'">
|
||||
[placeholder]="'DMP-EDITOR.PLACEHOLDER.DESCRIPTION'" [required]="field.required">
|
||||
</rich-text-editor-component>
|
||||
</div>
|
||||
<div *ngIf="field.type == 2">
|
||||
|
@ -218,13 +218,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div *ngIf="field.type == 6">
|
||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [type]="1" (onFormChanged)="formChanged()"></funding-info>
|
||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="1" (onFormChanged)="formChanged()"></funding-info>
|
||||
</div>
|
||||
<div *ngIf="field.type == 7">
|
||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [type]="2" (onFormChanged)="formChanged()"></funding-info>
|
||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="2" (onFormChanged)="formChanged()"></funding-info>
|
||||
</div>
|
||||
<div *ngIf="field.type == 8">
|
||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [type]="3" (onFormChanged)="formChanged()"></funding-info>
|
||||
<funding-info [formGroup]="formGroup" [grantformGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isFinalized]="isFinalized" [isNew]="isNew" [isUserOwner]="isUserOwner" [isRequired]="field.required" [type]="3" (onFormChanged)="formChanged()"></funding-info>
|
||||
</div>
|
||||
<div *ngIf="field.type == 9">
|
||||
<mat-form-field>
|
||||
|
@ -274,11 +274,17 @@
|
|||
</mat-form-field>
|
||||
</div>
|
||||
<div *ngIf="field.type === extraFieldTypesEnum.RICH_TEXT">
|
||||
<mat-form-field>
|
||||
<!-- <rich-text-editor-component [parentFormGroup]="formGroup" [controlName]="'label'"
|
||||
[placeholder]="field.placeholder">
|
||||
</rich-text-editor-component> -->
|
||||
</mat-form-field>
|
||||
<ng-container formArrayName="extraFields">
|
||||
<ng-container *ngFor="let control of extraFieldsArray().controls; let extraFieldIndex = index;">
|
||||
<ng-container [formGroupName]="extraFieldIndex">
|
||||
<ng-container *ngIf="control.get('id').value === field.id">
|
||||
<rich-text-editor-component [parentFormGroup]="control" [controlName]="'value'"
|
||||
[placeholder]="field.placeholder" [required]="field.required">
|
||||
</rich-text-editor-component>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
<div *ngIf="field.type === extraFieldTypesEnum.DATE">
|
||||
<mat-form-field>
|
||||
|
|
|
@ -55,6 +55,7 @@ import { Guid } from '@common/types/guid';
|
|||
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
|
||||
import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model';
|
||||
import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component';
|
||||
import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status';
|
||||
|
||||
interface Visible {
|
||||
value: boolean;
|
||||
|
@ -305,6 +306,10 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
|||
};
|
||||
}
|
||||
|
||||
extraFieldsArray(): FormArray {
|
||||
return this.formGroup.get('extraFields') as FormArray;
|
||||
}
|
||||
|
||||
setIsUserOwner() {
|
||||
if (this.dmp) {
|
||||
const principal: Principal = this.authService.current();
|
||||
|
@ -450,7 +455,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
|||
}
|
||||
|
||||
previousStep() {
|
||||
this.step = this.step !== 0 ? this.step - 1 : this.step;
|
||||
this.step = this.step !== 1 ? this.step - 1 : this.step;
|
||||
this.resetScroll();
|
||||
// if (this.step >= this.stepsBeforeDatasets) {
|
||||
// this.datasetId = this.datasets.at(this.step - this.stepsBeforeDatasets).get('id').value;
|
||||
|
@ -813,7 +818,10 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
|||
let extraField = new DmpExtraFieldEditorModel();
|
||||
extraField.id = field.id;
|
||||
if (!isNullOrUndefined(this.dmp.extraFields)) {
|
||||
extraField.value = this.dmp.extraFields.find(f => f.id === field.id).value;
|
||||
let found = this.dmp.extraFields.find(f => f.id === field.id);
|
||||
if(found !== undefined) {
|
||||
extraField.value = found.value;
|
||||
}
|
||||
}
|
||||
extraFields.push(extraField.buildForm());
|
||||
}
|
||||
|
@ -925,6 +933,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
|||
let fields: Array<string> = new Array();
|
||||
var request = new DataTableRequest<DmpBlueprintCriteria>(0, 10, { fields: fields });
|
||||
request.criteria = new DmpBlueprintCriteria();
|
||||
request.criteria.status = DmpProfileStatus.Finalized;
|
||||
return this.dmpProfileService.getPagedBlueprint(request).pipe(map(x => x.data));
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ export class DmpEditorModel {
|
|||
baseContext.validation.push({ key: 'groupId', validators: [BackendErrorValidator(this.validationErrorModel, 'groupId')] });
|
||||
baseContext.validation.push({ key: 'version', validators: [BackendErrorValidator(this.validationErrorModel, 'version')] });
|
||||
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: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'grant', validators: [BackendErrorValidator(this.validationErrorModel, 'grant')] });
|
||||
baseContext.validation.push({ key: 'project', validators: [BackendErrorValidator(this.validationErrorModel, 'project')] });
|
||||
baseContext.validation.push({ key: 'funder', validators: [BackendErrorValidator(this.validationErrorModel, 'funder')] });
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div class="funder-form" *ngIf="type == 1">
|
||||
<div *ngIf="!isCreateNewFunder">
|
||||
<mat-form-field appearance="outline">
|
||||
<app-single-auto-complete required='true' [formControl]="funderFormGroup.get('existFunder')" placeholder="{{'DMP-EDITOR.FIELDS.FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration">
|
||||
<app-single-auto-complete [required]="isRequired" [formControl]="funderFormGroup.get('existFunder')" placeholder="{{'DMP-EDITOR.FIELDS.FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration">
|
||||
</app-single-auto-complete>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<mat-icon *ngIf="!isFunderPending && funderFormGroup.get('reference').dirty && funderFormGroup.get('reference').invalid" class="text-danger" matSuffix>clear</mat-icon>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.FUNDER-LABEL' | translate}}" type="text" name="label" [formControl]="funderFormGroup.get('label')" required>
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.FUNDER-LABEL' | translate}}" type="text" name="label" [formControl]="funderFormGroup.get('label')">
|
||||
<mat-error *ngIf="funderFormGroup.get('label').hasError('backendError')">
|
||||
{{funderFormGroup.get('label').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="funderFormGroup.get('label').hasError('required')">
|
||||
|
@ -66,7 +66,7 @@
|
|||
<div class="grant-form" *ngIf="type == 2">
|
||||
<div *ngIf="!isCreateNew">
|
||||
<mat-form-field appearance="outline">
|
||||
<app-single-auto-complete required='true' [formControl]="grantformGroup.get('existGrant')" placeholder="{{'DMP-EDITOR.FIELDS.GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
|
||||
<app-single-auto-complete [required]="isRequired" [formControl]="grantformGroup.get('existGrant')" placeholder="{{'DMP-EDITOR.FIELDS.GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
|
||||
</app-single-auto-complete>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
@ -81,14 +81,14 @@
|
|||
<mat-icon *ngIf="!isGrantPending && grantformGroup.get('reference').dirty && grantformGroup.get('reference').invalid" class="text-danger" matSuffix>clear</mat-icon>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.GRANT-LABEL' | translate}}" type="text" name="label" [formControl]="grantformGroup.get('label')" required>
|
||||
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.GRANT-LABEL' | translate}}" type="text" name="label" [formControl]="grantformGroup.get('label')">
|
||||
<mat-error *ngIf="grantformGroup.get('label').hasError('backendError')">
|
||||
{{grantformGroup.get('label').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="grantformGroup.get('label').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" [formControl]="grantformGroup.get('description')" [required]="true"></textarea>
|
||||
<textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" [formControl]="grantformGroup.get('description')"></textarea>
|
||||
<mat-error *ngIf="grantformGroup.get('description').hasError('backendError')">
|
||||
{{projectFormGroup.get('description').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="grantformGroup.get('description').hasError('required')">
|
||||
|
@ -122,14 +122,14 @@
|
|||
<div class="project-form" *ngIf="type == 3">
|
||||
<div *ngIf="!isCreateNewProject">
|
||||
<mat-form-field appearance="outline">
|
||||
<app-single-auto-complete [formControl]="projectFormGroup.get('existProject')" placeholder="{{'DMP-EDITOR.FIELDS.PROJECT' | translate}}" [configuration]="projectAutoCompleteConfiguration">
|
||||
<app-single-auto-complete [formControl]="projectFormGroup.get('existProject')" placeholder="{{'DMP-EDITOR.FIELDS.PROJECT' | translate}}" [configuration]="projectAutoCompleteConfiguration" [required]="isRequired">
|
||||
</app-single-auto-complete>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- Create New Project -->
|
||||
<div *ngIf="isCreateNewProject">
|
||||
<mat-form-field appearance="outline">
|
||||
<input matInput [placeholder]="'DMP-EDITOR.FUNDING-INFO.UNIQUE-IDENTIFIER' | translate" type="text" [formControl]="projectFormGroup.get('reference')">
|
||||
<input matInput [placeholder]="'DMP-EDITOR.FUNDING-INFO.UNIQUE-IDENTIFIER' | translate" type="text" [formControl]="projectFormGroup.get('reference')" [required]="isRequired">
|
||||
<i matSuffix class="fa fa-spinner fa-spin" *ngIf="isProjectPending"></i>
|
||||
<mat-error *ngIf="projectFormGroup.get('reference').hasError('projectIdentifierExists')">{{'DMP-EDITOR.FUNDING-INFO.IDENTIFIER-PROJECT-EXISTS' | translate}}</mat-error>
|
||||
<mat-icon *ngIf="!isProjectPending && projectFormGroup.get('reference').dirty && projectFormGroup.get('reference').valid" class="text-success" matSuffix>check</mat-icon>
|
||||
|
|
|
@ -28,6 +28,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
@Input() isClone: boolean = false;
|
||||
@Input() isNewVersion: boolean;
|
||||
|
||||
@Input() isRequired: boolean;
|
||||
@Input() type: number;
|
||||
|
||||
@Input() formGroup: FormGroup;
|
||||
|
@ -81,16 +82,24 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
|
||||
this.initializeReferenceValidators();
|
||||
|
||||
this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0);
|
||||
this.isCreateNewProject = (this.projectFormGroup.get('label').value != null && this.projectFormGroup.get('label').value.length > 0);
|
||||
this.isCreateNewFunder = (this.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0);
|
||||
this.setGrantValidators();
|
||||
this.setProjectValidators();
|
||||
this.setFunderValidators();
|
||||
if (this.grantformGroup != null) {
|
||||
this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0);
|
||||
this.setGrantValidators();
|
||||
}
|
||||
if (this.projectFormGroup != null) {
|
||||
this.isCreateNewProject = (this.projectFormGroup.get('label').value != null && this.projectFormGroup.get('label').value.length > 0);
|
||||
this.setProjectValidators();
|
||||
}
|
||||
if (this.funderFormGroup != null) {
|
||||
this.isCreateNewFunder = (this.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0);
|
||||
this.setFunderValidators();
|
||||
}
|
||||
this.registerFormListeners();
|
||||
if (this.isNew && !this.isClone) {
|
||||
this.grantformGroup.reset();
|
||||
this.grantformGroup.disable();
|
||||
if (this.grantformGroup != null && this.funderFormGroup != null) {
|
||||
this.grantformGroup.reset();
|
||||
this.grantformGroup.disable();
|
||||
}
|
||||
}
|
||||
|
||||
this.formGroup.valueChanges.pipe(takeUntil(this._destroyed))
|
||||
|
@ -101,108 +110,114 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
initializeReferenceValidators() {
|
||||
|
||||
//Validator for funder
|
||||
this.funderFormGroup.get('reference').valueChanges.pipe(
|
||||
takeUntil(this._destroyed),
|
||||
filter(value =>!isNullOrUndefined(value)),
|
||||
tap(_=>this.isFunderPending = true),
|
||||
debounceTime(500),
|
||||
switchMap(value=> {
|
||||
const requestItem = new RequestItem<FunderCriteria>();
|
||||
requestItem.criteria = new FunderCriteria();
|
||||
requestItem.criteria.exactReference = this._FUNDER_PREFIX +value;
|
||||
return this.funderService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
|
||||
}),
|
||||
map(response=>{
|
||||
if(response && response.length){
|
||||
const internalFunders = (response as Array<any>).filter(funder=> funder.key === this._KEY);
|
||||
if (this.funderFormGroup != null) {
|
||||
this.funderFormGroup.get('reference').valueChanges.pipe(
|
||||
takeUntil(this._destroyed),
|
||||
filter(value =>!isNullOrUndefined(value)),
|
||||
tap(_=>this.isFunderPending = true),
|
||||
debounceTime(500),
|
||||
switchMap(value=> {
|
||||
const requestItem = new RequestItem<FunderCriteria>();
|
||||
requestItem.criteria = new FunderCriteria();
|
||||
requestItem.criteria.exactReference = this._FUNDER_PREFIX +value;
|
||||
return this.funderService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
|
||||
}),
|
||||
map(response=>{
|
||||
if(response && response.length){
|
||||
const internalFunders = (response as Array<any>).filter(funder=> funder.key === this._KEY);
|
||||
|
||||
if(internalFunders && internalFunders.length){
|
||||
return {funderIdentifierExists:true};
|
||||
if(internalFunders && internalFunders.length){
|
||||
return {funderIdentifierExists:true};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
)
|
||||
.subscribe(error=>{
|
||||
this.isFunderPending = false;
|
||||
this.funderFormGroup.get('reference').setErrors(error);
|
||||
if(!error && this.funderFormGroup.get('reference').validator){
|
||||
const validator = this.funderFormGroup.get('reference').validator({} as AbstractControl);
|
||||
if(validator && validator.required && this.funderFormGroup.get('reference').touched && !this.funderFormGroup.get('reference').value){
|
||||
this.funderFormGroup.get('reference').setErrors({required : true});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})
|
||||
)
|
||||
.subscribe(error=>{
|
||||
this.isFunderPending = false;
|
||||
this.funderFormGroup.get('reference').setErrors(error);
|
||||
if(!error && this.funderFormGroup.get('reference').validator){
|
||||
const validator = this.funderFormGroup.get('reference').validator({} as AbstractControl);
|
||||
if(validator && validator.required && this.funderFormGroup.get('reference').touched && !this.funderFormGroup.get('reference').value){
|
||||
this.funderFormGroup.get('reference').setErrors({required : true});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//Validator for grants
|
||||
this.grantformGroup.get('reference').valueChanges.pipe(
|
||||
takeUntil(this._destroyed),
|
||||
filter(value =>!isNullOrUndefined(value)),
|
||||
tap(_=> this.isGrantPending = true),
|
||||
debounceTime(500),
|
||||
switchMap(value=> {
|
||||
const requestItem = new RequestItem<GrantCriteria>();
|
||||
requestItem.criteria = new GrantCriteria();
|
||||
requestItem.criteria.exactReference = this._GRANT_PREFIX + value;
|
||||
return this.grantService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
|
||||
}),
|
||||
map(response=>{
|
||||
if(response && response.length){
|
||||
const internalGrants = (response as Array<any>).filter(grant=> grant.key === this._KEY);
|
||||
if (this.grantformGroup != null) {
|
||||
this.grantformGroup.get('reference').valueChanges.pipe(
|
||||
takeUntil(this._destroyed),
|
||||
filter(value =>!isNullOrUndefined(value)),
|
||||
tap(_=> this.isGrantPending = true),
|
||||
debounceTime(500),
|
||||
switchMap(value=> {
|
||||
const requestItem = new RequestItem<GrantCriteria>();
|
||||
requestItem.criteria = new GrantCriteria();
|
||||
requestItem.criteria.exactReference = this._GRANT_PREFIX + value;
|
||||
return this.grantService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
|
||||
}),
|
||||
map(response=>{
|
||||
if(response && response.length){
|
||||
const internalGrants = (response as Array<any>).filter(grant=> grant.key === this._KEY);
|
||||
|
||||
if(internalGrants && internalGrants.length){
|
||||
return {grantIdentifierExists:true};
|
||||
if(internalGrants && internalGrants.length){
|
||||
return {grantIdentifierExists:true};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
)
|
||||
.subscribe(error=>{
|
||||
this.isGrantPending = false;
|
||||
this.grantformGroup.get('reference').setErrors(error);
|
||||
if(!error && this.grantformGroup.get('reference').validator){
|
||||
const validator = this.grantformGroup.get('reference').validator({} as AbstractControl);
|
||||
if(validator && validator.required && this.grantformGroup.get('reference').touched && !this.grantformGroup.get('reference').value){
|
||||
this.grantformGroup.get('reference').setErrors({required : true});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})
|
||||
)
|
||||
.subscribe(error=>{
|
||||
this.isGrantPending = false;
|
||||
this.grantformGroup.get('reference').setErrors(error);
|
||||
if(!error && this.grantformGroup.get('reference').validator){
|
||||
const validator = this.grantformGroup.get('reference').validator({} as AbstractControl);
|
||||
if(validator && validator.required && this.grantformGroup.get('reference').touched && !this.grantformGroup.get('reference').value){
|
||||
this.grantformGroup.get('reference').setErrors({required : true});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//validator for projects
|
||||
this.projectFormGroup.get('reference').valueChanges.pipe(
|
||||
takeUntil(this._destroyed),
|
||||
filter(value =>!isNullOrUndefined(value)),
|
||||
tap(_ => this.isProjectPending = true),
|
||||
debounceTime(500),
|
||||
switchMap(value=> {
|
||||
const requestItem = new RequestItem<ProjectCriteria>();
|
||||
requestItem.criteria = new ProjectCriteria();
|
||||
requestItem.criteria.exactReference = this._PROJECT_PREFIX + value;
|
||||
return this.projectService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
|
||||
}),
|
||||
map(response=>{
|
||||
if(response && response.length){
|
||||
const internalProjects = (response as Array<any>).filter(project=> project.key === this._KEY);
|
||||
if(internalProjects && internalProjects.length){
|
||||
return {projectIdentifierExists:true};
|
||||
if (this.projectFormGroup != null) {
|
||||
this.projectFormGroup.get('reference').valueChanges.pipe(
|
||||
takeUntil(this._destroyed),
|
||||
filter(value =>!isNullOrUndefined(value)),
|
||||
tap(_ => this.isProjectPending = true),
|
||||
debounceTime(500),
|
||||
switchMap(value=> {
|
||||
const requestItem = new RequestItem<ProjectCriteria>();
|
||||
requestItem.criteria = new ProjectCriteria();
|
||||
requestItem.criteria.exactReference = this._PROJECT_PREFIX + value;
|
||||
return this.projectService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed));
|
||||
}),
|
||||
map(response=>{
|
||||
if(response && response.length){
|
||||
const internalProjects = (response as Array<any>).filter(project=> project.key === this._KEY);
|
||||
if(internalProjects && internalProjects.length){
|
||||
return {projectIdentifierExists:true};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
)
|
||||
.subscribe(error=>{
|
||||
this.isProjectPending = false;
|
||||
this.projectFormGroup.get('reference').setErrors(error);
|
||||
if(!error && this.projectFormGroup.get('reference').validator){
|
||||
const validator = this.projectFormGroup.get('reference').validator({} as AbstractControl);
|
||||
if(validator && validator.required && this.projectFormGroup.get('reference').touched && !this.projectFormGroup.get('reference').value){
|
||||
this.projectFormGroup.get('reference').setErrors({required : true});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})
|
||||
)
|
||||
.subscribe(error=>{
|
||||
this.isProjectPending = false;
|
||||
this.projectFormGroup.get('reference').setErrors(error);
|
||||
if(!error && this.projectFormGroup.get('reference').validator){
|
||||
const validator = this.projectFormGroup.get('reference').validator({} as AbstractControl);
|
||||
if(validator && validator.required && this.projectFormGroup.get('reference').touched && !this.projectFormGroup.get('reference').value){
|
||||
this.projectFormGroup.get('reference').setErrors({required : true});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
configureAutoCompletes(): void {
|
||||
|
@ -283,7 +298,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.grantformGroup.get('description').enable();
|
||||
|
||||
this.grantformGroup.get('reference').enable();
|
||||
this.grantformGroup.get('reference').setValidators(Validators.required);
|
||||
if(this.isRequired)
|
||||
this.grantformGroup.get('reference').setValidators(Validators.required);
|
||||
this.grantformGroup.get('reference').updateValueAndValidity();
|
||||
} else if (this.isClone && !this.isNewVersion) {
|
||||
this.grantformGroup.get('existGrant').enable();
|
||||
|
@ -326,7 +342,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.projectFormGroup.get('description').enable();
|
||||
|
||||
this.projectFormGroup.get('reference').enable()
|
||||
this.projectFormGroup.get('reference').setValidators(Validators.required);
|
||||
if(this.isRequired)
|
||||
this.projectFormGroup.get('reference').setValidators(Validators.required);
|
||||
this.projectFormGroup.get('reference').updateValueAndValidity();
|
||||
} else if (this.isClone && !this.isNewVersion) {
|
||||
this.projectFormGroup.get('existProject').enable();
|
||||
|
@ -368,7 +385,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.funderFormGroup.get('label').enable();
|
||||
|
||||
this.funderFormGroup.get('reference').enable();
|
||||
this.funderFormGroup.get('reference').setValidators(Validators.required);
|
||||
if(this.isRequired)
|
||||
this.funderFormGroup.get('reference').setValidators(Validators.required);
|
||||
this.funderFormGroup.get('reference').updateValueAndValidity();
|
||||
|
||||
} else if (this.isClone && !this.isNewVersion) {
|
||||
|
@ -383,7 +401,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
} else {
|
||||
this.funderFormGroup.get('label').enable();
|
||||
this.funderFormGroup.get('reference').enable();
|
||||
this.funderFormGroup.get('reference').setValidators(Validators.required);
|
||||
if(this.isRequired)
|
||||
this.funderFormGroup.get('reference').setValidators(Validators.required);
|
||||
this.funderFormGroup.get('reference').updateValueAndValidity();
|
||||
}
|
||||
} else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) {
|
||||
|
@ -407,11 +426,13 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
|
||||
registerFormListeners() {
|
||||
this.funderFormGroup.valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.funderValueChanged(x);
|
||||
})
|
||||
if (this.funderFormGroup != null) {
|
||||
this.funderFormGroup.valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.funderValueChanged(x);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
funderValueChanged(funder: any) {
|
||||
|
|
|
@ -36,9 +36,9 @@ export class FunderFormModel {
|
|||
createValidationContext(): ValidationContext {
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
baseContext.validation.push({ key: 'id', validators: [] });
|
||||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'label', validators: [BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'status', validators: [] });
|
||||
baseContext.validation.push({ key: 'existFunder', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'existFunder')] });
|
||||
baseContext.validation.push({ key: 'existFunder', validators: [BackendErrorValidator(this.validationErrorModel, 'existFunder')] });
|
||||
baseContext.validation.push({ key: 'reference', validators: [BackendErrorValidator(this.validationErrorModel, 'reference')] });
|
||||
return baseContext;
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ export class GrantTabModel {
|
|||
createValidationContext(): ValidationContext {
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
baseContext.validation.push({ key: 'id', validators: [] });
|
||||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'label', validators: [BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'status', validators: [] });
|
||||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'existGrant', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] });
|
||||
baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'existGrant', validators: [ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] });
|
||||
baseContext.validation.push({ key: 'funderId', validators: [ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'funderId')] });
|
||||
baseContext.validation.push({ key: 'reference', validators: [BackendErrorValidator(this.validationErrorModel, 'reference')] });
|
||||
return baseContext;
|
||||
|
|
Loading…
Reference in New Issue