Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
433c28c510
|
@ -14,6 +14,7 @@ import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/
|
||||||
import { FunderFormModel } from '../editor/grant-tab/funder-form-model';
|
import { FunderFormModel } from '../editor/grant-tab/funder-form-model';
|
||||||
import { ProjectFormModel } from '../editor/grant-tab/project-form-model';
|
import { ProjectFormModel } from '../editor/grant-tab/project-form-model';
|
||||||
import { GrantTabModel } from '../editor/grant-tab/grant-tab-model';
|
import { GrantTabModel } from '../editor/grant-tab/grant-tab-model';
|
||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-clone',
|
selector: 'app-dmp-clone',
|
||||||
|
@ -90,12 +91,22 @@ export class DmpCloneComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
if (!this.isFormValid()) { return; }
|
if (!this.isFormValid()) { return; }
|
||||||
this.dmpService.clone(this.formGroup.getRawValue(), this.itemId)
|
if (this.isNewVersion) {
|
||||||
.pipe(takeUntil(this._destroyed))
|
this.dmpService.newVersion(this.formGroup.getRawValue(), this.itemId)
|
||||||
.subscribe(
|
.pipe(takeUntil(this._destroyed))
|
||||||
complete => this.onCallbackSuccess(),
|
.subscribe(
|
||||||
error => this.onCallbackError(error)
|
complete => this.onCallbackSuccess(),
|
||||||
);
|
error => this.onCallbackErrorNewVersion(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dmpService.clone(this.formGroup.getRawValue(), this.itemId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
complete => this.onCallbackSuccess(),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
|
@ -107,6 +118,10 @@ export class DmpCloneComponent extends BaseComponent implements OnInit {
|
||||||
this.setErrorModel(error.error);
|
this.setErrorModel(error.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) {
|
||||||
|
this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error);
|
||||||
|
}
|
||||||
|
|
||||||
public setErrorModel(validationErrorModel: ValidationErrorModel) {
|
public setErrorModel(validationErrorModel: ValidationErrorModel) {
|
||||||
Object.keys(validationErrorModel).forEach(item => {
|
Object.keys(validationErrorModel).forEach(item => {
|
||||||
(<any>this.dmp.validationErrorModel)[item] = (<any>validationErrorModel)[item];
|
(<any>this.dmp.validationErrorModel)[item] = (<any>validationErrorModel)[item];
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<mat-icon>settings_backup_restore</mat-icon>
|
<mat-icon>settings_backup_restore</mat-icon>
|
||||||
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-FUNDER' | translate}}</span>
|
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-FUNDER' | translate}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 add-entity" *ngIf="!isCreateNewFunder" (click)="createFunder()">
|
<div class="col-12" [ngClass]="isNewVersion?'disabled-toggle':'add-entity'" *ngIf="!isCreateNewFunder" (click)="createFunder()">
|
||||||
<mat-icon>add</mat-icon>
|
<mat-icon>add</mat-icon>
|
||||||
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.CREATE-NEW-FUNDER' | translate}}</span>
|
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.CREATE-NEW-FUNDER' | translate}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
<mat-icon>settings_backup_restore</mat-icon>
|
<mat-icon>settings_backup_restore</mat-icon>
|
||||||
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-PROJECT' | translate}}</span>
|
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-PROJECT' | translate}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 add-entity" *ngIf="!isCreateNewProject" (click)="createProject()">
|
<div class="col-12" [ngClass]="isNewVersion?'disabled-toggle':'add-entity'" *ngIf="!isCreateNewProject" (click)="createProject()">
|
||||||
<mat-icon>add</mat-icon>
|
<mat-icon>add</mat-icon>
|
||||||
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.CREATE-NEW-PROJECT' | translate}}</span>
|
<span>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.CREATE-NEW-PROJECT' | translate}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -74,7 +74,7 @@ export class GrantTabComponent implements OnInit {
|
||||||
this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0);
|
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.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.isCreateNewFunder = (this.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0);
|
||||||
this.setValidators();
|
this.setGrantValidators();
|
||||||
this.setProjectValidators();
|
this.setProjectValidators();
|
||||||
this.setFunderValidators();
|
this.setFunderValidators();
|
||||||
}
|
}
|
||||||
|
@ -106,33 +106,31 @@ export class GrantTabComponent implements OnInit {
|
||||||
createGrant() {
|
createGrant() {
|
||||||
if (this.isNewVersion) { return };
|
if (this.isNewVersion) { return };
|
||||||
this.isCreateNew = !this.isCreateNew;
|
this.isCreateNew = !this.isCreateNew;
|
||||||
this.setValidators();
|
this.setGrantValidators();
|
||||||
}
|
}
|
||||||
|
|
||||||
createProject() {
|
createProject() {
|
||||||
|
if (this.isNewVersion) { return };
|
||||||
this.isCreateNewProject = !this.isCreateNewProject;
|
this.isCreateNewProject = !this.isCreateNewProject;
|
||||||
this.setProjectValidators();
|
this.setProjectValidators();
|
||||||
}
|
}
|
||||||
|
|
||||||
createFunder() {
|
createFunder() {
|
||||||
|
if (this.isNewVersion) { return };
|
||||||
this.isCreateNewFunder = !this.isCreateNewFunder;
|
this.isCreateNewFunder = !this.isCreateNewFunder;
|
||||||
this.setFunderValidators();
|
this.setFunderValidators();
|
||||||
}
|
}
|
||||||
|
|
||||||
setValidators() {
|
setGrantValidators() {
|
||||||
if (this.isCreateNew) {
|
if (this.isCreateNew) {
|
||||||
this.grantformGroup.get('existGrant').disable();
|
this.grantformGroup.get('existGrant').disable();
|
||||||
this.grantformGroup.get('label').enable();
|
this.grantformGroup.get('label').enable();
|
||||||
this.grantformGroup.get('description').enable();
|
this.grantformGroup.get('description').enable();
|
||||||
} else if (this.isFinalized) {
|
} else if (this.isFinalized || this.isNewVersion) {
|
||||||
this.grantformGroup.get('existGrant').disable();
|
this.grantformGroup.get('existGrant').disable();
|
||||||
this.grantformGroup.get('label').disable();
|
this.grantformGroup.get('label').disable();
|
||||||
this.grantformGroup.get('description').disable();
|
this.grantformGroup.get('description').disable();
|
||||||
}
|
} else {
|
||||||
if (this.isNewVersion) {
|
|
||||||
this.grantformGroup.get('label').disable();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.grantformGroup.get('existGrant').enable();
|
this.grantformGroup.get('existGrant').enable();
|
||||||
this.grantformGroup.get('label').disable();
|
this.grantformGroup.get('label').disable();
|
||||||
this.grantformGroup.get('label').reset();
|
this.grantformGroup.get('label').reset();
|
||||||
|
@ -146,12 +144,11 @@ export class GrantTabComponent implements OnInit {
|
||||||
this.projectFormGroup.get('existProject').disable();
|
this.projectFormGroup.get('existProject').disable();
|
||||||
this.projectFormGroup.get('label').enable();
|
this.projectFormGroup.get('label').enable();
|
||||||
this.projectFormGroup.get('description').enable();
|
this.projectFormGroup.get('description').enable();
|
||||||
} else if (this.isFinalized) {
|
} else if (this.isFinalized || this.isNewVersion) {
|
||||||
this.projectFormGroup.get('existProject').disable();
|
this.projectFormGroup.get('existProject').disable();
|
||||||
this.projectFormGroup.get('label').disable();
|
this.projectFormGroup.get('label').disable();
|
||||||
this.projectFormGroup.get('description').disable();
|
this.projectFormGroup.get('description').disable();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.projectFormGroup.get('existProject').enable();
|
this.projectFormGroup.get('existProject').enable();
|
||||||
this.projectFormGroup.get('label').disable();
|
this.projectFormGroup.get('label').disable();
|
||||||
this.projectFormGroup.get('label').reset();
|
this.projectFormGroup.get('label').reset();
|
||||||
|
@ -164,11 +161,10 @@ export class GrantTabComponent implements OnInit {
|
||||||
if (this.isCreateNewFunder) {
|
if (this.isCreateNewFunder) {
|
||||||
this.funderFormGroup.get('existFunder').disable();
|
this.funderFormGroup.get('existFunder').disable();
|
||||||
this.funderFormGroup.get('label').enable();
|
this.funderFormGroup.get('label').enable();
|
||||||
} else if (this.isFinalized) {
|
} else if (this.isFinalized || this.isNewVersion) {
|
||||||
this.funderFormGroup.get('existFunder').disable();
|
this.funderFormGroup.get('existFunder').disable();
|
||||||
this.funderFormGroup.get('label').disable();
|
this.funderFormGroup.get('label').disable();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.funderFormGroup.enable();
|
this.funderFormGroup.enable();
|
||||||
this.funderFormGroup.get('label').disable();
|
this.funderFormGroup.get('label').disable();
|
||||||
this.funderFormGroup.get('label').reset();
|
this.funderFormGroup.get('label').reset();
|
||||||
|
|
Loading…
Reference in New Issue