Inheritance: System.Web.UI.WebControls.CompositeControl
Exemple #1
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            Controls.Clear();

            _noteNew    = new NoteControl();
            _noteNew.ID = "noteNew";
            _noteNew.SaveButtonClick += note_SaveButtonClick;
            Controls.Add(_noteNew);

            _lbShowMore        = new LinkButton();
            _lbShowMore.ID     = "lbShowMore";
            _lbShowMore.Click += _lbShowMore_Click;
            _lbShowMore.AddCssClass("load-more btn btn-xs btn-action");
            Controls.Add(_lbShowMore);

            var iDownPre = new HtmlGenericControl("i");

            iDownPre.Attributes.Add("class", "fa fa-angle-down");
            _lbShowMore.Controls.Add(iDownPre);

            var spanDown = new HtmlGenericControl("span");

            spanDown.InnerHtml = " Load More ";
            _lbShowMore.Controls.Add(spanDown);

            var iDownPost = new HtmlGenericControl("i");

            iDownPost.Attributes.Add("class", "fa fa-angle-down");
            _lbShowMore.Controls.Add(iDownPost);
        }
Exemple #2
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            Controls.Clear();

            _noteNew = new NoteControl();
            _noteNew.ID = "noteNew";
            _noteNew.SaveButtonClick += note_SaveButtonClick;
            Controls.Add( _noteNew );

            _lbShowMore = new LinkButton();
            _lbShowMore.ID = "lbShowMore";
            _lbShowMore.Click += _lbShowMore_Click;
            _lbShowMore.AddCssClass( "load-more btn btn-xs btn-action" );
            Controls.Add( _lbShowMore );

            var iDownPre = new HtmlGenericControl( "i" );
            iDownPre.Attributes.Add( "class", "fa fa-angle-down" );
            _lbShowMore.Controls.Add( iDownPre );

            var spanDown = new HtmlGenericControl( "span" );
            spanDown.InnerHtml = " Load More ";
            _lbShowMore.Controls.Add( spanDown );

            var iDownPost = new HtmlGenericControl( "i" );
            iDownPost.Attributes.Add( "class", "fa fa-angle-down" );
            _lbShowMore.Controls.Add( iDownPost );
        }
