コード例 #1
0
        void PresentFamilyPage_Internal(Rock.Client.Family family)
        {
            // display the view controller. Ignore requests to re-view the same family (which we key off the ID to know)
            if (CurrentFamilyInfoViewController == null || CurrentFamilyInfoViewController.Family.Id != family.Id)
            {
                // first, clear out whatever our current is, because that's changing
                CurrentFamilyInfoViewController = null;

                // now, see if this family is already in a controller within the stack
                foreach (UIViewController controller in SubNavigationController.ChildViewControllers)
                {
                    // is it a match?
                    FamilyInfoViewController currController = controller as FamilyInfoViewController;
                    if (currController != null && currController.Family == family)
                    {
                        // then pop to it, and take it as our current reference
                        SubNavigationController.PopToViewController(currController, true);
                        CurrentFamilyInfoViewController = currController;
                        break;
                    }
                }

                // if this is still null, it isn't in our stack, so we can go ahead and push a new one.
                if (CurrentFamilyInfoViewController == null)
                {
                    CurrentFamilyInfoViewController = new FamilyInfoViewController(this, family);
                    SubNavigationController.PushViewController(CurrentFamilyInfoViewController, true);
                }

                HomeButton.Enabled      = true;
                AddFamilyButton.Enabled = true;
            }
        }
コード例 #2
0
        public void PresentFamilyPage(Rock.Client.Family family)
        {
            // add this family to the history bar, and setup a delegate that will call the internal presentation function
            HistoryBar.TryPushHistoryItem(family, PresentFamilyPage_Internal);

            // call the presentation function
            PresentFamilyPage_Internal(family);
        }
コード例 #3
0
        public void FamilyUpdated(Rock.Client.Family family)
        {
            // this is called when a page (likely the current family page) updates a family.
            // This lets us notify SearchFamilies and the HistoryBar.
            if (HistoryBar.TryUpdateHistoryItem(family) == false)
            {
                // it failed to update, so it's likely a new family. Add it to the history.
                HistoryBar.TryPushHistoryItem(family, PresentFamilyPage_Internal);
            }

            SearchFamiliesViewController.TryUpdateFamily(family);
        }
コード例 #4
0
        public void TryUpdateFamily(Rock.Client.Family family)
        {
            // see if the family exists
            Rock.Client.Family currFamily = Families.Where(f => f.Id == family.Id).SingleOrDefault( );

            // if it does, get its index and replace it.
            if (currFamily != null)
            {
                int currIndex = Families.IndexOf(currFamily);
                Families[currIndex] = family;
            }
        }
コード例 #5
0
        public bool TryUpdateHistoryItem(Rock.Client.Family family)
        {
            // find the history item storing this family
            HistoryItem currItem = HistoryList.Where(h => h.Family.Id == family.Id).SingleOrDefault( );

            if (currItem != null)
            {
                // update the family and button title for the entry
                currItem.Family = family;
                currItem.Button.SetTitle(UI.FamilySuffixManager.FamilyNameNoSuffix(family.Name), UIControlState.Normal);

                return(true);
            }

            return(false);
        }
コード例 #6
0
        public FamilyInfoViewController( ContainerViewController parent, Rock.Client.Family family )
        {
            SaveResult = new SaveResultView();

            Parent = parent;

            FamilyGroupObject = null;

            // support creating a NEW family by letting them pass null as the
            // family argument
            if ( family != null )
            {
                Family = family;
            }
            else
            {
                GuestFamilies = new List<Rock.Client.GuestFamily>();
                Family = new Rock.Client.Family();
            }

            Dynamic_FamilyControls = new List<IDynamic_UIView>( );
        }
コード例 #7
0
            public HistoryItem(Rock.Client.Family family, OnHistoryItemClick onClick)
            {
                // store the family
                Family = family;

                // create the button and add its click handler
                Button = UIButton.FromType(UIButtonType.System);
                Button.SetTitle(UI.FamilySuffixManager.FamilyNameNoSuffix(Family.Name), UIControlState.Normal);
                Button.SetTitleColor(Theme.GetColor(Config.Instance.VisualSettings.FooterTextColor), UIControlState.Normal);

                // now measure the button label
                NSString createLabel = new NSString(UI.FamilySuffixManager.FamilyNameNoSuffix(Family.Name));
                CGSize   buttonSize  = createLabel.StringSize(Button.Font);

                Button.Bounds = new CGRect(0, 0, buttonSize.Width, buttonSize.Height);


                Button.TouchUpInside += delegate
                {
                    onClick(Family);
                };
            }
