Skip to content

Commit

Permalink
Merge branch 'master' into feature/SHIBUI-703
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Nov 6, 2018
2 parents 75ba2d1 + 3485ee5 commit ccc6800
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
20 changes: 17 additions & 3 deletions ui/src/app/metadata/domain/component/unsaved-entity.dialog.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
<ng-container>
<ng-container [ngSwitch]="message">
<div aria-label="Save your information? modal" role="region" tabindex="0">
<div class="modal-header">
<h4 class="modal-title" translate="message.unsaved-dialog-title">Save your information?</h4>
</div>
<div class="modal-body">
<p translate="message.unsaved-editor">You have not saved your changes. If you exit this screen, your changes will be lost.</p>
<p *ngSwitchCase="'resolver'">
<translate-i18n key="message.unsaved-source-1">
You have not completed the wizard!
Do you wish to save this information?
You can finish the wizard later by clicking the "Edit"
</translate-i18n>
<i class="fa fa-fw fa-edit"></i>
<translate-i18n key="message.unsaved-source-2">icon on the dashboard.</translate-i18n>
</p>
<p *ngSwitchDefault [translate]="message">You have not saved your changes. If you exit this screen, your changes will be lost.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="this.close()">
<span translate="action.discard-changes" aria-label="Discard changes, go back to dashboard">Discard Changes</span>
<span *ngSwitchCase="'resolver'" translate="action.finish-later" [attr.aria-label]="'action.finish-later' | translate">
Finish Later
</span>
<span *ngSwitchDefault translate="action.discard-changes" [attr.aria-label]="'action.discard-changes' | translate">
Discard Changes
</span>
</button>
<button type="button" class="btn btn-secondary" (click)="this.dismiss()" translate="action.cancel" aria-label="Close modal and go back to editing">Cancel</button>
</div>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/metadata/domain/component/unsaved-entity.dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { Subject } from 'rxjs/Subject';
export class UnsavedEntityComponent {
readonly subject: Subject<boolean> = new Subject<boolean>();

@Input() message;

constructor(
public activeModal: NgbActiveModal
) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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 } from '../action/entity.action';
import { UpdateChanges, Clear } from '../action/entity.action';

@Component({
selector: 'resolver-wizard-page',
Expand Down Expand Up @@ -127,6 +127,8 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat
}
))
);

this.changes$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(c => this.changes = c);
}

next(): void {
Expand Down Expand Up @@ -170,12 +172,15 @@ export class ResolverWizardComponent implements OnDestroy, CanComponentDeactivat
currentState: RouterStateSnapshot,
nextState: RouterStateSnapshot
): Observable<boolean> {
if (nextState.url.match('wizard')) { return of(true); }
if (nextState.url.match('blank')) { return of(true); }
if (Object.keys(this.changes).length > 0) {
let modal = this.modalService.open(UnsavedEntityComponent);
modal.componentInstance.action = new UpdateChanges(this.latest);
modal.componentInstance.message = 'resolver';
modal.result.then(
() => this.router.navigate([nextState.url]),
() => {
this.store.dispatch(new Clear());
this.router.navigate([nextState.url]);
},
() => console.warn('denied')
);
}
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/metadata/resolver/resolver.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const ResolverRoutes: Routes = [
{
path: 'blank/:index',
component: ResolverWizardComponent,
canDeactivate: [],
canDeactivate: [
CanDeactivateGuard
],
children: [
{
path: '',
Expand Down

0 comments on commit ccc6800

Please sign in to comment.