Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Email" /> class.
        /// </summary>
        public Sms()
        {
            ddlFrom = new RockDropDownList();
            ddlFrom.BindToDefinedType( DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.COMMUNICATION_SMS_FROM ) ) );

            tbTextMessage = new RockTextBox();
        }
Beispiel #2
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 = null;

            if (configurationValues != null)
            {
                if (configurationValues.ContainsKey("fieldtype") && configurationValues["fieldtype"].Value == "rb")
                {
                    editControl = new RockRadioButtonList {
                        ID = id
                    };
                    ((RadioButtonList)editControl).RepeatDirection = RepeatDirection.Horizontal;
                }
                else
                {
                    editControl = new RockDropDownList {
                        ID = id
                    };
                }

                if (configurationValues.ContainsKey("values"))
                {
                    string listSource = configurationValues["values"].Value;

                    if (listSource.ToUpper().Contains("SELECT") && listSource.ToUpper().Contains("FROM"))
                    {
                        var       tableValues = new List <string>();
                        DataTable dataTable   = new Rock.Data.Service().GetDataTable(listSource, CommandType.Text, null);
                        if (dataTable != null && dataTable.Columns.Contains("Value") && dataTable.Columns.Contains("Text"))
                        {
                            foreach (DataRow row in dataTable.Rows)
                            {
                                editControl.Items.Add(new ListItem(row["text"].ToString(), row["value"].ToString()));
                            }
                        }
                    }

                    else
                    {
                        foreach (string keyvalue in listSource.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            var keyValueArray = keyvalue.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                            if (keyValueArray.Length > 0)
                            {
                                ListItem li = new ListItem();
                                li.Value = keyValueArray[0];
                                li.Text  = keyValueArray.Length > 1 ? keyValueArray[1] : keyValueArray[0];
                                editControl.Items.Add(li);
                            }
                        }
                    }
                }
            }

            return(editControl);
        }
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var controls = new List <Control>();

            // Add the registration template picker
            int?selectedTemplateId = null;

            if (_ddlRegistrationTemplate != null)
            {
                selectedTemplateId = _ddlRegistrationTemplate.SelectedValueAsId();
            }

            _ddlRegistrationTemplate                = new RockDropDownList();
            _ddlRegistrationTemplate.CssClass       = "js-registration-template";
            _ddlRegistrationTemplate.ID             = filterControl.ID + "_ddlRegistrationTemplate";
            _ddlRegistrationTemplate.Label          = "Registration Template";
            _ddlRegistrationTemplate.DataTextField  = "Name";
            _ddlRegistrationTemplate.DataValueField = "Id";
            _ddlRegistrationTemplate.DataSource     = new RegistrationTemplateService(new RockContext()).Queryable()
                                                      .OrderBy(a => a.Name)
                                                      .Select(d => new
            {
                d.Id,
                d.Name
            })
                                                      .ToList();
            _ddlRegistrationTemplate.DataBind();
            _ddlRegistrationTemplate.SelectedIndexChanged += ddlRegistrationTemplate_SelectedIndexChanged;
            _ddlRegistrationTemplate.AutoPostBack          = true;
            _ddlRegistrationTemplate.SelectedValue         = selectedTemplateId.ToStringSafe();
            filterControl.Controls.Add(_ddlRegistrationTemplate);

            // Now add the registration instance picker
            _ddlRegistrationInstance          = new RockDropDownList();
            _ddlRegistrationInstance.CssClass = "js-registration-instance";
            _ddlRegistrationInstance.Label    = "Registration Instance";
            _ddlRegistrationInstance.ID       = filterControl.ID + "_ddlRegistrationInstance";
            filterControl.Controls.Add(_ddlRegistrationInstance);

            PopulateRegistrationInstanceList(_ddlRegistrationTemplate.SelectedValueAsId() ?? 0);

            _rblRegistrationType                 = new RockRadioButtonList();
            _rblRegistrationType.CssClass        = "js-registration-type";
            _rblRegistrationType.ID              = filterControl.ID + "_registrationType";
            _rblRegistrationType.RepeatDirection = RepeatDirection.Horizontal;
            _rblRegistrationType.Label           = "Person";
            _rblRegistrationType.Help            = "Choose whether to filter by the person who did the registering (registrar) or the person who was registered (registrant).";
            _rblRegistrationType.Items.Add(new ListItem("Registrar", "1"));
            _rblRegistrationType.Items.Add(new ListItem("Registrant", "2"));
            _rblRegistrationType.SelectedValue = "2";
            filterControl.Controls.Add(_rblRegistrationType);

            return(new Control[3] {
                _ddlRegistrationTemplate, _ddlRegistrationInstance, _rblRegistrationType
            });
        }
