Exemplo n.º 1
0
 /// <summary>
 /// Sets the value.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="configurationValues">The configuration values.</param>
 /// <param name="value">The value.</param>
 public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
 {
     if (value != null)
     {
         GroupPicker groupPicker = control as GroupPicker;
         int         groupId     = 0;
         int.TryParse(value, out groupId);
         Group group = new GroupService().Get(groupId);
         groupPicker.SetValue(group);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field.
        /// IMPORTANT! The order of the controls must match the order/index usage
        /// in the ConfigurationValues and SetConfigurationValues methods.
        /// </summary>
        /// <returns></returns>
        public override List <Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            // Save the selected groupType before we rebind it.
            int?groupId = null;

            if (_gpGroupPicker != null)
            {
                groupId = _gpGroupPicker.SelectedValue.AsIntegerOrNull();

                // store this so we know if the Group actually changes when the SelectedIndexChanged is fired.
                _groupId = groupId;
            }

            // build a group picker (the one that gets selected is
            // used to build a list of groupmember values)
            _gpGroupPicker             = new GroupPicker();
            _gpGroupPicker.Label       = "Group";
            _gpGroupPicker.Help        = "The Group to select the member(s) from.";
            _gpGroupPicker.SelectItem += OnQualifierUpdated;
            if (groupId.HasValue)
            {
                _gpGroupPicker.SetValue(groupId.Value);
            }
            controls.Add(_gpGroupPicker);

            // Add checkbox for deciding if the group member picker list is rendered as a drop
            // down list or a checkbox list.
            var cb = new RockCheckBox();

            controls.Add(cb);
            cb.AutoPostBack    = true;
            cb.CheckedChanged += OnQualifierUpdated;
            cb.Label           = "Allow Multiple Values";
            cb.Text            = "Yes";
            cb.Help            = "When set, allows multiple group members to be selected.";

            // option for Displaying an enhanced 'chosen' value picker
            var cbEnanced = new RockCheckBox();

            controls.Add(cbEnanced);
            cbEnanced.AutoPostBack    = true;
            cbEnanced.CheckedChanged += OnQualifierUpdated;
            cbEnanced.Label           = "Enhance For Long Lists";
            cbEnanced.Text            = "Yes";
            cbEnanced.Help            = "When set, will render a searchable selection of options.";

            return(controls);
        }