Пример #1
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();

            var tbValuePrompt = new RockTextBox();
            controls.Add( tbValuePrompt );
            tbValuePrompt.AutoPostBack = true;
            tbValuePrompt.TextChanged += OnQualifierUpdated;
            tbValuePrompt.Label = "Label Prompt";
            tbValuePrompt.Help = "The text to display as a prompt in the label textbox.";

            var ddl = new RockDropDownList();
            controls.Add( ddl );
            ddl.AutoPostBack = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.DataTextField = "Name";
            ddl.DataValueField = "Id";
            ddl.DataSource = new Rock.Model.DefinedTypeService( new RockContext() ).Queryable().OrderBy( d => d.Order ).ToList();
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem(string.Empty, string.Empty));
            ddl.Label = "Defined Type";
            ddl.Help = "Optional Defined Type to select values from, otherwise values will be free-form text fields.";

            var tbCustomValues = new RockTextBox();
            controls.Add( tbCustomValues );
            tbCustomValues.TextMode = TextBoxMode.MultiLine;
            tbCustomValues.Rows = 3;
            tbCustomValues.AutoPostBack = true;
            tbCustomValues.TextChanged += OnQualifierUpdated;
            tbCustomValues.Label = "Custom Values";
            tbCustomValues.Help = "Optional list of options to use for the values.  Format is either 'value1,value2,value3,...', or 'value1:text1,value2:text2,value3:text3,...'.";

            return controls;
        }
Пример #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            EnsureChildControls();

            _ddlFieldType.DataSource = FieldTypeCache.All();
            _ddlFieldType.DataBind();

            base.OnInit(e);
        }
Пример #3
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();

            var ddl = new RockDropDownList();
            controls.Add( ddl );
            ddl.AutoPostBack = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.DataTextField = "Name";
            ddl.DataValueField = "Id";
            ddl.DataSource = new Rock.Model.DefinedTypeService().Queryable().OrderBy( d => d.Order ).ToList();
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem(string.Empty, string.Empty));
            ddl.Label = "Defined Type";
            ddl.Help = "Optional Defined Type to select values from, otherwise values will be free-form text fields.";
            return controls;
        }
Пример #4
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()
        {
            Controls.Clear();

            _hfFormGuid = new HiddenField();
            _hfFormGuid.ID = this.ID + "_hfFormGuid";
            Controls.Add( _hfFormGuid );

            _ddlNotificationSystemEmail = new RockDropDownList();
            _ddlNotificationSystemEmail.DataValueField = "Id";
            _ddlNotificationSystemEmail.DataTextField = "Title";
            _ddlNotificationSystemEmail.Label = "Notification Email";
            _ddlNotificationSystemEmail.Help = "An optional system email that should be sent to the person or people assigned to this activity (Any System Email with a category of 'Workflow').";
            _ddlNotificationSystemEmail.ID = this.ID + "_ddlNotificationSystemEmail";
            Controls.Add( _ddlNotificationSystemEmail );

            _ddlNotificationSystemEmail.DataSource = new SystemEmailService( new RockContext() ).Queryable()
                .Where( e => e.Category == "Workflow" ).OrderBy( e => e.Title ).ToList();
            _ddlNotificationSystemEmail.DataBind();
            _ddlNotificationSystemEmail.Items.Insert( 0, new ListItem( "None", "0" ) );

            _cbIncludeActions = new RockCheckBox();
            _cbIncludeActions.Label = "Include Actions in Email";
            _cbIncludeActions.Text = "Yes";
            _cbIncludeActions.Help = "Should the email include the option for recipient to select an action directly from within the email? Note: This only applies if none of the the form fields are required.";
            _cbIncludeActions.ID = this.ID + "_cbIncludeActions";
            Controls.Add( _cbIncludeActions );

            _ceHeaderText = new CodeEditor();
            _ceHeaderText.Label = "Form Header";
            _ceHeaderText.Help = "Text to display to user above the form fields. <span class='tip tip-liquid'></span> <span class='tip tip-html'>";
            _ceHeaderText.ID = this.ID + "_tbHeaderText";
            _ceHeaderText.EditorMode = CodeEditorMode.Html;
            _ceHeaderText.EditorTheme = CodeEditorTheme.Rock;
            _ceHeaderText.EditorHeight = "200";
            Controls.Add( _ceHeaderText );

            _ceFooterText = new CodeEditor();
            _ceFooterText.Label = "Form Footer";
            _ceFooterText.Help = "Text to display to user below the form fields. <span class='tip tip-liquid'></span> <span class='tip tip-html'>";
            _ceFooterText.ID = this.ID + "_tbFooterText";
            _ceFooterText.EditorMode = CodeEditorMode.Html;
            _ceFooterText.EditorTheme = CodeEditorTheme.Rock;
            _ceFooterText.EditorHeight = "200";
            Controls.Add( _ceFooterText );

            _falActions = new WorkflowFormActionList();
            _falActions.ID = this.ID + "_falActions";
            Controls.Add( _falActions );

            _ddlActionAttribute = new RockDropDownList();
            _ddlActionAttribute.ID = this.ID + "_ddlActionAttribute";
            _ddlActionAttribute.Label = "Command Selected Attribute";
            _ddlActionAttribute.Help = "Optional text attribute that should be updated with the selected command label.";
            Controls.Add( _ddlActionAttribute );
        }
