/// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            if (_page == null)
            {
                return;
            }

            var rockContext = new RockContext();
            var pageService = new PageService(rockContext);
            var childPages  = pageService.GetByParentPageId(_page.Id).ToList();

            pageService.Reorder(childPages, e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            Rock.Web.Cache.PageCache.Flush(_page.Id);

            foreach (var page in childPages)
            {
                // make sure the PageCache for all the re-ordered pages get flushed so the new Order is updated
                Rock.Web.Cache.PageCache.Flush(page.Id);
            }

            _page.FlushChildPages();
            PageUpdated = true;

            BindGrid();
        }
Beispiel #2
0
        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gDefinedValues_GridReorder(object sender, GridReorderEventArgs e)
        {
            var definedType = DefinedTypeCache.Read(Rock.SystemGuid.DefinedType.PROTECT_MY_MINISTRY_PACKAGES.AsGuid());

            if (definedType != null)
            {
                var changedIds = new List <int>();

                using (var rockContext = new RockContext())
                {
                    var definedValueService = new DefinedValueService(rockContext);
                    var definedValues       = definedValueService.Queryable().Where(a => a.DefinedTypeId == definedType.Id).OrderBy(a => a.Order).ThenBy(a => a.Value);
                    changedIds = definedValueService.Reorder(definedValues.ToList(), e.OldIndex, e.NewIndex);
                    rockContext.SaveChanges();
                }

                DefinedTypeCache.Flush(definedType.Id);
                foreach (int id in changedIds)
                {
                    Rock.Web.Cache.DefinedValueCache.Flush(id);
                }
            }

            BindPackageGrid();
        }
Beispiel #3
0
        /// <summary>
        /// Handles the GridReorder event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void gList_GridReorder(object sender, GridReorderEventArgs e)
        {
            int oldIndex  = e.OldIndex;
            int newIndex  = e.NewIndex;
            int projectId = hfProjectId.ValueAsInt();

            var projectPointOfAssessmentService = new ResidencyService <ProjectPointOfAssessment>();
            var items = projectPointOfAssessmentService.Queryable()
                        .Where(a => a.ProjectId.Equals(projectId))
                        .OrderBy(a => a.AssessmentOrder).ToList();

            ProjectPointOfAssessment movedItem = items[oldIndex];

            items.RemoveAt(oldIndex);
            if (newIndex >= items.Count)
            {
                items.Add(movedItem);
            }
            else
            {
                items.Insert(newIndex, movedItem);
            }

            UpdateItemOrders(projectPointOfAssessmentService, items);

            BindGrid();
        }
Beispiel #4
0
        void rGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            var tagService = new Rock.Model.TagService();
            var queryable  = tagService.Queryable().
                             Where(t => t.EntityTypeId == _entityTypeId &&
                                   (t.EntityTypeQualifierColumn ?? string.Empty) == _entityQualifierColumn &&
                                   (t.EntityTypeQualifierValue ?? string.Empty) == _entityQualifierValue);

            if (_ownerId.HasValue)
            {
                queryable = queryable.Where(t => t.OwnerId == _ownerId.Value);
            }
            else
            {
                queryable = queryable.Where(t => t.OwnerId == null);
            }

            var items = queryable
                        .OrderBy(t => t.Order)
                        .ToList();

            tagService.Reorder(items, e.OldIndex, e.NewIndex, CurrentPersonId);

            BindGrid();
        }
        /// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Controls.GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            var components = _container.Dictionary.ToList();
            var movedItem  = components[e.OldIndex];

            components.RemoveAt(e.OldIndex);
            if (e.NewIndex >= components.Count)
            {
                components.Add(movedItem);
            }
            else
            {
                components.Insert(e.NewIndex, movedItem);
            }

            var rockContext = new RockContext();
            int order       = 0;

            foreach (var item in components)
            {
                Component component = item.Value.Value;
                if (component.Attributes.ContainsKey("Order"))
                {
                    Rock.Attribute.Helper.SaveAttributeValue(component, component.Attributes["Order"], order.ToString(), rockContext);
                }

                order++;
            }

            _container.Refresh();

            BindGrid();
        }
