예제 #1
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <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);

            RockDropDownList contentChannelTypePicker = new RockDropDownList();

            contentChannelTypePicker.ID = filterControl.ID + "_contentChannelTypePicker";
            contentChannelTypePicker.AddCssClass("js-content-channel-picker");
            contentChannelTypePicker.Label = "Content Channel Type";

            contentChannelTypePicker.Items.Clear();
            var contentChannelTypeList = new ContentChannelTypeService(new RockContext()).Queryable().OrderBy(a => a.Name).ToList();

            foreach (var contentChannelType in contentChannelTypeList)
            {
                contentChannelTypePicker.Items.Add(new ListItem(contentChannelType.Name, contentChannelType.Id.ToString()));
            }

            contentChannelTypePicker.SelectedIndexChanged += contentChannelTypePicker_SelectedIndexChanged;
            contentChannelTypePicker.AutoPostBack          = true;
            contentChannelTypePicker.Visible = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add(contentChannelTypePicker);

            // set the contentChannelTypePicker selected value now so we can create the other controls that depend on knowing the contentChannelTypeId
            int?contentChannelTypeId = filterControl.Page.Request.Params[contentChannelTypePicker.UniqueID].AsIntegerOrNull();

            contentChannelTypePicker.SelectedValue = contentChannelTypeId.ToString();
            contentChannelTypePicker_SelectedIndexChanged(contentChannelTypePicker, new EventArgs());

            return(new Control[] { containerControl });
        }
예제 #2
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var rblTagType = new RockRadioButtonList();

            rblTagType.ID              = filterControl.ID + "_tagType";
            rblTagType.Label           = "Tag Type";
            rblTagType.RepeatDirection = RepeatDirection.Horizontal;
            rblTagType.Items.Add(new ListItem("Personal Tags", "1"));
            rblTagType.Items.Add(new ListItem("Organizational Tags", "2"));
            rblTagType.SelectedValue         = "1";
            rblTagType.AutoPostBack          = true;
            rblTagType.SelectedIndexChanged += rblTagType_SelectedIndexChanged;
            rblTagType.CssClass              = "js-tag-type";
            filterControl.Controls.Add(rblTagType);

            var ddlTagList = new RockDropDownList();

            ddlTagList.ID    = filterControl.ID + "_ddlTagList";
            ddlTagList.Label = "Tag";
            ddlTagList.AddCssClass("js-tag-filter-list");
            filterControl.Controls.Add(ddlTagList);

            PopulateTagList(filterControl);

            return(new Control[2] {
                rblTagType, ddlTagList
            });
        }
예제 #3
0
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            string yesText = "Yes";
            string noText  = "No";

            if (configurationValues != null)
            {
                if (configurationValues.ContainsKey("truetext"))
                {
                    yesText = configurationValues["truetext"].Value;
                }
                if (configurationValues.ContainsKey("falsetext"))
                {
                    noText = configurationValues["falsetext"].Value;
                }
            }

            ListControl filterValueControl = new RockDropDownList();

            filterValueControl.ID = string.Format("{0}_ctlCompareValue", id);
            filterValueControl.AddCssClass("js-filter-control");

            if (!required)
            {
                filterValueControl.Items.Add(new ListItem());
            }
            filterValueControl.Items.Add(new ListItem(yesText, "True"));
            filterValueControl.Items.Add(new ListItem(noText, "False"));
            return(filterValueControl);
        }
예제 #4
0
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            var ddlList = new RockDropDownList();

            ddlList.ID = string.Format("{0}_ddlList", id);
            ddlList.AddCssClass("js-filter-control");

            if (!required)
            {
                ddlList.Items.Add(new ListItem());
            }

            if (ListSource.Any())
            {
                foreach (var item in ListSource)
                {
                    ListItem listItem = new ListItem(item.Value, item.Key);
                    ddlList.Items.Add(listItem);
                }

                return(ddlList);
            }

            return(null);
        }