Пример #5
0
        /// <summary>
        /// Creates the fee field.
        /// </summary>
        /// <param name="fee">The fee.</param>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        /// <param name="feeValues">The fee values.</param>
        private void CreateFeeField( RegistrationTemplateFee fee, bool setValues, List<FeeInfo> feeValues )
        {
            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.ToString("C2"));
                }

                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:C2})", nameAndValue[0], nameAndValue[1].AsDecimal() ) );
                    }
                }

                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() );
                    }
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Adds the filter controls and grid columns for all of the registration template's form fields
        /// that were configured to 'Show on Grid'
        /// </summary>
        private void AddDynamicRegistrantControls()
        {
            phRegistrantFormFieldFilters.Controls.Clear();

            // Remove any of the dynamic person fields
            var dynamicColumns = new List<string> {
                "PersonAlias.Person.BirthDate",
            };
            foreach ( var column in gRegistrants.Columns
                .OfType<BoundField>()
                .Where( c => dynamicColumns.Contains( c.DataField ) )
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            // Remove any of the dynamic attribute fields
            foreach ( var column in gRegistrants.Columns
                .OfType<AttributeField>()
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            // Remove the fees field
            foreach ( var column in gRegistrants.Columns
                .OfType<TemplateField>()
                .Where( c => c.HeaderText == "Fees" )
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            // Remove the delete field
            foreach ( var column in gRegistrants.Columns
                .OfType<DeleteField>()
                .ToList() )
            {
                gRegistrants.Columns.Remove( column );
            }

            if ( RegistrantFields != null )
            {
                foreach ( var field in RegistrantFields )
                {
                    if ( field.FieldSource == RegistrationFieldSource.PersonField && field.PersonFieldType.HasValue )
                    {
                        switch ( field.PersonFieldType.Value )
                        {
                            case RegistrationPersonFieldType.Campus:
                                {
                                    var ddlCampus = new RockDropDownList();
                                    ddlCampus.ID = "ddlCampus";
                                    ddlCampus.Label = "Home Campus";
                                    ddlCampus.DataValueField = "Id";
                                    ddlCampus.DataTextField = "Name";
                                    ddlCampus.DataSource = CampusCache.All();
                                    ddlCampus.DataBind();
                                    ddlCampus.Items.Insert( 0, new ListItem( "", "" ) );
                                    ddlCampus.SetValue( fRegistrants.GetUserPreference( "Home Campus" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlCampus );

                                    var templateField = new TemplateField();
                                    templateField.ItemTemplate = new LiteralFieldTemplate( "lCampus" );
                                    templateField.HeaderText = "Campus";
                                    gRegistrants.Columns.Add( templateField );

                                    break;
                                }

                            case RegistrationPersonFieldType.Email:
                                {
                                    var tbEmailFilter = new RockTextBox();
                                    tbEmailFilter.ID = "tbEmailFilter";
                                    tbEmailFilter.Label = "Email";
                                    tbEmailFilter.Text = fRegistrants.GetUserPreference( "Email" );
                                    phRegistrantFormFieldFilters.Controls.Add( tbEmailFilter );

                                    string dataFieldExpression = "PersonAlias.Person.Email";
                                    var emailField = new BoundField();
                                    emailField.DataField = dataFieldExpression;
                                    emailField.HeaderText = "Email";
                                    emailField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( emailField );

                                    break;
                                }

                            case RegistrationPersonFieldType.Birthdate:
                                {
                                    var drpBirthdateFilter = new DateRangePicker();
                                    drpBirthdateFilter.ID = "drpBirthdateFilter";
                                    drpBirthdateFilter.Label = "Birthdate Range";
                                    drpBirthdateFilter.DelimitedValues = fRegistrants.GetUserPreference( "Birthdate Range" );
                                    phRegistrantFormFieldFilters.Controls.Add( drpBirthdateFilter );

                                    string dataFieldExpression = "PersonAlias.Person.BirthDate";
                                    var birthdateField = new DateField();
                                    birthdateField.DataField = dataFieldExpression;
                                    birthdateField.HeaderText = "Birthdate";
                                    birthdateField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( birthdateField );

                                    break;
                                }

                            case RegistrationPersonFieldType.Gender:
                                {
                                    var ddlGenderFilter = new RockDropDownList();
                                    ddlGenderFilter.BindToEnum<Gender>( true );
                                    ddlGenderFilter.ID = "ddlGenderFilter";
                                    ddlGenderFilter.Label = "Gender";
                                    ddlGenderFilter.SetValue( fRegistrants.GetUserPreference( "Gender" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlGenderFilter );

                                    string dataFieldExpression = "PersonAlias.Person.Gender";
                                    var genderField = new EnumField();
                                    genderField.DataField = dataFieldExpression;
                                    genderField.HeaderText = "Gender";
                                    genderField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( genderField );

                                    break;
                                }

                            case RegistrationPersonFieldType.MaritalStatus:
                                {
                                    var ddlMaritalStatusFilter = new RockDropDownList();
                                    ddlMaritalStatusFilter.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid() ), true );
                                    ddlMaritalStatusFilter.ID = "ddlMaritalStatusFilter";
                                    ddlMaritalStatusFilter.Label = "Marital Status";
                                    ddlMaritalStatusFilter.SetValue( fRegistrants.GetUserPreference( "Marital Status" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlMaritalStatusFilter );

                                    string dataFieldExpression = "PersonAlias.Person.MaritalStatusValue.Value";
                                    var maritalStatusField = new BoundField();
                                    maritalStatusField.DataField = dataFieldExpression;
                                    maritalStatusField.HeaderText = "MaritalStatus";
                                    maritalStatusField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( maritalStatusField );

                                    break;
                                }

                            case RegistrationPersonFieldType.MobilePhone:
                                {
                                    var tbPhoneFilter = new RockTextBox();
                                    tbPhoneFilter.ID = "tbPhoneFilter";
                                    tbPhoneFilter.Label = "Phone";
                                    tbPhoneFilter.Text = fRegistrants.GetUserPreference( "Phone" );
                                    phRegistrantFormFieldFilters.Controls.Add( tbPhoneFilter );

                                    var templateField = new TemplateField();
                                    templateField.ItemTemplate = new LiteralFieldTemplate( "lPhone" );
                                    templateField.HeaderText = "Phone(s)";
                                    gRegistrants.Columns.Add( templateField );

                                    break;
                                }
                        }
                    }

                    else if ( field.Attribute != null )
                    {
                        var attribute = field.Attribute;
                        var control = attribute.FieldType.Field.FilterControl( attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter );
                        if ( control != null )
                        {
                            if ( control is IRockControl )
                            {
                                var rockControl = (IRockControl)control;
                                rockControl.Label = attribute.Name;
                                rockControl.Help = attribute.Description;
                                phRegistrantFormFieldFilters.Controls.Add( control );
                            }
                            else
                            {
                                var wrapper = new RockControlWrapper();
                                wrapper.ID = control.ID + "_wrapper";
                                wrapper.Label = attribute.Name;
                                wrapper.Controls.Add( control );
                                phRegistrantFormFieldFilters.Controls.Add( wrapper );
                            }

                            string savedValue = fRegistrants.GetUserPreference( attribute.Key );
                            if ( !string.IsNullOrWhiteSpace( savedValue ) )
                            {
                                try
                                {
                                    var values = JsonConvert.DeserializeObject<List<string>>( savedValue );
                                    attribute.FieldType.Field.SetFilterValues( control, attribute.QualifierValues, values );
                                }
                                catch { }
                            }
                        }

                        string dataFieldExpression = attribute.Id.ToString() + attribute.Key;
                        bool columnExists = gRegistrants.Columns.OfType<AttributeField>().FirstOrDefault( a => a.DataField.Equals( dataFieldExpression ) ) != null;
                        if ( !columnExists )
                        {
                            AttributeField boundField = new AttributeField();
                            boundField.DataField = dataFieldExpression;
                            boundField.HeaderText = attribute.Name;
                            boundField.SortExpression = string.Empty;

                            var attributeCache = Rock.Web.Cache.AttributeCache.Read( attribute.Id );
                            if ( attributeCache != null )
                            {
                                boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                            }

                            gRegistrants.Columns.Add( boundField );
                        }

                    }
                }
            }

            // Add fee column
            var feeField = new TemplateField();
            feeField.HeaderText = "Fees";
            feeField.ItemTemplate = new LiteralFieldTemplate( "lFees" );
            gRegistrants.Columns.Add( feeField );

            var deleteField = new DeleteField();
            gRegistrants.Columns.Add( deleteField );
            deleteField.Click += gRegistrants_Delete;
        }
Пример #7
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();

            _lNickName.ID           = "_lNickName";
            _lLastName.ID           = "_lLastName";
            _tbNickName.ID          = "_tbNickName";
            _tbLastName.ID          = "_tbLastName";
            _ddlSuffix.ID           = "_ddlSuffix";
            _ddlGender.ID           = "_ddlGender";
            _dpBirthdate.ID         = "_dtBirthdate";
            _ddlGradePicker.ID      = "_ddlGrade";
            _pnbMobile.ID           = "_pnbPhone";
            _ddlRelationshipType.ID = "_ddlRelationshipType";
            _phAttributes.ID        = "_phAttributes";
            _lbDelete.ID            = "_lbDelete";

            Controls.Add(_lNickName);
            Controls.Add(_lLastName);
            Controls.Add(_tbNickName);
            Controls.Add(_tbLastName);
            Controls.Add(_ddlSuffix);
            Controls.Add(_dpBirthdate);
            Controls.Add(_ddlGender);
            Controls.Add(_ddlGradePicker);
            Controls.Add(_pnbMobile);
            Controls.Add(_ddlRelationshipType);
            Controls.Add(_phAttributes);
            Controls.Add(_lbDelete);

            _lNickName.Label = "First Name";

            _lLastName.Label = "Last Name";

            _tbNickName.CssClass             = "form-control";
            _tbNickName.Required             = true;
            _tbNickName.RequiredErrorMessage = "First Name is required for all children";
            _tbNickName.Label = "First Name";

            _tbLastName.Required             = true;
            _tbLastName.RequiredErrorMessage = "Last Name is required for all children";
            _tbLastName.Label = "Last Name";

            _ddlSuffix.CssClass = "form-control";
            _ddlSuffix.Label    = "Suffix";
            string suffixValue = _ddlSuffix.SelectedValue;

            _ddlSuffix.Items.Clear();
            _ddlSuffix.BindToDefinedType(DefinedTypeCache.Read(Rock.SystemGuid.DefinedType.PERSON_SUFFIX.AsGuid()), true);
            if (!string.IsNullOrEmpty(suffixValue))
            {
                _ddlSuffix.SelectedValue = suffixValue;
            }

            _ddlGender.RequiredErrorMessage = "Gender is required for all children";
            _ddlGender.Label = "Gender";
            string genderValue = _ddlGender.SelectedValue;

            _ddlGender.Items.Clear();
            _ddlGender.BindToEnum <Gender>(true, new Gender[] { Gender.Unknown });
            if (!string.IsNullOrEmpty(genderValue))
            {
                _ddlGender.SelectedValue = genderValue;
            }

            _dpBirthdate.RequiredErrorMessage = "Birthdate is required for all children";
            _dpBirthdate.Label       = "Birth Date";
            _dpBirthdate.ShowOnFocus = false;
            _dpBirthdate.StartView   = DatePicker.StartViewOption.decade;

            _ddlGradePicker.CssClass             = "form-control";
            _ddlGradePicker.RequiredErrorMessage = _ddlGradePicker.Label + " is required for all children";
            _ddlGradePicker.Label = "Grade";

            _pnbMobile.CssClass = "form-control";
            _pnbMobile.Label    = "Mobile Phone";

            _ddlRelationshipType.CssClass       = "form-control";
            _ddlRelationshipType.Required       = true;
            _ddlRelationshipType.Label          = "Relationship To Adult";
            _ddlRelationshipType.DataValueField = "Key";
            _ddlRelationshipType.DataTextField  = "Value";
            string relationshipTypeValue = _ddlRelationshipType.SelectedValue;

            _ddlRelationshipType.Items.Clear();
            _ddlRelationshipType.DataSource = RelationshipTypeList;
            _ddlRelationshipType.DataBind();
            if (!string.IsNullOrEmpty(relationshipTypeValue))
            {
                _ddlRelationshipType.SelectedValue = relationshipTypeValue;
            }

            foreach (var attribute in AttributeList)
            {
                attribute.AddControl(_phAttributes.Controls, "", this.ValidationGroup, false, true, attribute.IsRequired);
            }

            _lbDelete.CssClass         = "btn btn-xs btn-danger pull-right";
            _lbDelete.Click           += lbDelete_Click;
            _lbDelete.CausesValidation = false;
            _lbDelete.Text             = "<i class='fa fa-times'></i>";
        }
Пример #8
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()
        {
            if ( !_controlsLoaded )
            {
                Controls.Clear();

                _hfExistingKeyNames = new HtmlInputHidden();
                _hfExistingKeyNames.AddCssClass( "js-existing-key-names" );
                _hfExistingKeyNames.ID = this.ID + "_hfExistingKeyNames";
                Controls.Add( _hfExistingKeyNames );

                _lAttributeActionTitle = new Literal();
                _lAttributeActionTitle.ID = "lAttributeActionTitle";
                Controls.Add( _lAttributeActionTitle );

                _validationSummary = new ValidationSummary();
                _validationSummary.ID = "valiationSummary";
                _validationSummary.CssClass = "alert alert-danger";
                _validationSummary.HeaderText = "Please Correct the Following";
                Controls.Add( _validationSummary );

                _tbName = new RockTextBox();
                _tbName.ID = "tbName";
                _tbName.Label = "Name";
                _tbName.Required = true;
                Controls.Add( _tbName );

                _tbDescription = new RockTextBox();
                _tbDescription.Label = "Description";
                _tbDescription.ID = "tbDescription";
                _tbDescription.TextMode = TextBoxMode.MultiLine;
                _tbDescription.Rows = 3;
                Controls.Add( _tbDescription );

                _cpCategories = new CategoryPicker();
                _cpCategories.ID = "cpCategories_" + this.ID.ToString();
                _cpCategories.Label = "Categories";
                _cpCategories.AllowMultiSelect = true;
                _cpCategories.EntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Attribute ) ).Id;
                _cpCategories.EntityTypeQualifierColumn = "EntityTypeId";
                Controls.Add( _cpCategories );

                _tbKey = new RockTextBox();
                _tbKey.ID = "tbKey";
                _tbKey.Label = "Key";
                _tbKey.Required = true;
                Controls.Add( _tbKey );

                _cvKey = new CustomValidator();
                _cvKey.ID = "cvKey";
                _cvKey.ControlToValidate = _tbKey.ID;
                _cvKey.ClientValidationFunction = "validateKey";
                _cvKey.ServerValidate += cvKey_ServerValidate;
                _cvKey.Display = ValidatorDisplay.Dynamic;
                _cvKey.CssClass = "validation-error help-inline";
                _cvKey.ErrorMessage = "There is already an existing property with the key value you entered.  Please select a different key value.";
                Controls.Add( _cvKey );

                _tbIconCssClass = new RockTextBox();
                _tbIconCssClass.ID = "_tbIconCssClass";
                _tbIconCssClass.Label = "Icon CSS Class";
                Controls.Add( _tbIconCssClass );

                _cbRequired = new RockCheckBox();
                _cbRequired.ID ="cbRequired";
                _cbRequired.Label = "Required";
                _cbRequired.Text = "Require a value";
                Controls.Add( _cbRequired );

                _cbShowInGrid = new RockCheckBox();
                _cbShowInGrid.ID = "cbShowInGrid";
                _cbShowInGrid.Label = "Show in Grid";
                _cbShowInGrid.Text = "Yes";
                _cbShowInGrid.Help = "If selected, this attribute will be included in a grid.";
                Controls.Add( _cbShowInGrid );

                _ddlFieldType = new RockDropDownList();
                _ddlFieldType.ID = "ddlFieldType";
                _ddlFieldType.Label = "Field Type";
                _ddlFieldType.AutoPostBack = true;
                _ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged;
                Controls.Add( _ddlFieldType );

                if ( !Page.IsPostBack )
                {
                    _ddlFieldType.DataValueField = "Id";
                    _ddlFieldType.DataTextField = "Name";
                    _ddlFieldType.DataSource = FieldTypeCache.All();
                    _ddlFieldType.DataBind();
                }

                _phQualifiers = new PlaceHolder();
                _phQualifiers.ID = "phQualifiers";
                _phQualifiers.EnableViewState = false;
                Controls.Add( _phQualifiers );

                _phDefaultValue = new PlaceHolder();
                _phDefaultValue.ID = "phDefaultValue";
                _phDefaultValue.EnableViewState = false;
                Controls.Add( _phDefaultValue );

                _btnSave = new LinkButton();
                _btnSave.ID = "btnSave";
                _btnSave.Text = "OK";
                _btnSave.CssClass = "btn btn-primary";
                _btnSave.Click += btnSave_Click;
                Controls.Add( _btnSave );

                _btnCancel = new LinkButton();
                _btnCancel.ID = "btnCancel";
                _btnCancel.Text = "Cancel";
                _btnCancel.CssClass = "btn btn-link";
                _btnCancel.CausesValidation = false;
                _btnCancel.Click += btnCancel_Click;
                Controls.Add( _btnCancel );

                _tbName.Attributes["onblur"] = string.Format( "populateAttributeKey('{0}','{1}')", _tbName.ClientID, _tbKey.ClientID );

                _controlsLoaded = true;
            }
        }
Пример #9
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();

            var ddl = new RockDropDownList();
            controls.Add( ddl );
            ddl.AutoPostBack = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.DataTextField = "Name";
            ddl.DataValueField = "Id";
            ddl.DataSource = new BinaryFileTypeService( new RockContext() )
                .Queryable()
                .OrderBy( f => f.Name )
                .Select( f => new { f.Id, f.Name } )
                .ToList();
            ddl.DataBind();
            ddl.Items.Insert( 0, new ListItem( string.Empty, string.Empty ) );
            ddl.Label = "File Type";
            ddl.Help = "The type of files to list.";

            return controls;
        }
