1
1
import { Component , Injector , ViewChild , NgZone } from '@angular/core' ;
2
- import { Platform , Events , Nav , SplitPane , NavController , ModalController , Loading , LoadingController , Toast , ToastController , Alert , AlertController , MenuController } from 'ionic-angular' ;
2
+ import { Platform , Events , Nav , SplitPane , NavController , ModalController , Modal , Loading , LoadingController , Toast , ToastController , Alert , AlertController , MenuController } from 'ionic-angular' ;
3
3
4
4
import { Badge } from '@ionic-native/badge' ;
5
5
import { Device } from '@ionic-native/device' ;
@@ -19,7 +19,10 @@ import { SignupPasswordPage } from '../pages/signup-password/signup-password';
19
19
import { SignupOwnerPage } from '../pages/signup-owner/signup-owner' ;
20
20
21
21
import { OnboardListPage } from '../pages/onboard-list/onboard-list' ;
22
+
22
23
import { CheckinListPage } from '../pages/checkin-list/checkin-list' ;
24
+ import { CheckinRespondPage } from '../pages/checkin-respond/checkin-respond' ;
25
+
23
26
import { GroupListPage } from '../pages/group-list/group-list' ;
24
27
import { PersonListPage } from '../pages/person-list/person-list' ;
25
28
import { PersonDetailsPage } from '../pages/person-details/person-details' ;
@@ -64,6 +67,8 @@ export class TenFourApp {
64
67
browser :boolean = false ;
65
68
desktop :boolean = false ;
66
69
70
+ checkin :Checkin = null ;
71
+
67
72
@ViewChild ( Nav )
68
73
nav :Nav ;
69
74
@@ -241,6 +246,9 @@ export class TenFourApp {
241
246
this . events . subscribe ( 'user:login' , ( ) => {
242
247
this . loadMenu ( ) ;
243
248
} ) ;
249
+ this . events . subscribe ( 'checkin:details' , ( data :any ) => {
250
+ this . showCheckinDetails ( data . checkin ) ;
251
+ } ) ;
244
252
resolve ( true ) ;
245
253
} )
246
254
}
@@ -620,6 +628,12 @@ export class TenFourApp {
620
628
return toast ;
621
629
}
622
630
631
+ protected showModal ( page :any , params :any = { } , options :any = { } ) :Modal {
632
+ let modal = this . modalController . create ( page , params , options ) ;
633
+ modal . present ( ) ;
634
+ return modal ;
635
+ }
636
+
623
637
private trackEvent ( event :string , properties :any = null ) {
624
638
return this . segment . track ( event , properties ) . then ( ( ) => {
625
639
this . logger . info ( this , "Segment" , "trackEvent" , event ) ;
@@ -662,4 +676,74 @@ export class TenFourApp {
662
676
}
663
677
}
664
678
679
+
680
+ private showCheckinDetails ( checkin :Checkin ) {
681
+ this . logger . info ( this , "showCheckinDetails" , checkin ) ;
682
+ this . zone . run ( ( ) => {
683
+ this . checkin = checkin ;
684
+ } ) ;
685
+ }
686
+
687
+ private hideCheckin ( ) {
688
+ this . zone . run ( ( ) => {
689
+ this . checkin = null ;
690
+ } ) ;
691
+ }
692
+
693
+ private editReply ( reply :Reply , event :any ) {
694
+ this . logger . info ( this , "editReply" ) ;
695
+ if ( reply . user_id == this . person . id ) {
696
+ let modal = this . showModal ( CheckinRespondPage , {
697
+ organization : this . organization ,
698
+ checkins : [ this . checkin ] ,
699
+ checkin : this . checkin ,
700
+ reply : reply
701
+ } ) ;
702
+ modal . onDidDismiss ( data => {
703
+ this . logger . info ( this , "editReply" , "Modal" , data ) ;
704
+ if ( data ) {
705
+ if ( data . canceled ) {
706
+ this . logger . info ( this , "editReply" , "Modal" , "Canceled" ) ;
707
+ }
708
+ else {
709
+ // TODO refresh the checkin list
710
+ }
711
+ }
712
+ } ) ;
713
+ }
714
+ }
715
+
716
+ private respondCheckin ( event :any ) {
717
+ this . logger . info ( this , "sendReply" ) ;
718
+ let modal = this . showModal ( CheckinRespondPage , {
719
+ organization : this . organization ,
720
+ checkins : [ this . checkin ] ,
721
+ checkin : this . checkin
722
+ } ) ;
723
+ modal . onDidDismiss ( data => {
724
+ this . logger . info ( this , "sendReply" , "Modal" , data ) ;
725
+ if ( data ) {
726
+ if ( data . canceled ) {
727
+ this . logger . info ( this , "sendReply" , "Modal" , "Canceled" ) ;
728
+ }
729
+ else {
730
+ // TODO refresh the checkin list
731
+ }
732
+ }
733
+ } ) ;
734
+ }
735
+
736
+ private resendCheckin ( event :any ) {
737
+ this . logger . info ( this , "resendCheckin" ) ;
738
+ let loading = this . showLoading ( "Resending..." ) ;
739
+ this . api . resendCheckin ( this . organization , this . checkin ) . then ( ( checkin :Checkin ) => {
740
+ loading . dismiss ( ) ;
741
+ this . showToast ( `Check-In ${ this . checkin . message } resent` ) ;
742
+ } ,
743
+ ( error :any ) => {
744
+ loading . dismiss ( ) ;
745
+ this . showAlert ( "Problem Resending Check-In" , error ) ;
746
+ } ) ;
747
+ }
748
+
665
749
}
0 commit comments