예제 #5
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            // Define Control: Is Leader?
            RockDropDownList ddlLeader = new RockDropDownList();

            ddlLeader.ID = string.Format("{0}_ddlMemberType", parentControl.ID);
            ddlLeader.AddCssClass("js-filter-control js-member-is-leader");
            ddlLeader.Label = "Member Type";
            ddlLeader.Items.Add(new ListItem(string.Empty, string.Empty));
            ddlLeader.Items.Add(new ListItem("Leader", "true"));
            ddlLeader.Items.Add(new ListItem("Not Leader", "false"));
            parentControl.Controls.Add(ddlLeader);

            // Define Control: Member Status
            RockDropDownList ddlMemberStatus = new RockDropDownList();

            ddlMemberStatus.ID = string.Format("{0}_ddlMemberStatus", parentControl.ID);
            ddlMemberStatus.AddCssClass("js-filter-control js-member-status");
            ddlMemberStatus.Label = "Member Status";
            ddlMemberStatus.Items.Add(new ListItem(string.Empty, string.Empty));
            foreach (GroupMemberStatus memberStatus in Enum.GetValues(typeof(GroupMemberStatus)))
            {
                ddlMemberStatus.Items.Add(new ListItem(memberStatus.ConvertToString(), memberStatus.ConvertToInt().ToString()));
            }

            parentControl.Controls.Add(ddlMemberStatus);

            return(new System.Web.UI.Control[] { ddlLeader, ddlMemberStatus });
        }
예제 #6
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var controls = new List <Control>();

            ddlStringFilterComparison    = ComparisonHelper.ComparisonControl(ComparisonHelper.StringFilterComparisonTypes);
            ddlStringFilterComparison.ID = string.Format("{0}_{1}", filterControl.ID, controls.Count());
            ddlStringFilterComparison.AddCssClass("js-filter-compare");
            filterControl.Controls.Add(ddlStringFilterComparison);
            controls.Add(ddlStringFilterComparison);

            tbPostalCode    = new RockTextBox();
            tbPostalCode.ID = filterControl.ID + "_tbPostalCode";
            tbPostalCode.AddCssClass("js-filter-control");
            filterControl.Controls.Add(tbPostalCode);
            controls.Add(tbPostalCode);

            ddlLocationType                = new RockDropDownList();
            ddlLocationType.ID             = filterControl.ID + "_ddlLocationType";
            ddlLocationType.Label          = "Location Type";
            ddlLocationType.DataValueField = "Id";
            ddlLocationType.DataTextField  = "Value";
            DefinedTypeCache locationDefinedType = DefinedTypeCache.Get(SystemGuid.DefinedType.GROUP_LOCATION_TYPE.AsGuid());

            ddlLocationType.BindToDefinedType(locationDefinedType);
            ddlLocationType.Items.Insert(0, new ListItem("(All Location Types)", ""));
            filterControl.Controls.Add(ddlLocationType);
            controls.Add(ddlLocationType);

            return(controls.ToArray());
        }
예제 #7
0
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            string yesText = "Yes";
            string noText  = "No";

            if (configurationValues != null)
            {
                if (configurationValues.ContainsKey(ConfigurationKey.TrueText))
                {
                    yesText = configurationValues[ConfigurationKey.TrueText].Value;
                }
                if (configurationValues.ContainsKey(ConfigurationKey.FalseText))
                {
                    noText = configurationValues[ConfigurationKey.FalseText].Value;
                }
            }

            // NOTE: Use the RockDropDown for the filter control even if the ControlType of the EditControl is set to something else
            ListControl filterValueControl = new RockDropDownList();

            filterValueControl.ID = string.Format("{0}_ctlCompareValue", id);
            filterValueControl.AddCssClass("js-filter-control");

            if (!required)
            {
                filterValueControl.Items.Add(new ListItem());
            }

            filterValueControl.Items.Add(new ListItem(yesText, "True"));
            filterValueControl.Items.Add(new ListItem(noText, "False"));
            return(filterValueControl);
        }
예제 #8
0
        /// <summary>
        /// Gets the filter compare control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <returns></returns>
        public virtual Control FilterCompareControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required)
        {
            RockDropDownList ddlCompare = ComparisonHelper.ComparisonControl(FilterComparisonType, required);

            ddlCompare.ID = string.Format("{0}_ddlCompare", id);
            ddlCompare.AddCssClass("js-filter-compare");
            return(ddlCompare);
        }
