/// <summary>
        /// Handles the SaveClick event of the dlgItemAttributes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgItemAttributes_SaveClick(object sender, EventArgs e)
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtItemAttributes.GetAttributeProperties(attribute);

            // Controls will show warnings
            if (!attribute.IsValid)
            {
                return;
            }

            if (ItemAttributesState.Any(a => a.Guid.Equals(attribute.Guid)))
            {
                attribute.Order = ItemAttributesState.Where(a => a.Guid.Equals(attribute.Guid)).FirstOrDefault().Order;
                ItemAttributesState.RemoveEntity(attribute.Guid);
            }
            else
            {
                attribute.Order = ItemAttributesState.Any() ? ItemAttributesState.Max(a => a.Order) + 1 : 0;
            }
            ItemAttributesState.Add(attribute);

            BindItemAttributesGrid();

            HideDialog();
        }
Example #2
0
        /// <summary>
        /// Handles the SaveClick event of the dlgEventOccurrenceAttribute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgEventOccurrenceAttribute_SaveClick(object sender, EventArgs e)
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtEventOccurrenceAttributes.GetAttributeProperties(attribute);

            if (!attribute.IsValid)
            {
                return;
            }

            if (EventOccurrenceAttributesState.Any(a => a.Guid.Equals(attribute.Guid)))
            {
                attribute.Order = EventOccurrenceAttributesState.Where(a => a.Guid.Equals(attribute.Guid)).FirstOrDefault().Order;
                EventOccurrenceAttributesState.RemoveEntity(attribute.Guid);
            }
            else
            {
                attribute.Order = EventOccurrenceAttributesState.Any() ? EventOccurrenceAttributesState.Max(a => a.Order) + 1 : 0;
            }

            EventOccurrenceAttributesState.Add(attribute);
            ReOrderEventOccurrenceAttributes(EventOccurrenceAttributesState);
            BindEventOccurrenceAttributesGrid();
            HideDialog();
        }