Beispiel #4
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override System.Collections.Generic.List <System.Web.UI.Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            var tbDateFormat = new RockTextBox();

            controls.Add(tbDateFormat);
            tbDateFormat.Label = "Date Format";
            tbDateFormat.Help  = "The format string to use for date (default is system short date).";

            var cbDisplayDiff = new RockCheckBox();

            controls.Add(cbDisplayDiff);
            cbDisplayDiff.Label = "Display as Elapsed Time";
            cbDisplayDiff.Text  = "Yes";
            cbDisplayDiff.Help  = "Display value as an elapsed time.";

            var ddlDatePickerMode = new RockDropDownList();

            controls.Add(ddlDatePickerMode);
            ddlDatePickerMode.Items.Clear();
            ddlDatePickerMode.Items.Add(new ListItem("Date Picker", DatePickerControlType.DatePicker.ConvertToString()));
            ddlDatePickerMode.Items.Add(new ListItem("Date Parts Picker", DatePickerControlType.DatePartsPicker.ConvertToString()));
            ddlDatePickerMode.Label                 = "Control Type";
            ddlDatePickerMode.Help                  = "Select 'Date Picker' to use a DatePicker, or 'Date Parts Picker' to select Month, Day and Year individually";
            ddlDatePickerMode.AutoPostBack          = true;
            ddlDatePickerMode.SelectedIndexChanged += OnQualifierUpdated;

            var cbDisplayCurrent = new RockCheckBox();

            controls.Add(cbDisplayCurrent);
            cbDisplayCurrent.AutoPostBack    = true;
            cbDisplayCurrent.CheckedChanged += OnQualifierUpdated;
            cbDisplayCurrent.Label           = "Display Current Option";
            cbDisplayCurrent.Text            = "Yes";
            cbDisplayCurrent.Help            = "Include option to specify value as the current date.";

            var nbFutureYearCount = new NumberBox();

            controls.Add(nbFutureYearCount);
            nbFutureYearCount.Label = "Future Years";
            nbFutureYearCount.Text  = "";
            nbFutureYearCount.Help  = "The number of years in the future in include the year picker. Set to 0 to limit to current year. Leaving it blank will default to 50.";

            // if this is the child type of DateTimeFieldType, change the labels and visibility of the controls as needed
            if (this is DateTimeFieldType)
            {
                tbDateFormat.Label        = "Date Time Format";
                tbDateFormat.Help         = "The format string to use for date (default is system short date and time).";
                ddlDatePickerMode.Visible = false;
                nbFutureYearCount.Visible = false;
                cbDisplayCurrent.Help     = "Include option to specify value as the current time.";
            }

            return(controls);
        }
Beispiel #5
0
        /// <summary>
        /// Binds the role dropdown list.
        /// </summary>
        /// <param name="rockDropdownList">The rock dropdown list.</param>
        private void BindRoleDropdownList(RockDropDownList rockDropdownList)
        {
            rockDropdownList.Items.Clear();

            foreach (var role in RoleCache.AllRoles())
            {
                string name = role.IsSecurityTypeGroup ? role.Name : "GROUP - " + role.Name;
                rockDropdownList.Items.Add(new ListItem(name, role.Id.ToString()));
            }
        }
Beispiel #6
0
        /// <summary>
        /// Gets the selection.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <returns></returns>
        public override string GetSelection(Type entityType, Control[] controls)
        {
            if (controls.Count() >= 1)
            {
                RockDropDownList ddlSignalType = controls[0] as RockDropDownList;
                return(ddlSignalType.SelectedValue);
            }

            return(string.Empty);
        }