Пример #10
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()
        {
            Controls.Clear();

            _hfValue.ID = this.ID + "_hfValue";
            Controls.Add(_hfValue);

            _actionControls     = new List <RockTextBox>();
            _buttonHtmlControls = new List <RockDropDownList>();
            _activityControls   = new List <RockDropDownList>();
            _responseControls   = new List <RockTextBox>();

            string[] nameValues = this.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < nameValues.Length; i++)
            {
                string[] nameValueResponse = nameValues[i].Split(new char[] { '^' });

                var tbAction = new RockTextBox();
                tbAction.ID = this.ID + "_tbAction" + i.ToString();
                Controls.Add(tbAction);
                tbAction.Placeholder = "Action";
                tbAction.AddCssClass("form-action-key");
                tbAction.AddCssClass("form-control");
                tbAction.AddCssClass("js-form-action-input");
                tbAction.Text = nameValueResponse.Length > 0 ? nameValueResponse[0] : string.Empty;
                _actionControls.Add(tbAction);

                var ddlButtonHtml = new RockDropDownList();
                ddlButtonHtml.ID = this.ID + "_ddlButtonHtml" + i.ToString();
                ddlButtonHtml.EnableViewState = false;
                Controls.Add(ddlButtonHtml);
                ddlButtonHtml.AddCssClass("form-action-button");
                ddlButtonHtml.AddCssClass("form-control");
                ddlButtonHtml.AddCssClass("js-form-action-input");
                var definedType = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.BUTTON_HTML.AsGuid());
                foreach (var definedValue in definedType.DefinedValues)
                {
                    var li = new ListItem(definedValue.Value, definedValue.Guid.ToString());
                    li.Selected = nameValueResponse.Length > 1 && li.Value.Equals(nameValueResponse[1], StringComparison.OrdinalIgnoreCase);
                    ddlButtonHtml.Items.Add(li);
                }
                _buttonHtmlControls.Add(ddlButtonHtml);

                var ddlActivity = new RockDropDownList();
                ddlActivity.ID = this.ID + "_ddlActivity" + i.ToString();
                ddlActivity.EnableViewState = false;
                Controls.Add(ddlActivity);
                ddlActivity.AddCssClass("form-action-value");
                ddlActivity.AddCssClass("form-control");
                ddlActivity.AddCssClass("js-form-action-input");
                ddlActivity.DataTextField  = "Value";
                ddlActivity.DataValueField = "Key";
                ddlActivity.DataSource     = Activities;
                ddlActivity.DataBind();
                ddlActivity.Items.Insert(0, new ListItem(string.Empty, string.Empty));
                foreach (ListItem li in ddlActivity.Items)
                {
                    li.Selected = nameValueResponse.Length > 2 && li.Value.Equals(nameValueResponse[2], StringComparison.OrdinalIgnoreCase);
                }
                _activityControls.Add(ddlActivity);

                var tbResponse = new RockTextBox();
                tbResponse.ID = this.ID + "_tbResponse" + i.ToString();
                Controls.Add(tbResponse);
                tbResponse.Placeholder = "Response Text";
                tbResponse.AddCssClass("form-action-response");
                tbResponse.AddCssClass("form-control");
                tbResponse.AddCssClass("js-form-action-input");
                tbResponse.Text = nameValueResponse.Length > 3 ? nameValueResponse[3] : string.Empty;
                _responseControls.Add(tbResponse);
            }
        }
        /// <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()
        {
            Controls.Clear();

            _hfValue.ID = this.ID + "_hfValue";
            Controls.Add( _hfValue );

            _actionControls = new List<RockTextBox>();
            _buttonHtmlControls = new List<RockDropDownList>();
            _activityControls = new List<RockDropDownList>();
            _responseControls = new List<RockTextBox>();

            string[] nameValues = this.Value.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries );
            for ( int i = 0; i < nameValues.Length; i++ )
            {
                string[] nameValueResponse = nameValues[i].Split( new char[] { '^' } );

                var tbAction = new RockTextBox();
                tbAction.ID = this.ID + "_tbAction" + i.ToString();
                Controls.Add( tbAction );
                tbAction.Placeholder = "Action";
                tbAction.AddCssClass( "form-action-key" );
                tbAction.AddCssClass( "form-control" );
                tbAction.AddCssClass( "js-form-action-input" );
                tbAction.Text = nameValueResponse.Length > 0 ? nameValueResponse[0] : string.Empty;
                _actionControls.Add( tbAction );

                var ddlButtonHtml = new RockDropDownList();
                ddlButtonHtml.ID = this.ID + "_ddlButtonHtml" + i.ToString();
                Controls.Add( ddlButtonHtml );
                ddlButtonHtml.AddCssClass( "form-action-button" );
                ddlButtonHtml.AddCssClass( "form-control" );
                ddlButtonHtml.AddCssClass( "js-form-action-input" );
                var definedType = Rock.Web.Cache.DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.BUTTON_HTML.AsGuid() );
                foreach( var definedValue in definedType.DefinedValues )
                {
                    var li = new ListItem( definedValue.Value, definedValue.Guid.ToString() );
                    li.Selected = nameValueResponse.Length > 1 && li.Value.Equals( nameValueResponse[1], StringComparison.OrdinalIgnoreCase );
                    ddlButtonHtml.Items.Add( li );
                }
                _buttonHtmlControls.Add( ddlButtonHtml );

                var ddlActivity = new RockDropDownList();
                ddlActivity.ID = this.ID + "_ddlActivity" + i.ToString();
                Controls.Add( ddlActivity );
                ddlActivity.AddCssClass( "form-action-value" );
                ddlActivity.AddCssClass( "form-control" );
                ddlActivity.AddCssClass( "js-form-action-input" );
                ddlActivity.DataTextField = "Value";
                ddlActivity.DataValueField = "Key";
                ddlActivity.DataSource = Activities;
                ddlActivity.DataBind();
                ddlActivity.Items.Insert( 0, new ListItem( string.Empty, string.Empty ) );
                foreach(ListItem li in ddlActivity.Items)
                {
                    li.Selected = nameValueResponse.Length > 2 && li.Value.Equals( nameValueResponse[2], StringComparison.OrdinalIgnoreCase );
                }
                _activityControls.Add( ddlActivity );

                var tbResponse = new RockTextBox();
                tbResponse.ID = this.ID + "_tbResponse" + i.ToString();
                Controls.Add( tbResponse );
                tbResponse.Placeholder = "Response Text";
                tbResponse.AddCssClass( "form-action-response" );
                tbResponse.AddCssClass( "form-control" );
                tbResponse.AddCssClass( "js-form-action-input" );
                tbResponse.Text = nameValueResponse.Length > 3 ? nameValueResponse[3] : string.Empty;
                _responseControls.Add( tbResponse );
            }
        }
        /// <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()
        {
            Controls.Clear();

            _hfFormGuid    = new HiddenField();
            _hfFormGuid.ID = this.ID + "_hfFormGuid";
            Controls.Add(_hfFormGuid);

            _ddlNotificationSystemEmail = new RockDropDownList();
            _ddlNotificationSystemEmail.EnableViewState = false;
            _ddlNotificationSystemEmail.DataValueField  = "Id";
            _ddlNotificationSystemEmail.DataTextField   = "Title";
            _ddlNotificationSystemEmail.Label           = "Notification Email";
            _ddlNotificationSystemEmail.Help            = "An optional system email that should be sent to the person or people assigned to this activity (Any System Email with a category of 'Workflow').";
            _ddlNotificationSystemEmail.ID = this.ID + "_ddlNotificationSystemEmail";
            Controls.Add(_ddlNotificationSystemEmail);

            var systemEmailCategory = CategoryCache.Get(Rock.SystemGuid.Category.SYSTEM_EMAIL_WORKFLOW.AsGuid());

            if (systemEmailCategory != null)
            {
                using (var rockContext = new RockContext())
                {
                    _ddlNotificationSystemEmail.DataSource = new SystemEmailService(rockContext).Queryable()
                                                             .Where(e => e.CategoryId == systemEmailCategory.Id)
                                                             .OrderBy(e => e.Title)
                                                             .Select(a => new { a.Id, a.Title })
                                                             .ToList();
                    _ddlNotificationSystemEmail.DataBind();
                }
            }

            _ddlNotificationSystemEmail.Items.Insert(0, new ListItem("None", "0"));

            _cbIncludeActions       = new RockCheckBox();
            _cbIncludeActions.Label = "Include Actions in Email";
            _cbIncludeActions.Text  = "Yes";
            _cbIncludeActions.Help  = "Should the email include the option for recipient to select an action directly from within the email? Note: This only applies if none of the the form fields are required. The workflow will be persisted immediately prior to sending the email.";
            _cbIncludeActions.ID    = this.ID + "_cbIncludeActions";
            Controls.Add(_cbIncludeActions);

            _ceHeaderText              = new CodeEditor();
            _ceHeaderText.Label        = "Form Header";
            _ceHeaderText.Help         = "Text to display to user above the form fields. <span class='tip tip-lava'></span> <span class='tip tip-html'>";
            _ceHeaderText.ID           = this.ID + "_tbHeaderText";
            _ceHeaderText.EditorMode   = CodeEditorMode.Html;
            _ceHeaderText.EditorTheme  = CodeEditorTheme.Rock;
            _ceHeaderText.EditorHeight = "200";
            Controls.Add(_ceHeaderText);

            _ceFooterText              = new CodeEditor();
            _ceFooterText.Label        = "Form Footer";
            _ceFooterText.Help         = "Text to display to user below the form fields. <span class='tip tip-lava'></span> <span class='tip tip-html'>";
            _ceFooterText.ID           = this.ID + "_tbFooterText";
            _ceFooterText.EditorMode   = CodeEditorMode.Html;
            _ceFooterText.EditorTheme  = CodeEditorTheme.Rock;
            _ceFooterText.EditorHeight = "200";
            Controls.Add(_ceFooterText);

            _falActions    = new WorkflowFormActionList();
            _falActions.ID = this.ID + "_falActions";
            Controls.Add(_falActions);

            _ddlActionAttribute = new RockDropDownList();
            _ddlActionAttribute.EnableViewState = false;
            _ddlActionAttribute.ID    = this.ID + "_ddlActionAttribute";
            _ddlActionAttribute.Label = "Command Selected Attribute";
            _ddlActionAttribute.Help  = "Optional text attribute that should be updated with the selected command label.";
            Controls.Add(_ddlActionAttribute);

            _cbAllowNotes       = new RockCheckBox();
            _cbAllowNotes.Label = "Enable Note Entry";
            _cbAllowNotes.Text  = "Yes";
            _cbAllowNotes.Help  = "Should this form include an area for viewing and editing notes related to the workflow?";
            _cbAllowNotes.ID    = this.ID + "_cbAllowNotes";
            Controls.Add(_cbAllowNotes);
        }