Beispiel #6
0
        /// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Controls.GridReorderEventArgs"/> instance containing the event data.</param>
        void rGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            var components = _container.Dictionary.ToList();
            var movedItem  = components[e.OldIndex];

            components.RemoveAt(e.OldIndex);
            if (e.NewIndex >= components.Count)
            {
                components.Add(movedItem);
            }
            else
            {
                components.Insert(e.NewIndex, movedItem);
            }

            using (new Rock.Data.UnitOfWorkScope())
            {
                int order = 0;
                foreach (var item in components)
                {
                    ComponentManaged component = item.Value.Value;
                    if (component.Attributes.ContainsKey("Order"))
                    {
                        Rock.Attribute.Helper.SaveAttributeValue(component, component.Attributes["Order"], order.ToString(), CurrentPersonId);
                    }
                    order++;
                }
            }

            _container.Refresh();

            BindGrid();
        }
        /// <summary>
        /// Handles the GridReorder event of the gItemAttributes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gItemAttributes_GridReorder(object sender, GridReorderEventArgs e)
        {
            var movedItem = ItemAttributesState.Where(a => a.Order == e.OldIndex).FirstOrDefault();

            if (movedItem != null)
            {
                if (e.NewIndex < e.OldIndex)
                {
                    // Moved up
                    foreach (var otherItem in ItemAttributesState.Where(a => a.Order < e.OldIndex && a.Order >= e.NewIndex))
                    {
                        otherItem.Order = otherItem.Order + 1;
                    }
                }
                else
                {
                    // Moved Down
                    foreach (var otherItem in ItemAttributesState.Where(a => a.Order > e.OldIndex && a.Order <= e.NewIndex))
                    {
                        otherItem.Order = otherItem.Order - 1;
                    }
                }

                movedItem.Order = e.NewIndex;
            }

            BindItemAttributesGrid();
        }
 /// <summary>
 /// Handles the Reorder event of the gLocations control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gLocations_Reorder(object sender, GridReorderEventArgs e)
 {
     if (ReorderLocationClick != null)
     {
         var eventArg = new ResourceGroupEventArg(GroupGuid, e.DataKey, e.OldIndex, e.NewIndex);
         ReorderLocationClick(this, eventArg);
     }
 }
Beispiel #9
0
        void gPageBlocks_GridReorder(object sender, GridReorderEventArgs e)
        {
            blockService.Reorder(
                blockService.GetByLayoutAndPageIdAndZone(null, _page.Id, _zoneName).ToList(),
                e.OldIndex, e.NewIndex, CurrentPersonId);

            BindGrids();
        }
Beispiel #10
0
        /// <summary>
        /// Handles the GridReorder event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void gList_GridReorder(object sender, GridReorderEventArgs e)
        {
            int oldIndex = e.OldIndex;
            int newIndex = e.NewIndex;
            int periodId = hfPeriodId.ValueAsInt();

            var trackService = new ResidencyService <Track>();
            var items        = trackService.Queryable()
                               .Where(a => a.PeriodId.Equals(periodId))
                               .OrderBy(a => a.DisplayOrder).ToList();

            RockTransactionScope.WrapTransaction(() =>
            {
                Track movedItem = items[oldIndex];
                items.RemoveAt(oldIndex);
                if (newIndex >= items.Count)
                {
                    items.Add(movedItem);
                }
                else
                {
                    items.Insert(newIndex, movedItem);
                }

                int order = 1;
                foreach (Track item in items)
                {
                    if (item != null)
                    {
                        if (item.DisplayOrder != order)
                        {
                            // temporarily, set the order to negative in case another row has this value.
                            item.DisplayOrder = -order;
                            trackService.Save(item, CurrentPersonId);
                        }
                    }

                    order++;
                }

                foreach (Track item in items)
                {
                    if (item != null)
                    {
                        if (item.DisplayOrder < 0)
                        {
                            // update the value back to positive now that all the rows have their new order
                            item.DisplayOrder = -item.DisplayOrder;
                            trackService.Save(item, CurrentPersonId);
                        }
                    }
                }
            });

            BindGrid();
        }