Beispiel #7
0
        /// <summary>
        /// Gets the selection.
        /// </summary>
        /// <param name="controls">The controls.</param>
        /// <returns></returns>
        public override string GetSelection(System.Web.UI.Control[] controls)
        {
            if (controls.Count() >= 0)
            {
                RockDropDownList ddlNoteType = controls[0] as RockDropDownList;
                return(string.Format("{0}", ddlNoteType.SelectedValue));
            }

            return(string.Empty);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            ddlInteractionChannel                       = new RockDropDownList();
            ddlInteractionChannel.ID                    = filterControl.ID + "_ddlInteractionChannel";
            ddlInteractionChannel.Label                 = "Interaction Channel";
            ddlInteractionChannel.CssClass              = "js-interaction-channel";
            ddlInteractionChannel.Required              = true;
            ddlInteractionChannel.AutoPostBack          = true;
            ddlInteractionChannel.EnhanceForLongLists   = true;
            ddlInteractionChannel.SelectedIndexChanged += ddlInteractionChannel_SelectedIndexChanged;
            filterControl.Controls.Add(ddlInteractionChannel);

            var interactionChannelService = new InteractionChannelService(new RockContext());
            var interactionChannels       = interactionChannelService.Queryable().OrderBy(a => a.Name).Select(a => new
            {
                a.Id,
                a.Name
            }).ToList();

            ddlInteractionChannel.Items.Clear();
            ddlInteractionChannel.Items.Add(new ListItem());
            ddlInteractionChannel.Items.AddRange(interactionChannels.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray());

            int?selectedInteractionChannelId = filterControl.Page.Request.Params[ddlInteractionChannel.UniqueID].AsIntegerOrNull();

            ddlInteractionChannel.SetValue(selectedInteractionChannelId);

            ddlInteractionComponent                     = new RockDropDownList();
            ddlInteractionComponent.ID                  = filterControl.ID + "_ddlInteractionComponent";
            ddlInteractionComponent.Label               = "Interaction Component";
            ddlInteractionComponent.CssClass            = "js-interaction-component";
            ddlInteractionComponent.EnhanceForLongLists = true;
            filterControl.Controls.Add(ddlInteractionComponent);

            PopulateInteractionComponent(selectedInteractionChannelId, ddlInteractionComponent);

            RockTextBox tbOperation = new RockTextBox();

            tbOperation.Label    = "Operation";
            tbOperation.ID       = filterControl.ID + "_tbOperation";
            tbOperation.CssClass = "js-tbOperation";
            filterControl.Controls.Add(tbOperation);

            SlidingDateRangePicker slidingDateRangePicker = new SlidingDateRangePicker();

            slidingDateRangePicker.ID = filterControl.ID + "_slidingDateRangePicker";
            slidingDateRangePicker.AddCssClass("js-sliding-date-range");
            slidingDateRangePicker.Label = "Date Range";
            slidingDateRangePicker.Help  = "The date range of the interactions";
            filterControl.Controls.Add(slidingDateRangePicker);

            return(new Control[4] {
                ddlInteractionChannel, ddlInteractionComponent, tbOperation, slidingDateRangePicker
            });
        }
