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 });
|
return this.http.get<DmpModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
createDmp(dataManagementPlanModel: DmpModel): Observable<DmpModel> {
|
createDmp(dataManagementPlanModel: DmpModel): Observable<String> {
|
||||||
return this.http.post<DmpModel>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
return this.http.post<String>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
inactivate(id: String): Observable<DmpModel> {
|
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">
|
<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}}
|
{{'DMP-EDITOR.ACTIONS.SAVE-CHANGES' | translate}}
|
||||||
</button>
|
</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}}
|
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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 { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
|
||||||
import { UserInfoListingModel } from '../../../core/model/user/user-info-listing';
|
import { UserInfoListingModel } from '../../../core/model/user/user-info-listing';
|
||||||
import { ProjectTabModel } from './project-tab/project-tab-model';
|
import { ProjectTabModel } from './project-tab/project-tab-model';
|
||||||
import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-editor-component',
|
selector: 'app-dmp-editor-component',
|
||||||
|
@ -233,23 +232,29 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
// return this.projectService.getWithExternal(projectRequestItem);
|
// return this.projectService.getWithExternal(projectRequestItem);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(showAddDatasetDialog?: boolean): void {
|
||||||
//this.touchAllFormFields(this.formGroup);
|
//this.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) { return; }
|
if (!this.isFormValid()) { return; }
|
||||||
this.onSubmit();
|
this.onSubmit(showAddDatasetDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFormValid() {
|
public isFormValid() {
|
||||||
return this.formGroup.valid;
|
return this.formGroup.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(showAddDatasetDialog?: boolean): void {
|
||||||
this.dmpService.createDmp(this.formGroup.getRawValue())
|
this.dmpService.createDmp(this.formGroup.getRawValue())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => {
|
||||||
|
if (showAddDatasetDialog) {
|
||||||
|
this.addDatasetOpenDialog(complete);
|
||||||
|
}
|
||||||
|
else { this.onCallbackSuccess() }
|
||||||
|
},
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
onCallbackSuccess(): void {
|
||||||
|
@ -433,8 +438,31 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
this.formGroup.disable();
|
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 = {
|
const dialogInputModel: DmpFinalizeDialogInput = {
|
||||||
dmpLabel: this.formGroup.get('label').value,
|
dmpLabel: this.formGroup.get('label').value,
|
||||||
dmpDescription: this.formGroup.get('description').value,
|
dmpDescription: this.formGroup.get('description').value,
|
||||||
|
@ -456,7 +484,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
if (result && !result.cancelled) {
|
if (result && !result.cancelled) {
|
||||||
this.formGroup.get('status').setValue(DmpStatus.Finalized);
|
this.formGroup.get('status').setValue(DmpStatus.Finalized);
|
||||||
this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized);
|
this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized);
|
||||||
this.formSubmit();
|
this.formSubmit(false);
|
||||||
dialogRef.close();
|
dialogRef.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
"DELETE-ITEM": "Delete this item?",
|
"DELETE-ITEM": "Delete this item?",
|
||||||
"DELETE-USER": "Remove this collaborator?",
|
"DELETE-USER": "Remove this collaborator?",
|
||||||
"FINALIZE-ITEM": "Finalize this item?",
|
"FINALIZE-ITEM": "Finalize this item?",
|
||||||
|
"ADD-DATASET": "Proceed on adding new Dataset?",
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"CONFIRM": "Yes",
|
"CONFIRM": "Yes",
|
||||||
"No": "No",
|
"No": "No",
|
||||||
|
|
Loading…
Reference in New Issue