Example #3
0
        private Rock.Model.Attribute SaveChangesToStateCollection(AttributeEditor editor, List <Rock.Model.Attribute> attributeStateCollection)
        {
            // Load the editor values into a new Attribute instance.
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();

            editor.GetAttributeProperties(attribute);

            // Get the stored state of the Attribute, and copy the values of the non-editable properties.
            var attributeState = attributeStateCollection.Where(a => a.Guid.Equals(attribute.Guid)).FirstOrDefault();

            if (attributeState != null)
            {
                attribute.Order                  = attributeState.Order;
                attribute.CreatedDateTime        = attributeState.CreatedDateTime;
                attribute.CreatedByPersonAliasId = attributeState.CreatedByPersonAliasId;
                attribute.ForeignGuid            = attributeState.ForeignGuid;
                attribute.ForeignId              = attributeState.ForeignId;
                attribute.ForeignKey             = attributeState.ForeignKey;

                attributeStateCollection.RemoveEntity(attribute.Guid);
            }
            else
            {
                // Set the Order of the new entry as the last item in the collection.
                attribute.Order = attributeStateCollection.Any() ? attributeStateCollection.Max(a => a.Order) + 1 : 0;
            }

            attributeStateCollection.Add(attribute);

            return(attribute);
        }
        /// <summary>
        /// Handles the Click event of the btnSaveGroupMemberAttribute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSaveGroupMemberAttribute_Click(object sender, EventArgs e)
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtGroupMemberAttributes.GetAttributeProperties(attribute);

            // Controls will show warnings
            if (!attribute.IsValid)
            {
                return;
            }

            GroupMemberAttributesState.RemoveEntity(attribute.Guid);
            GroupMemberAttributesState.Add(attribute);

            pnlDetails.Visible = true;
            pnlGroupMemberAttribute.Visible = false;

            BindGroupMemberAttributesGrid();
        }
        /// <summary>
        /// Handles the Click event of the btnSaveAttribute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSaveAttribute_Click(object sender, EventArgs e)
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtAdTypeAttributes.GetAttributeProperties(attribute);

            // Controls will show warnings
            if (!attribute.IsValid)
            {
                return;
            }

            AttributesState.RemoveEntity(attribute.Guid);
            AttributesState.Add(attribute);

            pnlDetails.Visible         = true;
            pnlAdTypeAttribute.Visible = false;

            BindMarketingCampaignAdAttributeTypeGrid();
        }
        /// <summary>
        /// Handles the SaveClick event of the dlgItemAttributes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgItemAttributes_SaveClick( object sender, EventArgs e )
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtItemAttributes.GetAttributeProperties( attribute );

            // Controls will show warnings
            if ( !attribute.IsValid )
            {
                return;
            }

            if ( ItemAttributesState.Any( a => a.Guid.Equals( attribute.Guid ) ) )
            {
                attribute.Order = ItemAttributesState.Where( a => a.Guid.Equals( attribute.Guid ) ).FirstOrDefault().Order;
                ItemAttributesState.RemoveEntity( attribute.Guid );
            }
            else
            {
                attribute.Order = ItemAttributesState.Any() ? ItemAttributesState.Max( a => a.Order ) + 1 : 0;
            }
            ItemAttributesState.Add( attribute );

            BindItemAttributesGrid();

            HideDialog();
        }
        /// <summary>
        /// Handles the SaveClick event of the dlgField control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgField_SaveClick( object sender, EventArgs e )
        {
            var formGuid = hfFormGuid.Value.AsGuid();
            var attributeGuid = hfAttributeGuid.Value.AsGuid();

            if ( FormFieldsState.ContainsKey( formGuid ) )
            {
                var attributeForm = FormFieldsState[formGuid].FirstOrDefault( a => a.Guid.Equals( attributeGuid ) );
                if ( attributeForm == null )
                {
                    attributeForm = new RegistrationTemplateFormField();
                    attributeForm.Order = FormFieldsState[formGuid].Any() ? FormFieldsState[formGuid].Max( a => a.Order ) + 1 : 0;
                    attributeForm.Guid = attributeGuid;
                    FormFieldsState[formGuid].Add( attributeForm );
                }

                attributeForm.PreText = ceAttributePreText.Text;
                attributeForm.PostText = ceAttributePostText.Text;
                attributeForm.FieldSource = ddlFieldSource.SelectedValueAsEnum<RegistrationFieldSource>();
                if ( ddlPersonField.Visible )
                {
                    attributeForm.PersonFieldType = ddlPersonField.SelectedValueAsEnum<RegistrationPersonFieldType>();
                }

                attributeForm.IsInternal = cbInternalField.Checked;
                attributeForm.IsSharedValue = cbCommonValue.Checked;

                int? attributeId = null;

                switch ( attributeForm.FieldSource )
                {
                    case RegistrationFieldSource.PersonField:
                        {
                            attributeForm.ShowCurrentValue = cbUsePersonCurrentValue.Checked;
                            attributeForm.IsGridField = cbShowOnGrid.Checked;
                            attributeForm.IsRequired = cbRequireInInitialEntry.Checked;
                            break;
                        }
                    case RegistrationFieldSource.PersonAttribute:
                        {
                            attributeId = ddlPersonAttributes.SelectedValueAsInt();
                            attributeForm.ShowCurrentValue = cbUsePersonCurrentValue.Checked;
                            attributeForm.IsGridField = cbShowOnGrid.Checked;
                            attributeForm.IsRequired = cbRequireInInitialEntry.Checked;
                            break;
                        }
                    case RegistrationFieldSource.GroupMemberAttribute:
                        {
                            attributeId = ddlGroupTypeAttributes.SelectedValueAsInt();
                            attributeForm.ShowCurrentValue = false;
                            attributeForm.IsGridField = cbShowOnGrid.Checked;
                            attributeForm.IsRequired = cbRequireInInitialEntry.Checked;
                            break;
                        }
                    case RegistrationFieldSource.RegistrationAttribute:
                        {
                            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
                            edtRegistrationAttribute.GetAttributeProperties( attribute );
                            attributeForm.Attribute = attribute;
                            attributeForm.Id = attribute.Id;
                            attributeForm.ShowCurrentValue = false;
                            attributeForm.IsGridField = attribute.IsGridColumn;
                            attributeForm.IsRequired = attribute.IsRequired;
                            break;
                        }
                }

                if ( attributeId.HasValue )
                {
                    using ( var rockContext = new RockContext() )
                    {
                        var attribute = new AttributeService( rockContext ).Get( attributeId.Value );
                        if ( attribute != null )
                        {
                            attributeForm.Attribute = attribute.Clone( false );
                            attributeForm.Attribute.FieldType = attribute.FieldType.Clone( false );
                            attributeForm.AttributeId = attribute.Id;
                        }
                    }
                }
            }

            HideDialog();

            BuildControls( true );
        }
        /// <summary>
        /// Handles the SaveClick event of the dlgAttribute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgActivityAttribute_SaveClick( object sender, EventArgs e )
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtActivityAttributes.GetAttributeProperties( attribute );

            // Controls will show warnings
            if ( !attribute.IsValid )
            {
                return;
            }

            var activityTypeGuid = hfActivityTypeGuid.Value.AsGuid();

            if ( ActivityAttributesState.ContainsKey( activityTypeGuid ) )
            {
                if ( ActivityAttributesState[activityTypeGuid].Any( a => a.Guid.Equals( attribute.Guid ) ) )
                {
                    attribute.Order = ActivityAttributesState[activityTypeGuid].Where( a => a.Guid.Equals( attribute.Guid ) ).FirstOrDefault().Order;
                    ActivityAttributesState[activityTypeGuid].RemoveEntity( attribute.Guid );
                }
                else
                {
                    attribute.Order = ActivityAttributesState[activityTypeGuid].Any() ? ActivityAttributesState[activityTypeGuid].Max( a => a.Order ) + 1 : 0;
                }
                ActivityAttributesState[activityTypeGuid].Add( attribute );

                ReOrderAttributes( ActivityAttributesState[activityTypeGuid] );
            }

            HideDialog();

            hfActivityTypeGuid.Value = string.Empty;

            BuildControls( true, activityTypeGuid );
        }
        /// <summary>
        /// Handles the Click event of the btnSaveAttribute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSaveAttribute_Click( object sender, EventArgs e )
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtAdTypeAttributes.GetAttributeProperties( attribute );

            // Controls will show warnings
            if ( !attribute.IsValid )
            {
                return;
            }

            AttributesState.RemoveEntity( attribute.Guid );
            AttributesState.Add( attribute );

            pnlDetails.Visible = true;
            pnlAdTypeAttribute.Visible = false;

            BindMarketingCampaignAdAttributeTypeGrid();
        }
Example #10
0
        /// <summary>
        /// Handles the SaveClick event of the dlgGroupMemberAttribute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgGroupMemberAttribute_SaveClick( object sender, EventArgs e )
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtGroupMemberAttributes.GetAttributeProperties( attribute );

            // Controls will show warnings
            if ( !attribute.IsValid )
            {
                return;
            }

            GroupMemberAttributesState.RemoveEntity( attribute.Guid );
            attribute.Order = GroupMemberAttributesState.Any() ? GroupMemberAttributesState.Max( a => a.Order ) + 1 : 0;
            GroupMemberAttributesState.Add( attribute );

            BindGroupMemberAttributesGrid();

            HideDialog();
        }