Пример #13
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()
        {
            if (!_controlsLoaded)
            {
                Controls.Clear();

                _lAttributeActionTitle    = new Literal();
                _lAttributeActionTitle.ID = "lAttributeActionTitle";
                Controls.Add(_lAttributeActionTitle);

                _validationSummary            = new ValidationSummary();
                _validationSummary.ID         = "valiationSummary";
                _validationSummary.CssClass   = "alert alert-danger";
                _validationSummary.HeaderText = "Please Correct the Following";
                Controls.Add(_validationSummary);

                _tbName          = new RockTextBox();
                _tbName.ID       = "tbName";
                _tbName.Label    = "Name";
                _tbName.Required = true;
                Controls.Add(_tbName);

                _tbDescription          = new RockTextBox();
                _tbDescription.Label    = "Description";
                _tbDescription.ID       = "tbDescription";
                _tbDescription.TextMode = TextBoxMode.MultiLine;
                _tbDescription.Rows     = 3;
                Controls.Add(_tbDescription);

                _cpCategories                           = new CategoryPicker();
                _cpCategories.ID                        = "cpCategories_" + this.ID.ToString();
                _cpCategories.Label                     = "Categories";
                _cpCategories.AllowMultiSelect          = true;
                _cpCategories.EntityTypeId              = EntityTypeCache.Read(typeof(Rock.Model.Attribute)).Id;
                _cpCategories.EntityTypeQualifierColumn = "EntityTypeId";
                Controls.Add(_cpCategories);

                _tbKey          = new RockTextBox();
                _tbKey.ID       = "tbKey";
                _tbKey.Label    = "Key";
                _tbKey.Required = true;
                Controls.Add(_tbKey);

                _cvKey    = new CustomValidator();
                _cvKey.ID = "cvKey";
                _cvKey.ControlToValidate        = _tbKey.ID;
                _cvKey.ClientValidationFunction = "validateKey";
                _cvKey.ServerValidate          += cvKey_ServerValidate;
                _cvKey.Display      = ValidatorDisplay.Dynamic;
                _cvKey.CssClass     = "validation-error help-inline";
                _cvKey.ErrorMessage = "There is already an existing property with the key value you entered.  Please select a different key value.";
                Controls.Add(_cvKey);

                _cbRequired       = new RockCheckBox();
                _cbRequired.ID    = "cbRequired";
                _cbRequired.Label = "Required";
                _cbRequired.Text  = "Require a value";
                Controls.Add(_cbRequired);

                _cbShowInGrid       = new RockCheckBox();
                _cbShowInGrid.ID    = "cbShowInGrid";
                _cbShowInGrid.Label = "Show in Grid";
                _cbShowInGrid.Text  = "Yes";
                _cbShowInGrid.Help  = "If selected, this attribute will be included in a grid.";
                Controls.Add(_cbShowInGrid);

                _ddlFieldType                       = new RockDropDownList();
                _ddlFieldType.ID                    = "ddlFieldType";
                _ddlFieldType.Label                 = "Field Type";
                _ddlFieldType.AutoPostBack          = true;
                _ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged;
                Controls.Add(_ddlFieldType);

                if (!Page.IsPostBack)
                {
                    _ddlFieldType.DataValueField = "Id";
                    _ddlFieldType.DataTextField  = "Name";
                    _ddlFieldType.DataSource     = new FieldTypeService()
                                                   .Queryable()
                                                   .OrderBy(a => a.Name)
                                                   .Select(a => new { a.Id, a.Name }).ToList();;
                    _ddlFieldType.DataBind();
                }

                _phQualifiers    = new PlaceHolder();
                _phQualifiers.ID = "phQualifiers";
                _phQualifiers.EnableViewState = false;
                Controls.Add(_phQualifiers);

                _phDefaultValue    = new PlaceHolder();
                _phDefaultValue.ID = "phDefaultValue";
                _phDefaultValue.EnableViewState = false;
                Controls.Add(_phDefaultValue);

                _btnSave          = new LinkButton();
                _btnSave.ID       = "btnSave";
                _btnSave.Text     = "OK";
                _btnSave.CssClass = "btn btn-primary";
                _btnSave.Click   += btnSave_Click;
                Controls.Add(_btnSave);

                _btnCancel                  = new LinkButton();
                _btnCancel.ID               = "btnCancel";
                _btnCancel.Text             = "Cancel";
                _btnCancel.CssClass         = "btn btn-link";
                _btnCancel.CausesValidation = false;
                _btnCancel.Click           += btnCancel_Click;
                Controls.Add(_btnCancel);

                _tbName.Attributes["onblur"] = string.Format("populateAttributeKey('{0}','{1}')", _tbName.ClientID, _tbKey.ClientID);

                _controlsLoaded = true;
            }
        }
