Skip to content

Commit

Permalink
Fixed double trigger issue in modals.
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Jan 11, 2018
1 parent 3e8b4a2 commit 9ee4381
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

import { ClarityModule } from 'clarity-angular';
import { SharedModule } from './shared/shared.module';

import { reducer, metaReducers } from './reducers';
Expand Down Expand Up @@ -67,6 +68,7 @@ const providers = [
FormsModule,
HttpClientModule,
SharedModule,
ClarityModule.forRoot(),
ComponentModule,
DocViewerModule,
StoreModule.forRoot(reducer, { metaReducers }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<clr-modal [clrModalOpen]="showDialog" (clrModalOpenChange)="toggleDialogChange.next()">
<clr-modal [clrModalOpen]="showDialog" (clrModalOpenChange)="toggleDialogChange.next($event)">
<h3 class="modal-title">
<div class="app-dialog-header">
<div class="app-dialog-title">{{ 'HISTORY_TEXT' | translate }}</div>
Expand All @@ -16,7 +16,7 @@ <h3 class="modal-title">
</div>
<div class="modal-footer">
<div class="app-dialog-footer">
<button class="app-button active-primary right" (click)="toggleDialogChange.next()">{{ 'DONE_BUTTON' | translate }}</button>
<button class="app-button active-primary right" (click)="toggleDialogChange.next($event)">{{ 'DONE_BUTTON' | translate }}</button>
</div>
</div>
</clr-modal>
4 changes: 2 additions & 2 deletions src/app/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const COMPONENTS = [
CodemirrorModule,
PipesModule,
SharedModule,
ClarityModule.forRoot()
ClarityModule
],
declarations: COMPONENTS,
exports: [...COMPONENTS, ClarityModule ]
exports: [...COMPONENTS ]
})
export class ComponentModule {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<clr-modal [clrModalOpen]="showVariableDialog" (clrModalOpenChange)="toggleVariableDialog.next()">
<clr-modal [clrModalOpen]="showVariableDialog" (clrModalOpenChange)="toggleVariableDialog.next($event)">
<h3 class="modal-title">
<div class="app-dialog-header">
<div class="app-dialog-title">{{ 'VARIABLES_TEXT' | translate }}</div>
Expand All @@ -18,7 +18,7 @@ <h3 class="modal-title">
</div>
<div class="modal-footer">
<div class="app-dialog-footer">
<button class="app-button active-primary right" (click)="toggleVariableDialog.next()">{{ 'SAVE_BUTTON' | translate }}</button>
<button class="app-button active-primary right" (click)="toggleVariableDialog.next($event)">{{ 'SAVE_BUTTON' | translate }}</button>
</div>
</div>
</clr-modal>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<clr-modal [clrModalOpen]="showDialog" (clrModalOpenChange)="toggleDialogChange.next()">
<clr-modal [clrModalOpen]="showDialog" (clrModalOpenChange)="toggleDialogChange.next($event)">
<h3 class="modal-title">
<div class="app-dialog-header">
<div class="app-dialog-title">{{ 'SUBSCRIPTION_URL_TEXT' | translate }}</div>
Expand All @@ -12,7 +12,7 @@ <h3 class="modal-title">
</div>
<div class="modal-footer">
<div class="app-dialog-footer">
<button class="app-button active-primary right" (click)="toggleDialogChange.next()">{{ 'SAVE_BUTTON' | translate }}</button>
<button class="app-button active-primary right" (click)="toggleDialogChange.next($event)">{{ 'SAVE_BUTTON' | translate }}</button>
</div>
</div>
</clr-modal>
10 changes: 5 additions & 5 deletions src/app/containers/window/window.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</div>
</div>
<div class="dialogs">
<clr-modal [clrModalOpen]="showHeaderDialog" (clrModalOpenChange)="toggleHeader()">
<clr-modal [clrModalOpen]="showHeaderDialog" (clrModalOpenChange)="toggleHeader($event)">
<h3 class="modal-title">
<div class="app-dialog-header">
<div class="app-dialog-title">{{ 'HEADERS_TEXT' | translate }}</div>
Expand All @@ -90,26 +90,26 @@ <h3 class="modal-title">
<div class="modal-footer">
<div class="app-dialog-footer">
<button class="app-button active-grey left" (click)="addHeader()">{{ 'ADD_HEADER_TEXT' | translate }}</button>
<button class="app-button active-primary right" (click)="toggleHeader()">{{ 'SAVE_BUTTON' | translate }}</button>
<button class="app-button active-primary right" (click)="toggleHeader($event)">{{ 'SAVE_BUTTON' | translate }}</button>
</div>
</div>
</clr-modal>
<app-set-variable-dialog
[variables]="variables"
[showVariableDialog]="showVariableDialog"
(toggleVariableDialog)="toggleVariableDialog()"
(toggleVariableDialog)="toggleVariableDialog($event)"
(variablesChange)="updateVariables($event)"
></app-set-variable-dialog>
<app-subscription-url-dialog
[subscriptionUrl]="subscriptionUrl"
[showDialog]="showSubscriptionUrlDialog"
(toggleDialogChange)="toggleSubscriptionUrlDialog()"
(toggleDialogChange)="toggleSubscriptionUrlDialog($event)"
(subscriptionUrlChange)="updateSubscriptionUrl($event)"
></app-subscription-url-dialog>
<app-history-dialog
[historyList]="historyList"
[showDialog]="showHistoryDialog"
(toggleDialogChange)="toggleHistoryDialog()"
(toggleDialogChange)="toggleHistoryDialog($event)"
(restoreHistoryChange)="restoreHistory($event)"
></app-history-dialog>
</div>
Expand Down
26 changes: 17 additions & 9 deletions src/app/containers/window/window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class WindowComponent implements OnInit {
console.log('Your query is a SUBSCRIPTION!!!');
// If the subscription URL is not set, show the dialog for the user to set it
if (!this.subscriptionUrl) {
this.toggleSubscriptionUrlDialog();
this.toggleSubscriptionUrlDialog(true);
} else {
this.startSubscription();
}
Expand All @@ -202,20 +202,28 @@ export class WindowComponent implements OnInit {
this.store.dispatch(new queryActions.SetQueryAction(query, this.windowId));
}

toggleHeader() {
this.store.dispatch(new dialogsActions.ToggleHeaderDialogAction(this.windowId));
toggleHeader(isOpen) {
if (this.showHeaderDialog !== isOpen) {
this.store.dispatch(new dialogsActions.ToggleHeaderDialogAction(this.windowId));
}
}

toggleVariableDialog() {
this.store.dispatch(new dialogsActions.ToggleVariableDialogAction(this.windowId));
toggleVariableDialog(isOpen) {
if (this.showVariableDialog !== isOpen) {
this.store.dispatch(new dialogsActions.ToggleVariableDialogAction(this.windowId));
}
}

toggleSubscriptionUrlDialog() {
this.store.dispatch(new dialogsActions.ToggleSubscriptionUrlDialogAction(this.windowId));
toggleSubscriptionUrlDialog(isOpen) {
if (this.showSubscriptionUrlDialog !== isOpen) {
this.store.dispatch(new dialogsActions.ToggleSubscriptionUrlDialogAction(this.windowId));
}
}

toggleHistoryDialog() {
this.store.dispatch(new dialogsActions.ToggleHistoryDialogAction(this.windowId));
toggleHistoryDialog(isOpen) {
if (this.showHistoryDialog !== isOpen) {
this.store.dispatch(new dialogsActions.ToggleHistoryDialogAction(this.windowId));
}
}

toggleDocs() {
Expand Down
2 changes: 2 additions & 0 deletions src/app/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { combineReducers, Action, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
import { compose } from '@ngrx/store';
import { localStorageSync } from 'ngrx-store-localstorage';
import { storeFreeze } from 'ngrx-store-freeze';

import { environment } from '../../environments/environment';

Expand Down Expand Up @@ -55,6 +56,7 @@ export const keySerializer = (key) => 'altair_' + key;

export const metaReducers: MetaReducer<any>[] = [
localStorageSync({ keys: ['windows', 'windowsMeta'], rehydrate: true, storageKeySerializer: keySerializer }),
// !environment.production ? storeFreeze : null,
log
];

Expand Down

0 comments on commit 9ee4381

Please sign in to comment.