Beispiel #10
0
        /// <summary>
        /// Creates the boolean edit control using the specified control type
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="booleanControlType">Type of the boolean control.</param>
        /// <returns></returns>
        private Control CreateBooleanEditControl(Dictionary <string, ConfigurationValue> configurationValues, string id, BooleanControlType booleanControlType)
        {
            string yesText = "Yes";
            string noText  = "No";

            if (configurationValues != null)
            {
                yesText = configurationValues.GetValueOrNull(ConfigurationKey.TrueText);
                noText  = configurationValues.GetValueOrNull(ConfigurationKey.FalseText);
            }

            if (yesText.IsNullOrWhiteSpace())
            {
                yesText = "Yes";
            }

            if (noText.IsNullOrWhiteSpace())
            {
                noText = "No";
            }

            Control editControl;

            if (booleanControlType == BooleanControlType.Checkbox)
            {
                var checkboxEditControl = new RockCheckBox {
                    ID = id
                };
                editControl = checkboxEditControl;
            }
            else if (booleanControlType == BooleanControlType.Toggle)
            {
                var toggleEditControl = new Toggle
                {
                    ID      = id,
                    OnText  = yesText,
                    OffText = noText,
                };

                editControl = toggleEditControl;
            }
            else
            {
                var dropDownEditControl = new RockDropDownList {
                    ID = id
                };
                dropDownEditControl.Items.Add(new ListItem());
                dropDownEditControl.Items.Add(new ListItem(noText, "False"));
                dropDownEditControl.Items.Add(new ListItem(yesText, "True"));

                editControl = dropDownEditControl;
            }

            return(editControl);
        }
        /// <summary>
        /// Ensures that the correct attribute filter controls are created based on the selected <see cref="StepType"/>.
        /// </summary>
        /// <param name="stepTypePicker">The <see cref="StepTypePicker"/>.</param>
        private void EnsureSelectedStepTypeControls(StepTypePicker stepTypePicker)
        {
            DynamicControlsPanel containerControl = stepTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            // Get the EntityFields for the attributes associated with the selected StepType.
            var entityFields = GetStepAttributes(stepTypePicker.SelectedValueAsId());

            // Create the attribute selection dropdown.
            string           propertyControlId = string.Format("{0}_ddlProperty", containerControl.ID);
            RockDropDownList ddlProperty       = containerControl.Controls.OfType <RockDropDownList>().FirstOrDefault(a => a.ID == propertyControlId);

            if (ddlProperty == null)
            {
                ddlProperty                       = new RockDropDownList();
                ddlProperty.ID                    = propertyControlId;
                ddlProperty.AutoPostBack          = true;
                ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
                ddlProperty.AddCssClass("js-property-dropdown");
                containerControl.Controls.Add(ddlProperty);
            }

            // Clear the list of items.  We will rebuild them to match the selected StepType.
            ddlProperty.Items.Clear();

            // Add an empty option.
            ddlProperty.Items.Add(new ListItem());

            // Add a ListItem for each of the attributes.
            foreach (var entityField in entityFields)
            {
                ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
            }

            if (stepTypePicker.Page.IsPostBack)
            {
                // If the attribute has been selected, make sure that value is retained.
                ddlProperty.SetValue(stepTypePicker.Page.Request.Params[ddlProperty.UniqueID]);
            }

            // Add the filter controls (comparison type and value).
            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                if (!containerControl.Controls.OfType <Control>().Any(a => a.ID == controlId))
                {
                    var control = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                    if (control != null)
                    {
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }
 /// <summary>
 /// Sets the selection.
 /// </summary>
 /// <param name="controls">The controls.</param>
 /// <param name="selection">The selection.</param>
 public override void SetSelection(System.Web.UI.Control[] controls, string selection)
 {
     if (controls.Count() == 1)
     {
         RockDropDownList dropDownList = controls[0] as RockDropDownList;
         if (dropDownList != null)
         {
             dropDownList.SetValue(selection);
         }
     }
 }
Beispiel #13
0
        /// <summary>
        /// Gets the selection.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <returns></returns>
        public override string GetSelection(Type entityType, Control[] controls)
        {
            if (controls.Count() >= 2)
            {
                RockDropDownList ddlNoteType = controls[0] as RockDropDownList;
                RockTextBox      tbContains  = controls[1] as RockTextBox;
                return($"{ddlNoteType.SelectedValue}|{tbContains.Text}");
            }

            return(string.Empty);
        }
Beispiel #14
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the contentChannelTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void contentChannelTypePicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            RockDropDownList     contentChannelTypePicker = sender as RockDropDownList;
            DynamicControlsPanel containerControl         = contentChannelTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl            = containerControl.FirstParentControlOfType <FilterField>();

            containerControl.Controls.Clear();
            containerControl.Controls.Add(contentChannelTypePicker);

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = string.Format("{0}_{1}_ddlProperty", containerControl.ID, contentChannelTypePicker.SelectedValue.AsInteger());
            ddlProperty.Attributes["EntityTypeId"] = EntityTypeCache.GetId <Rock.Model.ContentChannelItem>().ToString();
            containerControl.Controls.Add(ddlProperty);

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());

            var entityFields = GetContentChannelItemAttributes(contentChannelTypePicker.SelectedValue.AsIntegerOrNull());

            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                var    control   = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                if (control != null)
                {
                    // Add the field to the dropdown of available fields
                    if (AttributeCache.Get(entityField.AttributeGuid.Value)?.EntityTypeQualifierColumn == "ContentChannelTypeId")
                    {
                        ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
                    }
                    else
                    {
                        ddlProperty.Items.Add(new ListItem(entityField.Title, entityField.UniqueName));
                    }

                    containerControl.Controls.Add(control);
                }
            }

            ddlProperty.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlProperty.Page.Request.Params[ddlProperty.UniqueID];

            if (selectedValue != null)
            {
                ddlProperty.SelectedValue = selectedValue;
                ddlProperty_SelectedIndexChanged(ddlProperty, new EventArgs());
            }

            ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
        }
Beispiel #15
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            // Create the field selection dropdown
            var ddlEntityField = new RockDropDownList();

            ddlEntityField.ID           = string.Format("{0}_ddlProperty", filterControl.ID);
            ddlEntityField.ClientIDMode = ClientIDMode.Predictable;
            containerControl.Controls.Add(ddlEntityField);

            // add Empty option first
            ddlEntityField.Items.Add(new ListItem());
            var rockBlock = filterControl.RockBlock();

            this.entityFields = EntityHelper.GetEntityFields(entityType);
            foreach (var entityField in this.entityFields)
            {
                bool isAuthorized = true;
                if (entityField.FieldKind == FieldKind.Attribute && entityField.AttributeGuid.HasValue)
                {
                    var attribute = AttributeCache.Read(entityField.AttributeGuid.Value);
                    if (attribute != null && rockBlock != null)
                    {
                        // only show the Attribute field in the drop down if they have VIEW Auth to it
                        isAuthorized = attribute.IsAuthorized(Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson);
                    }
                }

                if (isAuthorized)
                {
                    ddlEntityField.Items.Add(new ListItem(entityField.Title, entityField.Name));
                }
            }

            ddlEntityField.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlEntityField.Page.Request.Params[ddlEntityField.UniqueID];

            if (selectedValue != null)
            {
                ddlEntityField.SelectedValue = selectedValue;
                ddlEntityField_SelectedIndexChanged(ddlEntityField, new EventArgs());
            }

            ddlEntityField.SelectedIndexChanged += ddlEntityField_SelectedIndexChanged;

            return(new Control[] { containerControl });
        }
