Make back button dismiss open modal
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2020-11-20 12:35:42 -06:00
parent 8dde908b97
commit d954777b89
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
9 changed files with 82 additions and 7 deletions

View File

@ -6,14 +6,14 @@ import {
Platform, Platform,
PopoverController, PopoverController,
LoadingController, LoadingController,
ToastController ToastController, NavController
} from '@ionic/angular'; } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx';
import { ApiService } from './service/api.service'; import { ApiService } from './service/api.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import {TREE_ACTIONS, TreeComponent} from '@circlon/angular-tree-component'; import {TREE_ACTIONS, TreeComponent} from '@circlon/angular-tree-component';
import {BehaviorSubject, Observable} from 'rxjs'; import {BehaviorSubject, fromEvent, Observable} from 'rxjs';
import {OptionPickerComponent} from './components/option-picker/option-picker.component'; import {OptionPickerComponent} from './components/option-picker/option-picker.component';
import {OptionMenuComponent} from './components/option-menu/option-menu.component'; import {OptionMenuComponent} from './components/option-menu/option-menu.component';
import {SelectorComponent} from './components/sharing/selector/selector.component'; import {SelectorComponent} from './components/sharing/selector/selector.component';
@ -83,6 +83,7 @@ export class AppComponent implements OnInit {
protected versionInterval?: any; protected versionInterval?: any;
protected showedNewVersionAlert = false; protected showedNewVersionAlert = false;
protected showedOfflineAlert = false; protected showedOfflineAlert = false;
protected backbuttonSubscription: any;
protected initialized$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false); protected initialized$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
constructor( constructor(
@ -90,6 +91,7 @@ export class AppComponent implements OnInit {
private splashScreen: SplashScreen, private splashScreen: SplashScreen,
private statusBar: StatusBar, private statusBar: StatusBar,
public readonly api: ApiService, public readonly api: ApiService,
protected navCtrl: NavController,
protected router: Router, protected router: Router,
protected alerts: AlertController, protected alerts: AlertController,
protected popover: PopoverController, protected popover: PopoverController,
@ -129,6 +131,17 @@ export class AppComponent implements OnInit {
this.initializeApp(); this.initializeApp();
} }
@HostListener('window:popstate', ['$event'])
dismissModal(event) {
const modal = this.modal.getTop();
if ( modal ) {
event.preventDefault();
event.stopPropagation();
this.modal.dismiss();
}
}
showOptions($event) { showOptions($event) {
this.popover.create({ this.popover.create({
event: $event, event: $event,
@ -152,8 +165,16 @@ export class AppComponent implements OnInit {
const modal = await this.modal.create({ const modal = await this.modal.create({
component: SearchComponent, component: SearchComponent,
cssClass: 'modal-med',
}); });
const modalState = {
modal : true,
desc : 'Search everything'
};
history.pushState(modalState, null);
this.hasSearchOpen = true; this.hasSearchOpen = true;
await modal.present(); await modal.present();
@ -208,10 +229,18 @@ export class AppComponent implements OnInit {
if ( result.data === 'share' ) { if ( result.data === 'share' ) {
this.modal.create({ this.modal.create({
component: SelectorComponent, component: SelectorComponent,
cssClass: 'modal-med',
componentProps: { componentProps: {
node: this.menuTarget.data, node: this.menuTarget.data,
} }
}).then(modal => { }).then(modal => {
const modalState = {
modal : true,
desc : 'Share page'
};
history.pushState(modalState, null);
modal.present(); modal.present();
}); });
} else if ( result.data === 'export_html' ) { } else if ( result.data === 'export_html' ) {

View File

@ -122,7 +122,7 @@
</ion-content> </ion-content>
<ion-footer> <ion-footer>
<ion-buttons> <ion-buttons style="padding: 10px;">
<ion-button (click)="onAddColumnClick()" fill="outline">Add Column</ion-button> <ion-button (click)="onAddColumnClick()" fill="outline">Add Column</ion-button>
<ion-button (click)="dismissModal(true)" color="success" fill="outline">Save</ion-button> <ion-button (click)="dismissModal(true)" color="success" fill="outline">Save</ion-button>
</ion-buttons> </ion-buttons>

View File

@ -146,12 +146,22 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit {
const modal = await this.modals.create({ const modal = await this.modals.create({
component: ColumnsComponent, component: ColumnsComponent,
componentProps: {columnSets: this.columnDefs}, componentProps: {columnSets: this.columnDefs},
cssClass: 'modal-med',
}); });
modal.onDidDismiss().then(result => { modal.onDidDismiss().then(result => {
this.setColumns(result.data); if ( result?.data ) {
this.setColumns(result.data);
}
}); });
const modalState = {
modal : true,
desc : 'Manage Columns'
};
history.pushState(modalState, null);
await modal.present(); await modal.present();
} }

View File

@ -50,6 +50,14 @@ export class ParagraphEditorComponent implements ICellEditorAngularComp, AfterVi
this.value = String(value.data); this.value = String(value.data);
this.finishEdit(); this.finishEdit();
}); });
const modalState = {
modal : true,
desc : 'Paragraph editor'
};
history.pushState(modalState, null);
modal.present(); modal.present();
}); });
}); });

View File

@ -15,7 +15,6 @@ export class ParagraphModalComponent {
) {} ) {}
dismissModal() { dismissModal() {
console.log(this.value);
this.modals.dismiss(this.value); this.modals.dismiss(this.value);
} }
} }

View File

@ -50,6 +50,14 @@ export class WysiwygEditorComponent implements ICellEditorAngularComp, AfterView
this.value = String(value.data); this.value = String(value.data);
this.finishEdit(); this.finishEdit();
}); });
const modalState = {
modal : true,
desc : 'WYSIWYG editor'
};
history.pushState(modalState, null);
modal.present(); modal.present();
}); });
}); });

View File

@ -125,6 +125,13 @@ export class FormInputComponent extends EditorNodeContract implements OnInit {
} }
}); });
const modalState = {
modal : true,
desc : 'Form input editor'
};
history.pushState(modalState, null);
await modal.present(); await modal.present();
} }
} }

View File

@ -179,6 +179,13 @@ export class EditorPage implements OnInit {
} }
}); });
const modalState = {
modal : true,
desc : 'Page versions'
};
history.pushState(modalState, null);
await modal.present(); await modal.present();
} }
} }

View File

@ -159,8 +159,15 @@ hr {
.modal-big { .modal-big {
.modal-wrapper { .modal-wrapper {
height: calc(100vh - 30px); min-height: calc(100vh - 30px);
width: calc(100vw - 30px); min-width: calc(100vw - 30px);
}
}
.modal-med {
.modal-wrapper {
min-height: calc(100vh - 100px);
min-width: calc(100vw - 200px);
} }
} }