コード例 #8
0
        public bool TryPushHistoryItem(Rock.Client.Family family, HistoryItem.OnHistoryItemClick onClick)
        {
            // key off the family's ID to see if it's unique or not.
            if (HistoryList.Where(h => h.Family.Id == family.Id).SingleOrDefault( ) == null)
            {
                HistoryItem newItem = new HistoryItem(family, onClick);

                // now add it to our list
                HistoryList.Add(newItem);

                // cap the list at 4 (beyond that, start dropping off the oldest one)
                if (HistoryList.Count > MaxHistory)
                {
                    HistoryList.RemoveAt(0);
                }

                UpdateItems( );

                return(true);
            }
            return(false);
        }
コード例 #9
0
        void OnNewPersonComplete( bool didSave, int workingFamilyId, bool isChild, object context )
        {
            KeyboardAdjustManager.Activate( );

            // did they make a change?
            if ( didSave == true )
            {
                BlockerView.Show( delegate
                    {
                        // Get the person that was just created.
                        ApplicationApi.GetPersonByGuid( ( (Rock.Client.Person)context ).Guid,
                            delegate(HttpStatusCode statusCode, string statusDescription, Rock.Client.Person newPerson )
                            {
                                if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) )
                                {
                                    // if our family ID is 0, we're supposed to be creating a new family
                                    if ( workingFamilyId == 0 )
                                    {
                                        // we know they were given a family when they were created. So get that family,
                                        // and we'll make that the family here that we're editing.
                                        ApplicationApi.GetFamiliesOfPerson( newPerson,
                                            delegate(System.Net.HttpStatusCode familyCode, string familyDescription, List<Rock.Client.Group> familyList )
                                            {
                                                // we expect there to be exactly ONE family, and it will be the one that was just created.
                                                if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) && familyList != null && familyList.Count == 1 )
                                                {
                                                    // take this as our family group object
                                                    FamilyGroupObject = familyList[ 0 ];

                                                    // now that they're in a family, we need to set their role appropriately (child or adult)
                                                    int adultChildMemberRoleId = isChild == true ? Config.Instance.FamilyMemberChildGroupRole.Id : Config.Instance.FamilyMemberAdultGroupRole.Id;
                                                    FamilyManagerApi.UpdatePersonRoleInFamily( FamilyGroupObject.Members.ToList( )[ 0 ], adultChildMemberRoleId, delegate(System.Net.HttpStatusCode updateRoleCode, string updateRoleDescription )
                                                        {
                                                            // if updating their role worked, continue!
                                                            if( Rock.Mobile.Network.Util.StatusInSuccessRange( updateRoleCode ) )
                                                            {
                                                                // copy over all the filled in info so we can update this newly created family.
                                                                UIToFamilyInfo( ref FamilyGroupObject, ref FamilyAddress, ref PendingAttribChanges );

                                                                // and immediately submit it. This will ensure we sync all the info they've typed
                                                                // up to Rock!
                                                                FamilyManagerApi.UpdateFullFamily( FamilyGroupObject, FamilyAddress, PendingAttribChanges, delegate(System.Net.HttpStatusCode updateFamilyCode, string updateFamilyDescription )
                                                                    {
                                                                        if ( Rock.Mobile.Network.Util.StatusInSuccessRange( updateFamilyCode ) )
                                                                        {
                                                                            // setup a family object that can be refreshed.
                                                                            Family = new Rock.Client.Family();
                                                                            Family.Id = FamilyGroupObject.Id;

                                                                            // go ahead and refresh the family
                                                                            RefreshFamily( );
                                                                        }
                                                                        else
                                                                        {
                                                                            // couldnt move them to the current family.
                                                                            BlockerView.Hide( delegate
                                                                                {
                                                                                    Rock.Mobile.Util.Debug.DisplayError( Strings.General_Error_Header, Strings.General_Error_Message );
                                                                                } );
                                                                        }
                                                                    } );
                                                            }
                                                            else
                                                            {
                                                                // couldnt move them to the current family.
                                                                BlockerView.Hide( delegate
                                                                    {
                                                                        Rock.Mobile.Util.Debug.DisplayError( Strings.General_Error_Header, Strings.General_Error_Message );
                                                                    } );
                                                            }
                                                        });
                                                }
                                                else
                                                {
                                                    // couldnt move them to the current family.
                                                    BlockerView.Hide( delegate
                                                        {
                                                            Rock.Mobile.Util.Debug.DisplayError( Strings.General_Error_Header, Strings.General_Error_Message );
                                                        } );
                                                }
                                            } );
                                    }
                                    else
                                    {
                                        // new person to existing family is easy. Simply add them to the working family,
                                        // and request that they are removed from any families they're already in (which will be the
                                        // one new one created by Rock)
                                        int adultChildMemberRoleId = isChild == true ? Config.Instance.FamilyMemberChildGroupRole.Id : Config.Instance.FamilyMemberAdultGroupRole.Id;
                                        FamilyManagerApi.AddPersonToFamily( newPerson, adultChildMemberRoleId, workingFamilyId, true, delegate(System.Net.HttpStatusCode addToFamilyCode, string addToFamilyDescription )
                                            {
                                                if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) )
                                                {
                                                    // update their status in this family (child / adult)

                                                    // go ahead and refresh the family
                                                    RefreshFamily( );
                                                }
                                                else
                                                {
                                                    // couldnt move them to the current family.
                                                    BlockerView.Hide( delegate { Rock.Mobile.Util.Debug.DisplayError( Strings.General_Error_Header, Strings.General_Error_Message );  } );
                                                }
                                            } );
                                    }
                                }
                            } );
                    } );
            }
        }
