Fixes bug on DMP wizard new dataset - (Issue #106)

This commit is contained in:
apapachristou 2019-06-19 11:59:47 +03:00
parent 4c834df6c5
commit 4ba6b687b6
8 changed files with 73 additions and 46 deletions

View File

@ -3,7 +3,8 @@ th {
}
.is-public {
padding-left: 0px;
padding-left: 5px;
padding-right: 5px;
border: 1px solid rgb(197, 224, 180);
color: rgb(131, 184, 95);
background-color: rgb(240, 247, 236);

View File

@ -3,7 +3,8 @@ th {
}
.is-public {
padding-left: 0px;
padding-left: 5px;
padding-right: 5px;
border: 1px solid rgb(197, 224, 180);
color: rgb(131, 184, 95);
background-color: rgb(240, 247, 236);

View File

@ -44,13 +44,16 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
ngOnInit() {
this.datasetCreateWizardModel = new DatasetCreateWizardModel();
this.formGroup = this.datasetCreateWizardModel.buildForm();
this.language.get('NAV-BAR.DATASET-DESCRIPTION-WIZARD').pipe(takeUntil(this._destroyed)).subscribe(x => {
this.breadCrumbs = Observable.of([
{
parentComponentName: 'Dashboard',
label: this.language.instant('NAV-BAR.DATASET-DESCRIPTION-WIZARD'),
label: x,
url: '/datasetcreatewizard'
}]
);
})
}
save() {
@ -58,7 +61,13 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue('0');
}
this.onSubmitSave();
// this.onSubmitSave();
const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id;
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(dmpId)
)
} else {
return;
}
@ -76,32 +85,33 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
}
}
onSubmitSave() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'),
confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'),
cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE')
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.datasetEditorWizardComponent.addDataset();
} else if (result === false) {
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess()
)
}
});
}
// onSubmitSave() {
// const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
// data: {
// message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'),
// confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'),
// cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE')
// }
// });
// dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
// if (result) {
// this.datasetEditorWizardComponent.addDataset();
// } else if (result === false) {
// this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
// .pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess()
// )
// }
// });
// }
onSubmitSaveAndFinalize() {
const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id;
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess()
complete => this.onCallbackSuccess(dmpId)
)
}
@ -117,9 +127,9 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
return this.formGroup.valid;
}
onCallbackSuccess(): void {
onCallbackSuccess(dmpId: string): void {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/home']);
this.router.navigate(['/plans/overview/' + dmpId]);
}
isActive(step: string): boolean {

View File

@ -46,6 +46,7 @@
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-LABEL' | translate}}"
type="string" name="datasetLabel" [formControl]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset].get('datasetLabel')"
required>
<mat-hint>{{'QUICKWIZARD.HINT' | translate}}</mat-hint>
</mat-form-field>
<app-dataset-description-form class="col-12" [form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]"
[visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="datasetProfile.value.id">

View File

@ -19,7 +19,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
breadCrumbs: Observable<BreadcrumbItem[]>;
@Input() formGroup: FormGroup;
@Input() datasetProfile: FormGroup;// DatasetProfileModel;
@Input() datasetProfile: FormGroup; // DatasetProfileModel;
@Input() datasetLabel: string;
editedDataset: boolean = false;
dataset: DatasetDescriptionFormEditorModel;
@ -28,6 +28,8 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
public toggleButton = 0;
public _inputValue: string;
isFirst: boolean;
constructor(
private datasetWizardService: DatasetWizardService,
public language: TranslateService,
@ -44,7 +46,8 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length;
if (length == 0) {
this.lastIndexOfDataset = length;
this.addDataset();
this.isFirst = true;
this.addDataset(this.isFirst);
this.onValChange("dataset");
}
});
@ -56,7 +59,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
this.editedDataset = false;
this._inputValue = "list";
} else if (event == "add") {
this.addDataset();
this.addDataset(this.isFirst);
this.toggleButton = 2;
this._inputValue = "dataset";
} else if (event == "dataset") {
@ -66,7 +69,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
}
editDataset(index: number) {
this.lastIndexOfDataset = index;
// this.lastIndexOfDataset = index;
this.toggleButton = 2;
this.editedDataset = true;
this._inputValue = "dataset"
@ -80,16 +83,26 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
}
addDataset() {
addDataset(isFirst: boolean) {
const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
if(isFirst) {
formGroup.get('datasetLabel').setValue(
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME') +
this.datasetProfile.value["label"] +
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME-FOR') +
this.datasetLabel);
this.datasetProfile.value["label"] + " " +
this.language.instant('GENERAL.NAMES.DATASET')
);
this.isFirst = false;
}
else {
formGroup.get('datasetLabel').setValue(
this.datasetProfile.value["label"] + " " +
this.language.instant('GENERAL.NAMES.DATASET') +
" (" +
this.lastIndexOfDataset + ")"
);
}
formArray.push(formGroup);
this.lastIndexOfDataset = formArray.length - 1;
this.editedDataset = true;

View File

@ -135,7 +135,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.datasetEditorWizardComponent.addDataset();
this.datasetEditorWizardComponent.addDataset(false);
} else if (result === false) {
this.quickWizardService.createQuickWizard(this.formGroup.value)
.pipe(takeUntil(this._destroyed))

View File

@ -53,7 +53,7 @@
<!-- END OF MOBILE MENU -->
<!-- Sidebar Menu -->
<ul class="nav" *ngFor="let groupMenuItem of groupMenuItems; last as isLast; first as isFirst; let i = index"
<ul class="nav" *ngFor="let groupMenuItem of groupMenuItems; last as isLast; first as isFirst;"
[class.nav-list-item]="showItem(groupMenuItem)">
<div *ngIf="showItem(groupMenuItem);">
<hr *ngIf="!isFirst">

View File

@ -910,6 +910,7 @@
"AFFIRMATIVE": "Yes",
"NEGATIVE": "No"
}
}
},
"HINT": "(Suggested Default Name)"
}
}