Beispiel #16
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            ddlLoginType          = new RockDropDownList();
            ddlLoginType.CssClass = "js-loginType-dropdown";
            ddlLoginType.ID       = filterControl.ID + "_ddlLoginType";
            ddlLoginType.Label    = "Login Type";
            ddlLoginType.Help     = "Select a specific Login Type";
            filterControl.Controls.Add(ddlLoginType);
            BindLoginType();

            return(new Control[] { ddlLoginType });
        }
Beispiel #17
0
 /// <summary>
 /// Sets the selection.
 /// </summary>
 /// <param name="controls">The controls.</param>
 /// <param name="selection">The selection.</param>
 public override void SetSelection(System.Web.UI.Control[] controls, string selection)
 {
     if (controls.Count() >= 0)
     {
         string[] selectionValues = selection.Split('|');
         if (selectionValues.Length >= 1)
         {
             RockDropDownList ddlNoteType = controls[0] as RockDropDownList;
             ddlNoteType.SelectedValue = selectionValues[0];
         }
     }
 }
Beispiel #18
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List <Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            // build a drop down list of defined types (the one that gets selected is
            // used to build a list of defined values)
            var ddl = new RockDropDownList();

            controls.Add(ddl);
            ddl.AutoPostBack          = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.Label = "Defined Type";
            ddl.Help  = "The Defined Type to select values from.";

            Rock.Model.DefinedTypeService definedTypeService = new Model.DefinedTypeService(new RockContext());
            foreach (var definedType in definedTypeService.Queryable().OrderBy(d => d.Name))
            {
                ddl.Items.Add(new ListItem(definedType.Name, definedType.Id.ToString()));
            }

            // Add checkbox for deciding if the defined values 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 defined type values to be selected.";

            // option for Display Descriptions
            var cbDescription = new RockCheckBox();

            controls.Add(cbDescription);
            cbDescription.AutoPostBack    = true;
            cbDescription.CheckedChanged += OnQualifierUpdated;
            cbDescription.Label           = "Display Descriptions";
            cbDescription.Text            = "Yes";
            cbDescription.Help            = "When set, the defined value descriptions will be displayed instead of the values.";

            // 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);
        }