예제 #9
0
        /// <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>
        /// Ensures that the controls that are created based on the WorkflowType have been created
        /// </summary>
        /// <param name="workflowTypePicker">The workflow type picker.</param>
        private void EnsureSelectedWorkflowTypeControls(WorkflowTypePicker workflowTypePicker)
        {
            DynamicControlsPanel containerControl = workflowTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            var entityFields = GetWorkflowAttributes(workflowTypePicker.SelectedValueAsId());

            // Create the field 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");
                ddlProperty.Attributes["EntityTypeId"] = EntityTypeCache.GetId <Rock.Model.Workflow>().ToString();
                containerControl.Controls.Add(ddlProperty);
            }

            // update the list of items just in case the WorkflowType changed
            ddlProperty.Items.Clear();

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());
            foreach (var entityField in entityFields)
            {
                // Add the field to the dropdown of available fields
                ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
            }

            if (workflowTypePicker.Page.IsPostBack)
            {
                ddlProperty.SetValue(workflowTypePicker.Page.Request.Params[ddlProperty.UniqueID]);
            }

            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);
                    }
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Gets the multiple option single quantity fee control
        /// </summary>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        /// <param name="feeValues">The fee values.</param>
        /// <param name="registrationInstance">The registration instance.</param>
        /// <param name="otherRegistrants">The other registrants that have been registered so far in this registration</param>
        /// <returns></returns>
        private Control GetFeeMultipleOptionSingleQuantityControl(bool setValues, List <FeeInfo> feeValues, RegistrationInstance registrationInstance, List <RegistrantInfo> otherRegistrants)
        {
            var fee = this;
            var ddl = new RockDropDownList();

            ddl.ID = "fee_" + fee.Id.ToString();
            ddl.AddCssClass("input-width-md");
            ddl.Label          = fee.Name;
            ddl.DataValueField = "Key";
            ddl.DataTextField  = "Value";
            ddl.Required       = fee.IsRequired;

            ddl.Items.Clear();
            ddl.Items.Add(new ListItem());
            foreach (var feeItem in fee.FeeItems)
            {
                var feeInfo      = feeValues?.FirstOrDefault(a => a.RegistrationTemplateFeeItemId == feeItem.Id);
                int currentValue = feeInfo?.Quantity ?? 0;

                int?usageCountRemaining = feeItem.GetUsageCountRemaining(registrationInstance, otherRegistrants);
                var listItem            = new ListItem(string.Format("{0} ({1})", feeItem.Name, feeItem.Cost.FormatAsCurrency()), feeItem.Id.ToString());
                if (usageCountRemaining.HasValue)
                {
                    if (usageCountRemaining <= 0)
                    {
                        // if there aren't any remaining, and the currentValue isn't counted in the used counts, disable the option
                        if (currentValue == 0)
                        {
                            listItem.Enabled = false;
                        }

                        listItem.Text += " (none remaining)";
                    }
                    else
                    {
                        listItem.Text += $" ({usageCountRemaining} remaining)";
                    }
                }

                ddl.Items.Add(listItem);
            }

            if (setValues && feeValues != null && feeValues.Any())
            {
                var defaultFeeItemId = feeValues.Where(f => f.Quantity > 0).Select(f => f.RegistrationTemplateFeeItemId).FirstOrDefault();

                ddl.SetValue(defaultFeeItemId);
            }

            return(ddl);
        }
예제 #12
0
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required)
        {
            var ddl = new RockDropDownList();

            ddl.ID = string.Format("{0}_ctlCompareValue", id);
            ddl.AddCssClass("js-filter-control");

            if (!required)
            {
                ddl.Items.Add(new ListItem());
            }
            ddl.Items.Add(new ListItem("True", "True"));
            ddl.Items.Add(new ListItem("False", "False"));
            return(ddl);
        }
예제 #13
0
 /// <summary>
 /// Gets the filter compare control.
 /// </summary>
 /// <param name="configurationValues">The configuration values.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="filterMode">The filter mode.</param>
 /// <returns></returns>
 public override Control FilterCompareControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
 {
     if (filterMode == FilterMode.SimpleFilter)
     {
         // hide the compare control for SimpleFilter mode
         RockDropDownList ddlCompare = ComparisonHelper.ComparisonControl(FilterComparisonType, required);
         ddlCompare.ID = string.Format("{0}_ddlCompare", id);
         ddlCompare.AddCssClass("js-filter-compare");
         ddlCompare.Visible = false;
         return(ddlCompare);
     }
     else
     {
         return(base.FilterCompareControl(configurationValues, id, required, filterMode));
     }
 }