Пример #14
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();

            _lNickName.ID                  = "_lNickName";
            _lLastName.ID                  = "_lLastName";
            _tbNickName.ID                 = "_tbNickName";
            _tbLastName.ID                 = "_tbLastName";
            _ddlSuffix.ID                  = "_ddlSuffix";
            _ddlGender.ID                  = "_ddlGender";
            _bpBirthdate.ID                = "_bpBirthdate";
            _ddlGradePicker.ID             = "_ddlGrade";
            _pnbMobile.ID                  = "_pnbPhone";
            _ebEmail.ID                    = "_ebEmail";
            _ddlRelationshipType.ID        = "_ddlRelationshipType";
            _phAttributes.ID               = "_phAttributes";
            _lbDelete.ID                   = "_lbDelete";
            _rblCommunicationPreference.ID = "_rblCommunicationPreference";

            Controls.Add(_lNickName);
            Controls.Add(_lLastName);
            Controls.Add(_tbNickName);
            Controls.Add(_tbLastName);
            Controls.Add(_ddlSuffix);
            Controls.Add(_bpBirthdate);
            Controls.Add(_ddlGender);
            Controls.Add(_ddlGradePicker);
            Controls.Add(_pnbMobile);
            Controls.Add(_ebEmail);
            Controls.Add(_rblCommunicationPreference);
            Controls.Add(_ddlRelationshipType);
            Controls.Add(_phAttributes);
            Controls.Add(_lbDelete);

            _lNickName.Label = "First Name";

            _lLastName.Label = "Last Name";

            _tbNickName.CssClass             = "form-control";
            _tbNickName.Required             = true;
            _tbNickName.RequiredErrorMessage = "First Name is required for all children";
            _tbNickName.Label = "First Name";

            _tbLastName.Required             = true;
            _tbLastName.RequiredErrorMessage = "Last Name is required for all children";
            _tbLastName.Label = "Last Name";

            _ddlSuffix.CssClass = "form-control";
            _ddlSuffix.Label    = "Suffix";
            string suffixValue = _ddlSuffix.SelectedValue;

            _ddlSuffix.Items.Clear();
            _ddlSuffix.DefinedTypeId = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.PERSON_SUFFIX.AsGuid()).Id;
            if (!string.IsNullOrEmpty(suffixValue))
            {
                _ddlSuffix.SelectedValue = suffixValue;
            }

            _ddlGender.RequiredErrorMessage = "Gender is required for all children";
            _ddlGender.Label = "Gender";
            string genderValue = _ddlGender.SelectedValue;

            _ddlGender.Items.Clear();
            _ddlGender.BindToEnum <Gender>(true, new Gender[] { Gender.Unknown });
            if (!string.IsNullOrEmpty(genderValue))
            {
                _ddlGender.SelectedValue = genderValue;
            }

            _bpBirthdate.RequiredErrorMessage = "Birth date is required for all children";
            _bpBirthdate.Label = "Birth Date";

            _ddlGradePicker.CssClass             = "form-control";
            _ddlGradePicker.RequiredErrorMessage = "Grade is required for all children";
            _ddlGradePicker.Label = "Grade";

            /*
             *      06/03/2020 - SK
             *      This is not needed because the PhoneNumberBox control already adds form-control in the correct spot
             */
            //_pnbMobile.CssClass = "form-control";

            _pnbMobile.Label = "Mobile Phone";
            _pnbMobile.RequiredErrorMessage = "A valid phone number is required for all children.";

            _ebEmail.Label = "Email Address";

            _rblCommunicationPreference.Label           = "Communication Preference";
            _rblCommunicationPreference.RepeatDirection = RepeatDirection.Horizontal;

            if (_rblCommunicationPreference.Items.Count == 0)
            {
                _rblCommunicationPreference.Items.Add(new ListItem("Email", "1"));
                _rblCommunicationPreference.Items.Add(new ListItem("SMS", "2"));
            }

            _ddlRelationshipType.CssClass       = "form-control";
            _ddlRelationshipType.Required       = true;
            _ddlRelationshipType.Label          = "Relationship to Adult";
            _ddlRelationshipType.DataValueField = "Key";
            _ddlRelationshipType.DataTextField  = "Value";
            string relationshipTypeValue = _ddlRelationshipType.SelectedValue;

            _ddlRelationshipType.Items.Clear();
            _ddlRelationshipType.DataSource = RelationshipTypeList;
            _ddlRelationshipType.DataBind();
            if (!string.IsNullOrEmpty(relationshipTypeValue))
            {
                _ddlRelationshipType.SelectedValue = relationshipTypeValue;
            }

            foreach (var attribute in AttributeList)
            {
                attribute.AddControl(_phAttributes.Controls, "", this.ValidationGroup, false, true, attribute.IsRequired);
            }

            _lbDelete.CssClass         = "btn btn-xs btn-square btn-danger pull-right";
            _lbDelete.Click           += lbDelete_Click;
            _lbDelete.CausesValidation = false;
            _lbDelete.Text             = "<i class='fa fa-times'></i>";
        }