Beispiel #19
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();
            CreateChildControls(this, Controls);

            groupsDisplay          = new Panel();
            groupsDisplay.CssClass = "panel panel-default";

            templateDropDownList                       = new RockDropDownList();
            templateDropDownList.Label                 = "Check-in Template";
            templateDropDownList.ID                    = "templateDropDownList_" + this.ID;
            templateDropDownList.CssClass              = "input-sm";
            templateDropDownList.DataTextField         = "Name";
            templateDropDownList.DataValueField        = "Id";
            templateDropDownList.AutoPostBack          = true;
            templateDropDownList.SelectedIndexChanged += templateDropDownList_SelectedIndexChanged;

            groupTypeDropDownList                       = new RockDropDownList();
            groupTypeDropDownList.Visible               = false;
            groupTypeDropDownList.Label                 = "Check-in Area";
            groupTypeDropDownList.ID                    = "groupTypeDropDownList_" + this.ID;
            groupTypeDropDownList.CssClass              = "input-sm";
            groupTypeDropDownList.DataTextField         = "Name";
            groupTypeDropDownList.DataValueField        = "Id";
            groupTypeDropDownList.AutoPostBack          = true;
            groupTypeDropDownList.SelectedIndexChanged += groupTypeDropDownList_SelectedIndexChanged;

            groupDropDownList                       = new RockDropDownList();
            groupDropDownList.Visible               = false;
            groupDropDownList.Label                 = "Check-in Group";
            groupDropDownList.ID                    = "groupDropDownList_" + this.ID;
            groupDropDownList.CssClass              = "input-sm";
            groupDropDownList.DataTextField         = "Name";
            groupDropDownList.DataValueField        = "Id";
            groupDropDownList.AutoPostBack          = true;
            groupDropDownList.SelectedIndexChanged += groupDropDownList_SelectedIndexChanged;

            addButton          = new BootstrapButton();
            addButton.Text     = "Add Group";
            addButton.Visible  = false;
            addButton.CssClass = "btn btn-primary btn-block clearfix";
            addButton.Click   += addButton_Click;

            Controls.Add(groupsDisplay);
            Controls.Add(templateDropDownList);
            Controls.Add(groupTypeDropDownList);
            Controls.Add(groupDropDownList);
            Controls.Add(addButton);

            BindTemplateDropDown();
            UpdateGroupsDisplay();
        }
        /// <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)
        {
            Panel pnlRange = new Panel {
                ID = id, CssClass = "form-control-group"
            };
            //Panel pnlCol1 = new Panel { CssClass = "col-md-6" };
            //Panel pnlCol2 = new Panel { CssClass = "col-md-6" };

            RockDropDownList lowerValueControl = new RockDropDownList {
                ID = string.Format("{0}_ddlLower", id)
            };

            lowerValueControl.CssClass = "input-width-md";
            RockDropDownList upperValueControl = new RockDropDownList {
                ID = string.Format("{0}_ddlUpper", id)
            };

            upperValueControl.CssClass = "input-width-md";
            pnlRange.Controls.Add(lowerValueControl);
            pnlRange.Controls.Add(new Label {
                CssClass = "to", Text = " to "
            });
            pnlRange.Controls.Add(upperValueControl);

            if (configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY))
            {
                Guid             definedTypeGuid = configurationValues.GetValueOrNull(DEFINED_TYPE_KEY).AsGuid();
                DefinedTypeCache definedType     = DefinedTypeCache.Get(definedTypeGuid);

                if (definedType != null)
                {
                    var definedValues = definedType.DefinedValues;
                    if (definedValues.Any())
                    {
                        bool useDescription = configurationValues.GetValueOrNull(DISPLAY_DESCRIPTION).AsBoolean();

                        lowerValueControl.Items.Add(new ListItem());
                        upperValueControl.Items.Add(new ListItem());

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

                    return(pnlRange);
                }
            }

            return(null);
        }