Beispiel #11
0
        /// <summary>
        /// Handles the GridReorder event of the grdFinancialBatch control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void rGridBatch_GridReorder(object sender, GridReorderEventArgs e)
        {
            var batchService = new Rock.Model.FinancialBatchService();
            var queryable    = batchService.Queryable();

            List <Rock.Model.FinancialBatch> items = queryable.ToList();

            batchService.Reorder(items, e.OldIndex, e.NewIndex, CurrentPersonId);
            BindGrid();
        }
Beispiel #12
0
        /// <summary>
        /// Handles the GridReorder event of the grdFinancialGivingProfile control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void rGridGivingProfile_GridReorder(object sender, GridReorderEventArgs e)
        {
            var profileService = new FinancialScheduledTransactionService();
            var queryable      = profileService.Queryable();

            List <FinancialScheduledTransaction> items = queryable.ToList();

            profileService.Reorder(items, e.OldIndex, e.NewIndex, CurrentPersonId);
            BindGrid();
        }
Beispiel #13
0
        void rGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            List <Rock.CMS.Auth> rules = authService.GetAuths(iSecured.AuthEntity, iSecured.Id, CurrentAction).ToList();

            authService.Reorder(rules, e.OldIndex, e.NewIndex, CurrentPersonId);

            Rock.Security.Authorization.ReloadAction(iSecured.AuthEntity, iSecured.Id, CurrentAction);

            BindGrid();
        }
        /// <summary>
        /// Handles the GridReorder event of the gAchievements control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gAchievements_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext = GetRockContext();
            var streakTypeAchievementTypes = GetAchievementTypes();

            GetAchievementTypeService().Reorder(streakTypeAchievementTypes.ToList(), e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            BindGrid();
        }
Beispiel #15
0
        private void gList_GridReorder(object sender, GridReorderEventArgs e)
        {
            var            rockContext    = new RockContext();
            ChapterService chapterService = new ChapterService(rockContext);
            var            courseId       = PageParameter(PageParameterKey.CourseId).AsInteger();
            var            items          = chapterService.Queryable().Where(p => p.CourseId == courseId).OrderBy(i => i.Order).ToList();

            chapterService.Reorder(items, e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();
            BindGrid();
        }
Beispiel #16
0
        /// <summary>
        /// Handles the GridReorder event of the gStepProgram control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs" /> instance containing the event data.</param>
        void gStepProgram_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext  = new RockContext();
            var service      = new StepProgramService(rockContext);
            var stepPrograms = service.Queryable().OrderBy(b => b.Order);

            service.Reorder(stepPrograms.ToList(), e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            BindGrid();
        }
        /// <summary>
        /// Handles the GridReorder event of the gConnectionOpportunities control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs" /> instance containing the event data.</param>
        protected void gConnectionOpportunities_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext             = new RockContext();
            var service                 = new ConnectionOpportunityService(rockContext);
            var connectionOpportunities = service.Queryable().OrderBy(b => b.Order);

            service.Reorder(connectionOpportunities.ToList(), e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            BindConnectionOpportunitiesGrid();
        }
Beispiel #18
0
        /// <summary>
        /// Handles the GridReorder event of the rGridEvent control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        void rGridEvent_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext     = new RockContext();
            var service         = new FollowingEventTypeService(rockContext);
            var followingEvents = service.Queryable().OrderBy(i => i.Order).ToList();

            service.Reorder(followingEvents, e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            BindGrid();
        }
Beispiel #19
0
        private void RGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext      = new RockContext();
            var attributeService = new AttributeService(rockContext);
            var qry = GetData(rockContext);
            var updatedAttributeIds = attributeService.Reorder(qry.ToList(), e.OldIndex, e.NewIndex);

            rockContext.SaveChanges();

            BindGrid();
        }
Beispiel #20
0
        void gBadge_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext = new RockContext();
            var service     = new BadgeService(rockContext);
            var badges      = service.Queryable().OrderBy(b => b.Order);

            service.Reorder(badges.ToList(), e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            BindGrid();
        }
Beispiel #21
0
        /// <summary>
        /// Handles the GridReorder event of the gDocumentTypes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gDocumentTypes_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext         = GetRockContext();
            var documentTypeService = new DocumentTypeService(rockContext);

            var documentTypes = documentTypeService.Queryable().OrderBy(dt => dt.Order).ToList();

            documentTypeService.Reorder(documentTypes, e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            BindGrid();
        }
