コード例 #1
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            ListControl editControl;

            if (configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean())
            {
                editControl = new RockListBox {
                    ID = id
                };
                editControl.AddCssClass("checkboxlist-group");
            }
            else
            {
                editControl = new RockDropDownList {
                    ID = id, EnhanceForLongLists = true
                };
                editControl.Items.Add(new ListItem());
            }

            if (configurationValues != null && configurationValues.ContainsKey(ENTITY_TYPE_KEY))
            {
                Guid?entityTypeGuid = configurationValues[ENTITY_TYPE_KEY].Value.AsGuidOrNull();
                if (entityTypeGuid.HasValue)
                {
                    var entityType = EntityTypeCache.Get(entityTypeGuid.Value);
                    if (entityType != null)
                    {
                        Rock.Model.AttributeService       attributeService = new Model.AttributeService(new RockContext());
                        IQueryable <Rock.Model.Attribute> attributeQuery;
                        if (configurationValues.ContainsKey(QUALIFIER_COLUMN_KEY) && configurationValues.ContainsKey(QUALIFIER_VALUE_KEY))
                        {
                            attributeQuery = attributeService
                                             .GetByEntityTypeQualifier(entityType.Id, configurationValues[QUALIFIER_COLUMN_KEY].Value, configurationValues[QUALIFIER_VALUE_KEY].Value, true);
                        }
                        else
                        {
                            attributeQuery = attributeService.GetByEntityTypeId(entityType.Id, true);
                        }

                        List <AttributeCache> attributeList = attributeQuery.ToAttributeCacheList();

                        if (attributeList.Any())
                        {
                            foreach (var attribute in attributeList.OrderBy(a => a.Name))
                            {
                                editControl.Items.Add(new ListItem(attribute.Name, attribute.Id.ToString(), attribute.IsActive));
                            }
                        }
                        return(editControl);
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            ListControl editControl;

            if (configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean())
            {
                editControl = new RockCheckBoxList {
                    ID = id
                };
                editControl.AddCssClass("checkboxlist-group");
            }
            else
            {
                editControl = new RockDropDownList {
                    ID = id
                };
                editControl.Items.Add(new ListItem());
            }

            if (configurationValues != null && configurationValues.ContainsKey(ENTITY_TYPE_KEY))
            {
                Guid?entityTypeGuid = configurationValues[ENTITY_TYPE_KEY].Value.AsGuidOrNull();
                if (entityTypeGuid.HasValue)
                {
                    var entityType = EntityTypeCache.Read(entityTypeGuid.Value);
                    if (entityType != null)
                    {
                        Rock.Model.AttributeService attributeService = new Model.AttributeService(new RockContext());
                        var attributes = attributeService.GetByEntityTypeId(entityType.Id);
                        if (attributes.Any())
                        {
                            foreach (var attribute in attributes.OrderBy(a => a.Name))
                            {
                                editControl.Items.Add(new ListItem(attribute.Name, attribute.Id.ToString()));
                            }
                        }
                        return(editControl);
                    }
                }
            }

            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            ListControl editControl;

            if ( configurationValues != null && configurationValues.ContainsKey( ALLOW_MULTIPLE_KEY ) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean() )
            {
                editControl = new RockCheckBoxList { ID = id };
                editControl.AddCssClass( "checkboxlist-group" );
            }
            else
            {
                editControl = new RockDropDownList { ID = id };
                editControl.Items.Add( new ListItem() );
            }

            if ( configurationValues != null && configurationValues.ContainsKey( ENTITY_TYPE_KEY ) )
            {
                Guid? entityTypeGuid = configurationValues[ENTITY_TYPE_KEY].Value.AsGuidOrNull();
                if ( entityTypeGuid.HasValue )
                {
                    var entityType = EntityTypeCache.Read( entityTypeGuid.Value );
                    if ( entityType != null )
                    {
                        Rock.Model.AttributeService attributeService = new Model.AttributeService( new RockContext() );
                        var attributes = attributeService.GetByEntityTypeId( entityType.Id );
                        if ( attributes.Any() )
                        {
                            foreach ( var attribute in attributes.OrderBy( a => a.Name ) )
                            {
                                editControl.Items.Add( new ListItem( attribute.Name, attribute.Id.ToString() ) );
                            }
                        }
                        return editControl;
                    }
                }
            }

            return null;
        }