Beispiel #21
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Control parentControl)
        {
            var pnlGroupAttributeFilterControls = new DynamicControlsPanel();

            pnlGroupAttributeFilterControls.ID = parentControl.GetChildControlInstanceName(_CtlGroup);
            parentControl.Controls.Add(pnlGroupAttributeFilterControls);

            pnlGroupAttributeFilterControls.Controls.Clear();

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = pnlGroupAttributeFilterControls.GetChildControlInstanceName(_CtlProperty);

            pnlGroupAttributeFilterControls.Controls.Add(ddlProperty);

            // Add empty selection as first item.
            ddlProperty.Items.Add(new ListItem());

            var rockBlock = parentControl.RockBlock();

            foreach (var entityField in GetGroupMemberAttributeEntityFields())
            {
                bool includeField = true;
                bool isAuthorized = true;

                if (entityField.FieldKind == FieldKind.Attribute)
                {
                    var attribute = AttributeCache.Get(entityField.AttributeGuid.Value);

                    // Don't include the attribute if it isn't active
                    if (attribute.IsActive == false)
                    {
                        includeField = false;
                    }

                    if (includeField && attribute != null && rockBlock != null)
                    {
                        // only show the Attribute field in the drop down if they have VIEW Auth to it
                        isAuthorized = attribute.IsAuthorized(Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson);
                    }
                }

                if (isAuthorized && includeField)
                {
                    // Add the field to the dropdown of available fields
                    ddlProperty.Items.Add(new ListItem(entityField.Title, entityField.UniqueName));
                }
            }

            return(new Control[] { pnlGroupAttributeFilterControls });
        }
        /// <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;

            var values = DocumentTypeCache.All().Select(v => new { v.Id, v.Name }).OrderBy(v => v.Name).ToList();

            var allowMultiple = true;

            if (configurationValues != null &&
                configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY))
            {
                allowMultiple = configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean(true);
            }

            if (!allowMultiple)
            {
                // Select single member
                editControl = new RockDropDownList {
                    ID = id
                };
            }
            else
            {
                // Select multiple members
                editControl = new RockListBox {
                    ID = id, DisplayDropAsAbsolute = true
                };
            }

            var items = new List <ListItem>();

            foreach (var value in values)
            {
                items.Add(new ListItem(value.Name, value.Id.ToString()));
            }

            if (items.Count > 0)
            {
                if (editControl is RockListBox)
                {
                    (editControl as RockListBox).Items.AddRange(items.ToArray());
                }
                else
                {
                    (editControl as RockDropDownList).Items.AddRange(items.ToArray());
                }

                return(editControl);
            }

            return(null);
        }
        /// <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)
        {
            var includeInactive        = false;
            int?connectionTypeFilterId = null;

            if (configurationValues != null)
            {
                includeInactive        = configurationValues.ContainsKey(INCLUDE_INACTIVE_KEY) && configurationValues[INCLUDE_INACTIVE_KEY].Value.AsBoolean();
                connectionTypeFilterId = configurationValues.ContainsKey(CONNECTION_TYPE_FILTER) ? configurationValues[CONNECTION_TYPE_FILTER].Value.AsIntegerOrNull() : null;
            }

            var activityTypes = new ConnectionActivityTypeService(new RockContext())
                                .Queryable().AsNoTracking()
                                .Where(o => o.IsActive || includeInactive)
                                .OrderBy(o => o.ConnectionType.Name)
                                .ThenBy(o => o.Name)
                                .Select(o => new { o.Guid, o.Name, o.ConnectionType })
                                .ToList();

            var editControl = new RockDropDownList {
                ID = id
            };

            editControl.Items.Add(new ListItem());

            if (activityTypes.Any())
            {
                foreach (var activityType in activityTypes)
                {
                    if (connectionTypeFilterId != null &&
                        (activityType.ConnectionType == null || activityType.ConnectionType.Id != connectionTypeFilterId))
                    {
                        continue;
                    }

                    var listItem = new ListItem(activityType.Name, activityType.Guid.ToString().ToUpper());

                    // Don't add an option group if there is a filter since that would be only one group.
                    if (connectionTypeFilterId == null &&
                        activityType.ConnectionType != null)
                    {
                        listItem.Attributes.Add("OptionGroup", activityType.ConnectionType.Name);
                    }

                    editControl.Items.Add(listItem);
                }

                return(editControl);
            }

            return(null);
        }
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            RockDropDownList ddlInteractionChannel = new RockDropDownList();

            ddlInteractionChannel.ID                    = parentControl.ID + "_ddlInteractionChannel";
            ddlInteractionChannel.Label                 = "Interaction Channel";
            ddlInteractionChannel.Required              = true;
            ddlInteractionChannel.AutoPostBack          = true;
            ddlInteractionChannel.SelectedIndexChanged += ddlInteractionChannel_SelectedIndexChanged;
            parentControl.Controls.Add(ddlInteractionChannel);

            var interactionChannelService = new InteractionChannelService(new RockContext());
            var noteTypes = interactionChannelService.Queryable().OrderBy(a => a.Name).Select(a => new
            {
                a.Id,
                a.Name
            }).ToList();

            ddlInteractionChannel.Items.Clear();
            ddlInteractionChannel.Items.Add(new ListItem());
            ddlInteractionChannel.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray());

            int?selectedInteractionChannelId = parentControl.Page.Request.Params[ddlInteractionChannel.UniqueID].AsIntegerOrNull();

            ddlInteractionChannel.SetValue(selectedInteractionChannelId);


            RockDropDownList ddlInteractionComponent = new RockDropDownList();

            ddlInteractionComponent.ID    = parentControl.ID + "_ddlInteractionComponent";
            ddlInteractionComponent.Label = "Interaction Component";
            ddlInteractionComponent.EnhanceForLongLists = true;
            parentControl.Controls.Add(ddlInteractionComponent);

            PopulateInteractionComponent(selectedInteractionChannelId, ddlInteractionComponent);
            RockTextBox tbOperation = new RockTextBox();

            tbOperation.Label = "Operation";
            tbOperation.ID    = parentControl.ID + "_tbOperation";
            parentControl.Controls.Add(tbOperation);


            RockRadioButtonList rblSelectionMode = new RockRadioButtonList();

            rblSelectionMode.ID    = parentControl.ID + "rblSelectionMode";
            rblSelectionMode.Label = "Selection Mode";
            rblSelectionMode.BindToEnum <FirstLastInteraction>();
            rblSelectionMode.SetValue(FirstLastInteraction.First.ConvertToInt());
            parentControl.Controls.Add(rblSelectionMode);

            return(new System.Web.UI.Control[] { ddlInteractionChannel, ddlInteractionComponent, tbOperation, rblSelectionMode });
        }
Beispiel #25
0
        /// <summary>
        /// Gets a dropdownlist of the supported comparison types
        /// </summary>
        /// <param name="supportedComparisonTypes">The supported comparison types.</param>
        /// <returns></returns>
        protected DropDownList ComparisonControl(ComparisonType supportedComparisonTypes)
        {
            var ddl = new RockDropDownList();

            foreach (ComparisonType comparisonType in Enum.GetValues(typeof(ComparisonType)))
            {
                if ((supportedComparisonTypes & comparisonType) == comparisonType)
                {
                    ddl.Items.Add(new ListItem(comparisonType.ConvertToString(), comparisonType.ConvertToInt().ToString()));
                }
            }
            return(ddl);
        }
