/// <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 Rock.Web.UI.Controls.RockCheckBoxList {
                    ID = id, RepeatDirection = RepeatDirection.Horizontal
                };
                editControl.AddCssClass("checkboxlist-group");
            }
            else
            {
                editControl = new Rock.Web.UI.Controls.RockDropDownList {
                    ID = id
                };
                editControl.Items.Add(new ListItem());
            }

            if (configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY))
            {
                int definedTypeId = 0;
                if (Int32.TryParse(configurationValues[DEFINED_TYPE_KEY].Value, out definedTypeId))
                {
                    Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService(new RockContext());
                    var definedValues = definedValueService.GetByDefinedTypeId(definedTypeId);
                    if (definedValues.Any())
                    {
                        bool useDescription = configurationValues.ContainsKey(DISPLAY_DESCRIPTION) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean();

                        foreach (var definedValue in definedValues)
                        {
                            editControl.Items.Add(new ListItem(useDescription ? definedValue.Description : definedValue.Value, definedValue.Id.ToString()));
                        }
                    }
                    return(editControl);
                }
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Loads the CheckBox items.
        /// </summary>
        private void LoadCheckBoxItems()
        {
            this.Items.Clear();

            if ( _definedTypeId.HasValue )
            {
                Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService( new RockContext() );
                var definedValues = definedValueService.GetByDefinedTypeId( _definedTypeId.Value );
                if ( definedValues.Any() )
                {
                    foreach ( var definedValue in definedValues )
                    {
                        this.Items.Add( new ListItem( this.DisplayDescriptions ? definedValue.Description : definedValue.Value, definedValue.Id.ToString() ) );
                    }
                }
            }
        }
Beispiel #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 Rock.Web.UI.Controls.RockCheckBoxList { ID = id, RepeatDirection = RepeatDirection.Horizontal };
                editControl.AddCssClass( "checkboxlist-group" );
            }
            else
            {
                editControl = new Rock.Web.UI.Controls.RockDropDownList { ID = id };
                editControl.Items.Add( new ListItem() );
            }

            if ( configurationValues != null && configurationValues.ContainsKey( DEFINED_TYPE_KEY ) )
            {
                int? definedTypeId = configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull();
                if ( definedTypeId.HasValue )
                {
                    Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService( new RockContext() );
                    var definedValues = definedValueService.GetByDefinedTypeId( definedTypeId.Value );
                    if ( definedValues.Any() )
                    {
                        bool useDescription = configurationValues.ContainsKey( DISPLAY_DESCRIPTION ) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean();

                        foreach ( var definedValue in definedValues )
                        {
                            editControl.Items.Add( new ListItem( useDescription ? definedValue.Description : definedValue.Value, definedValue.Id.ToString() ) );
                        }
                    }

                    return editControl;
                }
            }

            return null;
        }