예제 #14
0
        /// <summary>
        /// Gets the filter compare control with the specified FilterMode
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public virtual Control FilterCompareControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            RockDropDownList ddlCompare = ComparisonHelper.ComparisonControl(FilterComparisonType, required);

            if (filterMode == FilterMode.SimpleFilter && (
                    FilterComparisonType == ComparisonHelper.BinaryFilterComparisonTypes ||
                    FilterComparisonType == ComparisonHelper.StringFilterComparisonTypes ||
                    FilterComparisonType == ComparisonHelper.ContainsFilterComparisonTypes))
            {
                // hide the compare control for SimpleFilter mode if it is a string, list, or binary comparison type
                ddlCompare.Visible = false;
            }

            ddlCompare.ID = string.Format("{0}_ddlCompare", id);
            ddlCompare.AddCssClass("js-filter-compare");
            return(ddlCompare);
        }
예제 #15
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var ddlIntegerCompare = ComparisonHelper.ComparisonControl(ComparisonHelper.NumericFilterComparisonTypes);

            ddlIntegerCompare.Label = "Count";
            ddlIntegerCompare.ID    = string.Format("{0}_ddlIntegerCompare", filterControl.ID);
            ddlIntegerCompare.AddCssClass("js-filter-compare");
            filterControl.Controls.Add(ddlIntegerCompare);

            var nbMemberCount = new NumberBox();

            nbMemberCount.Label = "&nbsp;";
            nbMemberCount.ID    = string.Format("{0}_nbMemberCount", filterControl.ID);
            nbMemberCount.AddCssClass("js-filter-control js-member-count");
            nbMemberCount.FieldName = "Member Count";
            filterControl.Controls.Add(nbMemberCount);

            RockDropDownList ddlLeader = new RockDropDownList();

            ddlLeader.ID = string.Format("{0}_ddlMemberType", filterControl.ID);
            ddlLeader.AddCssClass("js-filter-control js-member-is-leader");
            ddlLeader.Label = "Member Type";
            ddlLeader.Items.Add(new ListItem(string.Empty, string.Empty));
            ddlLeader.Items.Add(new ListItem("Leader", "true"));
            ddlLeader.Items.Add(new ListItem("Not Leader", "false"));
            filterControl.Controls.Add(ddlLeader);
            ddlLeader.Style[HtmlTextWriterStyle.Display] = this.SimpleMemberCountMode ? "none" : string.Empty;

            RockDropDownList ddlMemberStatus = new RockDropDownList();

            ddlMemberStatus.ID = string.Format("{0}_ddlMemberStatus", filterControl.ID);
            ddlMemberStatus.AddCssClass("js-filter-control js-member-status");
            ddlMemberStatus.Label = "Member Status";
            ddlMemberStatus.Items.Add(new ListItem(string.Empty, string.Empty));
            foreach (GroupMemberStatus memberStatus in Enum.GetValues(typeof(GroupMemberStatus)))
            {
                ddlMemberStatus.Items.Add(new ListItem(memberStatus.ConvertToString(), memberStatus.ConvertToInt().ToString()));
            }

            filterControl.Controls.Add(ddlMemberStatus);

            ddlLeader.Visible       = !this.SimpleMemberCountMode;
            ddlMemberStatus.Visible = !this.SimpleMemberCountMode;

            return(new Control[] { ddlIntegerCompare, nbMemberCount, ddlLeader, ddlMemberStatus });
        }
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required)
        {
            var ddlList = new RockDropDownList();

            ddlList.ID = string.Format("{0}_ddlList", id);
            ddlList.AddCssClass("js-filter-control");

            if (!required)
            {
                ddlList.Items.Add(new ListItem());
            }

            var control = EditControl(configurationValues, id);

            if (control is RockCheckBoxList)
            {
                foreach (ListItem li in ((RockCheckBoxList)control).Items)
                {
                    ddlList.Items.Add(new ListItem(li.Text, li.Value));
                }
            }

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

            var ddlIntegerCompare = ComparisonHelper.ComparisonControl(ComparisonHelper.NumericFilterComparisonTypes);

            ddlIntegerCompare.ID = string.Format("{0}_{1}", filterControl.ID, controls.Count());
            ddlIntegerCompare.AddCssClass("js-filter-compare");
            filterControl.Controls.Add(ddlIntegerCompare);
            controls.Add(ddlIntegerCompare);

            var ddlGradeDefinedValue = new RockDropDownList();

            ddlGradeDefinedValue.ID = string.Format("{0}_{1}", filterControl.ID, controls.Count());
            ddlGradeDefinedValue.AddCssClass("js-filter-control");

            ddlGradeDefinedValue.Items.Clear();

            // add blank item as first item
            ddlGradeDefinedValue.Items.Add(new ListItem());

            var schoolGrades = DefinedTypeCache.Read(Rock.SystemGuid.DefinedType.SCHOOL_GRADES.AsGuid());

            if (schoolGrades != null)
            {
                foreach (var schoolGrade in schoolGrades.DefinedValues.OrderByDescending(a => a.Value.AsInteger()))
                {
                    ddlGradeDefinedValue.Items.Add(new ListItem(schoolGrade.Description, schoolGrade.Guid.ToString()));
                }
            }

            filterControl.Controls.Add(ddlGradeDefinedValue);
            controls.Add(ddlGradeDefinedValue);

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

            tbCommunicationId.Label      = "Communication Id";
            tbCommunicationId.ID         = filterControl.GetChildControlInstanceName(_CtlCommunicationId);
            tbCommunicationId.CssClass   = "js-communicationId";
            tbCommunicationId.Required   = true;
            tbCommunicationId.NumberType = ValidationDataType.Integer;
            filterControl.Controls.Add(tbCommunicationId);

            // Define Control: Communication Status DropDown List
            var ddlCommunicationStatus = new RockDropDownList();

            ddlCommunicationStatus.ID       = filterControl.GetChildControlInstanceName(_CtlCommunicationStatus);
            ddlCommunicationStatus.Label    = "Communication Status";
            ddlCommunicationStatus.Help     = "Specifies the type of Communication Status that the recipient must have to be included in the result.";
            ddlCommunicationStatus.Required = true;
            ddlCommunicationStatus.AddCssClass("js-filter-status");
            ddlCommunicationStatus.BindToEnum <CommunicationStatusType>();
            filterControl.Controls.Add(ddlCommunicationStatus);

            return(new Control[] { tbCommunicationId, ddlCommunicationStatus });
        }