Beispiel #26
0
        /// <summary>
        /// Reads new values entered by the user for the field
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues"></param>
        /// <returns></returns>
        public override string GetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            Panel pnlRange = control as Panel;

            if (pnlRange != null)
            {
                RockDropDownList lowerValueControl = pnlRange.Controls.OfType <RockDropDownList>().FirstOrDefault(a => a.ID.EndsWith("_ddlLower"));
                RockDropDownList upperValueControl = pnlRange.Controls.OfType <RockDropDownList>().FirstOrDefault(a => a.ID.EndsWith("_ddlUpper"));
                return(string.Format("{0},{1}", lowerValueControl.SelectedValue, upperValueControl.SelectedValue));
            }

            return(null);
        }
        /// <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)
        {
            var ddl = new RockDropDownList {
                ID = id
            };

            foreach (ComparisonType comparisonType in Enum.GetValues(typeof(ComparisonType)))
            {
                ddl.Items.Add(new ListItem(comparisonType.ConvertToString(), comparisonType.ConvertToInt().ToString()));
            }

            return(ddl);
        }
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection(Type entityType, Control[] controls, string selection)
        {
            var values = selection.Split('|');

            DropDownList     ddlCompare           = controls[0] as DropDownList;
            RockDropDownList ddlGradeDefinedValue = controls[1] as RockDropDownList;

            if (values.Length == 2)
            {
                ddlCompare.SelectedValue = values[0];
                ddlGradeDefinedValue.SetValue(values[1]);
            }
        }
Beispiel #29
0
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection(Type entityType, Control[] controls, string selection)
        {
            string[] selectionValues = selection.Split('|');

            if (selectionValues.Length >= 2)
            {
                RockDropDownList ddlFilterBy = controls[0] as RockDropDownList;
                ddlFilterBy.SelectedValue = selectionValues[0];

                RockDropDownList ddlCourseRequirement = controls[1] as RockDropDownList;
                ddlCourseRequirement.SetValue(selectionValues[1]);
            }
        }
        /// <summary>
        /// Gets the selection.
        /// </summary>
        /// <param name="controls">The controls.</param>
        /// <returns></returns>
        public override string GetSelection(System.Web.UI.Control[] controls)
        {
            if (controls.Count() == 1)
            {
                RockDropDownList dropDownList = controls[0] as RockDropDownList;
                if (dropDownList != null)
                {
                    return(dropDownList.SelectedValue);
                }
            }

            return(null);
        }
Beispiel #31
0
        /// <summary>
        /// Populate a drop-down list with Connection Types.
        /// </summary>
        /// <param name="control"></param>
        private void InitializeConnectionTypesList(RockDropDownList control)
        {
            var definedValues = this.GetConnectionTypesList();

            control.Items.Clear();

            control.Items.Add(new ListItem(string.Empty));

            foreach (var item in definedValues)
            {
                control.Items.Add(new ListItem(item.Value, item.Id.ToString()));
            }
        }
Beispiel #32
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();

            ddlFrom = new RockDropDownList();
            ddlFrom.ID = string.Format( "ddlFrom_{0}", this.ID );
            ddlFrom.Label = "From";
            ddlFrom.Help = "The number to originate message from (configured under Admin Tools > General Settings > Defined Types > SMS From Values).";
            ddlFrom.BindToDefinedType( DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.COMMUNICATION_SMS_FROM ) ), false, true );
            Controls.Add( ddlFrom );

            rcwMessage = new RockControlWrapper();
            rcwMessage.ID = string.Format( "rcwMessage_{0}", this.ID );
            rcwMessage.Label = "Message";
            Controls.Add( rcwMessage );

            mfpMessage = new MergeFieldPicker();
            mfpMessage.ID = string.Format( "mfpMergeFields_{0}", this.ID );
            mfpMessage.MergeFields.Clear();
            mfpMessage.MergeFields.Add( "GlobalAttribute" );
            mfpMessage.MergeFields.Add( "Rock.Model.Person" );
            mfpMessage.CssClass += " pull-right margin-b-sm";
            mfpMessage.SelectItem += mfpMergeFields_SelectItem;
            rcwMessage.Controls.Add( mfpMessage );

            tbMessage = new RockTextBox();
            tbMessage.ID = string.Format( "tbTextMessage_{0}", this.ID );
            tbMessage.TextMode = TextBoxMode.MultiLine;
            tbMessage.Rows = 3;
            rcwMessage.Controls.Add( tbMessage );
        }