/// <summary> /// Handles the Add actions event. /// </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 gFilters_Add(object sender, EventArgs e) { var rockContext = new RockContext(); var attributeService = new AttributeService(rockContext); // Reset attribute editor fields. edtFilter.Name = string.Empty; edtFilter.Key = string.Empty; edtFilter.AbbreviatedName = ""; Rock.Model.Attribute attribute = new Rock.Model.Attribute(); // Set attribute fields to those from a new attribute to made sure the AttributeEditor / ViewState has no leftover values. edtFilter.AttributeGuid = attribute.Guid; edtFilter.AttributeId = attribute.Id; edtFilter.IsFieldTypeEditable = true; edtFilter.SetAttributeFieldType(FieldTypeCache.Get(Rock.SystemGuid.FieldType.TEXT).Id, null); edtFilter.ReservedKeyNames = AttributeCache.AllForEntityType(_blockTypeEntityId) .Where(a => a.EntityTypeQualifierColumn == "Id" && a.EntityTypeQualifierValue == _block.Id.ToString()) .Select(a => a.Key) .Distinct() .ToList(); mdFilter.Title = "Add Filter"; mdFilter.Show(); }
/// <summary> /// Builds the non bulk dynamic controls. /// </summary> private void BuildNonBulkDynamicControls() { var stepAttributes = AttributeCache.AllForEntityType <Step>(); avcNonBulkAttributes.ExcludedAttributes = stepAttributes .Where(a => a.Key == "Order" || a.Key == "Active" || a.ShowOnBulk) .ToArray(); var stepType = GetStepType(); if (stepType != null) { var step = GetCurrentSetPersonStep() ?? new Step { StepTypeId = stepType.Id }; step.LoadAttributes(); avcNonBulkAttributes.AddEditControls(step); } else { avcNonBulkAttributes.AddEditControls(null); } UpdateNonBulkDynamicControlsForPersonChange(); }
/// <summary> /// Builds the bulk dynamic controls. /// </summary> private void BuildBulkDynamicControls() { var stepAttributes = AttributeCache.AllForEntityType <Step>(); avcBulkAttributes.ExcludedAttributes = stepAttributes .Where(a => a.Key == "Order" || a.Key == "Active" || !a.ShowOnBulk) .ToArray(); var stepType = GetStepType(); if (stepType != null) { var step = new Step { StepTypeId = stepType.Id }; step.LoadAttributes(); avcBulkAttributes.AddEditControls(step); } else { avcBulkAttributes.AddEditControls(null); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { if (!Page.IsPostBack) { BindComponents(); InitializeAdvancedSettingsToggle(); int? smsPipelineId = GetSmsPipelineId(); SmsPipeline smsPipeline = null; if (smsPipelineId == null || smsPipelineId == 0) { BindEditDetails(null); } else { var smsPipelineService = new SmsPipelineService(new RockContext()); smsPipeline = GetSmsPipeline(smsPipelineId.Value, smsPipelineService, "SmsActions"); BindReadOnlyDetails(smsPipeline); } BindActions(smsPipeline); // This must come after BindComponents so that the SmsActionContainer will // have been initialized already and any new attributes created. var attributes = AttributeCache.AllForEntityType <SmsAction>() .Where(a => a.Key == "Order" || a.Key == "Active"); avcAttributes.ExcludedAttributes = attributes.ToArray(); avcAttributes.ExcludedCategoryNames = new string[] { SmsActionComponent.BaseAttributeCategories.Filters }; avcFilters.IncludedCategoryNames = new string[] { SmsActionComponent.BaseAttributeCategories.Filters }; } else { if (Request["__EVENTTARGET"].ToStringSafe() == lbDragCommand.ClientID) { ProcessDragEvents(); } if (hfIsTestingDrawerOpen.Value.AsBoolean()) { divTestingDrawer.Style.Add("display", null); } else { divTestingDrawer.Style.Add("display", "none"); } } base.OnLoad(e); }
/// <summary> /// Gets the custom settings control. The returned control will be added to the parent automatically. /// </summary> /// <param name="attributeEntity">The attribute entity.</param> /// <param name="parent">The parent control that will eventually contain the returned control.</param> /// <returns> /// A control that contains all the custom UI. /// </returns> public override Control GetCustomSettingsControl(IHasAttributes attributeEntity, Control parent) { var pnlContent = new Panel(); var jfBuilder = new JsonFieldsBuilder { Label = "Additional Fields", SourceType = typeof(GroupMember), AvailableAttributes = AttributeCache.AllForEntityType <GroupMember>() .Where(a => a.EntityTypeQualifierColumn.IsNullOrWhiteSpace() && a.EntityTypeQualifierValue.IsNullOrWhiteSpace()) .ToList() }; pnlContent.Controls.Add(jfBuilder); return(pnlContent); }
/// <summary> /// Handles the Edit filters event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void gFilters_Edit(object sender, RowEventArgs e) { var rockContext = new RockContext(); var attributeService = new AttributeService(rockContext); var attribute = new AttributeService(rockContext).Get(e.RowKeyId); edtFilter.ReservedKeyNames = AttributeCache.AllForEntityType(_blockTypeEntityId) .Where(a => a.EntityTypeQualifierColumn == "Id" && a.EntityTypeQualifierValue == _block.Id.ToString() && a.Id != e.RowKeyId) .Select(a => a.Key) .Distinct() .ToList(); edtFilter.SetAttributeProperties(attribute); mdFilter.Title = "Edit Filter"; mdFilter.Show(); }
/// <summary> /// Build the dynamic controls based on the attributes /// </summary> private void BuildDynamicControls(bool editMode) { var excludedAttributes = AttributeCache.AllForEntityType <Step>() .Where(a => a.Key == "Order" || a.Key == "Active"); avcAttributes.ExcludedAttributes = excludedAttributes.ToArray(); var stepType = GetStepType(); var step = GetStep() ?? new Step { StepTypeId = stepType.Id }; step.LoadAttributes(); if (editMode) { avcAttributes.AddEditControls(step); } else { avcAttributesView.AddDisplayControls(step); } }
/// <summary> /// Builds the filter controls. /// </summary> private void BuildControls() { var attributes = AttributeCache.AllForEntityType(_blockTypeEntityId) .Where(a => a.EntityTypeQualifierColumn == "Id" && a.EntityTypeQualifierValue == _block.Id.ToString()) .OrderBy(a => a.Order) .ToList(); var exclusions = new List <string>(); exclusions.Add(AttributeKey.RedirectPage); _block.LoadAttributes(); phAttributes.Controls.Clear(); var attributeKeys = new List <string>(); foreach (var attribute in attributes) { if (attribute.IsAuthorized(Authorization.VIEW, CurrentPerson)) { attributeKeys.Add(attribute.Key); } } try { Helper.AddEditControls(string.Empty, attributeKeys, _block, phAttributes, string.Empty, false, exclusions, _filtersPerRow); } catch { pnlFilters.Visible = false; nbBuildErrors.Visible = true; nbBuildErrors.Text = "Not all filter controls could be built. The most likely cause of this issue is a mis-configured filter."; } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { if (!Page.IsPostBack) { CurrentParameters = this.RockPage.PageParameters(); // Get list of attributes with default values (4/12/2022 JME replaces code that read // this from the DB with the call below that reads from cache. var attribsWithDefaultValue = AttributeCache.AllForEntityType(_blockTypeEntityId) .Where(a => a.EntityTypeQualifierColumn == "Id" && a.EntityTypeQualifierValue == _block.Id.ToString() && a.DefaultValue != null && a.DefaultValue != string.Empty) .ToList(); // If we have any filters with default values, we want to load this block with the page parameters already set. if (attribsWithDefaultValue.Any() && !this.RockPage.PageParameters().Any()) { ResetFilters(); } else { LoadFilters(); } } else { LoadFilters(); } base.OnLoad(e); btnFilter.Visible = GetAttributeValue(AttributeKey.ShowFilterButton).AsBoolean(); btnResetFilters.Visible = GetAttributeValue(AttributeKey.ShowResetFiltersButton).AsBoolean(); }