diff --git a/ui/src/app/metadata/manager/container/dashboard-resolvers-list.component.ts b/ui/src/app/metadata/manager/container/dashboard-resolvers-list.component.ts index d32b1742c..b3d331387 100644 --- a/ui/src/app/metadata/manager/container/dashboard-resolvers-list.component.ts +++ b/ui/src/app/metadata/manager/container/dashboard-resolvers-list.component.ts @@ -72,7 +72,7 @@ export class DashboardResolversListComponent implements OnInit { edit(entity: MetadataEntity): void { if (entity.isDraft()) { - this.router.navigate(['metadata', 'resolver', 'new', 'blank'], { + this.router.navigate(['metadata', 'resolver', 'new'], { queryParams: { entityId: entity.getId() } diff --git a/ui/src/app/metadata/resolver/container/resolver-wizard-step.component.ts b/ui/src/app/metadata/resolver/container/resolver-wizard-step.component.ts index c916cb689..5e09b5215 100644 --- a/ui/src/app/metadata/resolver/container/resolver-wizard-step.component.ts +++ b/ui/src/app/metadata/resolver/container/resolver-wizard-step.component.ts @@ -51,12 +51,14 @@ export class ResolverWizardStepComponent implements OnDestroy { this.model$ = this.schema$.pipe( withLatestFrom( this.store.select(fromWizard.getModel), + this.store.select(fromResolver.getSelectedDraft), this.changes$, this.definition$ ), - map(([schema, model, changes, definition]) => ({ + map(([schema, model, selected, changes, definition]) => ({ model: { ...model, + ...selected, ...changes }, definition @@ -70,7 +72,7 @@ export class ResolverWizardStepComponent implements OnDestroy { skipWhile(([ changes, definition ]) => !definition || !changes), map(([ changes, definition ]) => definition.parser(changes.value)), withLatestFrom(this.store.select(fromResolver.getSelectedDraft)), - map(([changes, original]) => ({ ...changes })) + map(([changes, original]) => ({ ...original, ...changes })) ) .subscribe(changes => { this.store.dispatch(new UpdateChanges(changes)); diff --git a/ui/src/app/metadata/resolver/container/resolver-wizard.component.html b/ui/src/app/metadata/resolver/container/resolver-wizard.component.html index 273a327e6..f5d57a27d 100644 --- a/ui/src/app/metadata/resolver/container/resolver-wizard.component.html +++ b/ui/src/app/metadata/resolver/container/resolver-wizard.component.html @@ -2,6 +2,4 @@
-
-
{{ changes$ | async | json }}
-
{{ schema$ | async | json }}
\ No newline at end of file + \ No newline at end of file diff --git a/ui/src/app/metadata/resolver/container/resolver-wizard.component.ts b/ui/src/app/metadata/resolver/container/resolver-wizard.component.ts index 62d57798f..0a62978ab 100644 --- a/ui/src/app/metadata/resolver/container/resolver-wizard.component.ts +++ b/ui/src/app/metadata/resolver/container/resolver-wizard.component.ts @@ -10,7 +10,7 @@ import { RouterStateSnapshot } from '@angular/router'; import { Observable, Subject, of } from 'rxjs'; -import { skipWhile, startWith } from 'rxjs/operators'; +import { skipWhile, startWith, distinctUntilChanged, map, defaultIfEmpty } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; @@ -93,13 +93,14 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat this.changes$ = this.store.select(fromResolver.getEntityChanges); this.schema$ = this.store.select(fromWizard.getSchema); - this.route.queryParams.subscribe(params => { - if (params.index) { - this.store.dispatch(new SetIndex(params.index)); - } else { - this.store.dispatch(new SetIndex(this.sourceWizard.steps[0].id)); - } - }); + this.route.params + .pipe( + map(params => params.index), + distinctUntilChanged() + ) + .subscribe(index => { + this.store.dispatch(new SetIndex(index)); + }); } next(): void { @@ -116,7 +117,16 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat } go(index: string): void { - this.store.dispatch(new SetIndex(index)); + this.router.navigate( + [ + '../', + index + ], + { + relativeTo: this.route, + queryParamsHandling: 'preserve' + } + ); } ngOnDestroy(): void { diff --git a/ui/src/app/metadata/resolver/effect/draft-collection.effects.ts b/ui/src/app/metadata/resolver/effect/draft-collection.effects.ts index 49bc7eb5e..73daf4de8 100644 --- a/ui/src/app/metadata/resolver/effect/draft-collection.effects.ts +++ b/ui/src/app/metadata/resolver/effect/draft-collection.effects.ts @@ -66,6 +66,7 @@ export class DraftCollectionEffects { ofType(DraftActionTypes.UPDATE_DRAFT_REQUEST), map(getPayload), switchMap(provider => { + console.log(provider); return this.draftService .update(provider) .pipe( diff --git a/ui/src/app/metadata/resolver/effect/wizard.effect.ts b/ui/src/app/metadata/resolver/effect/wizard.effect.ts index f53e0fa70..3aa75c3f9 100644 --- a/ui/src/app/metadata/resolver/effect/wizard.effect.ts +++ b/ui/src/app/metadata/resolver/effect/wizard.effect.ts @@ -18,17 +18,18 @@ import * as fromResolver from '../reducer'; import { EntityDraftService } from '../../domain/service/draft.service'; import { SetIndex, WizardActionTypes } from '../../../wizard/action/wizard.action'; +import { UpdateDraftRequest } from '../action/draft.action'; @Injectable() export class WizardEffects { - @Effect({ dispatch: false }) + @Effect() updateResolver$ = this.actions$.pipe( ofType(ResolverEntityActionTypes.UPDATE_CHANGES), map(action => action.payload), - switchMap(provider => this.draftService.update(provider)) + map(provider => new UpdateDraftRequest(provider)) ); @Effect() @@ -38,32 +39,22 @@ export class WizardEffects { map(provider => new Clear()) ); - @Effect({ dispatch: false }) - updateIndexInUrl$ = this.actions$.pipe( - ofType(WizardActionTypes.SET_INDEX), - map(action => action.payload), - tap(index => { - const params = { ...this.activatedRoute.snapshot.queryParams, index }; - this.router.navigate([], { - relativeTo: this.activatedRoute, - queryParams: params, - queryParamsHandling: 'preserve' - }); - }) - ); - @Effect({ dispatch: false }) updateEntityIdInUrl$ = this.actions$.pipe( ofType(ResolverEntityActionTypes.UPDATE_CHANGES), map(action => action.payload), - withLatestFrom(this.store.select(fromResolver.getEntityChanges)), - map(([id, changes]) => changes.entityId ), - tap(entityId => { - const params = { ...this.activatedRoute.snapshot.queryParams, entityId }; + withLatestFrom( + this.store.select(fromResolver.getEntityChanges), + this.activatedRoute.queryParams + ), + tap(([id, changes, params]) => { this.router.navigate([], { relativeTo: this.activatedRoute, - queryParams: params, - queryParamsHandling: 'preserve' + queryParams: { + ...params, + entityId: changes.entityId + }, + queryParamsHandling: 'merge' }); }) ); diff --git a/ui/src/app/metadata/resolver/resolver.routing.ts b/ui/src/app/metadata/resolver/resolver.routing.ts index ca1911706..885851148 100644 --- a/ui/src/app/metadata/resolver/resolver.routing.ts +++ b/ui/src/app/metadata/resolver/resolver.routing.ts @@ -23,9 +23,9 @@ export const ResolverRoutes: Routes = [ path: 'new', component: NewResolverComponent, children: [ - { path: '', redirectTo: 'blank', pathMatch: 'prefix' }, + { path: '', redirectTo: 'blank/common', pathMatch: 'prefix' }, { - path: 'blank', + path: 'blank/:index', component: ResolverWizardComponent, canDeactivate: [], children: [