Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Efstratios Giannopoulos 2024-04-17 17:18:01 +03:00
commit c28c700eff
6 changed files with 58 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -41,7 +41,7 @@
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillingSourceId')"
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}"
[configuration]="prefillingSourceService.singleAutocompleteConfiguration">
[configuration]="prefillingSourceService.singleAutocompleteConfiguration" (optionSelected)="changePreffillingSource($event)">
</app-single-auto-complete>
<mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -77,6 +77,10 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
};
}
changePreffillingSource(){
this.prefillForm.get('prefillId').setValue(null);
}
// addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) {
// const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
// const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;

View File

@ -11,8 +11,8 @@
</div>
<div class="ml-auto d-flex flex-row">
<div class="col-auto d-flex align-items-center">
<button [disabled]="saving" *ngIf="isDirty()" type="button" mat-raised-button class="discard-btn mr-3" (click)="discard()">
{{'DMP-EDITOR.ACTIONS.DISCARD' | translate}}
<button [disabled]="saving" *ngIf="isDirty()" type="button" mat-raised-button class="discard-btn mr-3" (click)="discardChanges()">
{{'DMP-EDITOR.ACTIONS.DISCARD.DISCARD' | translate}}
</button>
<button [disabled]="saving" *ngIf="isNew" mat-raised-button type="button" (click)="formSubmit()" class="save-btn">
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}

View File

@ -271,6 +271,47 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
}
}
discardChanges() {
let messageText = "";
let confirmButtonText = "";
let cancelButtonText = "";
let isDeleteConfirmation = false;
if (this.isNew) {
messageText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-MESSAGE');
confirmButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-CONFIRM');
cancelButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-DENY');
isDeleteConfirmation = true;
} else {
messageText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-MESSAGE');
confirmButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-CONFIRM');
cancelButtonText = this.language.instant('DMP-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-DENY');
isDeleteConfirmation = false;
}
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
restoreFocus: false,
data: {
message: messageText,
confirmButton: confirmButtonText,
cancelButton: cancelButtonText,
isDeleteConfirmation: true
},
maxWidth: '40em'
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
setTimeout(x => {
this.step = this.step > 0 ? this.step - 1 : 0;
this.ngOnInit();
});
}
});
}
public delete() {
const value = this.formGroup.value;
if (value.id) {

View File

@ -1412,7 +1412,15 @@
"DMP-BLUEPRINT-VERSION": "Version"
},
"ACTIONS": {
"DISCARD": "Discard",
"DISCARD": {
"DISCARD": "Discard",
"DISCARD-NEW-MESSAGE": "All unsaved changes will be lost. Would you like to proceed?",
"DISCARD-NEW-CONFIRM": "Yes, revert changes.",
"DISCARD-NEW-DENY": "No.",
"DISCARD-EDITED-MESSAGE": "All unsaved changes will be lost. Would you like to proceed?",
"DISCARD-EDITED-CONFIRM": "Yes, revert changes.",
"DISCARD-EDITED-DENY": "No."
},
"SAVE": "Save",
"DELETE": "Delete",
"ADD-DESCRIPTION-IN-SECTION": "Add Description",