Workflow Action Form Row Editor
Inheritance: System.Web.UI.WebControls.CompositeControl
        /// <summary>
        /// Sets the form.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="workflowTypeAttributes">The workflow type attributes.</param>
        public void SetForm(WorkflowActionForm value, Dictionary <Guid, Rock.Model.Attribute> workflowTypeAttributes)
        {
            EnsureChildControls();

            if (value != null)
            {
                _hfFormGuid.Value = value.Guid.ToString();
                _ddlNotificationSystemEmail.SetValue(value.NotificationSystemEmailId);
                _cbIncludeActions.Checked = value.IncludeActionsInNotification;
                _ceHeaderText.Text        = value.Header;
                _ceFooterText.Text        = value.Footer;
                _falActions.Value         = value.Actions;
                _cbAllowNotes.Checked     = value.AllowNotes.HasValue && value.AllowNotes.Value;

                // Remove any existing rows (shouldn't be any)
                foreach (var attributeRow in Controls.OfType <WorkflowFormAttributeRow>())
                {
                    Controls.Remove(attributeRow);
                }

                foreach (var formAttribute in value.FormAttributes.OrderBy(a => a.Order))
                {
                    var row = new WorkflowFormAttributeRow();
                    row.AttributeGuid = formAttribute.Attribute.Guid;
                    row.AttributeName = formAttribute.Attribute.Name;
                    row.Guid          = formAttribute.Guid;
                    row.IsVisible     = formAttribute.IsVisible;
                    row.IsEditable    = !formAttribute.IsReadOnly;
                    row.IsRequired    = formAttribute.IsRequired;
                    row.HideLabel     = formAttribute.HideLabel;
                    row.PreHtml       = formAttribute.PreHtml;
                    row.PostHtml      = formAttribute.PostHtml;
                    Controls.Add(row);
                }

                _ddlActionAttribute.Items.Clear();
                _ddlActionAttribute.Items.Add(new ListItem());
                foreach (var attributeItem in workflowTypeAttributes)
                {
                    var fieldType = FieldTypeCache.Get(attributeItem.Value.FieldTypeId);
                    if (fieldType != null && fieldType.Field is Rock.Field.Types.TextFieldType)
                    {
                        var li = new ListItem(attributeItem.Value.Name, attributeItem.Key.ToString());
                        li.Selected = value.ActionAttributeGuid.HasValue && value.ActionAttributeGuid.Value.ToString() == li.Value;
                        _ddlActionAttribute.Items.Add(li);
                    }
                }
            }
            else
            {
                _hfFormGuid.Value = string.Empty;
                _ddlNotificationSystemEmail.SelectedIndex = 0;
                _cbIncludeActions.Checked = true;
                _ceHeaderText.Text        = string.Empty;
                _ceFooterText.Text        = string.Empty;
                _falActions.Value         = "Submit^^^Your information has been submitted successfully.";
                _ddlNotificationSystemEmail.SelectedIndex = 0;
                _cbAllowNotes.Checked = false;
            }
        }
Example #2
0
        /// <summary>
        /// Sets the form.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="workflowTypeAttributes">The workflow type attributes.</param>
        public void SetForm( WorkflowActionForm value, Dictionary<Guid, Rock.Model.Attribute> workflowTypeAttributes )
        {
            EnsureChildControls();

            if ( value != null )
            {
                _hfFormGuid.Value = value.Guid.ToString();
                _ddlNotificationSystemEmail.SetValue( value.NotificationSystemEmailId );
                _cbIncludeActions.Checked = value.IncludeActionsInNotification;
                _ceHeaderText.Text = value.Header;
                _ceFooterText.Text = value.Footer;
                _falActions.Value = value.Actions;

                // Remove any existing rows (shouldn't be any)
                foreach ( var attributeRow in Controls.OfType<WorkflowFormAttributeRow>() )
                {
                    Controls.Remove( attributeRow );
                }

                foreach ( var formAttribute in value.FormAttributes.OrderBy( a => a.Order ) )
                {
                    var row = new WorkflowFormAttributeRow();
                    row.AttributeGuid = formAttribute.Attribute.Guid;
                    row.AttributeName = formAttribute.Attribute.Name;
                    row.Guid = formAttribute.Guid;
                    row.IsVisible = formAttribute.IsVisible;
                    row.IsEditable = !formAttribute.IsReadOnly;
                    row.IsRequired = formAttribute.IsRequired;
                    Controls.Add( row );
                }

                _ddlActionAttribute.Items.Clear();
                _ddlActionAttribute.Items.Add( new ListItem() );
                foreach ( var attributeItem in workflowTypeAttributes )
                {
                    var fieldType = FieldTypeCache.Read( attributeItem.Value.FieldTypeId );
                    if ( fieldType != null && fieldType.Field is Rock.Field.Types.TextFieldType )
                    {
                        var li = new ListItem( attributeItem.Value.Name, attributeItem.Key.ToString() );
                        li.Selected = value.ActionAttributeGuid.HasValue && value.ActionAttributeGuid.Value.ToString() == li.Value;
                        _ddlActionAttribute.Items.Add( li );
                    }
                }

            }
            else
            {
                _hfFormGuid.Value = string.Empty;
                _ddlNotificationSystemEmail.SelectedIndex = 0;
                _cbIncludeActions.Checked = true;
                _ceHeaderText.Text = string.Empty;
                _ceFooterText.Text = string.Empty;
                _falActions.Value = "Submit^^^Your information has been submitted successfully.";
                _ddlNotificationSystemEmail.SelectedIndex = 0;
            }
        }