예제 #19
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var ddlActivityType = new RockDropDownList();

            ddlActivityType.ID = filterControl.ID + "_ddlActivityType";
            ddlActivityType.AddCssClass("js-activity-type");
            ddlActivityType.Label = "Activity Type";
            filterControl.Controls.Add(ddlActivityType);
            var activityTypes = new ConnectionActivityTypeService(new RockContext()).Queryable("ConnectionType").AsNoTracking().Where(a => a.IsActive)
                                .OrderBy(a => a.ConnectionTypeId.HasValue)
                                .ThenBy(a => a.Name)
                                .ToList();

            ddlActivityType.Items.Clear();
            ddlActivityType.Items.Insert(0, new ListItem());
            foreach (var activityType in activityTypes)
            {
                var activityName = GetActivityName(activityType);
                ddlActivityType.Items.Add(new ListItem(activityName, activityType.Guid.ToString()));
            }

            var ddlIntegerCompare = ComparisonHelper.ComparisonControl(ComparisonHelper.NumericFilterComparisonTypes);

            ddlIntegerCompare.Label = "Count";
            ddlIntegerCompare.ID    = filterControl.ID + "_ddlIntegerCompare";
            ddlIntegerCompare.AddCssClass("js-filter-compare");
            filterControl.Controls.Add(ddlIntegerCompare);

            var nbCount = new NumberBox();

            nbCount.ID    = filterControl.ID + "_nbCount";
            nbCount.Label = "&nbsp;"; // give it whitespace label so it lines up nicely
            nbCount.AddCssClass("js-count");
            filterControl.Controls.Add(nbCount);

            var slidingDateRangePicker = new SlidingDateRangePicker();

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

            var controls = new Control[4] {
                ddlActivityType, ddlIntegerCompare, nbCount, slidingDateRangePicker
            };

            // convert pipe to comma delimited
            var defaultDelimitedValues = slidingDateRangePicker.DelimitedValues.Replace("|", ",");
            var defaultCount           = 1;

            // set the default values in case this is a newly added filter
            var selectionConfig = new SelectionConfig()
            {
                IntegerCompare = ComparisonType.GreaterThanOrEqualTo,
                MinimumCount   = defaultCount,
                SlidingDateRangeDelimitedValues = defaultDelimitedValues
            };

            SetSelection(
                entityType,
                controls,
                selectionConfig.ToJson());

            return(controls);
        }
