/// <summary>
        /// Saves the state of the group type controls to viewstate.
        /// </summary>
        private void SaveGroupTypeControlsToViewState()
        {
            // save all the base grouptypes (along with their children) to viewstate
            var groupTypeList = new List <GroupType>();

            foreach (var checkinGroupTypeEditor in phCheckinGroupTypes.Controls.OfType <CheckinGroupTypeEditor>())
            {
                var groupType = checkinGroupTypeEditor.GetCheckinGroupType();
                groupTypeList.Add(groupType);
            }

            ViewStateList <GroupType> groupTypeViewStateList = new ViewStateList <GroupType>();

            groupTypeViewStateList.AddAll(groupTypeList);

            ViewState["CheckinGroupTypes"] = groupTypeViewStateList;

            // save all the checkinlabels for all the grouptypes (recursively) to viewstate
            GroupTypeCheckinLabelAttributesState = new Dictionary <Guid, List <CheckinGroupTypeEditor.CheckinLabelAttributeInfo> >();
            foreach (var checkinGroupTypeEditor in phCheckinGroupTypes.ControlsOfTypeRecursive <CheckinGroupTypeEditor>().ToList())
            {
                GroupTypeCheckinLabelAttributesState.Add(checkinGroupTypeEditor.GroupTypeGuid, checkinGroupTypeEditor.CheckinLabels);
            }
        }
        /// <summary>
        /// Sorts the workflow activity list contents.
        /// </summary>
        /// <param name="eventParam">The event param.</param>
        /// <param name="values">The values.</param>
        private void SortWorkflowActivityListContents( string eventParam, string[] values )
        {
            // put viewstate list into a new list, shuffle the contents, then save it back to the viewstate list
            // SaveWorkflowActivityControlsToViewState();
            List<WorkflowActivityType> workflowActivityTypeSortList = WorkflowActivityTypesState.ToList();
            Guid? activeWorkflowActivityTypeGuid = null;
            Guid? activeWorkflowActionTypeGuid = null;

            var workflowActivityTypeEditorList = phActivities.Controls.OfType<WorkflowActivityEditor>().ToList();

            if ( eventParam.Equals( "re-order-activity" ) )
            {
                Guid workflowActivityTypeGuid = new Guid( values[0] );
                int newIndex = int.Parse( values[1] );
                WorkflowActivityType workflowActivityType = workflowActivityTypeSortList.FirstOrDefault( a => a.Guid.Equals( workflowActivityTypeGuid ) );
                workflowActivityTypeSortList.RemoveEntity( workflowActivityTypeGuid );
                if ( workflowActivityType != null )
                {
                    if ( newIndex >= workflowActivityTypeSortList.Count() )
                    {
                        workflowActivityTypeSortList.Add( workflowActivityType );
                    }
                    else
                    {
                        workflowActivityTypeSortList.Insert( newIndex, workflowActivityType );
                    }
                }

                int order = 0;
                foreach ( var item in workflowActivityTypeSortList )
                {
                    item.Order = order++;
                }
            }
            else if ( eventParam.Equals( "re-order-action" ) )
            {
                Guid workflowActionTypeGuid = new Guid( values[0] );
                int newIndex = int.Parse( values[1] );
                WorkflowActivityType workflowActivityType = workflowActivityTypeSortList.FirstOrDefault( a => a.ActionTypes.Any( b => b.Guid.Equals( workflowActionTypeGuid ) ) );
                if ( workflowActivityType != null )
                {
                    WorkflowActionType workflowActionType = workflowActivityType.ActionTypes.FirstOrDefault( a => a.Guid.Equals( workflowActionTypeGuid ) );
                    if ( workflowActionType != null )
                    {
                        activeWorkflowActivityTypeGuid = workflowActivityType.Guid;
                        List<WorkflowActionType> workflowActionTypes = workflowActivityType.ActionTypes.ToList();
                        workflowActionTypes.Remove( workflowActionType );
                        if ( newIndex >= workflowActionTypes.Count() )
                        {
                            workflowActionTypes.Add( workflowActionType );
                        }
                        else
                        {
                            workflowActionTypes.Insert( newIndex, workflowActionType );
                        }

                        int order = 0;
                        foreach ( var item in workflowActionTypes )
                        {
                            item.Order = order++;
                        }
                    }
                }
            }
            else if ( eventParam.Equals( "re-order-formfield" ) )
            {
                Guid workflowFormFieldGuid = new Guid( values[0] );
                int newIndex = int.Parse( values[1] );
                WorkflowActivityType workflowActivityType = workflowActivityTypeSortList
                    .FirstOrDefault( a =>
                        a.ActionTypes.Any( b =>
                            b.WorkflowForm != null &&
                            b.WorkflowForm.FormAttributes.Any ( c =>
                                c.Guid.Equals(workflowFormFieldGuid) ) ) );
                if ( workflowActivityType != null )
                {
                    WorkflowActionType workflowActionType = workflowActivityType.ActionTypes
                        .FirstOrDefault( a =>
                            a.WorkflowForm != null &&
                            a.WorkflowForm.FormAttributes != null &&
                            a.WorkflowForm.FormAttributes.Any( b =>
                                b.Guid.Equals( workflowFormFieldGuid ) ) );
                    if ( workflowActionType != null )
                    {
                        WorkflowActionFormAttribute workflowFormAttribute = workflowActionType.WorkflowForm.FormAttributes
                            .Where( a => a.Guid.Equals( workflowFormFieldGuid ) )
                            .FirstOrDefault();
                        if ( workflowFormAttribute != null )
                        {
                            activeWorkflowActivityTypeGuid = workflowActivityType.Guid;
                            activeWorkflowActionTypeGuid = workflowActionType.Guid;

                            List<WorkflowActionFormAttribute> workflowFormAttributes = workflowActionType.WorkflowForm.FormAttributes.ToList();
                            workflowFormAttributes.Remove( workflowFormAttribute );
                            if ( newIndex >= workflowFormAttributes.Count() )
                            {
                                workflowFormAttributes.Add( workflowFormAttribute );
                            }
                            else
                            {
                                workflowFormAttributes.Insert( newIndex, workflowFormAttribute );
                            }

                            int order = 0;
                            foreach ( var item in workflowFormAttributes )
                            {
                                item.Order = order++;
                            }
                        }
                    }
                }
            }

            WorkflowActivityTypesState = new ViewStateList<WorkflowActivityType>();
            WorkflowActivityTypesState.AddAll( workflowActivityTypeSortList );
            BuildWorkflowActivityControlsFromViewState( activeWorkflowActivityTypeGuid, activeWorkflowActionTypeGuid );
        }
        /// <summary>
        /// Sorts the workflow activity list contents.
        /// </summary>
        /// <param name="eventParam">The event param.</param>
        /// <param name="values">The values.</param>
        private void SortWorkflowActivityListContents(string eventParam, string[] values)
        {
            // put viewstate list into a new list, shuffle the contents, then save it back to the viewstate list
            SaveWorkflowActivityControlsToViewState();
            List <WorkflowActivityType> workflowActivityTypeSortList = WorkflowActivityTypesState.ToList();
            Guid?activeWorkflowActivityTypeGuid = null;

            if (eventParam.Equals("re-order-activity"))
            {
                Guid workflowActivityTypeGuid = new Guid(values[0]);
                int  newIndex = int.Parse(values[1]);
                WorkflowActivityType workflowActivityType = workflowActivityTypeSortList.FirstOrDefault(a => a.Guid.Equals(workflowActivityTypeGuid));
                workflowActivityTypeSortList.RemoveEntity(workflowActivityTypeGuid);
                if (workflowActivityType != null)
                {
                    if (newIndex >= workflowActivityTypeSortList.Count())
                    {
                        workflowActivityTypeSortList.Add(workflowActivityType);
                    }
                    else
                    {
                        workflowActivityTypeSortList.Insert(newIndex, workflowActivityType);
                    }
                }

                int order = 0;
                foreach (var item in workflowActivityTypeSortList)
                {
                    item.Order = order++;
                }
            }
            else if (eventParam.Equals("re-order-action"))
            {
                Guid workflowActionTypeGuid = new Guid(values[0]);
                int  newIndex = int.Parse(values[1]);
                WorkflowActivityType workflowActivityType = workflowActivityTypeSortList.FirstOrDefault(a => a.ActionTypes.Any(b => b.Guid.Equals(workflowActionTypeGuid)));
                WorkflowActionType   workflowActionType   = workflowActivityType.ActionTypes.FirstOrDefault(a => a.Guid.Equals(workflowActionTypeGuid));
                workflowActivityTypeSortList.RemoveEntity(workflowActionTypeGuid);
                if (workflowActivityType != null)
                {
                    activeWorkflowActivityTypeGuid = workflowActivityType.Guid;
                    List <WorkflowActionType> workflowActionTypes = workflowActivityType.ActionTypes.ToList();
                    workflowActionTypes.Remove(workflowActionType);
                    if (newIndex >= workflowActionTypes.Count())
                    {
                        workflowActionTypes.Add(workflowActionType);
                    }
                    else
                    {
                        workflowActionTypes.Insert(newIndex, workflowActionType);
                    }

                    int order = 0;
                    foreach (var item in workflowActionTypes)
                    {
                        item.Order = order++;
                    }
                }
            }

            WorkflowActivityTypesState = new ViewStateList <WorkflowActivityType>();
            WorkflowActivityTypesState.AddAll(workflowActivityTypeSortList);
            BuildWorkflowActivityControlsFromViewState(activeWorkflowActivityTypeGuid);
        }
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        private void ShowEditDetails( GroupType groupType )
        {
            hlType.Visible = false;
            if ( groupType.Id == 0 )
            {
                lReadOnlyTitle.Text = ActionTitle.Add( GroupType.FriendlyTypeName ).FormatAsHtmlTitle();
                if ( groupType.GroupTypePurposeValue != null )
                {
                    hlType.Text = groupType.GroupTypePurposeValue.Value;
                    hlType.Visible = true;
                }
            }
            else
            {
                lReadOnlyTitle.Text = groupType.Name.FormatAsHtmlTitle();
            }

            SetEditMode( true );

            var rockContext = new RockContext();

            var groupTypeService = new GroupTypeService( rockContext );
            var attributeService = new AttributeService( rockContext );

            LoadDropDowns( groupType.Id );

            // General
            tbName.ReadOnly = groupType.IsSystem;
            tbName.Text = groupType.Name;

            tbDescription.ReadOnly = groupType.IsSystem;
            tbDescription.Text = groupType.Description;

            tbGroupTerm.ReadOnly = groupType.IsSystem;
            tbGroupTerm.Text = groupType.GroupTerm;

            tbGroupMemberTerm.ReadOnly = groupType.IsSystem;
            tbGroupMemberTerm.Text = groupType.GroupMemberTerm;

            ddlGroupTypePurpose.Enabled = !groupType.IsSystem;
            ddlGroupTypePurpose.SetValue( groupType.GroupTypePurposeValueId );

            ChildGroupTypesDictionary = new Dictionary<int, string>();
            groupType.ChildGroupTypes.ToList().ForEach( a => ChildGroupTypesDictionary.Add( a.Id, a.Name ) );
            BindChildGroupTypesGrid();

            // Display
            cbShowInGroupList.Checked = groupType.ShowInGroupList;
            cbShowInNavigation.Checked = groupType.ShowInNavigation;
            tbIconCssClass.Text = groupType.IconCssClass;

            // Locations
            cbAllowMultipleLocations.Enabled = !groupType.IsSystem;
            cbAllowMultipleLocations.Checked = groupType.AllowMultipleLocations;

            cblScheduleTypes.Enabled = !groupType.IsSystem;
            foreach ( ListItem li in cblScheduleTypes.Items )
            {
                ScheduleType scheduleType = (ScheduleType)li.Value.AsInteger();
                li.Selected = ( groupType.AllowedScheduleTypes & scheduleType ) == scheduleType;
            }

            ScheduleExclusionDictionary = new Dictionary<Guid, DateRange>();
            groupType.GroupScheduleExclusions.ToList().ForEach( s => ScheduleExclusionDictionary.Add( s.Guid, new DateRange( s.StartDate, s.EndDate ) ) );
            BindScheduleExclusionsGrid();

            cblLocationSelectionModes.Enabled = !groupType.IsSystem;
            foreach ( ListItem li in cblLocationSelectionModes.Items )
            {
                GroupLocationPickerMode mode = (GroupLocationPickerMode)li.Value.AsInteger();
                li.Selected = ( groupType.LocationSelectionMode & mode ) == mode;
            }

            LocationTypesDictionary = new Dictionary<int, string>();
            groupType.LocationTypes.ToList().ForEach( a => LocationTypesDictionary.Add( a.LocationTypeValueId, a.LocationTypeValue.Value ) );
            BindLocationTypesGrid();

            // Support Location Schedules
            cbEnableLocationSchedules.Enabled = !groupType.IsSystem;
            cbEnableLocationSchedules.Checked = groupType.EnableLocationSchedules ?? false;

            // Check In
            cbTakesAttendance.Checked = groupType.TakesAttendance;
            cbSendAttendanceReminder.Checked = groupType.SendAttendanceReminder;
            ddlAttendanceRule.SetValue( (int)groupType.AttendanceRule );
            ddlPrintTo.SetValue( (int)groupType.AttendancePrintTo );

            // Attributes
            gtpInheritedGroupType.Enabled = !groupType.IsSystem;
            gtpInheritedGroupType.SelectedGroupTypeId = groupType.InheritedGroupTypeId;

            var groupTypeRoles = new List<GroupTypeRole>();
            foreach ( var role in groupType.Roles )
            {
                role.LoadAttributes();
                groupTypeRoles.Add( role );
            }
            GroupTypeRolesState = new ViewStateList<GroupTypeRole>();
            GroupTypeRolesState.AddAll( groupTypeRoles );

            BindGroupTypeRolesGrid();

            string qualifierValue = groupType.Id.ToString();

            GroupTypeAttributesState = new ViewStateList<Attribute>();
            GroupTypeAttributesState.AddAll( attributeService.GetByEntityTypeId( new GroupType().TypeId ).AsQueryable()
                .Where( a =>
                    a.EntityTypeQualifierColumn.Equals( "Id", StringComparison.OrdinalIgnoreCase ) &&
                    a.EntityTypeQualifierValue.Equals( qualifierValue ) )
                .OrderBy( a => a.Order )
                .ThenBy( a => a.Name )
                .ToList() );
            BindGroupTypeAttributesGrid();

            GroupAttributesState = new ViewStateList<Attribute>();
            GroupAttributesState.AddAll( attributeService.GetByEntityTypeId( new Group().TypeId ).AsQueryable()
                .Where( a =>
                    a.EntityTypeQualifierColumn.Equals( "GroupTypeId", StringComparison.OrdinalIgnoreCase ) &&
                    a.EntityTypeQualifierValue.Equals( qualifierValue ) )
                .OrderBy( a => a.Order )
                .ThenBy( a => a.Name )
                .ToList() );
            BindGroupAttributesGrid();

            GroupMemberAttributesState = new ViewStateList<Attribute>();
            GroupMemberAttributesState.AddAll( attributeService.GetByEntityTypeId( new GroupMember().TypeId ).AsQueryable()
                .Where( a =>
                    a.EntityTypeQualifierColumn.Equals( "GroupTypeId", StringComparison.OrdinalIgnoreCase ) &&
                    a.EntityTypeQualifierValue.Equals( qualifierValue ) )
                .OrderBy( a => a.Order )
                .ThenBy( a => a.Name )
                .ToList() );
            BindGroupMemberAttributesGrid();

            BindInheritedAttributes( groupType.InheritedGroupTypeId, groupTypeService, attributeService );
        }
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowEditDetails(Group group)
        {
            if (group.Id == 0)
            {
                lReadOnlyTitle.Text = ActionTitle.Add(Group.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();
            }

            SetEditMode(true);

            tbName.Text              = group.Name;
            tbDescription.Text       = group.Description;
            cbIsSecurityRole.Checked = group.IsSecurityRole;
            cbIsActive.Checked       = group.IsActive;

            LoadDropDowns();

            GroupMemberAttributesState = new ViewStateList <Attribute>();

            gpParentGroup.SetValue(group.ParentGroup ?? new GroupService().Get(group.ParentGroupId ?? 0));

            // GroupType depends on Selected ParentGroup
            ddlParentGroup_SelectedIndexChanged(null, null);
            gpParentGroup.Label = "Parent Group";

            if (group.Id == 0 && ddlGroupType.Items.Count > 1)
            {
                if (GetAttributeValue("LimittoSecurityRoleGroups").FromTrueFalse())
                {
                    // default GroupType for new Group to "Security Roles"  if LimittoSecurityRoleGroups
                    var securityRoleGroupType = new GroupTypeService().Queryable().FirstOrDefault(a => a.Guid.Equals(new Guid(Rock.SystemGuid.GroupType.GROUPTYPE_SECURITY_ROLE)));
                    if (securityRoleGroupType != null)
                    {
                        ddlGroupType.SetValue(securityRoleGroupType.Id);
                    }
                    else
                    {
                        ddlGroupType.SelectedIndex = 0;
                    }
                }
                else
                {
                    // if this is a new group (and not "LimitToSecurityRoleGroups", and there is more than one choice for GroupType, default to no selection so they are forced to choose (vs unintentionallly choosing the default one)
                    ddlGroupType.SelectedIndex = 0;
                }
            }
            else
            {
                ddlGroupType.SetValue(group.GroupTypeId);
            }

            ddlCampus.SetValue(group.CampusId);

            phGroupTypeAttributes.Controls.Clear();
            GroupType groupType = new GroupTypeService().Get(group.GroupTypeId);

            if (groupType != null)
            {
                groupType.LoadAttributes();
                Rock.Attribute.Helper.AddDisplayControls(groupType, phGroupTypeAttributes);
            }

            phGroupAttributes.Controls.Clear();
            group.LoadAttributes();
            Rock.Attribute.Helper.AddEditControls(group, phGroupAttributes, true);

            // if this block's attribute limit group to SecurityRoleGroups, don't let them edit the SecurityRole checkbox value
            if (GetAttributeValue("LimittoSecurityRoleGroups").FromTrueFalse())
            {
                cbIsSecurityRole.Enabled = false;
                cbIsSecurityRole.Checked = true;
            }

            AttributeService attributeService = new AttributeService();

            string qualifierValue           = group.Id.ToString();
            var    qryGroupMemberAttributes = attributeService.GetByEntityTypeId(new GroupMember().TypeId).AsQueryable()
                                              .Where(a => a.EntityTypeQualifierColumn.Equals("GroupId", StringComparison.OrdinalIgnoreCase) &&
                                                     a.EntityTypeQualifierValue.Equals(qualifierValue));

            GroupMemberAttributesState.AddAll(qryGroupMemberAttributes.ToList());
            BindGroupMemberAttributesGrid();
        }
Esempio n. 6
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="binaryFileTypeId">The binary file type identifier.</param>
        public void ShowDetail(int binaryFileTypeId)
        {
            pnlDetails.Visible = true;
            BinaryFileType binaryFileType = null;

            var rockContext = new RockContext();

            if (!binaryFileTypeId.Equals(0))
            {
                binaryFileType    = new BinaryFileTypeService(rockContext).Get(binaryFileTypeId);
                lActionTitle.Text = ActionTitle.Edit(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (binaryFileType == null)
            {
                binaryFileType = new BinaryFileType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            BinaryFileAttributesState = new ViewStateList <Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text                    = binaryFileType.Name;
            tbDescription.Text             = binaryFileType.Description;
            tbIconCssClass.Text            = binaryFileType.IconCssClass;
            cbAllowCaching.Checked         = binaryFileType.AllowCaching;
            cbRequiresViewSecurity.Checked = binaryFileType.RequiresViewSecurity;

            nbMaxWidth.Text  = binaryFileType.MaxWidth.ToString();
            nbMaxHeight.Text = binaryFileType.MaxHeight.ToString();

            ddlPreferredFormat.BindToEnum <PreferredFormat>();
            ddlPreferredFormat.SetValue((int)binaryFileType.PreferredFormat);

            ddlPreferredResolution.BindToEnum <PreferredResolution>();
            ddlPreferredResolution.SetValue((int)binaryFileType.PreferredResolution);

            ddlPreferredColorDepth.BindToEnum <PreferredColorDepth>();
            ddlPreferredColorDepth.SetValue((int)binaryFileType.PreferredColorDepth);

            cbPreferredRequired.Checked = binaryFileType.PreferredRequired;

            if (binaryFileType.StorageEntityType != null)
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString().ToUpper();
            }

            AttributeService attributeService = new AttributeService(rockContext);

            string qualifierValue          = binaryFileType.Id.ToString();
            var    qryBinaryFileAttributes = attributeService.GetByEntityTypeId(new BinaryFile().TypeId).AsQueryable()
                                             .Where(a => a.EntityTypeQualifierColumn.Equals("BinaryFileTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(qualifierValue));

            BinaryFileAttributesState.AddAll(qryBinaryFileAttributes.ToList());
            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly       = false;
            bool restrictedEdit = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFileType.FriendlyTypeName);
            }

            if (binaryFileType.IsSystem)
            {
                restrictedEdit         = true;
                nbEditModeMessage.Text = EditModeMessage.System(BinaryFileType.FriendlyTypeName);
            }

            phAttributes.Controls.Clear();
            binaryFileType.LoadAttributes();

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
            }

            if (readOnly)
            {
                Rock.Attribute.Helper.AddDisplayControls(binaryFileType, phAttributes);
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls(binaryFileType, phAttributes, true);
            }

            // the only thing we'll restrict for restrictedEdit is the Name (plus they won't be able to remove Attributes that are marked as IsSystem
            tbName.ReadOnly = readOnly || restrictedEdit;

            gBinaryFileAttributes.Enabled = !readOnly;
            gBinaryFileAttributes.Columns.OfType <EditField>().First().Visible = !readOnly;
            gBinaryFileAttributes.Actions.ShowAdd = !readOnly;

            // allow these to be edited in restricted edit mode if not readonly
            tbDescription.ReadOnly         = readOnly;
            tbIconCssClass.ReadOnly        = readOnly;
            cbAllowCaching.Enabled         = !readOnly;
            cbRequiresViewSecurity.Enabled = !readOnly;
            cpStorageType.Enabled          = !readOnly;
            nbMaxWidth.ReadOnly            = readOnly;
            nbMaxHeight.ReadOnly           = readOnly;
            ddlPreferredFormat.Enabled     = !readOnly;
            ddlPreferredResolution.Enabled = !readOnly;
            ddlPreferredColorDepth.Enabled = !readOnly;
            cbPreferredRequired.Enabled    = !readOnly;
            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail( string itemKey, int itemKeyValue )
        {
            if ( !itemKey.Equals( "marketingCampaignAdTypeId" ) )
            {
                return;
            }

            pnlDetails.Visible = true;
            MarketingCampaignAdType marketingCampaignAdType = null;

            var rockContext = new RockContext();

            if ( !itemKeyValue.Equals( 0 ) )
            {
                marketingCampaignAdType = new MarketingCampaignAdTypeService( rockContext ).Get( itemKeyValue );
                lActionTitle.Text = "Ad Type Detail".FormatAsHtmlTitle();
            }
            else
            {
                marketingCampaignAdType = new MarketingCampaignAdType { Id = 0 };
                lActionTitle.Text = "Ad Type Detail".FormatAsHtmlTitle();
            }

            LoadDropDowns();

            // load data into UI controls
            AttributesState = new ViewStateList<Attribute>();

            hfMarketingCampaignAdTypeId.Value = marketingCampaignAdType.Id.ToString();
            tbName.Text = marketingCampaignAdType.Name;
            ddlDateRangeType.SetValue( (int)marketingCampaignAdType.DateRangeType );

            AttributeService attributeService = new AttributeService( rockContext );

            string qualifierValue = marketingCampaignAdType.Id.ToString();
            var qry = attributeService.GetByEntityTypeId( new MarketingCampaignAd().TypeId ).AsQueryable()
                .Where( a => a.EntityTypeQualifierColumn.Equals( "MarketingCampaignAdTypeId", StringComparison.OrdinalIgnoreCase )
                && a.EntityTypeQualifierValue.Equals( qualifierValue ) );

            AttributesState.AddAll( qry.ToList() );
            BindMarketingCampaignAdAttributeTypeGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if ( !IsUserAuthorized( Authorization.EDIT ) )
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( MarketingCampaignAdType.FriendlyTypeName );
            }

            if ( marketingCampaignAdType.IsSystem )
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem( MarketingCampaignAdType.FriendlyTypeName );
            }

            if ( readOnly )
            {
                lActionTitle.Text = ActionTitle.View( MarketingCampaignAdType.FriendlyTypeName );
                btnCancel.Text = "Close";
            }

            tbName.ReadOnly = readOnly;
            ddlDateRangeType.Enabled = !readOnly;
            gMarketingCampaignAdAttributeTypes.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Saves the state of the group type controls to viewstate.
        /// </summary>
        private void SaveGroupTypeControlsToViewState()
        {
            var rockContext = new RockContext();

            // save all the base grouptypes (along with their children) to viewstate
            var groupTypeList = new List<GroupType>();
            foreach ( var checkinGroupTypeEditor in phCheckinGroupTypes.Controls.OfType<CheckinGroupTypeEditor>() )
            {
                var groupType = checkinGroupTypeEditor.GetCheckinGroupType( rockContext );
                groupTypeList.Add( groupType );
            }

            ViewStateList<GroupType> groupTypeViewStateList = new ViewStateList<GroupType>();
            groupTypeViewStateList.AddAll( groupTypeList );
            ViewState["CheckinGroupTypes"] = groupTypeViewStateList;

            // get all GroupTypes' editors to save groups and labels
            var recursiveGroupTypeEditors = phCheckinGroupTypes.ControlsOfTypeRecursive<CheckinGroupTypeEditor>().ToList();

            // save each GroupTypes' Groups to ViewState (since GroupType.Groups are not Serialized)
            var groupTypeGroupsList = new List<Group>();
            foreach ( var editor in recursiveGroupTypeEditors )
            {
                var groupType = editor.GetCheckinGroupType( rockContext );
                groupTypeGroupsList.AddRange( groupType.Groups );
            }

            ViewStateList<Group> checkinGroupTypesGroups = new ViewStateList<Group>();
            checkinGroupTypesGroups.AddAll( groupTypeGroupsList );
            ViewState["CheckinGroupTypesGroups"] = checkinGroupTypesGroups;

            // save all the checkinlabels for all the grouptypes (recursively) to viewstate
            GroupTypeCheckinLabelAttributesState = new Dictionary<Guid, List<CheckinGroupTypeEditor.CheckinLabelAttributeInfo>>();
            foreach ( var checkinGroupTypeEditor in recursiveGroupTypeEditors )
            {
                GroupTypeCheckinLabelAttributesState.Add( checkinGroupTypeEditor.GroupTypeGuid, checkinGroupTypeEditor.CheckinLabels );
            }
        }
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowEditDetails( Group group )
        {
            if ( group.Id == 0 )
            {
                lReadOnlyTitle.Text = ActionTitle.Add( Group.FriendlyTypeName ).FormatAsHtmlTitle();
                hlInactive.Visible = false;
            }
            else
            {
                lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();
            }

            SetEditMode( true );

            tbName.Text = group.Name;
            tbDescription.Text = group.Description;
            cbIsSecurityRole.Checked = group.IsSecurityRole;
            cbIsActive.Checked = group.IsActive;

            var rockContext = new RockContext();

            var groupService = new GroupService( rockContext );
            var attributeService = new AttributeService( rockContext );

            LoadDropDowns();

            gpParentGroup.SetValue( group.ParentGroup ?? groupService.Get( group.ParentGroupId ?? 0 ) );

            // GroupType depends on Selected ParentGroup
            ddlParentGroup_SelectedIndexChanged( null, null );
            gpParentGroup.Label = "Parent Group";

            if ( group.Id == 0 && ddlGroupType.Items.Count > 1 )
            {
                if ( GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean() )
                {
                    // default GroupType for new Group to "Security Roles"  if LimittoSecurityRoleGroups
                    var securityRoleGroupType = GroupTypeCache.GetSecurityRoleGroupType();
                    if ( securityRoleGroupType != null )
                    {
                        ddlGroupType.SetValue( securityRoleGroupType.Id );
                    }
                    else
                    {
                        ddlGroupType.SelectedIndex = 0;
                    }
                }
                else
                {
                    // if this is a new group (and not "LimitToSecurityRoleGroups", and there is more than one choice for GroupType, default to no selection so they are forced to choose (vs unintentionallly choosing the default one)
                    ddlGroupType.SelectedIndex = 0;
                }
            }
            else
            {
                ddlGroupType.SetValue( group.GroupTypeId );
            }

            ddlCampus.SetValue( group.CampusId );

            var groupLocations = new List<GroupLocation>();
            foreach ( var groupLocation in group.GroupLocations )
            {
                var groupLocationState = new GroupLocation();
                groupLocationState.CopyPropertiesFrom( groupLocation );
                if ( groupLocation.Location != null )
                {
                    groupLocationState.Location = new Location();
                    groupLocationState.Location.CopyPropertiesFrom( groupLocation.Location );
                }

                if ( groupLocation.GroupLocationTypeValue != null )
                {
                    groupLocationState.GroupLocationTypeValue = new DefinedValue();
                    groupLocationState.GroupLocationTypeValue.CopyPropertiesFrom( groupLocation.GroupLocationTypeValue );
                }
                groupLocations.Add( groupLocationState );
            }
            GroupLocationsState = new ViewStateList<GroupLocation>();
            GroupLocationsState.AddAll( groupLocations );

            ShowGroupTypeEditDetails( GroupTypeCache.Read( group.GroupTypeId ), group, true );

            // if this block's attribute limit group to SecurityRoleGroups, don't let them edit the SecurityRole checkbox value
            if ( GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean() )
            {
                cbIsSecurityRole.Enabled = false;
                cbIsSecurityRole.Checked = true;
            }

            string qualifierValue = group.Id.ToString();
            GroupMemberAttributesState = new ViewStateList<Attribute>();
            GroupMemberAttributesState.AddAll( attributeService.GetByEntityTypeId( new GroupMember().TypeId ).AsQueryable()
                    .Where( a =>
                        a.EntityTypeQualifierColumn.Equals( "GroupId", StringComparison.OrdinalIgnoreCase ) &&
                        a.EntityTypeQualifierValue.Equals( qualifierValue ) )
                    .OrderBy( a => a.Order )
                    .ThenBy( a => a.Name )
                    .ToList() );
            BindGroupMemberAttributesGrid();

            BindInheritedAttributes( group.GroupTypeId, attributeService );
        }
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("binaryFileTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            BinaryFileType binaryFileType;

            var rockContext = new RockContext();

            if (!itemKeyValue.Equals(0))
            {
                binaryFileType    = new BinaryFileTypeService(rockContext).Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                binaryFileType = new BinaryFileType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            BinaryFileAttributesState = new ViewStateList <Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text                = binaryFileType.Name;
            tbDescription.Text         = binaryFileType.Description;
            tbIconCssClass.Text        = binaryFileType.IconCssClass;
            cbAllowCaching.Checked     = binaryFileType.AllowCaching;
            cbRequiresSecurity.Checked = binaryFileType.RequiresSecurity;

            if (binaryFileType.StorageEntityType != null)
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString().ToUpper();
            }

            AttributeService attributeService = new AttributeService(rockContext);

            string qualifierValue          = binaryFileType.Id.ToString();
            var    qryBinaryFileAttributes = attributeService.GetByEntityTypeId(new BinaryFile().TypeId).AsQueryable()
                                             .Where(a => a.EntityTypeQualifierColumn.Equals("BinaryFileTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(qualifierValue));

            BinaryFileAttributesState.AddAll(qryBinaryFileAttributes.ToList());
            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFileType.FriendlyTypeName);
            }

            if (binaryFileType.IsSystem)
            {
                nbEditModeMessage.Text = EditModeMessage.System(BinaryFileType.FriendlyTypeName);
            }

            phAttributes.Controls.Clear();
            binaryFileType.LoadAttributes();

            if (readOnly || binaryFileType.IsSystem)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(binaryFileType, phAttributes);
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls(binaryFileType, phAttributes, true);
            }

            tbName.ReadOnly               = readOnly || binaryFileType.IsSystem;
            tbDescription.ReadOnly        = readOnly || binaryFileType.IsSystem;
            tbIconCssClass.ReadOnly       = readOnly || binaryFileType.IsSystem;
            cbAllowCaching.Enabled        = !readOnly && !binaryFileType.IsSystem;
            cbRequiresSecurity.Enabled    = !readOnly && !binaryFileType.IsSystem;
            gBinaryFileAttributes.Enabled = !readOnly && !binaryFileType.IsSystem;

            // allow storagetype to be edited if IsSystem
            cpStorageType.Enabled = !readOnly;

            // allow save to be clicked if IsSystem since some things can be edited
            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail( string itemKey, int itemKeyValue )
        {
            if ( !itemKey.Equals( "binaryFileTypeId" ) )
            {
                return;
            }

            pnlDetails.Visible = true;
            BinaryFileType binaryFileType;

            var rockContext = new RockContext();

            if ( !itemKeyValue.Equals( 0 ) )
            {
                binaryFileType = new BinaryFileTypeService( rockContext ).Get( itemKeyValue );
                lActionTitle.Text = ActionTitle.Edit( BinaryFileType.FriendlyTypeName ).FormatAsHtmlTitle();
            }
            else
            {
                binaryFileType = new BinaryFileType { Id = 0 };
                lActionTitle.Text = ActionTitle.Add( BinaryFileType.FriendlyTypeName ).FormatAsHtmlTitle();
            }

            BinaryFileAttributesState = new ViewStateList<Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text = binaryFileType.Name;
            tbDescription.Text = binaryFileType.Description;
            tbIconCssClass.Text = binaryFileType.IconCssClass;
            cbAllowCaching.Checked = binaryFileType.AllowCaching;
            cbRequiresSecurity.Checked = binaryFileType.RequiresSecurity;

            if ( binaryFileType.StorageEntityType != null )
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString().ToUpper();
            }

            AttributeService attributeService = new AttributeService( rockContext );

            string qualifierValue = binaryFileType.Id.ToString();
            var qryBinaryFileAttributes = attributeService.GetByEntityTypeId( new BinaryFile().TypeId ).AsQueryable()
                .Where( a => a.EntityTypeQualifierColumn.Equals( "BinaryFileTypeId", StringComparison.OrdinalIgnoreCase )
                && a.EntityTypeQualifierValue.Equals( qualifierValue ) );

            BinaryFileAttributesState.AddAll( qryBinaryFileAttributes.ToList() );
            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if ( !IsUserAuthorized( Authorization.EDIT ) )
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( BinaryFileType.FriendlyTypeName );
            }

            if ( binaryFileType.IsSystem )
            {
                nbEditModeMessage.Text = EditModeMessage.System( BinaryFileType.FriendlyTypeName );
            }

            phAttributes.Controls.Clear();
            binaryFileType.LoadAttributes();

            if ( readOnly || binaryFileType.IsSystem)
            {
                lActionTitle.Text = ActionTitle.View( BinaryFileType.FriendlyTypeName ).FormatAsHtmlTitle();
                btnCancel.Text = "Close";
                Rock.Attribute.Helper.AddDisplayControls( binaryFileType, phAttributes );
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls( binaryFileType, phAttributes, true );
            }

            tbName.ReadOnly = readOnly || binaryFileType.IsSystem;
            tbDescription.ReadOnly = readOnly || binaryFileType.IsSystem;
            tbIconCssClass.ReadOnly = readOnly || binaryFileType.IsSystem;
            cbAllowCaching.Enabled = !readOnly && !binaryFileType.IsSystem;
            cbRequiresSecurity.Enabled = !readOnly && !binaryFileType.IsSystem;
            gBinaryFileAttributes.Enabled = !readOnly && !binaryFileType.IsSystem;

            // allow storagetype to be edited if IsSystem
            cpStorageType.Enabled = !readOnly;

            // allow save to be clicked if IsSystem since some things can be edited
            btnSave.Visible = !readOnly ;
        }
