Fixes bug with quick wizard navigation after save

This commit is contained in:
ikalyvas 2019-03-06 16:41:24 +02:00
parent 9a14a73b86
commit 3a3bea121e
3 changed files with 20 additions and 10 deletions

View File

@ -5,11 +5,10 @@ import { QuickWizardCreateAdd } from './quick-wizard-create-add/quick-wizard-cre
const routes: Routes = [
{ path: '', component: DashboardComponent },
{ path: 'create-add', component: QuickWizardCreateAdd }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class DashboardRoutingModule { }
export class DashboardRoutingModule { }

View File

@ -1,25 +1,29 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatStepper } from '@angular/material';
import { Router } from '@angular/router/src/router';
import { Router } from '@angular/router';
import { BaseComponent } from '../../core/common/base/base.component';
import { QuickWizardService } from '../../core/services/quick-wizard/quick-wizard.service';
import { DatasetCreateWizardModel } from './dataset-create-wizard.model';
import { IBreadCrumbComponent } from '../misc/breadcrumb/definition/IBreadCrumbComponent';
import { Observable } from 'rxjs';
import { BreadcrumbItem } from '../misc/breadcrumb/definition/breadcrumb-item';
@Component({
selector: 'dataset-create-wizard.component',
templateUrl: 'dataset-create-wizard.component.html',
styleUrls: ['./dataset-create-wizard.component.scss'],
})
export class DatasetCreateWizard extends BaseComponent implements OnInit {
export class DatasetCreateWizard extends BaseComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]>;
isLinear = false;
formGroup: FormGroup;
router: Router;
datasetCreateWizardModel: DatasetCreateWizardModel;
@ViewChild('stepper') stepper: MatStepper;
constructor(
private router: Router,
private formBuilder: FormBuilder,
public quickWizardService: QuickWizardService,
) {
@ -29,6 +33,13 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit {
ngOnInit() {
this.datasetCreateWizardModel = new DatasetCreateWizardModel();
this.formGroup = this.datasetCreateWizardModel.buildForm();
this.breadCrumbs = Observable.of([
{
parentComponentName: 'Dashboard',
label: 'Quick Add Dataset',
url: '/datasetcreatewizard'
}]
);
}
save() {
@ -38,7 +49,7 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit {
submit() {
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
.subscribe(data => {
this.router.navigateByUrl('/create-add');
this.router.navigateByUrl('/home');
})
}

View File

@ -52,11 +52,11 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
this.breadCrumbs = Observable.of([
{
parentComponentName: 'Dashboard',
label: 'QuickCreate',
label: 'Quick Create DMP',
url: '/quick-wizard'
}]
);
}
isActive(step: string): boolean {
@ -112,7 +112,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
onCallbackSuccess(): 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/create-add']);
this.router.navigate(['/home']);
}
onCallbackError(errorResponse: any) {
@ -153,4 +153,4 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
}
}