예제 #20
0
        /// <summary>
        /// Gets the multiple option single quantity fee control
        /// </summary>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        /// <param name="feeValues">The fee values.</param>
        /// <param name="registrationInstance">The registration instance.</param>
        /// <param name="otherRegistrants">The other registrants that have been registered so far in this registration</param>
        /// <returns></returns>
        private Control GetFeeMultipleOptionSingleQuantityControl(bool setValues, List <FeeInfo> feeValues, RegistrationInstance registrationInstance, List <RegistrantInfo> otherRegistrants)
        {
            var fee = this;
            var ddl = new RockDropDownList
            {
                ID             = "fee_" + fee.Id.ToString(),
                Label          = fee.Name,
                DataValueField = "Key",
                DataTextField  = "Value",
                Required       = fee.IsRequired
            };

            ddl.AddCssClass("input-width-md");
            ddl.Items.Clear();
            ddl.Items.Add(new ListItem());

            foreach (var feeItem in fee.FeeItems)
            {
                var feeInfo      = feeValues?.FirstOrDefault(a => a.RegistrationTemplateFeeItemId == feeItem.Id);
                int currentValue = feeInfo?.Quantity ?? 0;

                string listItemText = feeItem.Cost == 0.0M ? feeItem.Name : $"{feeItem.Name} ({feeItem.Cost.FormatAsCurrency()})";
                var    listItem     = new ListItem(listItemText, feeItem.Id.ToString());

                int?usageCountRemaining = feeItem.GetUsageCountRemaining(registrationInstance, otherRegistrants);
                if (usageCountRemaining.HasValue)
                {
                    if (usageCountRemaining <= 0)
                    {
                        listItem.Text += " (none remaining)";

                        // if there aren't any remaining, and the currentValue isn't counted in the used counts, disable the option
                        if (currentValue == 0)
                        {
                            // Unless this should be hidden, then set to null so it isn't added.
                            if (HideWhenNoneRemaining == true)
                            {
                                listItem = null;
                            }
                            else
                            {
                                listItem.Enabled = false;
                            }
                        }
                    }
                    else
                    {
                        listItem.Text += $" ({usageCountRemaining} remaining)";
                    }
                }

                if (listItem != null)
                {
                    ddl.Items.Add(listItem);
                }
            }

            // The first item is blank. If there are no other items then return null, this will prevent the control from showing and won't count as a control when deciding to show the fee div.
            if (ddl.Items.Count == 1)
            {
                return(null);
            }

            if (setValues && feeValues != null && feeValues.Any())
            {
                var defaultFeeItemId = feeValues.Where(f => f.Quantity > 0).Select(f => f.RegistrationTemplateFeeItemId).FirstOrDefault();

                ddl.SetValue(defaultFeeItemId);
            }

            return(ddl);
        }