コード例 #10
0
        void HandleFamilyGone( )
        {
            // this is called if we search for a family and they aren't there. If that happens,
            // notify the user, and setup values as if this is a new family
            BlockerView.Hide( delegate
                {
                    Rock.Mobile.Util.Debug.DisplayError( Strings.FamilyInfo_Header_Gone, Strings.FamilyInfo_Body_Gone );

                    FamilyGroupObject = null;

                    GuestFamilies = new List<Rock.Client.GuestFamily>();
                    Family = new Rock.Client.Family();

                    TableView.Source = new TableSource( this );
                    FamilyName.SetCurrentValue( string.Empty );
                    TableView.ReloadData( );
                } );
        }
コード例 #11
0
        void AddPeopleToNewFamily( List<Rock.Client.GroupMember> familyMembers, bool removeFromOtherFamilies )
        {
            // first create a new family
            Rock.Client.Group familyGroup = new Rock.Client.Group();
            Rock.Client.GroupLocation familyAddress = new Rock.Client.GroupLocation();
            List<KeyValuePair<string, string>> pendingAttribChanges = new List<KeyValuePair<string, string>>( );

            UIToFamilyInfo( ref familyGroup, ref familyAddress, ref pendingAttribChanges );

            // if the family name field wasn't set, the family will still have no name, so we'll use the
            // person to add's last name.
            if ( UI.FamilySuffixManager.FamilyNameBlankOrSuffix( familyGroup.Name ) == true )
            {
                familyGroup.Name = FamilySuffixManager.FamilyNameWithSuffix( familyMembers[ 0 ].Person.LastName );
            }

            FamilyManagerApi.CreateNewFamily( familyGroup,
                delegate(System.Net.HttpStatusCode statusCode, string statusDescription )
                {
                    if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) )
                    {
                        // now get that group
                        ApplicationApi.GetFamilyGroupModelByGuid( familyGroup.Guid,
                            delegate(HttpStatusCode getFamilyCode, string getFamilyDesc, Rock.Client.Group model )
                            {
                                // now take the model returned and copy that into our familyGroup, because
                                // it should be everything that was plus new data like the ID.
                                familyGroup = model;

                                if ( Rock.Mobile.Network.Util.StatusInSuccessRange( getFamilyCode ) )
                                {
                                    FamilyManagerApi.UpdateFullFamily( familyGroup, familyAddress, pendingAttribChanges,
                                        delegate(System.Net.HttpStatusCode updateFamilyCode, string updateFamilyDesc )
                                        {
                                            if ( Rock.Mobile.Network.Util.StatusInSuccessRange( updateFamilyCode ) )
                                            {
                                                // take the model from the GetFamily as our family. Our address can be
                                                // the address we got from the UI.
                                                FamilyGroupObject = model;
                                                FamilyAddress = familyAddress;

                                                // setup a family object that can be refreshed.
                                                Family = new Rock.Client.Family();
                                                Family.Id = FamilyGroupObject.Id;

                                                // now use the standard addPeopleToFamily
                                                AddPeopleToFamily( familyMembers, Family.Id, removeFromOtherFamilies );
                                            }
                                            // Error retrieving the newly created family
                                            else
                                            {
                                                BlockerView.Hide( delegate
                                                    {
                                                        Rock.Mobile.Util.Debug.DisplayError( Strings.General_Error_Header, Strings.General_Error_Message );
                                                    } );
                                            }
                                        });
                                }
                                // Error retrieving the newly created family
                                else
                                {
                                    BlockerView.Hide( delegate
                                        {
                                            Rock.Mobile.Util.Debug.DisplayError( Strings.General_Error_Header, Strings.General_Error_Message );
                                        } );
                                }
                            } );
                    }
                    // Error creating the new family
                    else
                    {
                        BlockerView.Hide( delegate
                            {
                                Rock.Mobile.Util.Debug.DisplayError( Strings.General_Error_Header, Strings.General_Error_Message );
                            } );
                    }
                } );
        }