Adds: DMP creation dialog to continue to dataset addition or not (Issue - # 74)
This commit is contained in:
parent
6596b3f953
commit
df50a4ee60
|
@ -60,8 +60,8 @@ export class DmpService {
|
|||
return this.http.get<DmpModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
||||
}
|
||||
|
||||
createDmp(dataManagementPlanModel: DmpModel): Observable<DmpModel> {
|
||||
return this.http.post<DmpModel>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
||||
createDmp(dataManagementPlanModel: DmpModel): Observable<String> {
|
||||
return this.http.post<String>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
inactivate(id: String): Observable<DmpModel> {
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
<button *ngIf="!isNew" mat-raised-button type="submit" [disabled]="!formGroup.valid" class="text-uppercase dark-theme mr-2" color="primary">
|
||||
{{'DMP-EDITOR.ACTIONS.SAVE-CHANGES' | translate}}
|
||||
</button>
|
||||
<button *ngIf="isNew" mat-raised-button type="submit" [disabled]="!formGroup.valid" class="text-uppercase dark-theme mr-2" color="primary">
|
||||
<button *ngIf="isNew" mat-raised-button type="button" (click)="addDataset()" [disabled]="!formGroup.valid" class="text-uppercase dark-theme mr-2" color="primary">
|
||||
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -34,7 +34,6 @@ import { AuthService } from '../../../core/services/auth/auth.service';
|
|||
import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
|
||||
import { UserInfoListingModel } from '../../../core/model/user/user-info-listing';
|
||||
import { ProjectTabModel } from './project-tab/project-tab-model';
|
||||
import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-editor-component',
|
||||
|
@ -233,23 +232,29 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
// return this.projectService.getWithExternal(projectRequestItem);
|
||||
// }
|
||||
|
||||
formSubmit(): void {
|
||||
formSubmit(showAddDatasetDialog?: boolean): void {
|
||||
//this.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.onSubmit();
|
||||
this.onSubmit(showAddDatasetDialog);
|
||||
}
|
||||
|
||||
public isFormValid() {
|
||||
return this.formGroup.valid;
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
onSubmit(showAddDatasetDialog?: boolean): void {
|
||||
this.dmpService.createDmp(this.formGroup.getRawValue())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
complete => {
|
||||
if (showAddDatasetDialog) {
|
||||
this.addDatasetOpenDialog(complete);
|
||||
}
|
||||
else { this.onCallbackSuccess() }
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
|
@ -433,8 +438,31 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
this.formGroup.disable();
|
||||
}
|
||||
|
||||
saveAndFinalize() {
|
||||
addDataset() {
|
||||
this.formSubmit(true);
|
||||
}
|
||||
|
||||
addDatasetOpenDialog(id: String) {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
maxWidth: '500px',
|
||||
data: {
|
||||
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ADD-DATASET'),
|
||||
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
||||
isDeleteConfirmation: false
|
||||
}
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.router.navigate(['datasets/new/' + id]);
|
||||
} else {
|
||||
this.router.navigate(['/plans']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveAndFinalize() {
|
||||
const dialogInputModel: DmpFinalizeDialogInput = {
|
||||
dmpLabel: this.formGroup.get('label').value,
|
||||
dmpDescription: this.formGroup.get('description').value,
|
||||
|
@ -456,7 +484,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
if (result && !result.cancelled) {
|
||||
this.formGroup.get('status').setValue(DmpStatus.Finalized);
|
||||
this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized);
|
||||
this.formSubmit();
|
||||
this.formSubmit(false);
|
||||
dialogRef.close();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
"DELETE-ITEM": "Delete this item?",
|
||||
"DELETE-USER": "Remove this collaborator?",
|
||||
"FINALIZE-ITEM": "Finalize this item?",
|
||||
"ADD-DATASET": "Proceed on adding new Dataset?",
|
||||
"ACTIONS": {
|
||||
"CONFIRM": "Yes",
|
||||
"No": "No",
|
||||
|
|
Loading…
Reference in New Issue