Пример #15
0
        /// <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 };
        }
        /// <summary>
        /// Adds the filter controls and grid columns for all of the registration template's form fields
        /// that were configured to 'Show on Grid'
        /// </summary>
        private void AddDynamicControls()
        {
            phRegistrantFormFieldFilters.Controls.Clear();
            phWaitListFormFieldFilters.Controls.Clear();

            ClearGrid( gGroupPlacements );
            ClearGrid( gRegistrants );
            ClearGrid( gWaitList );

            if ( RegistrantFields != null )
            {
                foreach ( var field in RegistrantFields )
                {
                    if ( field.FieldSource == RegistrationFieldSource.PersonField && field.PersonFieldType.HasValue )
                    {
                        switch ( field.PersonFieldType.Value )
                        {
                            case RegistrationPersonFieldType.Campus:
                                {
                                    var ddlCampus = new RockDropDownList();
                                    ddlCampus.ID = "ddlCampus";
                                    ddlCampus.Label = "Home Campus";
                                    ddlCampus.DataValueField = "Id";
                                    ddlCampus.DataTextField = "Name";
                                    ddlCampus.DataSource = CampusCache.All();
                                    ddlCampus.DataBind();
                                    ddlCampus.Items.Insert( 0, new ListItem( "", "" ) );
                                    ddlCampus.SetValue( fRegistrants.GetUserPreference( "Home Campus" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlCampus );

                                    var ddlCampus2 = new RockDropDownList();
                                    ddlCampus2.ID = "ddlCampus";
                                    ddlCampus2.Label = "Home Campus";
                                    ddlCampus2.DataValueField = "Id";
                                    ddlCampus2.DataTextField = "Name";
                                    ddlCampus2.DataSource = CampusCache.All();
                                    ddlCampus2.DataBind();
                                    ddlCampus2.Items.Insert( 0, new ListItem( "", "" ) );
                                    ddlCampus2.SetValue( fRegistrants.GetUserPreference( "WL-Home Campus" ) );
                                    phWaitListFormFieldFilters.Controls.Add( ddlCampus2 );

                                    var templateField = new RockLiteralField();
                                    templateField.ID = "lCampus";
                                    templateField.HeaderText = "Campus";
                                    gRegistrants.Columns.Add( templateField );

                                    var templateField2 = new RockLiteralField();
                                    templateField2.ID = "lCampus";
                                    templateField2.HeaderText = "Campus";
                                    gGroupPlacements.Columns.Add( templateField2 );

                                    var templateField3 = new RockLiteralField();
                                    templateField3.ID = "lCampus";
                                    templateField3.HeaderText = "Campus";
                                    gWaitList.Columns.Add( templateField3 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Email:
                                {
                                    var tbEmailFilter = new RockTextBox();
                                    tbEmailFilter.ID = "tbEmailFilter";
                                    tbEmailFilter.Label = "Email";
                                    tbEmailFilter.Text = fRegistrants.GetUserPreference( "Email" );
                                    phRegistrantFormFieldFilters.Controls.Add( tbEmailFilter );

                                    var tbEmailFilter2 = new RockTextBox();
                                    tbEmailFilter2.ID = "tbEmailFilter";
                                    tbEmailFilter2.Label = "Email";
                                    tbEmailFilter2.Text = fRegistrants.GetUserPreference( "WL-Email" );
                                    phWaitListFormFieldFilters.Controls.Add( tbEmailFilter2 );

                                    string dataFieldExpression = "PersonAlias.Person.Email";
                                    var emailField = new RockBoundField();
                                    emailField.DataField = dataFieldExpression;
                                    emailField.HeaderText = "Email";
                                    emailField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( emailField );

                                    var emailField2 = new RockBoundField();
                                    emailField2.DataField = dataFieldExpression;
                                    emailField2.HeaderText = "Email";
                                    emailField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( emailField2 );

                                    var emailField3 = new RockBoundField();
                                    emailField3.DataField = dataFieldExpression;
                                    emailField3.HeaderText = "Email";
                                    emailField3.SortExpression = dataFieldExpression;
                                    gWaitList.Columns.Add( emailField3 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Birthdate:
                                {
                                    var drpBirthdateFilter = new DateRangePicker();
                                    drpBirthdateFilter.ID = "drpBirthdateFilter";
                                    drpBirthdateFilter.Label = "Birthdate Range";
                                    drpBirthdateFilter.DelimitedValues = fRegistrants.GetUserPreference( "Birthdate Range" );
                                    phRegistrantFormFieldFilters.Controls.Add( drpBirthdateFilter );

                                    var drpBirthdateFilter2 = new DateRangePicker();
                                    drpBirthdateFilter2.ID = "drpBirthdateFilter";
                                    drpBirthdateFilter2.Label = "Birthdate Range";
                                    drpBirthdateFilter2.DelimitedValues = fRegistrants.GetUserPreference( "WL-Birthdate Range" );
                                    phWaitListFormFieldFilters.Controls.Add( drpBirthdateFilter2 );

                                    string dataFieldExpression = "PersonAlias.Person.BirthDate";
                                    var birthdateField = new DateField();
                                    birthdateField.DataField = dataFieldExpression;
                                    birthdateField.HeaderText = "Birthdate";
                                    birthdateField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( birthdateField );

                                    var birthdateField2 = new DateField();
                                    birthdateField2.DataField = dataFieldExpression;
                                    birthdateField2.HeaderText = "Birthdate";
                                    birthdateField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( birthdateField2 );

                                    var birthdateField3 = new DateField();
                                    birthdateField3.DataField = dataFieldExpression;
                                    birthdateField3.HeaderText = "Birthdate";
                                    birthdateField3.SortExpression = dataFieldExpression;
                                    gWaitList.Columns.Add( birthdateField3 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Grade:
                                {
                                    var gpGradeFilter = new GradePicker();
                                    gpGradeFilter.ID = "gpGradeFilter";
                                    gpGradeFilter.Label = "Grade";
                                    gpGradeFilter.UseAbbreviation = true;
                                    gpGradeFilter.UseGradeOffsetAsValue = true;
                                    gpGradeFilter.CssClass = "input-width-md";
                                    gpGradeFilter.SetValue( fRegistrants.GetUserPreference( "Grade" ).AsIntegerOrNull() );
                                    phRegistrantFormFieldFilters.Controls.Add( gpGradeFilter );

                                    var gpGradeFilter2 = new GradePicker();
                                    gpGradeFilter2.ID = "gpGradeFilter";
                                    gpGradeFilter2.Label = "Grade";
                                    gpGradeFilter2.UseAbbreviation = true;
                                    gpGradeFilter2.UseGradeOffsetAsValue = true;
                                    gpGradeFilter2.CssClass = "input-width-md";
                                    gpGradeFilter2.SetValue( fRegistrants.GetUserPreference( "WL-Grade" ).AsIntegerOrNull() );
                                    phWaitListFormFieldFilters.Controls.Add( gpGradeFilter2 );

                                    string dataFieldExpression = "PersonAlias.Person.GraduationYear";
                                    var gradeField = new RockBoundField();
                                    gradeField.DataField = dataFieldExpression;
                                    gradeField.HeaderText = "Graduation Year";
                                    gradeField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( gradeField );

                                    var gradeField2 = new RockBoundField();
                                    gradeField2.DataField = dataFieldExpression;
                                    gradeField2.HeaderText = "Graduation Year";
                                    gradeField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( gradeField2 );

                                    var gradeField3 = new RockBoundField();
                                    gradeField3.DataField = dataFieldExpression;
                                    gradeField3.HeaderText = "Graduation Year";
                                    gradeField3.SortExpression = dataFieldExpression;
                                    gWaitList.Columns.Add( gradeField3 );

                                    break;
                                }

                            case RegistrationPersonFieldType.Gender:
                                {
                                    var ddlGenderFilter = new RockDropDownList();
                                    ddlGenderFilter.BindToEnum<Gender>( true );
                                    ddlGenderFilter.ID = "ddlGenderFilter";
                                    ddlGenderFilter.Label = "Gender";
                                    ddlGenderFilter.SetValue( fRegistrants.GetUserPreference( "Gender" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlGenderFilter );

                                    var ddlGenderFilter2 = new RockDropDownList();
                                    ddlGenderFilter2.BindToEnum<Gender>( true );
                                    ddlGenderFilter2.ID = "ddlGenderFilter";
                                    ddlGenderFilter2.Label = "Gender";
                                    ddlGenderFilter2.SetValue( fRegistrants.GetUserPreference( "WL-Gender" ) );
                                    phWaitListFormFieldFilters.Controls.Add( ddlGenderFilter2 );

                                    string dataFieldExpression = "PersonAlias.Person.Gender";
                                    var genderField = new EnumField();
                                    genderField.DataField = dataFieldExpression;
                                    genderField.HeaderText = "Gender";
                                    genderField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( genderField );

                                    var genderField2 = new EnumField();
                                    genderField2.DataField = dataFieldExpression;
                                    genderField2.HeaderText = "Gender";
                                    genderField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( genderField2 );

                                    var genderField3 = new EnumField();
                                    genderField3.DataField = dataFieldExpression;
                                    genderField3.HeaderText = "Gender";
                                    genderField3.SortExpression = dataFieldExpression;
                                    gWaitList.Columns.Add( genderField3 );
                                    break;
                                }

                            case RegistrationPersonFieldType.MaritalStatus:
                                {
                                    var ddlMaritalStatusFilter = new RockDropDownList();
                                    ddlMaritalStatusFilter.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid() ), true );
                                    ddlMaritalStatusFilter.ID = "ddlMaritalStatusFilter";
                                    ddlMaritalStatusFilter.Label = "Marital Status";
                                    ddlMaritalStatusFilter.SetValue( fRegistrants.GetUserPreference( "Marital Status" ) );
                                    phRegistrantFormFieldFilters.Controls.Add( ddlMaritalStatusFilter );

                                    var ddlMaritalStatusFilter2 = new RockDropDownList();
                                    ddlMaritalStatusFilter2.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid() ), true );
                                    ddlMaritalStatusFilter2.ID = "ddlMaritalStatusFilter";
                                    ddlMaritalStatusFilter2.Label = "Marital Status";
                                    ddlMaritalStatusFilter2.SetValue( fRegistrants.GetUserPreference( "WL-Marital Status" ) );
                                    phWaitListFormFieldFilters.Controls.Add( ddlMaritalStatusFilter2 );

                                    string dataFieldExpression = "PersonAlias.Person.MaritalStatusValue.Value";
                                    var maritalStatusField = new RockBoundField();
                                    maritalStatusField.DataField = dataFieldExpression;
                                    maritalStatusField.HeaderText = "MaritalStatus";
                                    maritalStatusField.SortExpression = dataFieldExpression;
                                    gRegistrants.Columns.Add( maritalStatusField );

                                    var maritalStatusField2 = new RockBoundField();
                                    maritalStatusField2.DataField = dataFieldExpression;
                                    maritalStatusField2.HeaderText = "MaritalStatus";
                                    maritalStatusField2.SortExpression = dataFieldExpression;
                                    gGroupPlacements.Columns.Add( maritalStatusField2 );

                                    var maritalStatusField3 = new RockBoundField();
                                    maritalStatusField3.DataField = dataFieldExpression;
                                    maritalStatusField3.HeaderText = "MaritalStatus";
                                    maritalStatusField3.SortExpression = dataFieldExpression;
                                    gWaitList.Columns.Add( maritalStatusField3 );

                                    break;
                                }

                            case RegistrationPersonFieldType.MobilePhone:
                                {
                                    var tbPhoneFilter = new RockTextBox();
                                    tbPhoneFilter.ID = "tbPhoneFilter";
                                    tbPhoneFilter.Label = "Phone";
                                    tbPhoneFilter.Text = fRegistrants.GetUserPreference( "Phone" );
                                    phRegistrantFormFieldFilters.Controls.Add( tbPhoneFilter );

                                    var tbPhoneFilter2 = new RockTextBox();
                                    tbPhoneFilter2.ID = "tbPhoneFilter";
                                    tbPhoneFilter2.Label = "Phone";
                                    tbPhoneFilter2.Text = fRegistrants.GetUserPreference( "WL-Phone" );
                                    phWaitListFormFieldFilters.Controls.Add( tbPhoneFilter2 );

                                    var phoneNumbersField = new PhoneNumbersField();
                                    phoneNumbersField.DataField = "PersonAlias.Person.PhoneNumbers";
                                    phoneNumbersField.HeaderText = "Phone(s)";
                                    gRegistrants.Columns.Add( phoneNumbersField );

                                    var phoneNumbersField2 = new PhoneNumbersField();
                                    phoneNumbersField2.DataField = "PersonAlias.Person.PhoneNumbers";
                                    phoneNumbersField2.HeaderText = "Phone(s)";
                                    gGroupPlacements.Columns.Add( phoneNumbersField2 );

                                    var phoneNumbersField3 = new PhoneNumbersField();
                                    phoneNumbersField3.DataField = "PersonAlias.Person.PhoneNumbers";
                                    phoneNumbersField3.HeaderText = "Phone(s)";
                                    gWaitList.Columns.Add( phoneNumbersField3 );

                                    break;
                                }
                        }
                    }
                    else if ( field.Attribute != null )
                    {
                        var attribute = field.Attribute;

                        // add dynamic filter to registrant grid
                        var control = attribute.FieldType.Field.FilterControl( attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter );
                        if ( control != null )
                        {
                            if ( control is IRockControl )
                            {
                                var rockControl = (IRockControl)control;
                                rockControl.Label = attribute.Name;
                                rockControl.Help = attribute.Description;
                                phRegistrantFormFieldFilters.Controls.Add( control );
                            }
                            else
                            {
                                var wrapper = new RockControlWrapper();
                                wrapper.ID = control.ID + "_wrapper";
                                wrapper.Label = attribute.Name;
                                wrapper.Controls.Add( control );
                                phRegistrantFormFieldFilters.Controls.Add( wrapper );
                            }

                            string savedValue = fRegistrants.GetUserPreference( attribute.Key );
                            if ( !string.IsNullOrWhiteSpace( savedValue ) )
                            {
                                try
                                {
                                    var values = JsonConvert.DeserializeObject<List<string>>( savedValue );
                                    attribute.FieldType.Field.SetFilterValues( control, attribute.QualifierValues, values );
                                }
                                catch { }
                            }
                        }

                        // add dynamic filter to wait list grid
                        var control2 = attribute.FieldType.Field.FilterControl( attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter );
                        if ( control2 != null )
                        {
                            if ( control2 is IRockControl )
                            {
                                var rockControl2 = (IRockControl)control2;
                                rockControl2.Label = attribute.Name;
                                rockControl2.Help = attribute.Description;
                                phWaitListFormFieldFilters.Controls.Add( control2 );
                            }
                            else
                            {
                                var wrapper2 = new RockControlWrapper();
                                wrapper2.ID = control.ID + "_wrapper";
                                wrapper2.Label = attribute.Name;
                                wrapper2.Controls.Add( control2 );
                                phWaitListFormFieldFilters.Controls.Add( wrapper2 );
                            }

                            string savedValue = fWaitList.GetUserPreference( "WL-" + attribute.Key );
                            if ( !string.IsNullOrWhiteSpace( savedValue ) )
                            {
                                try
                                {
                                    var values = JsonConvert.DeserializeObject<List<string>>( savedValue );
                                    attribute.FieldType.Field.SetFilterValues( control2, attribute.QualifierValues, values );
                                }
                                catch { }
                            }
                        }

                        string dataFieldExpression = attribute.Id.ToString() + attribute.Key;
                        bool columnExists = gRegistrants.Columns.OfType<AttributeField>().FirstOrDefault( a => a.DataField.Equals( dataFieldExpression ) ) != null;
                        if ( !columnExists )
                        {
                            AttributeField boundField = new AttributeField();
                            boundField.DataField = dataFieldExpression;
                            boundField.AttributeId = attribute.Id;
                            boundField.HeaderText = attribute.Name;

                            AttributeField boundField2 = new AttributeField();
                            boundField2.DataField = dataFieldExpression;
                            boundField2.AttributeId = attribute.Id;
                            boundField2.HeaderText = attribute.Name;

                            AttributeField boundField3 = new AttributeField();
                            boundField3.DataField = dataFieldExpression;
                            boundField3.AttributeId = attribute.Id;
                            boundField3.HeaderText = attribute.Name;

                            var attributeCache = Rock.Web.Cache.AttributeCache.Read( attribute.Id );
                            if ( attributeCache != null )
                            {
                                boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                                boundField2.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                                boundField3.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                            }

                            gRegistrants.Columns.Add( boundField );
                            gGroupPlacements.Columns.Add( boundField2 );
                            gWaitList.Columns.Add( boundField3 );
                        }
                    }
                }
            }

            // Add fee column
            var feeField = new RockLiteralField();
            feeField.ID = "lFees";
            feeField.HeaderText = "Fees";
            gRegistrants.Columns.Add( feeField );

            var deleteField = new DeleteField();
            gRegistrants.Columns.Add( deleteField );
            deleteField.Click += gRegistrants_Delete;

            var groupPickerField = new GroupPickerField();
            groupPickerField.HeaderText = "Group";
            groupPickerField.RootGroupId = gpGroupPlacementParentGroup.SelectedValueAsInt();
            gGroupPlacements.Columns.Add( groupPickerField );
        }