Exemple #3
0
        /// <summary>
        /// Rebuilds the notes.
        /// </summary>
        /// <param name="setSelection">if set to <c>true</c> [set selection].</param>
        public void RebuildNotes( bool setSelection )
        {
            ClearNotes();
            ShowMoreOption = false;

            int? currentPersonId = null;
            var currentPerson = GetCurrentPerson();
            if ( currentPerson != null )
            {
                currentPersonId = currentPerson.Id;
                _noteNew.CreatedByPhotoId = currentPerson.PhotoId;
                _noteNew.CreatedByGender = currentPerson.Gender;
                _noteNew.CreatedByName = currentPerson.FullName;
                _noteNew.CreatedByPersonId = currentPerson.Id;
                _noteNew.CreatedByAge = currentPerson.Age;
            }
            else
            {
                _noteNew.CreatedByPhotoId = null;
                _noteNew.CreatedByGender = Gender.Male;
                _noteNew.CreatedByName = string.Empty;
                _noteNew.CreatedByPersonId = null;
                _noteNew.CreatedByAge = null;
            }

            _noteNew.EntityId = EntityId;

            if ( ViewableNoteTypes != null && ViewableNoteTypes.Any() && EntityId.HasValue )
            {
                using ( var rockContext = new RockContext() )
                {
                    var viewableNoteTypeIds = ViewableNoteTypes.Select( t => t.Id ).ToList();
                    var qry = new NoteService( rockContext ).Queryable( "CreatedByPersonAlias.Person" )
                        .Where( n =>
                            viewableNoteTypeIds.Contains( n.NoteTypeId ) &&
                            n.EntityId == EntityId.Value );

                    if ( SortDirection == ListSortDirection.Descending )
                    {
                        qry = qry.OrderByDescending( n => n.IsAlert == true )
                            .ThenByDescending( n => n.CreatedDateTime );
                    }
                    else
                    {
                        qry = qry.OrderByDescending( n => n.IsAlert == true )
                            .ThenBy( n => n.CreatedDateTime );
                    }

                    var notes = qry.ToList();

                    NoteCount = notes.Count();

                    int i = 0;
                    foreach ( var note in notes )
                    {
                        if ( SortDirection == ListSortDirection.Descending && i >= DisplayCount )
                        {
                            ShowMoreOption = true;
                            break;
                        }

                        if ( note.IsAuthorized( Authorization.VIEW, currentPerson ) )
                        {
                            var noteEditor = new NoteControl();
                            noteEditor.NoteTypes = EditableNoteTypes;
                            noteEditor.ID = string.Format( "note_{0}", note.Guid.ToString().Replace( "-", "_" ) );
                            noteEditor.Note = note;
                            noteEditor.IsPrivate = note.IsPrivateNote;
                            noteEditor.CanEdit = note.IsAuthorized( Authorization.ADMINISTRATE, currentPerson );
                            noteEditor.SaveButtonClick += note_Updated;
                            noteEditor.DeleteButtonClick += note_Updated;
                            Controls.Add( noteEditor );

                            i++;
                        }
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Rebuilds the notes.
        /// </summary>
        /// <param name="setSelection">if set to <c>true</c> [set selection].</param>
        public void RebuildNotes(bool setSelection)
        {
            ClearNotes();
            ShowMoreOption = false;

            int?currentPersonId = null;
            var currentPerson   = GetCurrentPerson();

            if (currentPerson != null)
            {
                currentPersonId           = currentPerson.Id;
                _noteNew.CreatedByPhotoId = currentPerson.PhotoId;
                _noteNew.CreatedByGender  = currentPerson.Gender;
                _noteNew.CreatedByName    = currentPerson.FullName;
            }
            else
            {
                _noteNew.CreatedByPhotoId = null;
                _noteNew.CreatedByGender  = Gender.Male;
                _noteNew.CreatedByName    = string.Empty;
            }

            _noteNew.EntityId = EntityId;

            if (ViewableNoteTypes != null && ViewableNoteTypes.Any() && EntityId.HasValue)
            {
                using (var rockContext = new RockContext())
                {
                    var viewableNoteTypeIds = ViewableNoteTypes.Select(t => t.Id).ToList();
                    var qry = new NoteService(rockContext).Queryable("CreatedByPersonAlias.Person")
                              .Where(n =>
                                     viewableNoteTypeIds.Contains(n.NoteTypeId) &&
                                     n.EntityId == EntityId.Value);

                    if (SortDirection == ListSortDirection.Descending)
                    {
                        qry = qry.OrderByDescending(n => n.IsAlert)
                              .ThenByDescending(n => n.CreatedDateTime);
                    }
                    else
                    {
                        qry = qry.OrderByDescending(n => n.IsAlert)
                              .ThenBy(n => n.CreatedDateTime);
                    }

                    var notes = qry.ToList();

                    NoteCount = notes.Count();

                    int i = 0;
                    foreach (var note in notes)
                    {
                        if (SortDirection == ListSortDirection.Descending && i >= DisplayCount)
                        {
                            ShowMoreOption = true;
                            break;
                        }

                        if (note.IsAuthorized(Authorization.VIEW, currentPerson))
                        {
                            var noteEditor = new NoteControl();
                            noteEditor.NoteTypes          = EditableNoteTypes;
                            noteEditor.ID                 = string.Format("note_{0}", note.Guid.ToString().Replace("-", "_"));
                            noteEditor.Note               = note;
                            noteEditor.IsPrivate          = note.IsPrivateNote;
                            noteEditor.CanEdit            = NoteTypeCache.Read(note.NoteTypeId).UserSelectable&& note.IsAuthorized(Authorization.ADMINISTRATE, currentPerson);
                            noteEditor.SaveButtonClick   += note_Updated;
                            noteEditor.DeleteButtonClick += note_Updated;
                            Controls.Add(noteEditor);

                            i++;
                        }
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Rebuilds the notes.
        /// </summary>
        /// <param name="setSelection">if set to <c>true</c> [set selection].</param>
        public void RebuildNotes( bool setSelection )
        {
            ClearNotes();

            int? currentPersonId = null;
            var currentPerson = GetCurrentPerson();
            if ( currentPerson != null )
            {
                currentPersonId = currentPerson.Id;
                _noteNew.CreatedByPhotoId = currentPerson.PhotoId;
                _noteNew.CreatedByGender = currentPerson.Gender;
                _noteNew.CreatedByName = currentPerson.FullName;
            }
            else
            {
                _noteNew.CreatedByPhotoId = null;
                _noteNew.CreatedByGender = Gender.Male;
                _noteNew.CreatedByName = string.Empty;
            }

            _noteNew.NoteTypeId = NoteTypeId;
            _noteNew.EntityId = EntityId;

            if ( NoteTypeId.HasValue && EntityId.HasValue )
            {
                ShowMoreOption = false;

                int noteCount = 0;

                var qry = new NoteService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person" )
                    .Where( n =>
                        n.NoteTypeId == NoteTypeId.Value &&
                        n.EntityId == EntityId.Value );

                if ( SortDirection == ListSortDirection.Descending )
                {
                    qry = qry.OrderByDescending( n => n.IsAlert )
                        .ThenByDescending( n => n.CreatedDateTime );
                }
                else
                {
                    qry = qry.OrderByDescending( n => n.IsAlert )
                        .ThenBy( n => n.CreatedDateTime );
                }

                foreach ( var note in qry )
                {
                    if ( noteCount >= DisplayCount )
                    {
                        ShowMoreOption = true;
                        break;
                    }

                    if ( note.IsAuthorized( Authorization.VIEW, currentPerson ) )
                    {
                        var noteEditor = new NoteControl();
                        noteEditor.ID = string.Format( "note_{0}", note.Guid.ToString().Replace( "-", "_" ) );
                        noteEditor.Note = note;
                        noteEditor.IsPrivate = note.IsPrivate( Authorization.VIEW, currentPerson );
                        noteEditor.CanEdit = note.IsAuthorized( Authorization.EDIT, currentPerson );
                        noteEditor.SaveButtonClick += note_Updated;
                        noteEditor.DeleteButtonClick += note_Updated;
                        Controls.Add( noteEditor );

                        noteCount++;
                    }
                }
            }
        }