Esempio n. 12
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("binaryFileTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            BinaryFileType binaryFileType = null;

            if (!itemKeyValue.Equals(0))
            {
                binaryFileType    = new BinaryFileTypeService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(BinaryFileType.FriendlyTypeName);
            }
            else
            {
                binaryFileType = new BinaryFileType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BinaryFileType.FriendlyTypeName);
            }

            BinaryFileAttributesState = new ViewStateList <Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text          = binaryFileType.Name;
            tbDescription.Text   = binaryFileType.Description;
            tbIconCssClass.Text  = binaryFileType.IconCssClass;
            imgIconSmall.ImageId = binaryFileType.IconSmallFileId;
            imgIconLarge.ImageId = binaryFileType.IconLargeFileId;

            if (binaryFileType.StorageEntityType != null)
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString();
            }

            AttributeService attributeService = new AttributeService();

            string qualifierValue          = binaryFileType.Id.ToString();
            var    qryBinaryFileAttributes = attributeService.GetByEntityTypeId(new BinaryFile().TypeId).AsQueryable()
                                             .Where(a => a.EntityTypeQualifierColumn.Equals("BinaryFileTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(qualifierValue));

            BinaryFileAttributesState.AddAll(qryBinaryFileAttributes.ToList());
            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFileType.FriendlyTypeName);
            }

            if (binaryFileType.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(BinaryFileType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFileType.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            tbIconCssClass.ReadOnly       = readOnly;
            imgIconLarge.Enabled          = !readOnly;
            imgIconSmall.Enabled          = !readOnly;
            gBinaryFileAttributes.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
Esempio n. 13
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("groupTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            GroupType groupType = null;

            using (new UnitOfWorkScope())
            {
                var groupTypeService = new GroupTypeService();
                var attributeService = new AttributeService();

                if (!itemKeyValue.Equals(0))
                {
                    groupType         = groupTypeService.Get(itemKeyValue);
                    lActionTitle.Text = ActionTitle.Edit(GroupType.FriendlyTypeName);
                }
                else
                {
                    groupType = new GroupType {
                        Id = 0, ShowInGroupList = true
                    };
                    groupType.ChildGroupTypes = new List <GroupType>();
                    groupType.LocationTypes   = new List <GroupTypeLocationType>();
                    lActionTitle.Text         = ActionTitle.Add(GroupType.FriendlyTypeName);
                }

                LoadDropDowns(groupType.Id);

                ChildGroupTypesDictionary = new Dictionary <int, string>();
                LocationTypesDictionary   = new Dictionary <int, string>();
                GroupTypeAttributesState  = new ViewStateList <Attribute>();
                GroupAttributesState      = new ViewStateList <Attribute>();

                hfGroupTypeId.Value    = groupType.Id.ToString();
                tbName.Text            = groupType.Name;
                tbDescription.Text     = groupType.Description;
                tbGroupTerm.Text       = groupType.GroupTerm;
                tbGroupMemberTerm.Text = groupType.GroupMemberTerm;
                ddlDefaultGroupRole.SetValue(groupType.DefaultGroupRoleId);
                cbShowInGroupList.Checked  = groupType.ShowInGroupList;
                cbShowInNavigation.Checked = groupType.ShowInNavigation;
                tbIconCssClass.Text        = groupType.IconCssClass;
                imgIconSmall.BinaryFileId  = groupType.IconSmallFileId;
                imgIconLarge.BinaryFileId  = groupType.IconLargeFileId;

                cbTakesAttendance.Checked = groupType.TakesAttendance;
                ddlAttendanceRule.SetValue((int)groupType.AttendanceRule);
                ddlAttendancePrintTo.SetValue((int)groupType.AttendancePrintTo);
                ddlLocationSelectionMode.SetValue((int)groupType.LocationSelectionMode);
                ddlGroupTypePurpose.SetValue(groupType.GroupTypePurposeValueId);
                cbAllowMultipleLocations.Checked          = groupType.AllowMultipleLocations;
                gtpInheritedGroupType.SelectedGroupTypeId = groupType.InheritedGroupTypeId;
                groupType.ChildGroupTypes.ToList().ForEach(a => ChildGroupTypesDictionary.Add(a.Id, a.Name));
                groupType.LocationTypes.ToList().ForEach(a => LocationTypesDictionary.Add(a.LocationTypeValueId, a.LocationTypeValue.Name));

                string qualifierValue         = groupType.Id.ToString();
                var    qryGroupTypeAttributes = attributeService.GetByEntityTypeId(new GroupType().TypeId).AsQueryable()
                                                .Where(a =>
                                                       a.EntityTypeQualifierColumn.Equals("Id", StringComparison.OrdinalIgnoreCase) &&
                                                       a.EntityTypeQualifierValue.Equals(qualifierValue));

                var qryGroupAttributes = attributeService.GetByEntityTypeId(new Group().TypeId).AsQueryable()
                                         .Where(a =>
                                                a.EntityTypeQualifierColumn.Equals("GroupTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                a.EntityTypeQualifierValue.Equals(qualifierValue));

                GroupTypeAttributesState.AddAll(qryGroupTypeAttributes
                                                .OrderBy(a => a.Order)
                                                .ThenBy(a => a.Name)
                                                .ToList());

                GroupAttributesState.AddAll(qryGroupAttributes
                                            .OrderBy(a => a.Order)
                                            .ThenBy(a => a.Name)
                                            .ToList());

                if (groupType.InheritedGroupTypeId.HasValue)
                {
                    RebuildAttributeLists(groupType.InheritedGroupTypeId, groupTypeService, attributeService, false);
                }
            }

            BindGroupTypeAttributesGrid();
            BindGroupAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(GroupType.FriendlyTypeName);
            }

            if (groupType.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(GroupType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(GroupType.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            ddlDefaultGroupRole.Enabled      = !readOnly;
            tbName.ReadOnly                  = readOnly;
            tbDescription.ReadOnly           = readOnly;
            tbGroupTerm.ReadOnly             = readOnly;
            tbGroupMemberTerm.ReadOnly       = readOnly;
            cbShowInGroupList.Enabled        = !readOnly;
            cbShowInNavigation.Enabled       = !readOnly;
            tbIconCssClass.ReadOnly          = readOnly;
            imgIconLarge.Enabled             = !readOnly;
            imgIconSmall.Enabled             = !readOnly;
            cbTakesAttendance.Enabled        = !readOnly;
            ddlAttendanceRule.Enabled        = !readOnly;
            ddlAttendancePrintTo.Enabled     = !readOnly;
            ddlLocationSelectionMode.Enabled = !readOnly;
            ddlGroupTypePurpose.Enabled      = !readOnly;
            cbAllowMultipleLocations.Enabled = !readOnly;
            gtpInheritedGroupType.Enabled    = !readOnly;
            gGroupTypeAttributes.Enabled     = !readOnly;
            gGroupAttributes.Enabled         = !readOnly;

            gChildGroupTypes.Enabled = !readOnly;
            gLocationTypes.Enabled   = !readOnly;
            btnSave.Visible          = !readOnly;

            BindChildGroupTypesGrid();
            BindLocationTypesGrid();
        }
Esempio n. 14
0
        /// <summary>
        /// Saves the state of the group type controls to viewstate.
        /// </summary>
        private void SaveGroupTypeControlsToViewState()
        {
            // save all the base grouptypes (along with their children) to viewstate
            var groupTypeList = new List<GroupType>();
            foreach ( var checkinGroupTypeEditor in phCheckinGroupTypes.Controls.OfType<CheckinGroupTypeEditor>() )
            {
                var groupType = checkinGroupTypeEditor.GetCheckinGroupType();
                groupTypeList.Add( groupType );
            }

            ViewStateList<GroupType> groupTypeViewStateList = new ViewStateList<GroupType>();
            groupTypeViewStateList.AddAll( groupTypeList );

            ViewState["CheckinGroupTypes"] = groupTypeViewStateList;

            // save all the checkinlabels for all the grouptypes (recursively) to viewstate
            GroupTypeCheckinLabelAttributesState = new Dictionary<Guid, List<CheckinGroupTypeEditor.CheckinLabelAttributeInfo>>();
            foreach ( var checkinGroupTypeEditor in phCheckinGroupTypes.ControlsOfTypeRecursive<CheckinGroupTypeEditor>().ToList() )
            {
                GroupTypeCheckinLabelAttributesState.Add( checkinGroupTypeEditor.GroupTypeGuid, checkinGroupTypeEditor.CheckinLabels );
            }
        }
        /// <summary>
        /// Saves the state of the workflow activity controls to view.
        /// </summary>
        private void SaveWorkflowActivityControlsToViewState()
        {
            var activityTypes = new List<WorkflowActivityType>();
            int order = 0;
            foreach ( var activityEditor in phActivities.Controls.OfType<WorkflowActivityEditor>() )
            {
                WorkflowActivityType workflowActivityType = activityEditor.GetWorkflowActivityType();
                workflowActivityType.Order = order++;
                activityTypes.Add( workflowActivityType );
            }

            WorkflowActivityTypesState = new ViewStateList<WorkflowActivityType>();
            WorkflowActivityTypesState.AddAll( activityTypes );
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("marketingCampaignAdTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            MarketingCampaignAdType marketingCampaignAdType = null;

            if (!itemKeyValue.Equals(0))
            {
                marketingCampaignAdType = new MarketingCampaignAdTypeService().Get(itemKeyValue);
                lActionTitle.Text       = ActionTitle.Edit(MarketingCampaignAdType.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                marketingCampaignAdType = new MarketingCampaignAdType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(MarketingCampaignAdType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            LoadDropDowns();

            // load data into UI controls
            AttributesState = new ViewStateList <Attribute>();

            hfMarketingCampaignAdTypeId.Value = marketingCampaignAdType.Id.ToString();
            tbName.Text = marketingCampaignAdType.Name;
            ddlDateRangeType.SetValue((int)marketingCampaignAdType.DateRangeType);

            AttributeService attributeService = new AttributeService();

            string qualifierValue = marketingCampaignAdType.Id.ToString();
            var    qry            = attributeService.GetByEntityTypeId(new MarketingCampaignAd().TypeId).AsQueryable()
                                    .Where(a => a.EntityTypeQualifierColumn.Equals("MarketingCampaignAdTypeId", StringComparison.OrdinalIgnoreCase) &&
                                           a.EntityTypeQualifierValue.Equals(qualifierValue));

            AttributesState.AddAll(qry.ToList());
            BindMarketingCampaignAdAttributeTypeGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(MarketingCampaignAdType.FriendlyTypeName);
            }

            if (marketingCampaignAdType.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(MarketingCampaignAdType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(MarketingCampaignAdType.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly          = readOnly;
            ddlDateRangeType.Enabled = !readOnly;
            gMarketingCampaignAdAttributeTypes.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="workflowType">Type of the workflow.</param>
        private void ShowEditDetails( WorkflowType workflowType, RockContext rockContext )
        {
            if ( workflowType.Id == 0 )
            {
                lReadOnlyTitle.Text = ActionTitle.Add( WorkflowType.FriendlyTypeName ).FormatAsHtmlTitle();
                hlInactive.Visible = false;
            }

            SetEditMode( true );

            LoadDropDowns();

            tbName.Text = workflowType.Name;
            tbDescription.Text = workflowType.Description;
            cbIsActive.Checked = workflowType.IsActive ?? false;
            cpCategory.SetValue( workflowType.CategoryId );
            tbWorkTerm.Text = workflowType.WorkTerm;
            tbProcessingInterval.Text = workflowType.ProcessingIntervalSeconds != null ? workflowType.ProcessingIntervalSeconds.ToString() : string.Empty;
            cbIsPersisted.Checked = workflowType.IsPersisted;
            ddlLoggingLevel.SetValue( (int)workflowType.LoggingLevel );

            var attributeService = new AttributeService( rockContext );
            AttributesState = new ViewStateList<Attribute>();
            AttributesState.AddAll( attributeService.GetByEntityTypeId( new Workflow().TypeId ).AsQueryable()
                .Where( a =>
                    a.EntityTypeQualifierColumn.Equals( "WorkflowTypeId", StringComparison.OrdinalIgnoreCase ) &&
                    a.EntityTypeQualifierValue.Equals( workflowType.Id.ToString() ) )
                .OrderBy( a => a.Order )
                .ThenBy( a => a.Name )
                .ToList() );
            BindAttributesGrid();

            phActivities.Controls.Clear();
            foreach ( WorkflowActivityType workflowActivityType in workflowType.ActivityTypes.OrderBy( a => a.Order ) )
            {
                CreateWorkflowActivityTypeEditorControls( workflowActivityType );
            }

            RefreshActivityLists();
        }
Esempio n. 18
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="binaryFileTypeId">The binary file type identifier.</param>
        public void ShowDetail( int binaryFileTypeId )
        {
            pnlDetails.Visible = true;
            BinaryFileType binaryFileType = null;

            var rockContext = new RockContext();

            if ( !binaryFileTypeId.Equals( 0 ) )
            {
                binaryFileType = new BinaryFileTypeService( rockContext ).Get( binaryFileTypeId );
                lActionTitle.Text = ActionTitle.Edit( BinaryFileType.FriendlyTypeName ).FormatAsHtmlTitle();
            }

            if ( binaryFileType == null )
            {
                binaryFileType = new BinaryFileType { Id = 0 };
                lActionTitle.Text = ActionTitle.Add( BinaryFileType.FriendlyTypeName ).FormatAsHtmlTitle();
            }

            BinaryFileAttributesState = new ViewStateList<Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text = binaryFileType.Name;
            tbDescription.Text = binaryFileType.Description;
            tbIconCssClass.Text = binaryFileType.IconCssClass;
            cbAllowCaching.Checked = binaryFileType.AllowCaching;
            cbRequiresViewSecurity.Checked = binaryFileType.RequiresViewSecurity;

            nbMaxWidth.Text = binaryFileType.MaxWidth.ToString();
            nbMaxHeight.Text = binaryFileType.MaxHeight.ToString();

            ddlPreferredFormat.BindToEnum<Format>();
            ddlPreferredFormat.SetValue( (int)binaryFileType.PreferredFormat );

            ddlPreferredResolution.BindToEnum<Resolution>();
            ddlPreferredResolution.SetValue( (int)binaryFileType.PreferredResolution );

            ddlPreferredColorDepth.BindToEnum<ColorDepth>();
            ddlPreferredColorDepth.SetValue( (int)binaryFileType.PreferredColorDepth );

            cbPreferredRequired.Checked = binaryFileType.PreferredRequired;

            if ( binaryFileType.StorageEntityType != null )
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString().ToUpper();
            }

            AttributeService attributeService = new AttributeService( rockContext );

            string qualifierValue = binaryFileType.Id.ToString();
            var qryBinaryFileAttributes = attributeService.GetByEntityTypeId( new BinaryFile().TypeId ).AsQueryable()
                .Where( a => a.EntityTypeQualifierColumn.Equals( "BinaryFileTypeId", StringComparison.OrdinalIgnoreCase )
                && a.EntityTypeQualifierValue.Equals( qualifierValue ) );

            BinaryFileAttributesState.AddAll( qryBinaryFileAttributes.ToList() );
            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;
            bool restrictedEdit = false;

            nbEditModeMessage.Text = string.Empty;
            if ( !IsUserAuthorized( Authorization.EDIT ) )
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( BinaryFileType.FriendlyTypeName );
            }

            if ( binaryFileType.IsSystem )
            {
                restrictedEdit = true;
                nbEditModeMessage.Text = EditModeMessage.System( BinaryFileType.FriendlyTypeName );
            }

            phAttributes.Controls.Clear();
            binaryFileType.LoadAttributes();

            if ( readOnly )
            {
                lActionTitle.Text = ActionTitle.View( BinaryFileType.FriendlyTypeName ).FormatAsHtmlTitle();
                btnCancel.Text = "Close";
            }

            if ( readOnly )
            {
                Rock.Attribute.Helper.AddDisplayControls( binaryFileType, phAttributes );
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls( binaryFileType, phAttributes, true, BlockValidationGroup );
            }

            // the only thing we'll restrict for restrictedEdit is the Name (plus they won't be able to remove Attributes that are marked as IsSystem
            tbName.ReadOnly = readOnly || restrictedEdit;

            gBinaryFileAttributes.Enabled = !readOnly;
            gBinaryFileAttributes.Columns.OfType<EditField>().First().Visible = !readOnly;
            gBinaryFileAttributes.Actions.ShowAdd = !readOnly;

            // allow these to be edited in restricted edit mode if not readonly
            tbDescription.ReadOnly = readOnly;
            tbIconCssClass.ReadOnly = readOnly;
            cbAllowCaching.Enabled = !readOnly;
            cbRequiresViewSecurity.Enabled = !readOnly;
            cpStorageType.Enabled = !readOnly;
            nbMaxWidth.ReadOnly = readOnly;
            nbMaxHeight.ReadOnly = readOnly;
            ddlPreferredFormat.Enabled = !readOnly;
            ddlPreferredResolution.Enabled = !readOnly;
            ddlPreferredColorDepth.Enabled = !readOnly;
            cbPreferredRequired.Enabled = !readOnly;
            btnSave.Visible = !readOnly;
        }