예제 #21
0
        private void BuildFees(bool setValues)
        {
            phFees.Controls.Clear();

            if (TemplateState.Fees != null && TemplateState.Fees.Any())
            {
                divFees.Visible = true;

                foreach (var fee in TemplateState.Fees.OrderBy(f => f.Order))
                {
                    var feeValues = new List <FeeInfo>();
                    if (RegistrantState.FeeValues.ContainsKey(fee.Id))
                    {
                        feeValues = RegistrantState.FeeValues[fee.Id];
                    }

                    if (fee.FeeType == RegistrationFeeType.Single)
                    {
                        string label = fee.Name;
                        var    cost  = fee.CostValue.AsDecimalOrNull();
                        if (cost.HasValue && cost.Value != 0.0M)
                        {
                            label = string.Format("{0} ({1})", fee.Name, cost.Value.FormatAsCurrency());
                        }

                        if (fee.AllowMultiple)
                        {
                            // Single Option, Multi Quantity
                            var numUpDown = new NumberUpDown();
                            numUpDown.ID      = "fee_" + fee.Id.ToString();
                            numUpDown.Label   = label;
                            numUpDown.Minimum = 0;
                            phFees.Controls.Add(numUpDown);

                            if (setValues && feeValues != null && feeValues.Any())
                            {
                                numUpDown.Value = feeValues.First().Quantity;
                            }
                        }
                        else
                        {
                            // Single Option, Single Quantity
                            var cb = new RockCheckBox();
                            cb.ID    = "fee_" + fee.Id.ToString();
                            cb.Label = label;
                            cb.SelectedIconCssClass   = "fa fa-check-square-o fa-lg";
                            cb.UnSelectedIconCssClass = "fa fa-square-o fa-lg";
                            phFees.Controls.Add(cb);

                            if (setValues && feeValues != null && feeValues.Any())
                            {
                                cb.Checked = feeValues.First().Quantity > 0;
                            }
                        }
                    }
                    else
                    {
                        // Parse the options to get name and cost for each
                        var      options    = new Dictionary <string, string>();
                        string[] nameValues = fee.CostValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string nameValue in nameValues)
                        {
                            string[] nameAndValue = nameValue.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);
                            if (nameAndValue.Length == 1)
                            {
                                options.AddOrIgnore(nameAndValue[0], nameAndValue[0]);
                            }
                            if (nameAndValue.Length == 2)
                            {
                                options.AddOrIgnore(nameAndValue[0], string.Format("{0} ({1})", nameAndValue[0], nameAndValue[1].AsDecimal().FormatAsCurrency()));
                            }
                        }

                        if (fee.AllowMultiple)
                        {
                            HtmlGenericControl feeAllowMultiple = new HtmlGenericControl("div");
                            phFees.Controls.Add(feeAllowMultiple);

                            feeAllowMultiple.AddCssClass("feetype-allowmultiples");

                            Label titleLabel = new Label();
                            feeAllowMultiple.Controls.Add(titleLabel);
                            titleLabel.CssClass = "control-label";
                            titleLabel.Text     = fee.Name;

                            foreach (var optionKeyVal in options)
                            {
                                var numUpDown = new NumberUpDown();
                                numUpDown.ID       = string.Format("fee_{0}_{1}", fee.Id, optionKeyVal.Key);
                                numUpDown.Label    = string.Format("{0}", optionKeyVal.Value);
                                numUpDown.Minimum  = 0;
                                numUpDown.CssClass = "fee-allowmultiple";
                                feeAllowMultiple.Controls.Add(numUpDown);

                                if (setValues && feeValues != null && feeValues.Any())
                                {
                                    numUpDown.Value = feeValues
                                                      .Where(f => f.Option == optionKeyVal.Key)
                                                      .Select(f => f.Quantity)
                                                      .FirstOrDefault();
                                }
                            }
                        }
                        else
                        {
                            // Multi Option, Single Quantity
                            var ddl = new RockDropDownList();
                            ddl.ID = "fee_" + fee.Id.ToString();
                            ddl.AddCssClass("input-width-md");
                            ddl.Label          = fee.Name;
                            ddl.DataValueField = "Key";
                            ddl.DataTextField  = "Value";
                            ddl.DataSource     = options;
                            ddl.DataBind();
                            ddl.Items.Insert(0, "");
                            phFees.Controls.Add(ddl);

                            if (setValues && feeValues != null && feeValues.Any())
                            {
                                ddl.SetValue(feeValues
                                             .Where(f => f.Quantity > 0)
                                             .Select(f => f.Option)
                                             .FirstOrDefault());
                            }
                        }
                    }
                }
            }
            else
            {
                divFees.Visible = false;
            }
        }