/// <summary> /// When implemented by a class, defines the <see cref="T:System.Web.UI.Control"/> object that child controls and templates belong to. These child controls are in turn defined within an inline template. /// </summary> /// <param name="container">The <see cref="T:System.Web.UI.Control"/> object to contain the instances of controls from the inline template.</param> public void InstantiateIn(Control container) { DataControlFieldCell cell = container as DataControlFieldCell; if (cell != null) { EditField editField = cell.ContainingField as EditField; ParentGrid = editField.ParentGrid; LinkButton lbEdit = new LinkButton(); lbEdit.ToolTip = "Edit"; lbEdit.Click += lbEdit_Click; cell.Controls.Add(lbEdit); } }
/// <summary> /// When implemented by a class, defines the <see cref="T:System.Web.UI.Control"/> object that child controls and templates belong to. These child controls are in turn defined within an inline template. /// </summary> /// <param name="container">The <see cref="T:System.Web.UI.Control"/> object to contain the instances of controls from the inline template.</param> public void InstantiateIn(Control container) { DataControlFieldCell cell = container as DataControlFieldCell; if (cell != null) { EditField editField = cell.ContainingField as EditField; ParentGrid = editField.ParentGrid; LinkButton lbEdit = new LinkButton(); lbEdit.CausesValidation = false; lbEdit.CssClass = "btn btn-edit btn-sm"; lbEdit.ToolTip = "Edit"; HtmlGenericControl buttonIcon = new HtmlGenericControl("i"); buttonIcon.Attributes.Add("class", "fa fa-pencil-square-o"); lbEdit.Controls.Add(buttonIcon); lbEdit.Click += lbEdit_Click; cell.Controls.Add(lbEdit); } }
/// <summary> /// Builds the dynamic controls. /// </summary> private void BuildDynamicControls() { // Clear attribute filter controls and recreate phFilterControls.Controls.Clear(); string ScheduleFilters = GetAttributeValue( "ScheduleFilters" ); if ( !string.IsNullOrEmpty( ScheduleFilters ) ) { if ( ScheduleFilters.Contains( "Day" ) ) { var control = FieldTypeCache.Read( Rock.SystemGuid.FieldType.DAY_OF_WEEK ).Field.FilterControl( null, "filter_dow", false, Rock.Reporting.FilterMode.SimpleFilter ); AddFilterControl( control, "Day of Week", "The day of week that group meets on." ); } if ( ScheduleFilters.Contains( "Time" ) ) { var control = FieldTypeCache.Read( Rock.SystemGuid.FieldType.TIME ).Field.FilterControl( null, "filter_time", false, Rock.Reporting.FilterMode.SimpleFilter ); AddFilterControl( control, "Time of Day", "The time of day that group meets." ); } } if ( AttributeFilters != null ) { foreach ( var attribute in AttributeFilters ) { var control = attribute.FieldType.Field.FilterControl( attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter ); if ( control != null ) { AddFilterControl( control, attribute.Name, attribute.Description ); } } } // Build attribute columns foreach ( var column in gGroups.Columns.OfType<AttributeField>().ToList() ) { gGroups.Columns.Remove( column ); } if ( AttributeColumns != null ) { foreach ( var attribute in AttributeColumns ) { string dataFieldExpression = attribute.Key; bool columnExists = gGroups.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; var attributeCache = AttributeCache.Read( attribute.Id ); if ( attributeCache != null ) { boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue; } gGroups.Columns.Add( boundField ); } } } // Add Register Column foreach ( var column in gGroups.Columns.OfType<EditField>().ToList() ) { gGroups.Columns.Remove( column ); } var registerPage = new PageReference( GetAttributeValue( "RegisterPage" ) ); if ( _targetPersonGuid != Guid.Empty ) { registerPage.Parameters = _urlParms; } if ( registerPage.PageId > 0 ) { var registerColumn = new EditField(); registerColumn.HeaderText = "Register"; registerColumn.Click += registerColumn_Click; gGroups.Columns.Add( registerColumn ); } var pageSizes = new List<int>(); if ( !String.IsNullOrWhiteSpace( GetAttributeValue( "PageSizes" ) ) ) { pageSizes = GetAttributeValue( "PageSizes" ).Split( ',' ).AsIntegerList(); } ddlPageSize.Items.Clear(); ddlPageSize.Items.AddRange( pageSizes.Select( a => new ListItem( a.ToString(), a.ToString() ) ).ToArray() ); ddlPageSize.Items.Add( new ListItem( "All", "0" ) ); if ( pageSizes.Any() ) { // set default PageSize to whatever is first in the PageSize setting ddlPageSize.Visible = true; ddlPageSize.SelectedValue = pageSizes[0].ToString(); } else { ddlPageSize.Visible = false; } // if the SortByDistance is enabled, prevent them from sorting by ColumnClick if ( GetAttributeValue( "SortByDistance" ).AsBoolean() ) { gGroups.AllowSorting = false; } }
/// <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"; _hfActivityTypeGuid = new HiddenField(); Controls.Add(_hfActivityTypeGuid); _hfActivityTypeGuid.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"; _lblInactive = new Label(); Controls.Add(_lblInactive); _lblInactive.ClientIDMode = ClientIDMode.Static; _lblInactive.ID = this.ID + "_lblInactive"; _lblInactive.CssClass = "pull-right"; _lblInactive.Text = "<span class='label label-danger'>Inactive</span>"; _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>" }); _sbSecurity = new SecurityButton(); Controls.Add(_sbSecurity); _sbSecurity.ID = this.ID + "_sbSecurity"; _sbSecurity.Attributes["class"] = "btn btn-security btn-xs security pull-right"; _sbSecurity.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.WorkflowActivityType)).Id; _cbActivityTypeIsActive = new RockCheckBox { Text = "Active" }; Controls.Add(_cbActivityTypeIsActive); _cbActivityTypeIsActive.ID = this.ID + "_cbActivityTypeIsActive"; string checkboxScriptFormat = @" javascript: if ($(this).is(':checked')) {{ $('#{0}').hide(); $('#{1}').removeClass('workflow-activity-inactive'); }} else {{ $('#{0}').show(); $('#{1}').addClass('workflow-activity-inactive'); }} "; _cbActivityTypeIsActive.InputAttributes.Add("onclick", string.Format(checkboxScriptFormat, _lblInactive.ID, this.ID + "_section")); _tbActivityTypeName = new RockTextBox(); Controls.Add(_tbActivityTypeName); _tbActivityTypeName.ID = this.ID + "_tbActivityTypeName"; _tbActivityTypeName.Label = "Name"; _tbActivityTypeName.Required = true; _tbActivityTypeName.Attributes["onblur"] = string.Format("javascript: $('#{0}').text($(this).val());", _lblActivityTypeName.ID); _tbActivityTypeDescription = new RockTextBox(); Controls.Add(_tbActivityTypeDescription); _tbActivityTypeDescription.ID = this.ID + "_tbActivityTypeDescription"; _tbActivityTypeDescription.Label = "Description"; _tbActivityTypeDescription.TextMode = TextBoxMode.MultiLine; _tbActivityTypeDescription.Rows = 2; _tbActivityTypeDescription.Attributes["onblur"] = string.Format("javascript: $('#{0}').text($(this).val());", _lblActivityTypeDescription.ID); _cbActivityTypeIsActivatedWithWorkflow = new RockCheckBox { Text = "Activated with Workflow" }; Controls.Add(_cbActivityTypeIsActivatedWithWorkflow); _cbActivityTypeIsActivatedWithWorkflow.ID = this.ID + "_cbActivityTypeIsActivatedWithWorkflow"; checkboxScriptFormat = @" javascript: if ($(this).is(':checked')) {{ $('#{0}').addClass('activated-with-workflow'); }} else {{ $('#{0}').removeClass('activated-with-workflow'); }} "; _cbActivityTypeIsActivatedWithWorkflow.InputAttributes.Add("onclick", string.Format(checkboxScriptFormat, this.ID + "_section")); _lbAddActionType = new LinkButton(); Controls.Add(_lbAddActionType); _lbAddActionType.ID = this.ID + "_lbAddAction"; _lbAddActionType.CssClass = "btn btn-xs btn-action add-action"; _lbAddActionType.Click += lbAddActionType_Click; _lbAddActionType.CausesValidation = false; _lbAddActionType.Controls.Add(new LiteralControl { Text = "<i class='fa fa-plus'></i> Add Action" }); _pwAttributes = new PanelWidget(); Controls.Add(_pwAttributes); _pwAttributes.ID = this.ID + "_pwAttributes"; _pwAttributes.Title = "Activity Attributes"; _pwAttributes.CssClass = "attribute-panel"; _gAttributes = new Grid(); _pwAttributes.Controls.Add(_gAttributes); _gAttributes.ID = this.ID + "_gAttributes"; _gAttributes.AllowPaging = false; _gAttributes.DisplayType = GridDisplayType.Light; _gAttributes.RowItemText = "Activity Attribute"; _gAttributes.AddCssClass("attribute-grid"); _gAttributes.DataKeyNames = new string[] { "Guid" }; _gAttributes.Actions.ShowAdd = true; _gAttributes.Actions.AddClick += gAttributes_Add; _gAttributes.GridRebind += gAttributes_Rebind; _gAttributes.GridReorder += gAttributes_Reorder; _gAttributes.ShowActionsInHeader = false; var reorderField = new ReorderField(); _gAttributes.Columns.Add(reorderField); var nameField = new BoundField(); nameField.DataField = "Name"; nameField.HeaderText = "Attribute"; _gAttributes.Columns.Add(nameField); var descField = new BoundField(); descField.DataField = "Description"; descField.HeaderText = "Description"; _gAttributes.Columns.Add(descField); var fieldTypeField = new BoundField(); fieldTypeField.DataField = "FieldType"; fieldTypeField.HeaderText = "Field Type"; _gAttributes.Columns.Add(fieldTypeField); var reqField = new BoolField(); reqField.DataField = "IsRequired"; reqField.HeaderText = "Required"; _gAttributes.Columns.Add(reqField); var editField = new EditField(); editField.Click += gAttributes_Edit; _gAttributes.Columns.Add(editField); var delField = new DeleteField(); delField.Click += gAttributes_Delete; _gAttributes.Columns.Add(delField); }
/// <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"; _hfFormGuid = new HiddenField(); Controls.Add( _hfFormGuid ); _hfFormGuid.ID = this.ID + "_hfFormGuid"; _hfFormId = new HiddenField(); Controls.Add( _hfFormId ); _hfFormId.ID = this.ID + "_hfFormId"; _lblFormName = new Label(); Controls.Add( _lblFormName ); _lblFormName.ClientIDMode = ClientIDMode.Static; _lblFormName.ID = this.ID + "_lblFormName"; _lbDeleteForm = new LinkButton(); Controls.Add( _lbDeleteForm ); _lbDeleteForm.CausesValidation = false; _lbDeleteForm.ID = this.ID + "_lbDeleteForm"; _lbDeleteForm.CssClass = "btn btn-xs btn-danger js-activity-delete"; _lbDeleteForm.Click += lbDeleteForm_Click; _lbDeleteForm.Controls.Add( new LiteralControl { Text = "<i class='fa fa-times'></i>" } ); _tbFormName = new RockTextBox(); Controls.Add( _tbFormName ); _tbFormName.ID = this.ID + "_tbFormName"; _tbFormName.Label = "Form Name"; _tbFormName.Required = true; _tbFormName.Attributes["onblur"] = string.Format( "javascript: $('#{0}').text($(this).val());", _lblFormName.ID ); _gFields = new Grid(); Controls.Add( _gFields ); _gFields.ID = this.ID + "_gFields"; _gFields.AllowPaging = false; _gFields.DisplayType = GridDisplayType.Light; _gFields.RowItemText = "Field"; _gFields.AddCssClass( "field-grid" ); _gFields.DataKeyNames = new string[] { "Guid" }; _gFields.Actions.ShowAdd = true; _gFields.Actions.AddClick += gFields_Add; _gFields.GridRebind += gFields_Rebind; _gFields.GridReorder += gFields_Reorder; var reorderField = new ReorderField(); _gFields.Columns.Add( reorderField ); var nameField = new BoundField(); nameField.DataField = "Name"; nameField.HeaderText = "Field"; _gFields.Columns.Add( nameField ); var sourceField = new EnumField(); sourceField.DataField = "FieldSource"; sourceField.HeaderText = "Source"; _gFields.Columns.Add( sourceField ); var typeField = new FieldTypeField(); typeField.DataField = "FieldType"; typeField.HeaderText = "Type"; _gFields.Columns.Add( typeField ); var isInternalField = new BoolField(); isInternalField.DataField = "IsInternal"; isInternalField.HeaderText = "Internal"; _gFields.Columns.Add( isInternalField ); var isSharedValueField = new BoolField(); isSharedValueField.DataField = "IsSharedValue"; isSharedValueField.HeaderText = "Common"; _gFields.Columns.Add( isSharedValueField ); var showCurrentValueField = new BoolField(); showCurrentValueField.DataField = "ShowCurrentValue"; showCurrentValueField.HeaderText = "Use Current Value"; _gFields.Columns.Add( showCurrentValueField ); var isRequiredField = new BoolField(); isRequiredField.DataField = "IsRequired"; isRequiredField.HeaderText = "Required"; _gFields.Columns.Add( isRequiredField ); var isGridField = new BoolField(); isGridField.DataField = "IsGridField"; isGridField.HeaderText = "Show on Grid"; _gFields.Columns.Add( isGridField ); var editField = new EditField(); editField.Click += gFields_Edit; _gFields.Columns.Add( editField ); var delField = new DeleteField(); delField.Click += gFields_Delete; _gFields.Columns.Add( delField ); }
/// <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"; _hfFormGuid = new HiddenField(); Controls.Add(_hfFormGuid); _hfFormGuid.ID = this.ID + "_hfFormGuid"; _hfFormId = new HiddenField(); Controls.Add(_hfFormId); _hfFormId.ID = this.ID + "_hfFormId"; _lblFormName = new Label(); Controls.Add(_lblFormName); _lblFormName.ClientIDMode = ClientIDMode.Static; _lblFormName.ID = this.ID + "_lblFormName"; _lbDeleteForm = new LinkButton(); Controls.Add(_lbDeleteForm); _lbDeleteForm.CausesValidation = false; _lbDeleteForm.ID = this.ID + "_lbDeleteForm"; _lbDeleteForm.CssClass = "btn btn-xs btn-danger js-activity-delete"; _lbDeleteForm.Click += lbDeleteForm_Click; _lbDeleteForm.Controls.Add(new LiteralControl { Text = "<i class='fa fa-times'></i>" }); _tbFormName = new RockTextBox(); Controls.Add(_tbFormName); _tbFormName.ID = this.ID + "_tbFormName"; _tbFormName.Label = "Form Name"; _tbFormName.Required = true; _tbFormName.Attributes["onblur"] = string.Format("javascript: $('#{0}').text($(this).val());", _lblFormName.ID); _gFields = new Grid(); Controls.Add(_gFields); _gFields.ID = this.ID + "_gFields"; _gFields.AllowPaging = false; _gFields.DisplayType = GridDisplayType.Light; _gFields.RowItemText = "Field"; _gFields.AddCssClass("field-grid"); _gFields.DataKeyNames = new string[] { "Guid" }; _gFields.Actions.ShowAdd = true; _gFields.Actions.AddClick += gFields_Add; _gFields.GridRebind += gFields_Rebind; _gFields.GridReorder += gFields_Reorder; var reorderField = new ReorderField(); _gFields.Columns.Add(reorderField); var nameField = new BoundField(); nameField.DataField = "Name"; nameField.HeaderText = "Field"; _gFields.Columns.Add(nameField); var sourceField = new EnumField(); sourceField.DataField = "FieldSource"; sourceField.HeaderText = "Source"; _gFields.Columns.Add(sourceField); var typeField = new FieldTypeField(); typeField.DataField = "FieldType"; typeField.HeaderText = "Type"; _gFields.Columns.Add(typeField); var isInternalField = new BoolField(); isInternalField.DataField = "IsInternal"; isInternalField.HeaderText = "Internal"; _gFields.Columns.Add(isInternalField); var isSharedValueField = new BoolField(); isSharedValueField.DataField = "IsSharedValue"; isSharedValueField.HeaderText = "Common"; _gFields.Columns.Add(isSharedValueField); var showCurrentValueField = new BoolField(); showCurrentValueField.DataField = "ShowCurrentValue"; showCurrentValueField.HeaderText = "Use Current Value"; _gFields.Columns.Add(showCurrentValueField); var isRequiredField = new BoolField(); isRequiredField.DataField = "IsRequired"; isRequiredField.HeaderText = "Required"; _gFields.Columns.Add(isRequiredField); var isGridField = new BoolField(); isGridField.DataField = "IsGridField"; isGridField.HeaderText = "Show on Grid"; _gFields.Columns.Add(isGridField); var showOnWaitListField = new BoolField(); showOnWaitListField.DataField = "ShowOnWaitlist"; showOnWaitListField.HeaderText = "Show on Wait List"; _gFields.Columns.Add(showOnWaitListField); var editField = new EditField(); editField.Click += gFields_Edit; _gFields.Columns.Add(editField); var delField = new DeleteField(); delField.Click += gFields_Delete; _gFields.Columns.Add(delField); }
/// <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"; _hfActivityTypeGuid = new HiddenField(); Controls.Add( _hfActivityTypeGuid ); _hfActivityTypeGuid.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"; _lblInactive = new Label(); Controls.Add( _lblInactive ); _lblInactive.ClientIDMode = ClientIDMode.Static; _lblInactive.ID = this.ID + "_lblInactive"; _lblInactive.CssClass = "pull-right"; _lblInactive.Text = "<span class='label label-danger'>Inactive</span>"; _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>" } ); _sbSecurity = new SecurityButton(); Controls.Add( _sbSecurity ); _sbSecurity.ID = this.ID + "_sbSecurity"; _sbSecurity.Attributes["class"] = "btn btn-security btn-xs security pull-right"; _sbSecurity.EntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.WorkflowActivityType ) ).Id; _cbActivityTypeIsActive = new RockCheckBox { Text = "Active" }; Controls.Add( _cbActivityTypeIsActive ); _cbActivityTypeIsActive.ID = this.ID + "_cbActivityTypeIsActive"; string checkboxScriptFormat = @" javascript: if ($(this).is(':checked')) {{ $('#{0}').hide(); $('#{1}').removeClass('workflow-activity-inactive'); }} else {{ $('#{0}').show(); $('#{1}').addClass('workflow-activity-inactive'); }} "; _cbActivityTypeIsActive.InputAttributes.Add( "onclick", string.Format( checkboxScriptFormat, _lblInactive.ID, this.ID + "_section" ) ); _tbActivityTypeName = new RockTextBox(); Controls.Add( _tbActivityTypeName ); _tbActivityTypeName.ID = this.ID + "_tbActivityTypeName"; _tbActivityTypeName.Label = "Name"; _tbActivityTypeName.Required = true; _tbActivityTypeName.Attributes["onblur"] = string.Format( "javascript: $('#{0}').text($(this).val());", _lblActivityTypeName.ID ); _tbActivityTypeDescription = new RockTextBox(); Controls.Add( _tbActivityTypeDescription ); _tbActivityTypeDescription.ID = this.ID + "_tbActivityTypeDescription"; _tbActivityTypeDescription.Label = "Description"; _tbActivityTypeDescription.TextMode = TextBoxMode.MultiLine; _tbActivityTypeDescription.Rows = 2; _tbActivityTypeDescription.Attributes["onblur"] = string.Format( "javascript: $('#{0}').text($(this).val());", _lblActivityTypeDescription.ID ); _cbActivityTypeIsActivatedWithWorkflow = new RockCheckBox { Text = "Activated with Workflow" }; Controls.Add( _cbActivityTypeIsActivatedWithWorkflow ); _cbActivityTypeIsActivatedWithWorkflow.ID = this.ID + "_cbActivityTypeIsActivatedWithWorkflow"; checkboxScriptFormat = @" javascript: if ($(this).is(':checked')) {{ $('#{0}').addClass('activated-with-workflow'); }} else {{ $('#{0}').removeClass('activated-with-workflow'); }} "; _cbActivityTypeIsActivatedWithWorkflow.InputAttributes.Add( "onclick", string.Format( checkboxScriptFormat, this.ID + "_section" ) ); _lbAddActionType = new LinkButton(); Controls.Add( _lbAddActionType ); _lbAddActionType.ID = this.ID + "_lbAddAction"; _lbAddActionType.CssClass = "btn btn-xs btn-action"; _lbAddActionType.Click += lbAddActionType_Click; _lbAddActionType.CausesValidation = false; _lbAddActionType.Controls.Add( new LiteralControl { Text = "<i class='fa fa-plus'></i> Add Action" } ); _pwAttributes = new PanelWidget(); Controls.Add( _pwAttributes ); _pwAttributes.ID = this.ID + "_pwAttributes"; _pwAttributes.Title = "Activity Attributes"; _pwAttributes.CssClass = "attribute-panel"; _gAttributes = new Grid(); _pwAttributes.Controls.Add( _gAttributes ); _gAttributes.ID = this.ID + "_gAttributes"; _gAttributes.AllowPaging = false; _gAttributes.DisplayType = GridDisplayType.Light; _gAttributes.RowItemText = "Activity Attribute"; _gAttributes.AddCssClass( "attribute-grid" ); _gAttributes.DataKeyNames = new string[] { "Guid" }; _gAttributes.Actions.ShowAdd = true; _gAttributes.Actions.AddClick += gAttributes_Add; _gAttributes.GridRebind += gAttributes_Rebind; _gAttributes.GridReorder += gAttributes_Reorder; var reorderField = new ReorderField(); _gAttributes.Columns.Add( reorderField ); var nameField = new BoundField(); nameField.DataField = "Name"; nameField.HeaderText = "Attribute"; _gAttributes.Columns.Add( nameField ); var descField = new BoundField(); descField.DataField = "Description"; descField.HeaderText = "Description"; _gAttributes.Columns.Add( descField ); var fieldTypeField = new BoundField(); fieldTypeField.DataField = "FieldType"; fieldTypeField.HeaderText = "Field Type"; _gAttributes.Columns.Add( fieldTypeField ); var reqField = new BoolField(); reqField.DataField = "IsRequired"; reqField.HeaderText = "Required"; _gAttributes.Columns.Add( reqField ); var editField = new EditField(); editField.Click += gAttributes_Edit; _gAttributes.Columns.Add( editField ); var delField = new DeleteField(); delField.Click += gAttributes_Delete; _gAttributes.Columns.Add( delField ); }
/// <summary> /// Builds the dynamic controls. /// </summary> private void BuildDynamicControls() { // Clear attribute filter controls and recreate phFilterControls.Controls.Clear(); string ScheduleFilters = GetAttributeValue( "ScheduleFilters" ); if ( !string.IsNullOrEmpty( ScheduleFilters ) ) { if ( ScheduleFilters.Contains( "Day" ) ) { var control = FieldTypeCache.Read( Rock.SystemGuid.FieldType.DAY_OF_WEEK ).Field.FilterControl( null, "filter_dow", false ); AddFilterControl( control, "Day of Week", "The day of week that group meets on." ); } if ( ScheduleFilters.Contains( "Time" ) ) { var control = FieldTypeCache.Read( Rock.SystemGuid.FieldType.TIME ).Field.FilterControl( null, "filter_time", false ); AddFilterControl( control, "Time of Day", "The time of day that group meets." ); } } if ( AttributeFilters != null ) { foreach ( var attribute in AttributeFilters ) { var control = attribute.FieldType.Field.FilterControl( attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false ); AddFilterControl( control, attribute.Name, attribute.Description ); } } // Build attribute columns foreach ( var column in gGroups.Columns.OfType<AttributeField>().ToList() ) { gGroups.Columns.Remove( column ); } if ( AttributeColumns != null ) { foreach ( var attribute in AttributeColumns ) { string dataFieldExpression = attribute.Key; bool columnExists = gGroups.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 = AttributeCache.Read( attribute.Id ); if ( attributeCache != null ) { boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue; } gGroups.Columns.Add( boundField ); } } } // Add Register Column foreach ( var column in gGroups.Columns.OfType<EditField>().ToList() ) { gGroups.Columns.Remove( column ); } var registerPage = new PageReference( GetAttributeValue( "RegisterPage" ) ); if ( registerPage.PageId > 0 ) { var registerColumn = new EditField(); registerColumn.HeaderText = "Register"; registerColumn.Click += registerColumn_Click; gGroups.Columns.Add( registerColumn ); } }
/// <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 ) { base.OnInit( e ); if ( _workflowType != null ) { gfWorkflows.ApplyFilterClick += gfWorkflows_ApplyFilterClick; gfWorkflows.DisplayFilterValue += gfWorkflows_DisplayFilterValue; // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it this.BlockUpdated += Block_BlockUpdated; this.AddConfigurationUpdateTrigger( upnlSettings ); gWorkflows.DataKeyNames = new string[] { "id" }; gWorkflows.Actions.ShowAdd = true; gWorkflows.Actions.AddClick += gWorkflows_Add; gWorkflows.GridRebind += gWorkflows_GridRebind; // Block Security and special attributes (RockPage takes care of View) bool canAddEditDelete = IsUserAuthorized( Authorization.EDIT ); gWorkflows.Actions.ShowAdd = canAddEditDelete; gWorkflows.IsDeleteEnabled = canAddEditDelete; AddAttributeColumns(); var dateField = new DateTimeField(); gWorkflows.Columns.Add( dateField ); dateField.DataField = "CreatedDateTime"; dateField.SortExpression = "CreatedDateTime"; dateField.HeaderText = "Created"; dateField.FormatAsElapsedTime = true; var statusField = new BoundField(); gWorkflows.Columns.Add( statusField ); statusField.DataField = "Status"; statusField.SortExpression = "Status"; statusField.HeaderText = "Status"; statusField.HtmlEncode = false; var stateField = new BoundField(); gWorkflows.Columns.Add( stateField ); stateField.DataField = "State"; stateField.SortExpression = "CompletedDateTime"; stateField.HeaderText = "State"; stateField.HtmlEncode = false; var formField = new EditField(); gWorkflows.Columns.Add( formField ); formField.IconCssClass = "fa fa-edit"; formField.Click += formField_Click; var deleteField = new DeleteField(); gWorkflows.Columns.Add( deleteField ); deleteField.Click += gWorkflows_Delete; if ( !string.IsNullOrWhiteSpace( _workflowType.WorkTerm ) ) { gWorkflows.RowItemText = _workflowType.WorkTerm; lGridTitle.Text = _workflowType.WorkTerm.Pluralize(); } RockPage.PageTitle = _workflowType.Name; if ( !string.IsNullOrWhiteSpace( _workflowType.IconCssClass ) ) { lHeadingIcon.Text = string.Format("<i class='{0}'></i>", _workflowType.IconCssClass); } } else { pnlWorkflowList.Visible = false; } }
/// <summary> /// Adds the attribute columns. /// </summary> private void AddDynamicControls() { // Clear the filter controls phAttributeFilters.Controls.Clear(); // Remove attribute columns foreach ( var column in gWorkflows.Columns.OfType<AttributeField>().ToList() ) { gWorkflows.Columns.Remove( column ); } if ( AvailableAttributes != null ) { foreach ( var attribute in AvailableAttributes ) { var control = attribute.FieldType.Field.FilterControl( attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false ); if ( control is IRockControl ) { var rockControl = (IRockControl)control; rockControl.Label = attribute.Name; rockControl.Help = attribute.Description; phAttributeFilters.Controls.Add( control ); } else { var wrapper = new RockControlWrapper(); wrapper.ID = control.ID + "_wrapper"; wrapper.Label = attribute.Name; wrapper.Controls.Add( control ); phAttributeFilters.Controls.Add( wrapper ); } string savedValue = gfWorkflows.GetUserPreference( MakeKeyUniqueToType( 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.Key; bool columnExists = gWorkflows.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; } gWorkflows.Columns.Add( boundField ); } } } var dateField = new DateTimeField(); gWorkflows.Columns.Add( dateField ); dateField.DataField = "CreatedDateTime"; dateField.SortExpression = "CreatedDateTime"; dateField.HeaderText = "Created"; dateField.FormatAsElapsedTime = true; var statusField = new BoundField(); gWorkflows.Columns.Add( statusField ); statusField.DataField = "Status"; statusField.SortExpression = "Status"; statusField.HeaderText = "Status"; statusField.HtmlEncode = false; var stateField = new BoundField(); gWorkflows.Columns.Add( stateField ); stateField.DataField = "State"; stateField.SortExpression = "CompletedDateTime"; stateField.HeaderText = "State"; stateField.HtmlEncode = false; var manageField = new EditField(); gWorkflows.Columns.Add( manageField ); manageField.IconCssClass = "fa fa-edit"; manageField.Click += gWorkflows_Manage; var deleteField = new DeleteField(); gWorkflows.Columns.Add( deleteField ); deleteField.Click += gWorkflows_Delete; }