/// <summary> /// This is where you implment the simple aspects of rendering your control. The rest /// will be handled by calling RenderControlHelper's RenderControl() method. /// </summary> /// <param name="writer">The writer.</param> public void RenderBaseControl(HtmlTextWriter writer) { bool ddlItemSelected = false; foreach (ListItem li in _dropDownList.Items) { if (li.Value == _hiddenField.Value) { li.Selected = true; ddlItemSelected = true; } else { li.Selected = false; } } if (!ddlItemSelected) { _textBox.Text = _hiddenField.Value; } writer.AddAttribute(HtmlTextWriterAttribute.Class, "row js-text-or-ddl-row " + this.CssClass); writer.AddAttribute(HtmlTextWriterAttribute.Style, this.Style.Value); writer.RenderBeginTag(HtmlTextWriterTag.Div); _hiddenField.RenderControl(writer); if (ValidateRequestMode == System.Web.UI.ValidateRequestMode.Disabled) { _hfDisableVrm.RenderControl(writer); } writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-xs-6"); writer.RenderBeginTag(HtmlTextWriterTag.Div); _textBox.AddCssClass("js-text-or-ddl-input"); _textBox.RenderControl(writer); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-xs-1"); writer.RenderBeginTag(HtmlTextWriterTag.Div); var lOr = new RockLiteral(); lOr.Label = " "; lOr.Text = "or"; lOr.RenderControl(writer); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-xs-5"); writer.RenderBeginTag(HtmlTextWriterTag.Div); _dropDownList.AddCssClass("js-text-or-ddl-input"); _dropDownList.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); // row RegisterClientScript(); }
/// <summary> /// Initializes a new instance of the <see cref="NewGroupMembersRow" /> class. /// </summary> public PreRegistrationChildRow() : base() { _lNickName = new RockLiteral(); _lLastName = new RockLiteral(); _tbNickName = new RockTextBox(); _tbLastName = new RockTextBox(); _ddlSuffix = new DefinedValuePicker(); _ddlGender = new RockDropDownList(); _dpBirthdate = new DatePicker(); _ddlGradePicker = new GradePicker { UseAbbreviation = true, UseGradeOffsetAsValue = true }; _ddlGradePicker.Label = string.Empty; _pnbMobile = new PhoneNumberBox(); _ddlRelationshipType = new RockDropDownList(); _phAttributes = new PlaceHolder(); _lbDelete = new LinkButton(); }
private void BuildForm( bool setValues ) { var form = _actionType.WorkflowForm; if ( setValues ) { var mergeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( null ); mergeFields.Add( "Action", _action ); mergeFields.Add( "Activity", _activity ); mergeFields.Add( "Workflow", _workflow ); lheadingText.Text = form.Header.ResolveMergeFields( mergeFields ); lFootingText.Text = form.Footer.ResolveMergeFields( mergeFields ); } phAttributes.Controls.Clear(); foreach ( var formAttribute in form.FormAttributes.OrderBy( a => a.Order ) ) { if ( formAttribute.IsVisible ) { var attribute = AttributeCache.Read( formAttribute.AttributeId ); string value = attribute.DefaultValue; if ( _workflow != null && _workflow.AttributeValues.ContainsKey( attribute.Key ) && _workflow.AttributeValues[attribute.Key].Any() ) { value = _workflow.AttributeValues[attribute.Key][0].Value; } if ( formAttribute.IsReadOnly ) { RockLiteral lAttribute = new RockLiteral(); lAttribute.ID = "lAttribute_" + formAttribute.Id.ToString(); lAttribute.Label = formAttribute.Attribute.Name; var field = attribute.FieldType.Field; string formattedValue = field.FormatValue( phAttributes, value, attribute.QualifierValues, false ); if ( field is Rock.Field.ILinkableFieldType ) { string url = ( (Rock.Field.ILinkableFieldType)field ).UrlLink( value, attribute.QualifierValues ); url = ResolveRockUrl( "~" ).EnsureTrailingForwardslash() + url; lAttribute.Text = string.Format( "<a href='{0}' target='_blank'>{1}</a>", url, formattedValue ); } else { lAttribute.Text = formattedValue; } phAttributes.Controls.Add( lAttribute ); } else { attribute.AddControl( phAttributes.Controls, value, BlockValidationGroup, setValues, true, formAttribute.IsRequired ); } } } phActions.Controls.Clear(); foreach ( var action in form.Actions.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries ) ) { var details = action.Split( new char[] { '^' } ); if ( details.Length > 0 ) { // Get the button html string buttonHtml = string.Empty; if ( details.Length > 1 ) { var definedValue = DefinedValueCache.Read( details[1].AsGuid() ); if ( definedValue != null ) { buttonHtml = definedValue.GetAttributeValue( "ButtonHTML" ); } } if ( string.IsNullOrWhiteSpace( buttonHtml ) ) { buttonHtml = "<a href='{{ ButtonLink }}' onclick='{{ ButtonClick }}' class='btn btn-primary' data-loading-text='<i class=\"fa fa-refresh fa-spin\"></i> {{ ButtonText }}'>{{ ButtonText }}</a>"; } var buttonMergeFields = new Dictionary<string, object>(); buttonMergeFields.Add( "ButtonText", details[0] ); buttonMergeFields.Add( "ButtonClick", string.Format( "if ( Page_ClientValidate('{0}') ) {{ $(this).button('loading'); return true; }} else {{ return false; }}", BlockValidationGroup ) ); buttonMergeFields.Add( "ButtonLink", Page.ClientScript.GetPostBackClientHyperlink( this, details[0] ) ); buttonHtml = buttonHtml.ResolveMergeFields( buttonMergeFields ); phActions.Controls.Add( new LiteralControl( buttonHtml ) ); phActions.Controls.Add( new LiteralControl( " " ) ); } } }
/// <summary> /// This is where you implment the simple aspects of rendering your control. The rest /// will be handled by calling RenderControlHelper's RenderControl() method. /// </summary> /// <param name="writer">The writer.</param> public void RenderBaseControl( HtmlTextWriter writer ) { bool ddlItemSelected = false; foreach ( ListItem li in _dropDownList.Items ) { if ( li.Value == _hiddenField.Value ) { li.Selected = true; ddlItemSelected = true; } else { li.Selected = false; } } if ( !ddlItemSelected ) { _textBox.Text = _hiddenField.Value; } writer.AddAttribute( HtmlTextWriterAttribute.Class, "row js-text-or-ddl-row " + this.CssClass ); writer.AddAttribute( HtmlTextWriterAttribute.Style, this.Style.Value ); writer.RenderBeginTag( HtmlTextWriterTag.Div ); _hiddenField.RenderControl( writer ); writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-xs-6" ); writer.RenderBeginTag( HtmlTextWriterTag.Div ); _textBox.AddCssClass( "js-text-or-ddl-input" ); _textBox.RenderControl( writer ); writer.RenderEndTag(); writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-xs-1" ); writer.RenderBeginTag( HtmlTextWriterTag.Div ); var lOr = new RockLiteral(); lOr.Label = " "; lOr.Text = "or"; lOr.RenderControl( writer ); writer.RenderEndTag(); writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-xs-5" ); writer.RenderBeginTag( HtmlTextWriterTag.Div ); _dropDownList.AddCssClass( "js-text-or-ddl-input" ); _dropDownList.RenderControl( writer ); writer.RenderEndTag(); writer.RenderEndTag(); // row RegisterClientScript(); }
/// <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(); _hfExpanded = new HiddenField(); Controls.Add(_hfExpanded); _hfExpanded.ID = this.ID + "_hfExpanded"; _hfExpanded.Value = "False"; _hfActivityGuid = new HiddenField(); Controls.Add(_hfActivityGuid); _hfActivityGuid.ID = this.ID + "_hfActivityTypeGuid"; _lblActivityTypeName = new Label(); Controls.Add(_lblActivityTypeName); _lblActivityTypeName.ClientIDMode = ClientIDMode.Static; _lblActivityTypeName.ID = this.ID + "_lblActivityTypeName"; _lblActivityTypeDescription = new Label(); Controls.Add(_lblActivityTypeDescription); _lblActivityTypeDescription.ClientIDMode = ClientIDMode.Static; _lblActivityTypeDescription.ID = this.ID + "_lblActivityTypeDescription"; _lblStatus = new Label(); Controls.Add(_lblStatus); _lblStatus.ClientIDMode = ClientIDMode.Static; _lblStatus.ID = this.ID + "_lblInactive"; _lblStatus.CssClass = "pull-right"; _lbDeleteActivityType = new LinkButton(); Controls.Add(_lbDeleteActivityType); _lbDeleteActivityType.CausesValidation = false; _lbDeleteActivityType.ID = this.ID + "_lbDeleteActivityType"; _lbDeleteActivityType.CssClass = "btn btn-xs btn-square btn-danger js-activity-delete"; _lbDeleteActivityType.Click += lbDeleteActivityType_Click; _lbDeleteActivityType.Controls.Add(new LiteralControl { Text = "<i class='fa fa-times'></i>" }); _cbActivityIsComplete = new RockCheckBox { Text = "Complete" }; Controls.Add(_cbActivityIsComplete); _cbActivityIsComplete.ID = this.ID + "_cbActivityTypeIsActive"; _cbActivityIsComplete.Label = "Activity Completed"; _cbActivityIsComplete.Text = "Yes"; _ppAssignedToPerson = new PersonPicker(); _ppAssignedToPerson.ID = this.ID + "_ppAssignedToPerson"; Controls.Add(_ppAssignedToPerson); _ppAssignedToPerson.Label = "Assign to Person"; _lAssignedToPerson = new RockLiteral(); _lAssignedToPerson.ID = this.ID + "_lAssignedToPerson"; Controls.Add(_lAssignedToPerson); _lAssignedToPerson.Label = "Assigned to Person"; _gpAssignedToGroup = new GroupPicker(); _gpAssignedToGroup.ID = this.ID + "_gpAssignedToGroup"; Controls.Add(_gpAssignedToGroup); _gpAssignedToGroup.Label = "Assign to Group"; _lAssignedToGroup = new RockLiteral(); _lAssignedToGroup.ID = this.ID + "_lAssignedToGroup"; Controls.Add(_lAssignedToGroup); _lAssignedToGroup.Label = "Assigned to Group"; _ddlAssignedToRole = new RockDropDownList(); Controls.Add(_ddlAssignedToRole); _ddlAssignedToRole.ID = this.ID + "_ddlAssignedToRole"; _ddlAssignedToRole.Label = "Assign to Security Role"; _lAssignedToRole = new RockLiteral(); _lAssignedToRole.ID = this.ID + "_lAssignedToRole"; Controls.Add(_lAssignedToRole); _lAssignedToRole.Label = "Assigned to Security Role"; _lState = new Literal(); Controls.Add(_lState); _lState.ID = this.ID + "_lState"; _ddlAssignedToRole.Items.Add(new ListItem(string.Empty, "0")); var roles = new GroupService(new RockContext()).Queryable().Where(g => g.IsSecurityRole).OrderBy(t => t.Name); if (roles.Any()) { foreach (var role in roles) { _ddlAssignedToRole.Items.Add(new ListItem(role.Name, role.Id.ToString())); } } _phAttributes = new PlaceHolder(); Controls.Add(_phAttributes); _phAttributes.ID = this.ID + "_phAttributes"; }
/// <summary> /// Shows the readonly details. /// </summary> /// <param name="eventItem">The event item.</param> private void ShowReadonlyDetails( EventItem eventItem ) { SetEditMode( false ); hfEventItemId.SetValue( eventItem.Id ); lReadOnlyTitle.Text = eventItem.Name.FormatAsHtmlTitle(); SetLabels( eventItem ); string imgTag = GetImageTag( eventItem.PhotoId, 300, 300, false, true ); if ( eventItem.PhotoId.HasValue ) { string imageUrl = ResolveRockUrl( String.Format( "~/GetImage.ashx?id={0}", eventItem.PhotoId.Value ) ); lImage.Text = string.Format( "<a href='{0}'>{1}</a>", imageUrl, imgTag ); divImage.Visible = true; } else { divImage.Visible = false; } lSummary.Visible = !string.IsNullOrWhiteSpace( eventItem.Summary ); lSummary.Text = eventItem.Summary; var calendars = eventItem.EventCalendarItems .Select( c => c.EventCalendar.Name ).ToList(); if ( calendars.Any() ) { lCalendar.Visible = true; lCalendar.Text = calendars.AsDelimited( ", " ); } else { lCalendar.Visible = false; } var audiences = eventItem.EventItemAudiences .Select( a => a.DefinedValue.Value ).ToList(); if ( audiences.Any() ) { lAudiences.Visible = true; lAudiences.Text = audiences.AsDelimited( ", " ); } else { lAudiences.Visible = false; } phAttributesView.Controls.Clear(); foreach ( var eventCalendarItem in eventItem.EventCalendarItems ) { eventCalendarItem.LoadAttributes(); if ( eventCalendarItem.Attributes.Count > 0 ) { foreach ( var attr in eventCalendarItem.Attributes ) { string value = eventCalendarItem.GetAttributeValue( attr.Key ); if ( !string.IsNullOrWhiteSpace( value ) ) { var rl = new RockLiteral(); rl.ID = "attr_" + attr.Key; rl.Label = attr.Value.Name; rl.Text = attr.Value.FieldType.Field.FormatValueAsHtml( null, value, attr.Value.QualifierValues, false ); phAttributesView.Controls.Add( rl ); } } } } }
private Control BuildRegistrantFieldControl( RegistrationTemplateFormField field, RegistrantInfo registrant, bool setValues ) { // Ignore the first/last name fields since they are displayed in the panel's heading if ( field.FieldSource == RegistrationFieldSource.PersonField && ( field.PersonFieldType == RegistrationPersonFieldType.FirstName || field.PersonFieldType == RegistrationPersonFieldType.LastName ) ) { return null; } object fieldValue = null; if ( registrant != null && registrant.FieldValues != null && registrant.FieldValues.ContainsKey( field.Id ) ) { fieldValue = registrant.FieldValues[field.Id]; } var rlField = new RockLiteral(); rlField.ID = string.Format( "rlField_{0}_{1}", registrant.Id, field.Id ); if ( fieldValue != null ) { if ( field.FieldSource == RegistrationFieldSource.PersonField ) { rlField.Label = field.PersonFieldType.ConvertToString( true ); switch ( field.PersonFieldType ) { case RegistrationPersonFieldType.Campus: { var campus = CampusCache.Read( fieldValue.ToString().AsInteger() ); rlField.Text = campus != null ? campus.Name : string.Empty; break; } case RegistrationPersonFieldType.Address: { var location = fieldValue.ToString().FromJsonOrNull<Location>(); rlField.Text = location != null ? location.ToString() : string.Empty; break; } case RegistrationPersonFieldType.Email: { rlField.Text = fieldValue.ToString(); break; } case RegistrationPersonFieldType.Birthdate: { var birthDate = fieldValue as DateTime?; rlField.Text = birthDate != null ? birthDate.Value.ToShortDateString() : string.Empty; break; } case RegistrationPersonFieldType.Gender: { var gender = fieldValue.ToString().ConvertToEnumOrNull<Gender>() ?? Gender.Unknown; rlField.Text = gender.ConvertToString(); break; } case RegistrationPersonFieldType.MaritalStatus: { var maritalStatusDv = DefinedValueCache.Read( fieldValue.ToString().AsInteger() ); rlField.Text = maritalStatusDv != null ? maritalStatusDv.Value : string.Empty; break; } case RegistrationPersonFieldType.MobilePhone: case RegistrationPersonFieldType.HomePhone: case RegistrationPersonFieldType.WorkPhone: { var pn = fieldValue as PhoneNumber; rlField.Text = pn != null ? pn.NumberFormatted : string.Empty; break; } } } else { if ( field.AttributeId.HasValue ) { var attribute = AttributeCache.Read( field.AttributeId.Value ); if ( attribute == null ) { return null; } rlField.Label = attribute.Name; rlField.Text = attribute.FieldType.Field.FormatValueAsHtml( null, fieldValue.ToString(), attribute.QualifierValues ); } } } return rlField; }
private void BuildRegistrantControls( RegistrantInfo registrant, bool setValues ) { var anchor = new HtmlAnchor(); anchor.Name = registrant.Id.ToString(); phDynamicControls.Controls.Add( anchor ); var divPanel = new HtmlGenericControl( "div" ); divPanel.AddCssClass( "panel" ); divPanel.AddCssClass( "panel-block" ); phDynamicControls.Controls.Add( divPanel ); var divHeading = new HtmlGenericControl( "div" ); divHeading.AddCssClass( "panel-heading" ); divHeading.AddCssClass( "clearfix" ); divPanel.Controls.Add( divHeading ); var h1Heading = new HtmlGenericControl( "h1" ); h1Heading.AddCssClass( "panel-title" ); h1Heading.AddCssClass( "pull-left" ); h1Heading.InnerHtml = "<i class='fa fa-user'></i> " + registrant.PersonName; divHeading.Controls.Add( h1Heading ); var divLabels = new HtmlGenericControl( "div" ); divLabels.AddCssClass( "panel-labels" ); divHeading.Controls.Add( divLabels ); if ( registrant.OnWaitList ) { var hlOnWaitList = new HighlightLabel(); hlOnWaitList.ID = string.Format( "hlWaitList_{0}", registrant.Id ); hlOnWaitList.LabelType = LabelType.Warning; hlOnWaitList.Text = "Wait List"; hlOnWaitList.CssClass = "margin-r-sm"; divLabels.Controls.Add( hlOnWaitList ); } decimal discountedTotalCost = registrant.DiscountedTotalCost( Registration.DiscountPercentage, Registration.DiscountAmount ); if ( discountedTotalCost != 0.0m ) { var hlCost = new HighlightLabel(); hlCost.ID = string.Format( "hlCost_{0}", registrant.Id ); hlCost.LabelType = LabelType.Info; hlCost.ToolTip = "Cost"; hlCost.Text = discountedTotalCost.FormatAsCurrency(); divLabels.Controls.Add( hlCost ); } if ( registrant.PersonId.HasValue ) { var aProfileLink = new HtmlAnchor(); aProfileLink.HRef = ResolveRockUrl( string.Format( "~/Person/{0}", registrant.PersonId.Value ) ); divLabels.Controls.Add( aProfileLink ); aProfileLink.AddCssClass( "btn btn-default btn-xs margin-l-sm" ); var iProfileLink = new HtmlGenericControl( "i" ); iProfileLink.AddCssClass( "fa fa-user" ); aProfileLink.Controls.Add( iProfileLink ); } var divBody = new HtmlGenericControl( "div" ); divBody.AddCssClass( "panel-body" ); divPanel.Controls.Add( divBody ); SignatureDocumentTemplate documentTemplate = null; if ( Registration != null && Registration.RegistrationInstance != null && Registration.RegistrationInstance.RegistrationTemplate != null && Registration.RegistrationInstance.RegistrationTemplate.RequiredSignatureDocumentTemplate != null ) { documentTemplate = Registration.RegistrationInstance.RegistrationTemplate.RequiredSignatureDocumentTemplate; } if ( documentTemplate != null && !registrant.SignatureDocumentId.HasValue ) { var template = Registration.RegistrationInstance.RegistrationTemplate; var divSigAlert = new HtmlGenericControl( "div" ); divSigAlert.AddCssClass( "alert alert-warning" ); divBody.Controls.Add( divSigAlert ); StringBuilder sb = new StringBuilder(); sb.Append( "<div class='row'><div class='col-md-9'>" ); sb.AppendFormat( "There is not a signed {0} for {1}", template.RequiredSignatureDocumentTemplate.Name, registrant.GetFirstName( template ) ); if ( registrant.SignatureDocumentLastSent.HasValue ) { sb.AppendFormat( " (a request was sent {0})", registrant.SignatureDocumentLastSent.Value.ToElapsedString() ); } sb.Append( ".</div>" ); divSigAlert.Controls.Add( new LiteralControl( sb.ToString() ) ); var divSigAction = new HtmlGenericControl( "div" ); divSigAction.AddCssClass( "col-md-3 text-right" ); divSigAlert.Controls.Add( divSigAction ); var lbResendDocumentRequest = new LinkButton(); lbResendDocumentRequest.CausesValidation = false; lbResendDocumentRequest.ID = string.Format( "lbResendDocumentRequest_{0}", registrant.Id ); lbResendDocumentRequest.Text = registrant.SignatureDocumentLastSent.HasValue ? "Resend Signature Request" : "Send Signature Request"; lbResendDocumentRequest.CssClass = "btn btn-warning btn-sm"; lbResendDocumentRequest.Click += lbResendDocumentRequest_Click; divSigAction.Controls.Add( lbResendDocumentRequest ); divSigAlert.Controls.Add( new LiteralControl( "</div>" ) ); } var divRow = new HtmlGenericControl( "div" ); divRow.AddCssClass( "row" ); divBody.Controls.Add( divRow ); var divLeftColumn = new HtmlGenericControl( "div" ); divLeftColumn.AddCssClass( "col-md-6"); divRow.Controls.Add( divLeftColumn ); var divRightColumn = new HtmlGenericControl( "div" ); divRightColumn.AddCssClass( "col-md-6"); divRow.Controls.Add( divRightColumn ); if ( RegistrationTemplateState != null && RegistrationTemplateState.GroupTypeId.HasValue && Registration != null && Registration.Group != null && Registration.Group.GroupTypeId == RegistrationTemplateState.GroupTypeId.Value ) { if ( Registration != null && Registration.Group != null ) { var rcwGroupMember = new RockControlWrapper(); rcwGroupMember.ID = string.Format( "rcwGroupMember_{0}", registrant.Id ); divLeftColumn.Controls.Add( rcwGroupMember ); rcwGroupMember.Label = "Group"; var pGroupMember = new HtmlGenericControl( "p" ); pGroupMember.ID = string.Format( "pGroupMember_{0}", registrant.Id ); divRow.AddCssClass( "form-control-static" ); rcwGroupMember.Controls.Add( pGroupMember ); if ( registrant.GroupMemberId.HasValue ) { var qryParams = new Dictionary<string, string>(); qryParams.Add( "GroupMemberId", registrant.GroupMemberId.Value.ToString() ); var aProfileLink = new HtmlAnchor(); aProfileLink.HRef = LinkedPageUrl( "GroupMemberPage", qryParams ); pGroupMember.Controls.Add( aProfileLink ); aProfileLink.Controls.Add( new LiteralControl( string.IsNullOrWhiteSpace( registrant.GroupName ) ? "Group" : registrant.GroupName ) ); } else { pGroupMember.Controls.Add( new LiteralControl( "None (" ) ); var lbGroupMember = new LinkButton(); lbGroupMember.CausesValidation = false; lbGroupMember.ID = string.Format( "lbGroupMember_{0}", registrant.Id ); lbGroupMember.Text = string.Format( "Add {0} to Target Group", registrant.GetFirstName( RegistrationTemplateState ) ); lbGroupMember.Click += lbGroupMember_Click; pGroupMember.Controls.Add( lbGroupMember ); pGroupMember.Controls.Add( new LiteralControl( ")" ) ); } } } foreach( var form in RegistrationTemplateState.Forms.OrderBy( f => f.Order ) ) { foreach( var field in form.Fields.OrderBy( f => f.Order ) ) { var fieldControl = BuildRegistrantFieldControl( field, registrant, setValues ); if ( fieldControl != null ) { divLeftColumn.Controls.Add( fieldControl ); } } } if ( registrant.Cost > 0.0m) { var rlCost = new RockLiteral(); rlCost.ID = string.Format( "rlCost_{0}", registrant.Id ); rlCost.Label = "Cost"; rlCost.Text = registrant.Cost.FormatAsCurrency(); decimal discountedCost = registrant.DiscountedCost( Registration.DiscountPercentage, Registration.DiscountAmount ); if ( registrant.Cost == discountedCost ) { var divCost = new HtmlGenericControl( "div" ); divCost.AddCssClass( "col-xs-12" ); divCost.Controls.Add( rlCost ); divRightColumn.Controls.Add( divCost ); } else { var rlDiscountedCost = new RockLiteral(); rlDiscountedCost.ID = string.Format( "rlDiscountedCost_{0}", registrant.Id ); rlDiscountedCost.Label = "Discounted Cost"; rlDiscountedCost.Text = discountedCost.FormatAsCurrency(); var divCost = new HtmlGenericControl( "div" ); divCost.AddCssClass( "col-xs-6" ); divCost.Controls.Add( rlCost ); divRightColumn.Controls.Add( divCost ); var divDiscountedCost = new HtmlGenericControl( "div" ); divDiscountedCost.AddCssClass( "col-xs-6" ); divDiscountedCost.Controls.Add( rlDiscountedCost ); divRightColumn.Controls.Add( divDiscountedCost ); } } foreach ( var fee in registrant.FeeValues ) { var templateFee = RegistrationTemplateState.Fees.Where( f => f.Id == fee.Key ).FirstOrDefault(); if ( templateFee != null && fee.Value != null ) { foreach ( var feeInfo in fee.Value ) { var discountedCost = registrant.DiscountApplies ? feeInfo.DiscountedCost( Registration.DiscountPercentage ) : feeInfo.TotalCost; var feeControl = BuildRegistrantFeeControl( templateFee, feeInfo, registrant, setValues ); if ( feeControl != null ) { if ( feeInfo.TotalCost == discountedCost ) { var divFee = new HtmlGenericControl( "div" ); divFee.AddCssClass( "col-xs-12" ); divFee.Controls.Add( feeControl ); divRightColumn.Controls.Add( divFee ); } else { var rlDiscountedFee = new RockLiteral(); rlDiscountedFee.ID = string.Format( "rlDiscountedFee_{0}_{1}_{2}", registrant.Id, templateFee.Id, feeInfo.Option ); rlDiscountedFee.Label = "Discounted Amount"; rlDiscountedFee.Text = discountedCost.FormatAsCurrency(); var divFee = new HtmlGenericControl( "div" ); divFee.AddCssClass( "col-xs-6" ); divFee.Controls.Add( feeControl ); divRightColumn.Controls.Add( divFee ); var divDiscountedFee = new HtmlGenericControl( "div" ); divDiscountedFee.AddCssClass( "col-xs-6" ); divDiscountedFee.Controls.Add( rlDiscountedFee ); divRightColumn.Controls.Add( divDiscountedFee ); } } } } } if ( documentTemplate != null && registrant.SignatureDocumentId.HasValue ) { var rlDocumentLink = new RockLiteral(); rlDocumentLink.ID = string.Format( "rlDocumentLink_{0}", registrant.Id ); rlDocumentLink.Label = documentTemplate.Name; rlDocumentLink.Text = string.Format( "<a href='{0}?id={1}' target='_blank'>View Document</a>", ResolveRockUrl( "~/GetFile.ashx" ), registrant.SignatureDocumentId.Value ); divRightColumn.Controls.Add( rlDocumentLink ); } var divActions = new HtmlGenericControl( "Div" ); divActions.AddCssClass( "actions" ); divBody.Controls.Add( divActions ); var lbEditRegistrant = new LinkButton(); lbEditRegistrant.Visible = EditAllowed; lbEditRegistrant.CausesValidation = false; lbEditRegistrant.ID = string.Format( "lbEditRegistrant_{0}", registrant.Id ); lbEditRegistrant.Text = "Edit"; lbEditRegistrant.CssClass = "btn btn-primary"; lbEditRegistrant.Click += lbEditRegistrant_Click; divActions.Controls.Add( lbEditRegistrant ); var lbDeleteRegistrant = new LinkButton(); lbDeleteRegistrant.Visible = EditAllowed; lbDeleteRegistrant.CausesValidation = false; lbDeleteRegistrant.ID = string.Format( "lbDeleteRegistrant_{0}", registrant.Id ); lbDeleteRegistrant.Text = "Delete"; lbDeleteRegistrant.CssClass = "btn btn-link"; lbDeleteRegistrant.Attributes["onclick"] = "javascript: return Rock.dialogs.confirmDelete(event, 'Registrant');"; lbDeleteRegistrant.Click += lbDeleteRegistrant_Click; divActions.Controls.Add( lbDeleteRegistrant ); }
private void BuildRegistrantControls( RegistrantInfo registrant, bool setValues ) { var anchor = new HtmlAnchor(); anchor.Name = registrant.Id.ToString(); phDynamicControls.Controls.Add( anchor ); var divPanel = new HtmlGenericControl( "div" ); divPanel.AddCssClass( "panel" ); divPanel.AddCssClass( "panel-block" ); phDynamicControls.Controls.Add( divPanel ); var divHeading = new HtmlGenericControl( "div" ); divHeading.AddCssClass( "panel-heading" ); divHeading.AddCssClass( "clearfix" ); divPanel.Controls.Add( divHeading ); var h1Heading = new HtmlGenericControl( "h1" ); h1Heading.AddCssClass( "panel-title" ); h1Heading.AddCssClass( "pull-left" ); h1Heading.InnerText = registrant.PersonName; divHeading.Controls.Add( h1Heading ); var divLabels = new HtmlGenericControl( "div" ); divLabels.AddCssClass( "panel-labels" ); divHeading.Controls.Add( divLabels ); decimal registrantCost = registrant.TotalCost; if ( registrantCost != 0.0m ) { var hlCost = new HighlightLabel(); hlCost.ID = string.Format( "hlCost_{0}", registrant.Id ); hlCost.LabelType = LabelType.Info; hlCost.ToolTip = "Cost"; hlCost.Text = registrantCost.ToString( "C2" ); divLabels.Controls.Add( hlCost ); } var divBody = new HtmlGenericControl( "div" ); divBody.AddCssClass( "panel-body" ); divPanel.Controls.Add( divBody ); var divRow = new HtmlGenericControl( "div" ); divRow.AddCssClass( "row" ); divBody.Controls.Add( divRow ); var divFields = new HtmlGenericControl( "div" ); divFields.AddCssClass( "col-md-6"); divRow.Controls.Add( divFields ); var divFees = new HtmlGenericControl( "div" ); divFees.AddCssClass( "col-md-6"); divRow.Controls.Add( divFees ); foreach( var form in RegistrationTemplateState.Forms ) { foreach( var field in form.Fields ) { var fieldControl = BuildRegistrantFieldControl( field, registrant, setValues ); if ( fieldControl != null ) { divFields.Controls.Add( fieldControl ); } } } if ( registrant.Cost > 0.0m) { var rlCost = new RockLiteral(); rlCost.ID = string.Format( "rlCost_{0}", registrant.Id ); rlCost.Label = "Cost"; rlCost.Text = registrant.Cost.ToString( "C2" ); divFees.Controls.Add( rlCost ); } foreach ( var fee in registrant.FeeValues ) { var templateFee = RegistrationTemplateState.Fees.Where( f => f.Id == fee.Key ).FirstOrDefault(); if ( templateFee != null && fee.Value != null ) { foreach ( var feeInfo in fee.Value ) { var feeControl = BuildRegistrantFeeControl( templateFee, feeInfo, registrant, setValues ); if ( feeControl != null ) { divFees.Controls.Add( feeControl ); } } } } var divActions = new HtmlGenericControl( "Div" ); divActions.AddCssClass( "actions" ); divBody.Controls.Add( divActions ); var lbEditRegistrant = new LinkButton(); lbEditRegistrant.Visible = EditAllowed; lbEditRegistrant.CausesValidation = false; lbEditRegistrant.ID = string.Format( "lbEditRegistrant_{0}", registrant.Id ); lbEditRegistrant.Text = "Edit"; lbEditRegistrant.CssClass = "btn btn-primary"; lbEditRegistrant.Click += lbEditRegistrant_Click; divActions.Controls.Add( lbEditRegistrant ); var lbDeleteRegistrant = new LinkButton(); lbDeleteRegistrant.Visible = EditAllowed; lbDeleteRegistrant.CausesValidation = false; lbDeleteRegistrant.ID = string.Format( "lbDeleteRegistrant_{0}", registrant.Id ); lbDeleteRegistrant.Text = "Delete"; lbDeleteRegistrant.CssClass = "btn btn-link"; lbDeleteRegistrant.Attributes["onclick"] = "javascript: return Rock.dialogs.confirmDelete(event, 'Registrant');"; lbDeleteRegistrant.Click += lbDeleteRegistrant_Click; divActions.Controls.Add( lbDeleteRegistrant ); }
/// <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(); _hfExpanded = new HiddenField(); Controls.Add( _hfExpanded ); _hfExpanded.ID = this.ID + "_hfExpanded"; _hfExpanded.Value = "False"; _hfActivityGuid = new HiddenField(); Controls.Add( _hfActivityGuid ); _hfActivityGuid.ID = this.ID + "_hfActivityTypeGuid"; _lblActivityTypeName = new Label(); Controls.Add( _lblActivityTypeName ); _lblActivityTypeName.ClientIDMode = ClientIDMode.Static; _lblActivityTypeName.ID = this.ID + "_lblActivityTypeName"; _lblActivityTypeDescription = new Label(); Controls.Add( _lblActivityTypeDescription ); _lblActivityTypeDescription.ClientIDMode = ClientIDMode.Static; _lblActivityTypeDescription.ID = this.ID + "_lblActivityTypeDescription"; _lblStatus = new Label(); Controls.Add( _lblStatus ); _lblStatus.ClientIDMode = ClientIDMode.Static; _lblStatus.ID = this.ID + "_lblInactive"; _lblStatus.CssClass = "pull-right"; _lbDeleteActivityType = new LinkButton(); Controls.Add( _lbDeleteActivityType ); _lbDeleteActivityType.CausesValidation = false; _lbDeleteActivityType.ID = this.ID + "_lbDeleteActivityType"; _lbDeleteActivityType.CssClass = "btn btn-xs btn-danger js-activity-delete"; _lbDeleteActivityType.Click += lbDeleteActivityType_Click; _lbDeleteActivityType.Controls.Add( new LiteralControl { Text = "<i class='fa fa-times'></i>" } ); _cbActivityIsComplete = new RockCheckBox { Text = "Complete" }; Controls.Add( _cbActivityIsComplete ); _cbActivityIsComplete.ID = this.ID + "_cbActivityTypeIsActive"; _cbActivityIsComplete.Label = "Activity Completed"; _cbActivityIsComplete.Text = "Yes"; _ppAssignedToPerson = new PersonPicker(); _ppAssignedToPerson.ID = this.ID + "_ppAssignedToPerson"; Controls.Add( _ppAssignedToPerson ); _ppAssignedToPerson.Label = "Assign to Person"; _lAssignedToPerson = new RockLiteral(); _lAssignedToPerson.ID = this.ID + "_lAssignedToPerson"; Controls.Add( _lAssignedToPerson ); _lAssignedToPerson.Label = "Assigned to Person"; _gpAssignedToGroup = new GroupPicker(); _gpAssignedToGroup.ID = this.ID + "_gpAssignedToGroup"; Controls.Add( _gpAssignedToGroup ); _gpAssignedToGroup.Label = "Assign to Group"; _lAssignedToGroup = new RockLiteral(); _lAssignedToGroup.ID = this.ID + "_lAssignedToGroup"; Controls.Add( _lAssignedToGroup ); _lAssignedToGroup.Label = "Assigned to Group"; _ddlAssignedToRole = new RockDropDownList(); Controls.Add( _ddlAssignedToRole ); _ddlAssignedToRole.ID = this.ID + "_ddlAssignedToRole"; _ddlAssignedToRole.Label = "Assign to Security Role"; _lAssignedToRole = new RockLiteral(); _lAssignedToRole.ID = this.ID + "_lAssignedToRole"; Controls.Add( _lAssignedToRole ); _lAssignedToRole.Label = "Assigned to Security Role"; _lState = new Literal(); Controls.Add( _lState ); _lState.ID = this.ID + "_lState"; _ddlAssignedToRole.Items.Add( new ListItem( string.Empty, "0" ) ); var roles = new GroupService( new RockContext() ).Queryable().Where( g => g.IsSecurityRole ).OrderBy( t => t.Name ); if ( roles.Any() ) { foreach ( var role in roles ) { _ddlAssignedToRole.Items.Add( new ListItem( role.Name, role.Id.ToString() ) ); } } _phAttributes = new PlaceHolder(); Controls.Add( _phAttributes ); _phAttributes.ID = this.ID + "_phAttributes"; }
private void BuildRegistrantControls( RegistrantInfo registrant, bool setValues ) { var anchor = new HtmlAnchor(); anchor.Name = registrant.Id.ToString(); phDynamicControls.Controls.Add( anchor ); var divPanel = new HtmlGenericControl( "div" ); divPanel.AddCssClass( "panel" ); divPanel.AddCssClass( "panel-block" ); phDynamicControls.Controls.Add( divPanel ); var divHeading = new HtmlGenericControl( "div" ); divHeading.AddCssClass( "panel-heading" ); divHeading.AddCssClass( "clearfix" ); divPanel.Controls.Add( divHeading ); var h1Heading = new HtmlGenericControl( "h1" ); h1Heading.AddCssClass( "panel-title" ); h1Heading.AddCssClass( "pull-left" ); h1Heading.InnerHtml = "<i class='fa fa-user'></i> " + registrant.PersonName; divHeading.Controls.Add( h1Heading ); var divLabels = new HtmlGenericControl( "div" ); divLabels.AddCssClass( "panel-labels" ); divHeading.Controls.Add( divLabels ); decimal registrantCost = registrant.TotalCost; if ( registrantCost != 0.0m ) { var hlCost = new HighlightLabel(); hlCost.ID = string.Format( "hlCost_{0}", registrant.Id ); hlCost.LabelType = LabelType.Info; hlCost.ToolTip = "Cost"; hlCost.Text = registrantCost.FormatAsCurrency(); divLabels.Controls.Add( hlCost ); } if ( registrant.PersonId.HasValue ) { var aProfileLink = new HtmlAnchor(); aProfileLink.HRef = ResolveRockUrl( string.Format( "~/Person/{0}", registrant.PersonId.Value ) ); divLabels.Controls.Add( aProfileLink ); aProfileLink.AddCssClass( "btn btn-default btn-xs margin-l-sm" ); var iProfileLink = new HtmlGenericControl( "i" ); iProfileLink.AddCssClass( "fa fa-user" ); aProfileLink.Controls.Add( iProfileLink ); } var divBody = new HtmlGenericControl( "div" ); divBody.AddCssClass( "panel-body" ); divPanel.Controls.Add( divBody ); var divRow = new HtmlGenericControl( "div" ); divRow.AddCssClass( "row" ); divBody.Controls.Add( divRow ); var divFields = new HtmlGenericControl( "div" ); divFields.AddCssClass( "col-md-6"); divRow.Controls.Add( divFields ); var divFees = new HtmlGenericControl( "div" ); divFees.AddCssClass( "col-md-6"); divRow.Controls.Add( divFees ); if ( RegistrationTemplateState != null && RegistrationTemplateState.GroupTypeId.HasValue && Registration != null && Registration.Group != null && Registration.Group.GroupTypeId == RegistrationTemplateState.GroupTypeId.Value ) { if ( Registration != null && Registration.Group != null ) { var rcwGroupMember = new RockControlWrapper(); rcwGroupMember.ID = string.Format( "rcwGroupMember_{0}", registrant.Id ); divFields.Controls.Add( rcwGroupMember ); rcwGroupMember.Label = "Group"; var pGroupMember = new HtmlGenericControl( "p" ); pGroupMember.ID = string.Format( "pGroupMember_{0}", registrant.Id ); divRow.AddCssClass( "form-control-static" ); rcwGroupMember.Controls.Add( pGroupMember ); if ( registrant.GroupMemberId.HasValue ) { var qryParams = new Dictionary<string, string>(); qryParams.Add( "GroupMemberId", registrant.GroupMemberId.Value.ToString() ); var aProfileLink = new HtmlAnchor(); aProfileLink.HRef = LinkedPageUrl( "GroupMemberPage", qryParams ); pGroupMember.Controls.Add( aProfileLink ); aProfileLink.Controls.Add( new LiteralControl( string.IsNullOrWhiteSpace( registrant.GroupName ) ? "Group" : registrant.GroupName ) ); } else { pGroupMember.Controls.Add( new LiteralControl( "None (" ) ); var lbGroupMember = new LinkButton(); lbGroupMember.CausesValidation = false; lbGroupMember.ID = string.Format( "lbGroupMember_{0}", registrant.Id ); lbGroupMember.Text = string.Format( "Add {0} to Target Group", registrant.GetFirstName( RegistrationTemplateState ) ); lbGroupMember.Click += lbGroupMember_Click; pGroupMember.Controls.Add( lbGroupMember ); pGroupMember.Controls.Add( new LiteralControl( ")" ) ); } } } foreach( var form in RegistrationTemplateState.Forms.OrderBy( f => f.Order ) ) { foreach( var field in form.Fields.OrderBy( f => f.Order ) ) { var fieldControl = BuildRegistrantFieldControl( field, registrant, setValues ); if ( fieldControl != null ) { divFields.Controls.Add( fieldControl ); } } } if ( registrant.Cost > 0.0m) { var rlCost = new RockLiteral(); rlCost.ID = string.Format( "rlCost_{0}", registrant.Id ); rlCost.Label = "Cost"; rlCost.Text = registrant.Cost.FormatAsCurrency(); divFees.Controls.Add( rlCost ); } foreach ( var fee in registrant.FeeValues ) { var templateFee = RegistrationTemplateState.Fees.Where( f => f.Id == fee.Key ).FirstOrDefault(); if ( templateFee != null && fee.Value != null ) { foreach ( var feeInfo in fee.Value ) { var feeControl = BuildRegistrantFeeControl( templateFee, feeInfo, registrant, setValues ); if ( feeControl != null ) { divFees.Controls.Add( feeControl ); } } } } var divActions = new HtmlGenericControl( "Div" ); divActions.AddCssClass( "actions" ); divBody.Controls.Add( divActions ); var lbEditRegistrant = new LinkButton(); lbEditRegistrant.Visible = EditAllowed; lbEditRegistrant.CausesValidation = false; lbEditRegistrant.ID = string.Format( "lbEditRegistrant_{0}", registrant.Id ); lbEditRegistrant.Text = "Edit"; lbEditRegistrant.CssClass = "btn btn-primary"; lbEditRegistrant.Click += lbEditRegistrant_Click; divActions.Controls.Add( lbEditRegistrant ); var lbDeleteRegistrant = new LinkButton(); lbDeleteRegistrant.Visible = EditAllowed; lbDeleteRegistrant.CausesValidation = false; lbDeleteRegistrant.ID = string.Format( "lbDeleteRegistrant_{0}", registrant.Id ); lbDeleteRegistrant.Text = "Delete"; lbDeleteRegistrant.CssClass = "btn btn-link"; lbDeleteRegistrant.Attributes["onclick"] = "javascript: return Rock.dialogs.confirmDelete(event, 'Registrant');"; lbDeleteRegistrant.Click += lbDeleteRegistrant_Click; divActions.Controls.Add( lbDeleteRegistrant ); }
/// <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(); _hfExpanded = new HiddenFieldWithClass(); Controls.Add( _hfExpanded ); _hfExpanded.ID = this.ID + "_hfExpanded"; _hfExpanded.CssClass = "filter-expanded"; _hfExpanded.Value = "False"; _hfActionTypeGuid = new HiddenField(); Controls.Add( _hfActionTypeGuid ); _hfActionTypeGuid.ID = this.ID + "_hfActionTypeGuid"; _lblActionTypeName = new Label(); Controls.Add( _lblActionTypeName ); _lblActionTypeName.ClientIDMode = ClientIDMode.Static; _lblActionTypeName.ID = this.ID + "_lblActionTypeName"; _lbDeleteActionType = new LinkButton(); Controls.Add( _lbDeleteActionType ); _lbDeleteActionType.CausesValidation = false; _lbDeleteActionType.ID = this.ID + "_lbDeleteActionType"; _lbDeleteActionType.CssClass = "btn btn-xs btn-danger js-action-delete"; _lbDeleteActionType.Click += lbDeleteActionType_Click; var iDelete = new HtmlGenericControl( "i" ); _lbDeleteActionType.Controls.Add( iDelete ); iDelete.AddCssClass( "fa fa-times" ); _ddlCriteriaAttribute = new RockDropDownList(); Controls.Add( _ddlCriteriaAttribute ); _ddlCriteriaAttribute.ID = this.ID + "_ddlCriteriaAttribute"; _ddlCriteriaAttribute.EnableViewState = false; _ddlCriteriaAttribute.CssClass = "js-conditional-run-criteria"; _ddlCriteriaAttribute.Label = "Run If"; _ddlCriteriaAttribute.Help = "Optional criteria to prevent the action from running. If the criteria is not met, this action will be skipped when this activity is processed."; _ddlCriteriaComparisonType = new RockDropDownList(); Controls.Add( _ddlCriteriaComparisonType ); _ddlCriteriaComparisonType.ID = this.ID + "_ddlCriteriaComparisonType"; _ddlCriteriaComparisonType.EnableViewState = false; _ddlCriteriaComparisonType.CssClass = "js-action-criteria-comparison"; _ddlCriteriaComparisonType.BindToEnum<ComparisonType>(); _ddlCriteriaComparisonType.Label = " "; _tbddlCriteriaValue = new RockTextOrDropDownList(); Controls.Add( _tbddlCriteriaValue ); _tbddlCriteriaValue.ID = this.ID + "_tbddlCriteriaValue"; _tbddlCriteriaValue.EnableViewState = false; _tbddlCriteriaValue.TextBox.Label = "Text Value"; _tbddlCriteriaValue.DropDownList.Label = "Attribute Value"; _tbActionTypeName = new RockTextBox(); Controls.Add( _tbActionTypeName ); _tbActionTypeName.ID = this.ID + "_tbActionTypeName"; _tbActionTypeName.Label = "Name"; _tbActionTypeName.Required = true; _tbActionTypeName.Attributes["onblur"] = string.Format( "javascript: $('#{0}').text($(this).val());", _lblActionTypeName.ID ); _wfatpEntityType = new WorkflowActionTypePicker(); _wfatpEntityType.SelectItem += wfatpEntityType_SelectItem; Controls.Add( _wfatpEntityType ); _wfatpEntityType.ID = this.ID + "_wfatpEntityType"; _wfatpEntityType.Label = "Action Type"; _rlEntityTypeOverview = new RockLiteral(); Controls.Add( _rlEntityTypeOverview ); _rlEntityTypeOverview.ID = this.ID + ""; _rlEntityTypeOverview.Label = "Action Type Overview"; _cbIsActionCompletedOnSuccess = new RockCheckBox { Text = "Action is Completed on Success" }; Controls.Add( _cbIsActionCompletedOnSuccess ); _cbIsActionCompletedOnSuccess.ID = this.ID + "_cbIsActionCompletedOnSuccess"; _cbIsActivityCompletedOnSuccess = new RockCheckBox { Text = "Activity is Completed on Success" }; Controls.Add( _cbIsActivityCompletedOnSuccess ); _cbIsActivityCompletedOnSuccess.ID = this.ID + "_cbIsActivityCompletedOnSuccess"; _formEditor = new WorkflowFormEditor(); Controls.Add( _formEditor ); _formEditor.ID = this.ID + "_formEditor"; _phActionAttributes = new PlaceHolder(); Controls.Add( _phActionAttributes ); _phActionAttributes.ID = this.ID + "_phActionAttributes"; }
/// <summary> /// Handles the ItemDataBound event of the rptrGroups control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param> protected void rptrGroups_ItemDataBound( object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e ) { if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem ) { var group = e.Item.DataItem as Group; if ( group != null ) { HyperLink hlEditGroup = e.Item.FindControl( "hlEditGroup" ) as HyperLink; if ( hlEditGroup != null ) { hlEditGroup.Visible = _allowEdit; var pageParams = new Dictionary<string, string>(); pageParams.Add( "PersonId", Person.Id.ToString() ); pageParams.Add( "GroupId", group.Id.ToString() ); hlEditGroup.NavigateUrl = LinkedPageUrl( "GroupEditPage", pageParams ); } Repeater rptrMembers = e.Item.FindControl( "rptrMembers" ) as Repeater; if ( rptrMembers != null ) { // use the _bindGroupsRockContext that is created/disposed in BindFamilies() var members = new GroupMemberService( _bindGroupsRockContext ).Queryable( "GroupRole,Person", true ) .Where( m => m.GroupId == group.Id && m.PersonId != Person.Id ) .OrderBy( m => m.GroupRole.Order ) .ToList(); var orderedMembers = new List<GroupMember>(); if ( _IsFamilyGroupType ) { // Add adult males orderedMembers.AddRange( members .Where( m => m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) && m.Person.Gender == Gender.Male ) .OrderByDescending( m => m.Person.Age ) ); // Add adult females orderedMembers.AddRange( members .Where( m => m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) && m.Person.Gender != Gender.Male ) .OrderByDescending( m => m.Person.Age ) ); // Add non-adults orderedMembers.AddRange( members .Where( m => !m.GroupRole.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ) ) .OrderByDescending( m => m.Person.Age ) ); } else { orderedMembers = members .OrderBy( m => m.GroupRole.Order ) .ThenBy( m => m.Person.LastName ) .ThenBy( m => m.Person.NickName ) .ToList(); } rptrMembers.ItemDataBound += rptrMembers_ItemDataBound; rptrMembers.DataSource = orderedMembers; rptrMembers.DataBind(); } Repeater rptrAddresses = e.Item.FindControl( "rptrAddresses" ) as Repeater; if ( rptrAddresses != null ) { rptrAddresses.ItemDataBound += rptrAddresses_ItemDataBound; rptrAddresses.ItemCommand += rptrAddresses_ItemCommand; rptrAddresses.DataSource = new GroupLocationService( _bindGroupsRockContext ).Queryable( "Location,GroupLocationTypeValue" ) .Where( l => l.GroupId == group.Id ) .OrderBy( l => l.GroupLocationTypeValue.Order ) .ToList(); rptrAddresses.DataBind(); } Panel pnlGroupAttributes = e.Item.FindControl( "pnlGroupAttributes" ) as Panel; HyperLink hlShowMoreAttributes = e.Item.FindControl( "hlShowMoreAttributes" ) as HyperLink; PlaceHolder phGroupAttributes = e.Item.FindControl( "phGroupAttributes" ) as PlaceHolder; PlaceHolder phMoreGroupAttributes = e.Item.FindControl( "phMoreGroupAttributes" ) as PlaceHolder; if ( pnlGroupAttributes != null && hlShowMoreAttributes != null && phGroupAttributes != null && phMoreGroupAttributes != null ) { hlShowMoreAttributes.Visible = false; phGroupAttributes.Controls.Clear(); phMoreGroupAttributes.Controls.Clear(); group.LoadAttributes(); var attributes = group.Attributes .Select( a => a.Value ) .OrderBy( a => a.Order ) .ToList(); foreach( var attribute in attributes ) { if ( attribute.IsAuthorized( Authorization.VIEW, CurrentPerson ) ) { string value = attribute.DefaultValue; if ( group.AttributeValues.ContainsKey( attribute.Key ) && group.AttributeValues[attribute.Key] != null ) { value = group.AttributeValues[attribute.Key].ValueFormatted; } if ( !string.IsNullOrWhiteSpace( value ) ) { var literalControl = new RockLiteral(); literalControl.ID = string.Format( "familyAttribute_{0}", attribute.Id ); literalControl.Label = attribute.Name; literalControl.Text = value; var div = new HtmlGenericControl( "div" ); div.AddCssClass( "col-md-3 col-sm-6" ); div.Controls.Add( literalControl ); if ( attribute.IsGridColumn ) { phGroupAttributes.Controls.Add( div ); } else { hlShowMoreAttributes.Visible = true; phMoreGroupAttributes.Controls.Add( div ); } } } } pnlGroupAttributes.Visible = phGroupAttributes.Controls.Count > 0 || phMoreGroupAttributes.Controls.Count > 0; } } } }
private void BuildForm( bool setValues ) { var form = _actionType.WorkflowForm; if ( setValues ) { var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson ); mergeFields.Add( "Action", _action ); mergeFields.Add( "Activity", _activity ); mergeFields.Add( "Workflow", _workflow ); lheadingText.Text = form.Header.ResolveMergeFields( mergeFields ); lFootingText.Text = form.Footer.ResolveMergeFields( mergeFields ); } if ( _workflow != null && _workflow.CreatedDateTime.HasValue ) { hlblDateAdded.Text = String.Format( "Added: {0}", _workflow.CreatedDateTime.Value.ToShortDateString() ); } else { hlblDateAdded.Visible = false; } phAttributes.Controls.Clear(); foreach ( var formAttribute in form.FormAttributes.OrderBy( a => a.Order ) ) { if ( formAttribute.IsVisible ) { var attribute = AttributeCache.Read( formAttribute.AttributeId ); string value = attribute.DefaultValue; if ( _workflow != null && _workflow.AttributeValues.ContainsKey( attribute.Key ) && _workflow.AttributeValues[attribute.Key] != null ) { value = _workflow.AttributeValues[attribute.Key].Value; } if ( !string.IsNullOrWhiteSpace( formAttribute.PreHtml)) { phAttributes.Controls.Add( new LiteralControl( formAttribute.PreHtml ) ); } if ( formAttribute.IsReadOnly ) { var field = attribute.FieldType.Field; string formattedValue = null; // get formatted value if ( attribute.FieldType.Class == typeof( Rock.Field.Types.ImageFieldType ).FullName ) { formattedValue = attribute.FieldType.Field.FormatValueAsHtml( phAttributes, value, attribute.QualifierValues, true ); } else { formattedValue = field.FormatValueAsHtml( phAttributes, value, attribute.QualifierValues ); } if ( formAttribute.HideLabel ) { phAttributes.Controls.Add( new LiteralControl( formattedValue ) ); } else { RockLiteral lAttribute = new RockLiteral(); lAttribute.ID = "lAttribute_" + formAttribute.Id.ToString(); lAttribute.Label = attribute.Name; if ( field is Rock.Field.ILinkableFieldType ) { string url = ( (Rock.Field.ILinkableFieldType)field ).UrlLink( value, attribute.QualifierValues ); url = ResolveRockUrl( "~" ).EnsureTrailingForwardslash() + url; lAttribute.Text = string.Format( "<a href='{0}' target='_blank'>{1}</a>", url, formattedValue ); } else { lAttribute.Text = formattedValue; } phAttributes.Controls.Add( lAttribute ); } } else { attribute.AddControl( phAttributes.Controls, value, BlockValidationGroup, setValues, true, formAttribute.IsRequired, ( formAttribute.HideLabel ? string.Empty : attribute.Name ) ); } if ( !string.IsNullOrWhiteSpace( formAttribute.PostHtml ) ) { phAttributes.Controls.Add( new LiteralControl( formAttribute.PostHtml ) ); } } } if ( form.AllowNotes.HasValue && form.AllowNotes.Value && _workflow != null && _workflow.Id != 0 ) { ncWorkflowNotes.EntityId = _workflow.Id; ncWorkflowNotes.RebuildNotes( setValues ); ShowNotes( true ); } else { ShowNotes( false ); } phActions.Controls.Clear(); foreach ( var action in form.Actions.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries ) ) { var details = action.Split( new char[] { '^' } ); if ( details.Length > 0 ) { // Get the button html string buttonHtml = string.Empty; if ( details.Length > 1 ) { var definedValue = DefinedValueCache.Read( details[1].AsGuid() ); if ( definedValue != null ) { buttonHtml = definedValue.GetAttributeValue( "ButtonHTML" ); } } if ( string.IsNullOrWhiteSpace( buttonHtml ) ) { buttonHtml = "<a href=\"{{ ButtonLink }}\" onclick=\"{{ ButtonClick }}\" class='btn btn-primary' data-loading-text='<i class=\"fa fa-refresh fa-spin\"></i> {{ ButtonText }}'>{{ ButtonText }}</a>"; } var buttonMergeFields = new Dictionary<string, object>(); buttonMergeFields.Add( "ButtonText", details[0].EscapeQuotes() ); buttonMergeFields.Add( "ButtonClick", string.Format( "if ( Page_ClientValidate('{0}') ) {{ $(this).button('loading'); return true; }} else {{ return false; }}", BlockValidationGroup ) ); buttonMergeFields.Add( "ButtonLink", Page.ClientScript.GetPostBackClientHyperlink( this, details[0] ) ); buttonHtml = buttonHtml.ResolveMergeFields( buttonMergeFields ); phActions.Controls.Add( new LiteralControl( buttonHtml ) ); phActions.Controls.Add( new LiteralControl( " " ) ); } } }
private Control BuildRegistrantFeeControl( RegistrationTemplateFee fee, FeeInfo feeInfo, RegistrantInfo registrant, bool setValues ) { if ( feeInfo.Quantity > 0 ) { var rlField = new RockLiteral(); rlField.ID = string.Format( "rlFee_{0}_{1}_{2}", registrant.Id, fee.Id, feeInfo.Option ); rlField.Label = fee.Name; if ( !string.IsNullOrWhiteSpace( feeInfo.Option ) ) { rlField.Label += " - " + feeInfo.Option; } if ( feeInfo.Quantity > 1 ) { rlField.Text = string.Format( "({0:N0} @ {1:C2}) {2:C2}", feeInfo.Quantity, feeInfo.Cost, feeInfo.TotalCost ); } else { rlField.Text = feeInfo.TotalCost.ToString( "C2" ); } return rlField; } return null; }
/// <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(); _hfExpanded = new HiddenFieldWithClass(); Controls.Add(_hfExpanded); _hfExpanded.ID = this.ID + "_hfExpanded"; _hfExpanded.CssClass = "filter-expanded"; _hfExpanded.Value = "False"; _hfActionTypeGuid = new HiddenField(); Controls.Add(_hfActionTypeGuid); _hfActionTypeGuid.ID = this.ID + "_hfActionTypeGuid"; _lblActionTypeName = new Label(); Controls.Add(_lblActionTypeName); _lblActionTypeName.ClientIDMode = ClientIDMode.Static; _lblActionTypeName.ID = this.ID + "_lblActionTypeName"; _lbDeleteActionType = new LinkButton(); Controls.Add(_lbDeleteActionType); _lbDeleteActionType.CausesValidation = false; _lbDeleteActionType.ID = this.ID + "_lbDeleteActionType"; _lbDeleteActionType.CssClass = "btn btn-xs btn-square btn-danger js-action-delete"; _lbDeleteActionType.Click += lbDeleteActionType_Click; var iDelete = new HtmlGenericControl("i"); _lbDeleteActionType.Controls.Add(iDelete); iDelete.AddCssClass("fa fa-times"); _ddlCriteriaAttribute = new RockDropDownList(); Controls.Add(_ddlCriteriaAttribute); _ddlCriteriaAttribute.ID = this.ID + "_ddlCriteriaAttribute"; _ddlCriteriaAttribute.EnableViewState = false; _ddlCriteriaAttribute.CssClass = "js-conditional-run-criteria"; _ddlCriteriaAttribute.Label = "Run If"; _ddlCriteriaAttribute.Help = "Optional criteria to prevent the action from running. If the criteria is not met, this action will be skipped when this activity is processed."; _ddlCriteriaComparisonType = new RockDropDownList(); Controls.Add(_ddlCriteriaComparisonType); _ddlCriteriaComparisonType.ID = this.ID + "_ddlCriteriaComparisonType"; _ddlCriteriaComparisonType.EnableViewState = false; _ddlCriteriaComparisonType.CssClass = "js-action-criteria-comparison"; _ddlCriteriaComparisonType.BindToEnum <ComparisonType>(); _ddlCriteriaComparisonType.Label = " "; _tbddlCriteriaValue = new RockTextOrDropDownList(); Controls.Add(_tbddlCriteriaValue); _tbddlCriteriaValue.ID = this.ID + "_tbddlCriteriaValue"; _tbddlCriteriaValue.EnableViewState = false; _tbddlCriteriaValue.TextBox.Label = "Text Value"; _tbddlCriteriaValue.DropDownList.Label = "Attribute Value"; _tbActionTypeName = new RockTextBox(); Controls.Add(_tbActionTypeName); _tbActionTypeName.ID = this.ID + "_tbActionTypeName"; _tbActionTypeName.Label = "Name"; _tbActionTypeName.Required = true; _tbActionTypeName.Attributes["onblur"] = string.Format("javascript: $('#{0}').text($(this).val());", _lblActionTypeName.ID); _wfatpEntityType = new WorkflowActionTypePicker(); _wfatpEntityType.SelectItem += wfatpEntityType_SelectItem; Controls.Add(_wfatpEntityType); _wfatpEntityType.ID = this.ID + "_wfatpEntityType"; _wfatpEntityType.Label = "Action Type"; _rlEntityTypeOverview = new RockLiteral(); Controls.Add(_rlEntityTypeOverview); _rlEntityTypeOverview.ID = this.ID + ""; _rlEntityTypeOverview.Label = "Action Type Overview"; _cbIsActionCompletedOnSuccess = new RockCheckBox { Text = "Action is Completed on Success" }; Controls.Add(_cbIsActionCompletedOnSuccess); _cbIsActionCompletedOnSuccess.ID = this.ID + "_cbIsActionCompletedOnSuccess"; _cbIsActivityCompletedOnSuccess = new RockCheckBox { Text = "Activity is Completed on Success" }; Controls.Add(_cbIsActivityCompletedOnSuccess); _cbIsActivityCompletedOnSuccess.ID = this.ID + "_cbIsActivityCompletedOnSuccess"; _formEditor = new WorkflowFormEditor(); Controls.Add(_formEditor); _formEditor.ID = this.ID + "_formEditor"; _phActionAttributes = new PlaceHolder(); Controls.Add(_phActionAttributes); _phActionAttributes.ID = this.ID + "_phActionAttributes"; }
/// <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(); tbFrom = new RockTextBox(); tbFrom.ID = string.Format("tbFrom_{0}", this.ID); tbFrom.MaxLength = 11; tbFrom.Label = "From"; tbFrom.Help = "The name the recipient will see as the message originating from."; Controls.Add(tbFrom); lFrom = new RockLiteral(); lFrom.ID = string.Format("lFrom_{0}", this.ID); lFrom.Label = "From"; Controls.Add(lFrom); rcwMessage = new RockControlWrapper(); rcwMessage.ID = string.Format("rcwMessage_{0}", this.ID); rcwMessage.Label = "Message"; rcwMessage.Help = "<span class='tip tip-lava'></span>"; Controls.Add(rcwMessage); mfpMessage = new MergeFieldPicker(); mfpMessage.ID = string.Format("mfpMergeFields_{0}", this.ID); mfpMessage.MergeFields.Clear(); mfpMessage.MergeFields.Add("GlobalAttribute"); mfpMessage.MergeFields.Add("Rock.Model.Person"); mfpMessage.CssClass += " pull-right margin-b-sm"; mfpMessage.SelectItem += mfpMergeFields_SelectItem; rcwMessage.Controls.Add(mfpMessage); tbMessage = new RockTextBox(); tbMessage.ID = string.Format("tbTextMessage_{0}", this.ID); tbMessage.TextMode = TextBoxMode.MultiLine; tbMessage.Rows = 3; rcwMessage.Controls.Add(tbMessage); cbAppendUserInfo = new RockCheckBox(); cbAppendUserInfo.ID = string.Format("cbAppendUserInfo_{0}", this.ID); cbAppendUserInfo.Label = "Add organisation footer to message?"; cbAppendUserInfo.Help = "Append your message with your organisation's custom mesage or just the name of your organisation?"; cbAppendUserInfo.Checked = true; Controls.Add(cbAppendUserInfo); hfSenderGuid = new HiddenField(); hfSenderGuid.ID = string.Format( "hfSenderGuid_{0}", this.ID ); Controls.Add( hfSenderGuid ); }