Beispiel #22
0
        /// <summary>
        /// Handles the GridReorder event of the gPageBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gPageBlocks_GridReorder(object sender, GridReorderEventArgs e)
        {
            BlockService blockService = new BlockService();
            int          pageId       = PageParameter("EditPage").AsInteger() ?? 0;

            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read(pageId);
            string zoneName = this.PageParameter("ZoneName");

            blockService.Reorder(blockService.GetByPageAndZone(page.Id, zoneName).ToList(), e.OldIndex, e.NewIndex, CurrentPersonId);

            BindGrids();
        }
Beispiel #23
0
        /// <summary>
        /// Handles the GridReorder event of the gList control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gList_GridReorder(object sender, GridReorderEventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                NoteTemplateService noteTemplateService = new NoteTemplateService(rockContext);
                var noteTemplates = noteTemplateService.Queryable().OrderBy(nt => nt.Order).ToList();
                noteTemplateService.Reorder(noteTemplates, e.OldIndex, e.NewIndex);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Beispiel #24
0
        /// <summary>
        /// Handles the GridReorder event of the gLinks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        void gLinks_GridReorder(object sender, GridReorderEventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                var service       = new DefinedValueService(rockContext);
                var definedValues = service.Queryable().Where(a => a.DefinedTypeId == _definedType.Id).OrderBy(a => a.Order).ThenBy(a => a.Value);
                var changedIds    = service.Reorder(definedValues.ToList(), e.OldIndex, e.NewIndex);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Beispiel #25
0
        /// <summary>
        /// Handles the GridReorder event of the gBatchList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gBatchList_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext  = new RockContext();
            var batchService = new Rock.Model.FinancialBatchService(rockContext);
            var queryable    = batchService.Queryable();

            List <Rock.Model.FinancialBatch> items = queryable.ToList();

            batchService.Reorder(items, e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();
            BindGrid();
        }
Beispiel #26
0
        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gDefinedValues_GridReorder(object sender, GridReorderEventArgs e)
        {
            int definedTypeId = hfDefinedTypeId.ValueAsInt();

            var rockContext         = new RockContext();
            var definedValueService = new DefinedValueService(rockContext);
            var definedValues       = definedValueService.Queryable().Where(a => a.DefinedTypeId == definedTypeId).OrderBy(a => a.Order).ThenBy(a => a.Value);
            var changedIds          = definedValueService.Reorder(definedValues.ToList(), e.OldIndex, e.NewIndex);

            rockContext.SaveChanges();
            BindDefinedValuesGrid();
        }
Beispiel #27
0
        void rGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            int entityTypeId = iSecured.TypeId;

            List <Rock.Model.Auth> rules = authService.GetAuths(iSecured.TypeId, iSecured.Id, CurrentAction).ToList();

            authService.Reorder(rules, e.OldIndex, e.NewIndex, CurrentPersonId);

            Authorization.ReloadAction(iSecured.TypeId, iSecured.Id, CurrentAction);

            BindGrid();
        }
Beispiel #28
0
        /// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGrid_GridReorder(object sender, GridReorderEventArgs e)
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                var tags = GetTags();
                if (tags != null)
                {
                    new TagService().Reorder(tags.ToList(), e.OldIndex, e.NewIndex, CurrentPersonId);
                }

                BindGrid();
            }
        }
Beispiel #29
0
        /// <summary>
        /// Handles the GridReorder event of the rGridAccounts control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGridAccount_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext = new RockContext();
            var accounts    = GetAccounts(rockContext);

            if (accounts != null)
            {
                new FinancialAccountService(rockContext).Reorder(accounts.ToList(), e.OldIndex, e.NewIndex);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Beispiel #30
0
        /// <summary>
        /// Handles the GridReorder event of the gGroupType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gGroupType_GridReorder(object sender, GridReorderEventArgs e)
        {
            using (new UnitOfWorkScope())
            {
                var groupTypes = GetGroupTypes();
                if (groupTypes != null)
                {
                    new GroupTypeService().Reorder(groupTypes.ToList(), e.OldIndex, e.NewIndex, CurrentPersonId);
                }

                BindGrid();
            }
        }