Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-947 (pull request #230)
Browse files Browse the repository at this point in the history
SHIBUI-947 Fixed issue with modal
  • Loading branch information
rmathis committed Nov 8, 2018
2 parents 0f425c5 + 794c948 commit e8ffd19
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ label.entity-id=Entity ID
label.service-provider-name=Service Provider Name
label.organization=Organization
label.contacts=Contacts
label.contact=Contact
label.mdui=MDUI Information
label.service-provider-sso-descriptor=Service Provider Sso Descriptor
label.service-enabled=Service Enabled
Expand Down
1 change: 1 addition & 0 deletions backend/src/main/resources/metadata-sources-ui-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
},
"definitions": {
"Contact": {
"title": "label.contact",
"type": "object",
"required": [
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('Dashboard Resolvers List Page', () => {
it('should route to the wizard page', () => {
spyOn(router, 'navigate');
instance.edit(draft);
expect(router.navigate).toHaveBeenCalledWith(['metadata', 'resolver', 'new'], {
expect(router.navigate).toHaveBeenCalledWith(['metadata', 'resolver', 'new', 'blank', 'org-info'], {
queryParams: { id: '1' }
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class DashboardResolversListComponent implements OnInit {

edit(entity: MetadataEntity): void {
if (entity.isDraft()) {
this.router.navigate(['metadata', 'resolver', 'new'], {
this.router.navigate(['metadata', 'resolver', 'new', 'blank', 'org-info'], {
queryParams: {
id: entity.getId()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnDestroy } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { withLatestFrom, map, distinctUntilChanged, skipWhile } from 'rxjs/operators';
import { withLatestFrom, map, distinctUntilChanged, skipWhile, filter } from 'rxjs/operators';
import { Store } from '@ngrx/store';

import * as fromResolver from '../reducer';
Expand Down Expand Up @@ -60,7 +60,7 @@ export class ResolverWizardStepComponent implements OnDestroy {
},
definition
})),
skipWhile(({ model, definition }) => !definition || !model),
filter(({ model, definition }) => (definition && model)),
map(({ model, definition }) => definition.formatter(model))
);

Expand All @@ -76,7 +76,7 @@ export class ResolverWizardStepComponent implements OnDestroy {

this.valueChangeEmitted$.pipe(
withLatestFrom(this.definition$),
skipWhile(([ changes, definition ]) => !definition || !changes),
filter(([ changes, definition ]) => (!!definition && !!changes)),
map(([ changes, definition ]) => definition.parser(changes.value)),
withLatestFrom(this.store.select(fromResolver.getSelectedDraft)),
map(([changes, original]) => ({ ...original, ...changes }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { METADATA_SOURCE_WIZARD } from '../wizard-definition';
import { MetadataSourceWizard } from '../../domain/model/wizards/metadata-source-wizard';
import { initialState } from '../reducer/entity.reducer';
import { MockWizardModule } from '../../../../testing/wizard.stub';
import { RouterStateSnapshot } from '@angular/router';
import { RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import { NgbModalStub } from '../../../../testing/modal.stub';
import { of } from 'rxjs';
import { MetadataResolver } from '../../domain/model';
Expand Down Expand Up @@ -115,9 +115,12 @@ describe('Resolver Wizard Component', () => {
}));

describe('canDeactivate method', () => {
it('should return true if moving to another edit page', async(() => {
it('should return true if moving to another page', async(() => {
app.canDeactivate(null, null, {
url: 'wizard'
url: 'blank',
root: <any>{
queryParams: { id: 'foo' }
}
} as RouterStateSnapshot).subscribe((can) => {
expect(can).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ import { SetDefinition, SetIndex, SetDisabled, ClearWizard } from '../../../wiza
import * as fromWizard from '../../../wizard/reducer';
import { LoadSchemaRequest } from '../../../wizard/action/wizard.action';
import { UnsavedEntityComponent } from '../../domain/component/unsaved-entity.dialog';
import { ModalService } from '../../../core/service/modal.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { UpdateChanges, Clear } from '../action/entity.action';
import { Clear } from '../action/entity.action';

@Component({
selector: 'resolver-wizard-page',
Expand Down Expand Up @@ -172,7 +171,7 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat
currentState: RouterStateSnapshot,
nextState: RouterStateSnapshot
): Observable<boolean> {
if (nextState.url.match('blank')) { return of(true); }
if (nextState.url.match('blank') && !!nextState.root.queryParams.id) { return of(true); }
if (Object.keys(this.changes).length > 0) {
let modal = this.modalService.open(UnsavedEntityComponent);
modal.componentInstance.message = 'resolver';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class DraftCollectionEffects {
)
),
tap(() => {
this.store.dispatch(new ClearWizard());
// this.store.dispatch(new ClearWizard());
this.store.dispatch(new Clear());
})
);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/wizard/component/wizard.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav *ngIf="index$ | async">
<nav *ngIf="(current$ | async) && (index$ | async)">
<ul class="nav nav-wizard">
<li class="nav-item" *ngIf="(previous$ | async)">
<button class="nav-link previous btn clearfix" (click)="onPrevious.emit(previousPage.index)" [disabled]="disabled$ | async"
Expand Down

0 comments on commit e8ffd19

Please sign in to comment.