Skip to content

Commit

Permalink
SHIBUI-914 Fixed issue with navigation, fixed schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Oct 9, 2018
1 parent fbc2926 commit 6fd5c07
Show file tree
Hide file tree
Showing 18 changed files with 389 additions and 142 deletions.
31 changes: 31 additions & 0 deletions ui/src/app/metadata/domain/model/wizards/metadata-source-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
fields: [
'serviceProviderName',
'entityId'
],
fieldsets: [
{
type: 'section',
fields: [
'serviceProviderName',
'entityId'
]
}
]
},
{
Expand All @@ -23,6 +32,20 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
fields: [
'organization',
'contacts'
],
fieldsets: [
{
type: 'group',
fields: [
'organization'
]
},
{
type: 'group',
fields: [
'contacts'
]
}
]
},
{
Expand Down Expand Up @@ -50,6 +73,14 @@ export class MetadataSourceWizard implements Wizard<MetadataResolver> {
schema: 'assets/schema/source/metadata-source.json',
fields: [
'logoutEndpoints'
],
fieldsets: [
{
type: 'group',
fields: [
'logoutEndpoints'
]
}
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export class ProviderWizardComponent implements OnDestroy {
constructor(
private store: Store<fromProvider.ProviderState>
) {



this.store
.select(fromWizard.getCurrentWizardSchema)
.subscribe(s => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="section-body p-4 border border-top-0 border-info">
<ul class="nav nav-wizard m-3">
<li class="nav-item">
<button class="nav-link previous btn clearfix" role="button" routerLink="/new/copy">
<button class="nav-link previous btn clearfix" role="button" [routerLink]="['../']">
<span class="direction pull-left">
<i class="fa fa-fw fa-arrow-circle-left d-block fa-2x"></i>
<translate-i18n key="action.back">Back</translate-i18n>
Expand Down
92 changes: 47 additions & 45 deletions ui/src/app/metadata/resolver/container/new-resolver.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,56 @@
</div>
</div>
<div class="section-body p-4 border border-top-0 border-info">
<h3 translate="label.how-are-you-adding-the-metadata-information">How are you adding the metadata information?</h3>
<br />
<div class="row">
<div class="col col-xl-6 col-lg-9 col-xs-12">
<div class="d-flex justify-content-between">
<div class="resolver-nav-option">
<button type="button"
class="btn btn-lg btn-block btn-secondary"
aria-label="Upload local metadata file or use a metadata URL"
role="button"
routerLink="upload"
routerLinkActive="btn-success">
<translate-i18n key="label.upload-url">Upload/URL</translate-i18n>
<i class="fa fa-link fa-2x d-block"></i>
</button>
</div>
<div class="">
<span class="subheading-1">&nbsp;<translate-i18n key="label.or">or</translate-i18n>&nbsp;</span>
</div>
<div class="resolver-nav-option">
<button type="button"
class="btn btn-lg btn-block btn-secondary"
aria-label="Create metadata source using the wizard"
role="button"
routerLink="blank"
routerLinkActive="btn-info">
<translate-i18n key="action.create">Create</translate-i18n>
<i class="fa fa-plus-square fa-2x d-block"></i>
</button>
</div>
<div class="">
<span class="subheading-1">&nbsp;<translate-i18n key="label.or">or</translate-i18n>&nbsp;</span>
</div>
<div class="resolver-nav-option">
<button type="button"
class="btn btn-lg btn-block btn-secondary"
aria-label="Copy a metadata source"
role="button"
routerLink="copy"
routerLinkActive="btn-warning">
<translate-i18n key="action.copy">Copy</translate-i18n>
<i class="fa fa-copy fa-2x d-block"></i>
</button>
<ng-container *ngIf="canSetNewType$ | async">
<h3 translate="label.how-are-you-adding-the-metadata-information">How are you adding the metadata information?</h3>
<br />
<div class="row">
<div class="col col-xl-6 col-lg-9 col-xs-12">
<div class="d-flex justify-content-between">
<div class="resolver-nav-option">
<button type="button"
class="btn btn-lg btn-block btn-secondary"
aria-label="Upload local metadata file or use a metadata URL"
role="button"
routerLink="upload"
routerLinkActive="btn-success">
<translate-i18n key="label.upload-url">Upload/URL</translate-i18n>
<i class="fa fa-link fa-2x d-block"></i>
</button>
</div>
<div class="">
<span class="subheading-1">&nbsp;<translate-i18n key="label.or">or</translate-i18n>&nbsp;</span>
</div>
<div class="resolver-nav-option">
<button type="button"
class="btn btn-lg btn-block btn-secondary"
aria-label="Create metadata source using the wizard"
role="button"
routerLink="blank"
routerLinkActive="btn-info">
<translate-i18n key="action.create">Create</translate-i18n>
<i class="fa fa-plus-square fa-2x d-block"></i>
</button>
</div>
<div class="">
<span class="subheading-1">&nbsp;<translate-i18n key="label.or">or</translate-i18n>&nbsp;</span>
</div>
<div class="resolver-nav-option">
<button type="button"
class="btn btn-lg btn-block btn-secondary"
aria-label="Copy a metadata source"
role="button"
routerLink="copy"
routerLinkActive="btn-warning">
<translate-i18n key="action.copy">Copy</translate-i18n>
<i class="fa fa-copy fa-2x d-block"></i>
</button>
</div>
</div>
<hr />
</div>
<hr />
</div>
</div>
</ng-container>
<router-outlet></router-outlet>
</div>
</section>
Expand Down
16 changes: 14 additions & 2 deletions ui/src/app/metadata/resolver/container/new-resolver.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { map, withLatestFrom } from 'rxjs/operators';

@Component({
selector: 'new-resolver-page',
templateUrl: './new-resolver.component.html',
styleUrls: ['./new-resolver.component.scss']
})
export class NewResolverComponent {
constructor() {}
} /* istanbul ignore next */

canSetNewType$: Observable<boolean>;

constructor(
private route: ActivatedRoute
) {
this.canSetNewType$ = this.route.queryParams.pipe(
withLatestFrom(this.route.url),
map(([params, url]) => this.route.snapshot.firstChild.routeConfig.path !== 'blank' || params.index === 'common')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class ResolverWizardStepComponent implements OnDestroy {
this.definition$ = this.store.select(fromWizard.getWizardDefinition);
this.changes$ = this.store.select(fromResolver.getEntityChanges);

// this.schema$.subscribe(s => console.log(s));

this.validators$ = this.definition$.pipe(
map((def) => def.getValidators())
);
Expand All @@ -68,9 +70,12 @@ export class ResolverWizardStepComponent implements OnDestroy {
this.valueChangeEmitted$.pipe(
withLatestFrom(this.definition$),
skipWhile(([ changes, definition ]) => !definition || !changes),
map(([ changes, definition ]) => definition.parser(changes))
map(([ changes, definition ]) => definition.parser(changes.value))
)
.subscribe(changes => this.store.dispatch(new UpdateChanges(changes)));
.subscribe(changes => {
// console.log(changes);
this.store.dispatch(new UpdateChanges(changes));
});

this.statusChangeEmitted$.pipe(distinctUntilChanged()).subscribe(errors => this.updateStatus(errors));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<div class="container-fluid" role="main">
<!--<wizard-nav [index]="wizardIndex$ | async"
(onNext)="next($event)"
(onPrevious)="previous($event)"
(onSave)="save($event)"></wizard-nav>-->
<hr />
<div class="py-4">
<router-outlet></router-outlet>
</div>
</div>
<wizard (onNext)="next()" (onPrevious)="previous()" (onSave)="save()"></wizard>
<hr />
<div class="py-4">
<router-outlet></router-outlet>
</div>
36 changes: 21 additions & 15 deletions ui/src/app/metadata/resolver/container/resolver-wizard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

import { MetadataResolver } from '../../domain/model/metadata-resolver';
import * as fromCollections from '../reducer';
import * as draftActions from '../action/draft.action';
import { AddResolverRequest } from '../action/collection.action';
import * as fromResolver from '../reducer';

import { UpdateChanges } from '../action/entity.action';
import { CanComponentDeactivate } from '../../../core/service/can-deactivate.guard';

import { UnsavedDialogComponent } from '../component/unsaved-dialog.component';
import { METADATA_SOURCE_WIZARD } from '../wizard-definition';
import { Wizard } from '../../../wizard/model';
import { SetDefinition, SetIndex } from '../../../wizard/action/wizard.action';
import { Wizard, WizardStep } from '../../../wizard/model';
import { SetDefinition, SetIndex, SetDisabled, ClearWizard } from '../../../wizard/action/wizard.action';

import * as fromWizard from '../../../wizard/reducer';
import { LoadSchemaRequest } from '../../../wizard/action/wizard.action';
Expand All @@ -41,6 +37,10 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat

private ngUnsubscribe: Subject<void> = new Subject<void>();

nextStep: WizardStep;
previousStep: WizardStep;
currentPage: string;

resolver$: Observable<MetadataResolver>;
resolver: MetadataResolver;
providerName$: Observable<string>;
Expand Down Expand Up @@ -75,27 +75,32 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat

this.store.dispatch(new SetDefinition(this.sourceWizard));

this.route.params.subscribe(params => {
this.store.select(fromWizard.getNext).subscribe(n => this.nextStep = n);
this.store.select(fromWizard.getPrevious).subscribe(p => this.previousStep = p);
this.store.select(fromWizard.getWizardIndex).subscribe(i => this.currentPage = i);

this.changes$ = this.store.select(fromResolver.getEntityChanges);

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));
}
});

console.log('hi');
}

save(): void {
this.store.dispatch(new AddResolverRequest(this.latest));
next(): void {
this.go(this.nextStep.id);
}

next(index: number): void {
this.go(index.toString());
previous(): void {
this.go(this.previousStep.id);
}

previous(index: number): void {
this.go(index.toString());
save(): void {
this.store.dispatch(new SetDisabled(true));
this.store.dispatch(new AddResolverRequest(this.resolver));
}

go(index: string): void {
Expand All @@ -105,6 +110,7 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat
ngOnDestroy(): void {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
this.store.dispatch(new ClearWizard());
}

canDeactivate(
Expand Down
52 changes: 46 additions & 6 deletions ui/src/app/metadata/resolver/effect/wizard.effect.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import { Injectable } from '@angular/core';
import { Effect, Actions, ofType } from '@ngrx/effects';

import { map, switchMap } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
import { Store } from '@ngrx/store';

import {
UpdateChanges,
Clear,
ResolverEntityActionTypes
} from '../action/entity.action';
import * as provider from '../action/collection.action';
import { ResolverCollectionActionTypes } from '../action/collection.action';
import {
ResolverCollectionActionTypes,
AddResolverSuccess
} from '../action/collection.action';

import * as fromResolver from '../reducer';

import { EntityDraftService } from '../../domain/service/draft.service';
import { SetIndex, WizardActionTypes } from '../../../wizard/action/wizard.action';



@Injectable()
export class WizardEffects {
Expand All @@ -24,13 +33,44 @@ export class WizardEffects {

@Effect()
addResolverSuccessDiscard$ = this.actions$.pipe(
ofType<provider.AddResolverSuccess>(ResolverCollectionActionTypes.ADD_RESOLVER_SUCCESS),
ofType<AddResolverSuccess>(ResolverCollectionActionTypes.ADD_RESOLVER_SUCCESS),
map(action => action.payload),
map(provider => new Clear())
);

@Effect({ dispatch: false })
updateIndexInUrl$ = this.actions$.pipe(
ofType<SetIndex>(WizardActionTypes.SET_INDEX),
map(action => action.payload),
tap(index => {
const params = { ...this.activatedRoute.snapshot.queryParams, index };
this.router.navigate([], {
relativeTo: this.activatedRoute,
queryParams: params
});
})
);

@Effect({ dispatch: false })
updateEntityIdInUrl$ = this.actions$.pipe(
ofType<UpdateChanges>(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 };
this.router.navigate([], {
relativeTo: this.activatedRoute,
queryParams: params
});
})
);

constructor(
private store: Store<fromResolver.State>,
private actions$: Actions,
private draftService: EntityDraftService
private draftService: EntityDraftService,
private activatedRoute: ActivatedRoute,
private router: Router
) { }
}
Loading

0 comments on commit 6fd5c07

Please sign in to comment.