Пример #1
0
        /// <summary>
        /// Creates the control(s) neccessary 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
                };
                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();
                    foreach (var definedValue in definedValueService.GetByDefinedTypeId(definedTypeId))
                    {
                        editControl.Items.Add(new ListItem(definedValue.Name, definedValue.Id.ToString()));
                    }
                }
            }

            return(editControl);
        }
Пример #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()));
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Creates the control(s) neccessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues)
        {
            ListControl editControl = new DropDownList();

            if (configurationValues != null && configurationValues.ContainsKey("definedtype"))
            {
                int definedTypeId = 0;
                if (Int32.TryParse(configurationValues["definedtype"].Value, out definedTypeId))
                {
                    Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService();
                    foreach (var definedValue in definedValueService.GetByDefinedTypeId(definedTypeId))
                    {
                        editControl.Items.Add(new ListItem(definedValue.Name, definedValue.Id.ToString()));
                    }
                }
            }
            return(editControl);
        }
Пример #4
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);
        }
Пример #5
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() ) );
                    }
                }
            }
        }
Пример #6
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;
        }