public labels(string pn, string fn) : base(pn, fn) 
 	{
 		_id = new FilterField<int?>(GetFullFieldName(), "id");
 		_tipolabel_tipo = new FilterField<string>(GetFullFieldName(), "tipolabel_tipo");
 		_value = new FilterField<string>(GetFullFieldName(), "value");
 		_main = new FilterField<bool?>(GetFullFieldName(), "main");
 	}
Example #2
0
 public ArtistFilter(FilterField iField, 
     String iValue, 
     Bitmap iArtwork, 
     String iExInfo)
 {
     Field = iField;
     Value = iValue;
     Artwork = iArtwork;
     ExInfo = iExInfo;
 }
Example #3
0
 public string[] GetFilters(FilterField field)
 {
     Hashtable ht = _filterFields[field.ToString()] as Hashtable;
     if (ht != null)
     {
         ArrayList al = new ArrayList(ht.Keys);
         return ((string[])al.ToArray(typeof(string)));
     }
     else
     {
         return new string[0];
     }
 }
Example #4
0
 	public iter(string pn, string fn) : base(pn, fn) 
 	{
 		_id = new FilterField<int?>(GetFullFieldName(), "id");
 		_nrecord = new FilterField<long?>(GetFullFieldName(), "nrecord");
 		_ncopia = new FilterField<long?>(GetFullFieldName(), "ncopia");
 		_datadoc = new FilterField<System.DateTime?>(GetFullFieldName(), "datadoc");
 		_storico = new FilterField<bool?>(GetFullFieldName(), "storico");
 		_stati_stato = new FilterField<string>(GetFullFieldName(), "stati_stato");
 		_prezzo = new FilterField<double?>(GetFullFieldName(), "prezzo");
 		_prezzoForzato = new FilterField<bool?>(GetFullFieldName(), "prezzoForzato");
 		_vigenteDa = new FilterField<System.DateTime?>(GetFullFieldName(), "vigenteDa");
 		_vigenteA = new FilterField<System.DateTime?>(GetFullFieldName(), "vigenteA");
 		_visibileDa = new FilterField<System.DateTime?>(GetFullFieldName(), "visibileDa");
 		_visibileA = new FilterField<System.DateTime?>(GetFullFieldName(), "visibileA");
 		_dataAggiornamento = new FilterField<System.DateTime?>(GetFullFieldName(), "dataAggiornamento");
 		_labels = new FilterObjectsCollection<labels>(GetFullFieldName(), "labels");
 		_disposizione = new disposizione(GetFullFieldName(), "disposizione");
 	}
        /// <summary>
        /// Creates the filter control.
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="reportEntityType">Type of the report entity.</param>
        /// <param name="setSelection">if set to <c>true</c> [set selection].</param>
        /// <param name="rockContext">The rock context.</param>
        private void CreateFilterControl(
            Control parentControl,
            DataViewFilter filter,
            EntityType reportEntityType,
            bool setSelection,
            RockContext rockContext )
        {
            try
            {
                var filteredEntityTypeName = EntityTypeCache.Read( reportEntityType ).Name;
                if ( filter.ExpressionType == FilterExpressionType.Filter )
                {
                    var filterControl = new FilterField();
                    bool filterIsVisible = _selectedDataFilterGuids.Contains( filter.Guid );

                    if ( filterIsVisible )
                    {
                        // only set FilterMode to simple if the filter is visible since SimpleFilters might have a different filtering behavior
                        filterControl.FilterMode = FilterMode.SimpleFilter;
                    }
                    else
                    {
                        filterControl.FilterMode = FilterMode.AdvancedFilter;
                    }

                    bool filterIsConfigurable = _configurableDataFilterGuids.Contains( filter.Guid );
                    bool showCheckbox = _togglableDataFilterGuids.Contains( filter.Guid ) || !filterIsConfigurable;
                    var dataFilterPrePostHtmlConfig = _dataFiltersPrePostHtmlConfig.GetValueOrNull( filter.Guid ) ?? new DataFilterPrePostHtmlConfig();
                    
                    filterControl.Visible = filterIsVisible;
                    
                    parentControl.Controls.Add( filterControl );

                    filterControl.DataViewFilterGuid = filter.Guid;

                    filterControl.HideFilterCriteria = !filterIsConfigurable;
                    filterControl.ID = string.Format( "ff_{0}", filterControl.DataViewFilterGuid.ToString( "N" ) );
                    filterControl.FilteredEntityTypeName = filteredEntityTypeName;

                    if ( filter.EntityTypeId.HasValue )
                    {
                        var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read( filter.EntityTypeId.Value, rockContext );
                        if ( entityTypeCache != null )
                        {
                            filterControl.FilterEntityTypeName = entityTypeCache.Name;
                        }
                    }

                    filterControl.Expanded = true;

                    filterControl.ShowCheckbox = filterIsVisible && showCheckbox;

                    var reportEntityTypeCache = EntityTypeCache.Read( reportEntityType );
                    var reportEntityTypeModel = reportEntityTypeCache.GetEntityType();

                    var filterEntityType = EntityTypeCache.Read( filter.EntityTypeId ?? 0 );
                    var component = Rock.Reporting.DataFilterContainer.GetComponent( filterEntityType.Name );
                    if ( component != null )
                    {
                        string selectionUserPreference = null;
                        bool? checkedUserPreference = null;
                        if ( setSelection && filterIsVisible )
                        {
                            if ( filterIsConfigurable )
                            {
                                selectionUserPreference = this.GetUserPreference( string.Format( "{0}_{1}_Selection", GetReportDataKeyPrefix(), filterControl.DataViewFilterGuid.ToString( "N" ) ) );
                            }

                            if ( filterControl.ShowCheckbox )
                            {
                                checkedUserPreference = this.GetUserPreference( string.Format( "{0}_{1}_Checked", GetReportDataKeyPrefix(), filterControl.DataViewFilterGuid.ToString( "N" ) ) ).AsBooleanOrNull() ?? true;
                            }
                        }

                        if ( checkedUserPreference.HasValue )
                        {
                            filterControl.SetCheckBoxChecked( checkedUserPreference.Value );
                        }

                        if ( setSelection )
                        {
                            var selection = filter.Selection;
                            if ( !string.IsNullOrWhiteSpace( selectionUserPreference ) )
                            {
                                if ( component is Rock.Reporting.DataFilter.PropertyFilter )
                                {
                                    selection = ( component as Rock.Reporting.DataFilter.PropertyFilter ).UpdateSelectionFromUserPreferenceSelection( selection, selectionUserPreference );
                                }
                                else
                                {
                                    selection = selectionUserPreference;
                                }
                            }

                            if ( component is Rock.Reporting.DataFilter.IUpdateSelectionFromPageParameters )
                            {
                                selection = ( component as Rock.Reporting.DataFilter.IUpdateSelectionFromPageParameters ).UpdateSelectionFromPageParameters( selection, this );
                            }

                            try
                            {
                                filterControl.SetSelection( selection );
                            }
                            catch ( Exception ex )
                            {
                                this.LogException( new Exception( "Exception setting selection for DataViewFilter: " + filter.Guid, ex ) );
                            }
                        }

                        string defaultFilterLabel;
                        if ( !filterIsConfigurable )
                        {
                            // not configurable so just label it with the selection summary
                            defaultFilterLabel = component.FormatSelection( reportEntityTypeModel, filter.Selection );

                            // configuration not visible, so set the selection to what it was in the dataview when it was saved, even if setSelection=False
                            filterControl.SetSelection( filter.Selection );
                        }
                        else if ( component is Rock.Reporting.DataFilter.PropertyFilter )
                        {
                            defaultFilterLabel = ( component as Rock.Reporting.DataFilter.PropertyFilter ).GetSelectionLabel( reportEntityTypeModel, filter.Selection );
                        }
                        else
                        {
                            defaultFilterLabel = component.GetTitle( reportEntityTypeModel );
                        }

                        var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson, new Rock.Lava.CommonMergeFieldsOptions { GetLegacyGlobalMergeFields = false } );
                        mergeFields.Add( "Filter", filter );
                        mergeFields.Add( "Label", defaultFilterLabel );

                        filterControl.Label = dataFilterPrePostHtmlConfig.LabelHtml.ResolveMergeFields( mergeFields );

                        if ( !string.IsNullOrEmpty( dataFilterPrePostHtmlConfig.PreHtml ) )
                        {
                            filterControl.PreHtml = dataFilterPrePostHtmlConfig.PreHtml.ResolveMergeFields( mergeFields );
                        }

                        if ( !string.IsNullOrEmpty( dataFilterPrePostHtmlConfig.PostHtml ) )
                        {
                            filterControl.PostHtml = dataFilterPrePostHtmlConfig.PostHtml.ResolveMergeFields( mergeFields );
                        }

                        if ( component is Rock.Reporting.DataFilter.OtherDataViewFilter )
                        {
                            // don't include the actual DataView Picker filter, just the child filters
                            parentControl.Controls.Remove( filterControl );

                            Rock.Reporting.DataFilter.OtherDataViewFilter otherDataViewFilter = component as Rock.Reporting.DataFilter.OtherDataViewFilter;
                            var otherDataView = otherDataViewFilter.GetSelectedDataView( filter.Selection );
                            if ( otherDataView != null )
                            {
                                CreateFilterControl( parentControl, otherDataView.DataViewFilter, reportEntityType, setSelection, rockContext );
                            }
                        }
                    }
                }
                else
                {
                    var groupControl = new FilterGroup();
                    parentControl.Controls.Add( groupControl );
                    groupControl.DataViewFilterGuid = filter.Guid;
                    groupControl.ID = string.Format( "fg_{0}", groupControl.DataViewFilterGuid.ToString( "N" ) );
                    groupControl.FilteredEntityTypeName = filteredEntityTypeName;
                    groupControl.IsDeleteEnabled = false;
                    groupControl.HidePanelHeader = true;
                    if ( setSelection )
                    {
                        groupControl.FilterType = filter.ExpressionType;
                    }

                    foreach ( var childFilter in filter.ChildFilters )
                    {
                        CreateFilterControl( groupControl, childFilter, reportEntityType, setSelection, rockContext );
                    }
                }
            }
            catch ( Exception ex )
            {
                this.LogException( new Exception( "Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex ) );
            }
        }
Example #6
0
 public void AddFilter(FilterField field, string filter)
 {
     try
     {
         Hashtable ht = _filterFields[field.ToString()] as Hashtable;
         if (ht != null)
         {
             if (ht[filter]==null)
             {
                 ht.Add(filter, true);
                 using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFile))
                 {
                     dbcon.ExecuteNonQuery(string.Format("insert into filterfields (field, filter) values ('{0}', '{1}')", field.ToString(), filter.Replace("'", "''")));
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteria"/> class.
 /// </summary>
 /// <param name="filterField">The filter field</param>
 /// <param name="filterOperator">The filter operator</param>
 /// <param name="filterValue">The filter value</param>
 public SearchCriteria(FilterField filterField, SearchConditionOperator filterOperator, object filterValue)
 {
     this.FilterField    = filterField;
     this.FilterOperator = filterOperator;
     this.FilterValue    = filterValue;
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaGreaterEqual"/> class.
 /// </summary>
 /// <param name="filterField">The filter field.</param>
 /// <param name="filterValue">The filter value.</param>
 public SearchCriteriaGreaterEqual(FilterField filterField, object filterValue)
     : base(filterField, SearchConditionOperator.GreaterEqual, filterValue)
 {
 }
Example #9
0
        /// <summary>
        /// Creates the filter control.
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="setSelection">if set to <c>true</c> [set selection].</param>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="contentChannel">The content channel.</param>
        private void CreateFilterControl(Control parentControl, DataViewFilter filter, bool setSelection, RockContext rockContext, ContentChannel contentChannel)
        {
            try
            {
                if (filter.ExpressionType == FilterExpressionType.Filter)
                {
                    var filterControl = new FilterField
                    {
                        Entity = new ContentChannelItem
                        {
                            ContentChannelId     = contentChannel.Id,
                            ContentChannelTypeId = contentChannel.ContentChannelTypeId
                        }
                    };

                    parentControl.Controls.Add(filterControl);
                    filterControl.DataViewFilterGuid = filter.Guid;
                    filterControl.ID = string.Format("ff_{0}", filterControl.DataViewFilterGuid.ToString("N"));

                    // Remove the 'Other Data View' Filter as it doesn't really make sense to have it available in this scenario
                    filterControl.ExcludedFilterTypes    = new string[] { typeof(Rock.Reporting.DataFilter.OtherDataViewFilter).FullName };
                    filterControl.FilteredEntityTypeName = ITEM_TYPE_NAME;

                    if (filter.EntityTypeId.HasValue)
                    {
                        var entityTypeCache = EntityTypeCache.Get(filter.EntityTypeId.Value, rockContext);
                        if (entityTypeCache != null)
                        {
                            filterControl.FilterEntityTypeName = entityTypeCache.Name;
                        }
                    }

                    filterControl.Expanded = filter.Expanded;
                    if (setSelection)
                    {
                        try
                        {
                            filterControl.SetSelection(filter.Selection);
                        }
                        catch (Exception ex)
                        {
                            ExceptionLogService.LogException(new Exception("Exception setting selection for DataViewFilter: " + filter.Guid, ex));
                        }
                    }

                    filterControl.DeleteClick += filterControl_DeleteClick;
                }
                else
                {
                    var groupControl = new FilterGroup();
                    parentControl.Controls.Add(groupControl);
                    groupControl.DataViewFilterGuid = filter.Guid;
                    groupControl.ID = string.Format("fg_{0}", groupControl.DataViewFilterGuid.ToString("N"));
                    groupControl.FilteredEntityTypeName = ITEM_TYPE_NAME;
                    groupControl.IsDeleteEnabled        = parentControl is FilterGroup;
                    if (setSelection)
                    {
                        groupControl.FilterType = filter.ExpressionType;
                    }

                    groupControl.AddFilterClick   += groupControl_AddFilterClick;
                    groupControl.AddGroupClick    += groupControl_AddGroupClick;
                    groupControl.DeleteGroupClick += groupControl_DeleteGroupClick;
                    foreach (var childFilter in filter.ChildFilters)
                    {
                        CreateFilterControl(groupControl, childFilter, setSelection, rockContext, contentChannel);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogService.LogException(new Exception("Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex));
            }
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaIn"/> class.
 /// </summary>
 /// <param name="filterField">The filter field.</param>
 /// <param name="filterValues">The filter values.</param>
 public SearchCriteriaIn(FilterField filterField, IEnumerable <object> filterValues)
     : base(filterField, SearchConditionOperator.In, filterValues)
 {
 }
Example #11
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            gp                  = new GroupPicker();
            gp.ID               = filterControl.ID + "_gp";
            gp.Label            = "Group(s)";
            gp.SelectItem      += gp_SelectItem;
            gp.CssClass         = "js-group-picker";
            gp.AllowMultiSelect = true;
            filterControl.Controls.Add(gp);

            cbChildGroups                 = new RockCheckBox();
            cbChildGroups.ID              = filterControl.ID + "_cbChildsGroups";
            cbChildGroups.Text            = "Include Child Group(s)";
            cbChildGroups.CssClass        = "js-include-child-groups";
            cbChildGroups.AutoPostBack    = true;
            cbChildGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbChildGroups);

            cbIncludeSelectedGroup                 = new RockCheckBox();
            cbIncludeSelectedGroup.ID              = filterControl.ID + "_cbIncludeSelectedGroup";
            cbIncludeSelectedGroup.Text            = "Include Selected Group(s)";
            cbIncludeSelectedGroup.CssClass        = "js-include-selected-groups";
            cbIncludeSelectedGroup.AutoPostBack    = true;
            cbIncludeSelectedGroup.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbIncludeSelectedGroup);

            cbChildGroupsPlusDescendants                 = new RockCheckBox();
            cbChildGroupsPlusDescendants.ID              = filterControl.ID + "_cbChildGroupsPlusDescendants";
            cbChildGroupsPlusDescendants.Text            = "Include All Descendants(s)";
            cbChildGroupsPlusDescendants.CssClass        = "js-include-child-groups-descendants";
            cbChildGroupsPlusDescendants.AutoPostBack    = true;
            cbChildGroupsPlusDescendants.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbChildGroupsPlusDescendants);

            cbIncludeInactiveGroups                 = new RockCheckBox();
            cbIncludeInactiveGroups.ID              = filterControl.ID + "_cbIncludeInactiveGroups";
            cbIncludeInactiveGroups.Text            = "Include Inactive Groups";
            cbIncludeInactiveGroups.CssClass        = "js-include-inactive-groups";
            cbIncludeInactiveGroups.AutoPostBack    = true;
            cbIncludeInactiveGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add(cbIncludeInactiveGroups);

            cblRole          = new RockCheckBoxList();
            cblRole.Label    = "with Group Member Role(s) (optional)";
            cblRole.ID       = filterControl.ID + "_cblRole";
            cblRole.CssClass = "js-roles";
            cblRole.Visible  = false;
            filterControl.Controls.Add(cblRole);

            RockDropDownList ddlGroupMemberStatus = new RockDropDownList();

            ddlGroupMemberStatus.CssClass = "js-group-member-status";
            ddlGroupMemberStatus.ID       = filterControl.ID + "_ddlGroupMemberStatus";
            ddlGroupMemberStatus.Label    = "with Group Member Status";
            ddlGroupMemberStatus.Help     = "Select a specific group member status to only include group members with that status. Leaving this blank will return all members.";
            ddlGroupMemberStatus.BindToEnum <GroupMemberStatus>(true);
            ddlGroupMemberStatus.SetValue(GroupMemberStatus.Active.ConvertToInt());
            filterControl.Controls.Add(ddlGroupMemberStatus);

            PanelWidget pwAdvanced = new PanelWidget();

            filterControl.Controls.Add(pwAdvanced);
            pwAdvanced.ID       = filterControl.ID + "_pwAttributes";
            pwAdvanced.Title    = "Advanced Filters";
            pwAdvanced.CssClass = "advanced-panel";

            SlidingDateRangePicker addedOnDateRangePicker = new SlidingDateRangePicker();

            addedOnDateRangePicker.ID = pwAdvanced.ID + "_addedOnDateRangePicker";
            addedOnDateRangePicker.AddCssClass("js-dateadded-sliding-date-range");
            addedOnDateRangePicker.Label = "Date Added:";
            addedOnDateRangePicker.Help  = "Select the date range that the person was added to the group. Leaving this blank will not restrict results to a date range.";
            pwAdvanced.Controls.Add(addedOnDateRangePicker);

            SlidingDateRangePicker firstAttendanceDateRangePicker = new SlidingDateRangePicker();

            firstAttendanceDateRangePicker.ID = filterControl.ID + "_firstAttendanceDateRangePicker";
            firstAttendanceDateRangePicker.AddCssClass("js-firstattendance-sliding-date-range");
            firstAttendanceDateRangePicker.Label = "First Attendance";
            firstAttendanceDateRangePicker.Help  = "The date range of the first attendance using the 'Sunday Date' of each attendance";
            pwAdvanced.Controls.Add(firstAttendanceDateRangePicker);

            SlidingDateRangePicker lastAttendanceDateRangePicker = new SlidingDateRangePicker();

            lastAttendanceDateRangePicker.ID = filterControl.ID + "_lastAttendanceDateRangePicker";
            lastAttendanceDateRangePicker.AddCssClass("js-lastattendance-sliding-date-range");
            lastAttendanceDateRangePicker.Label = "Last Attendance";
            lastAttendanceDateRangePicker.Help  = "The date range of the last attendance using the 'Sunday Date' of each attendance";
            pwAdvanced.Controls.Add(lastAttendanceDateRangePicker);

            return(new Control[11] {
                gp, cbChildGroups, cbIncludeSelectedGroup, cbChildGroupsPlusDescendants, cblRole, ddlGroupMemberStatus, cbIncludeInactiveGroups, addedOnDateRangePicker, pwAdvanced, firstAttendanceDateRangePicker, lastAttendanceDateRangePicker
            });
        }
        /// <summary>
        /// Creates the filter control.
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="filteredEntityTypeName">Name of the filtered entity type.</param>
        /// <param name="setSelection">if set to <c>true</c> [set selection].</param>
        /// <param name="rockContext">The rock context.</param>
        private void CreateFilterControl(Control parentControl, DataViewFilter filter, string filteredEntityTypeName, bool setSelection, RockContext rockContext)
        {
            try
            {
                if (filter.ExpressionType == FilterExpressionType.Filter)
                {
                    var filterControl = new FilterField();
                    parentControl.Controls.Add(filterControl);
                    filterControl.DataViewFilterGuid = filter.Guid;
                    filterControl.ID = string.Format("ff_{0}", filterControl.DataViewFilterGuid.ToString("N"));
                    filterControl.FilteredEntityTypeName = filteredEntityTypeName;
                    if (filter.EntityTypeId.HasValue)
                    {
                        var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read(filter.EntityTypeId.Value, rockContext);
                        if (entityTypeCache != null)
                        {
                            filterControl.FilterEntityTypeName = entityTypeCache.Name;
                        }
                    }

                    filterControl.Expanded = filter.Expanded;
                    if (setSelection)
                    {
                        try
                        {
                            filterControl.SetSelection(filter.Selection);
                        }
                        catch (Exception ex)
                        {
                            this.LogException(new Exception("Exception setting selection for DataViewFilter: " + filter.Guid, ex));
                        }
                    }

                    filterControl.DeleteClick += filterControl_DeleteClick;
                }
                else
                {
                    var groupControl = new FilterGroup();
                    parentControl.Controls.Add(groupControl);
                    groupControl.DataViewFilterGuid = filter.Guid;
                    groupControl.ID = string.Format("fg_{0}", groupControl.DataViewFilterGuid.ToString("N"));
                    groupControl.FilteredEntityTypeName = filteredEntityTypeName;
                    groupControl.IsDeleteEnabled        = parentControl is FilterGroup;
                    if (setSelection)
                    {
                        groupControl.FilterType = filter.ExpressionType;
                    }

                    groupControl.AddFilterClick   += groupControl_AddFilterClick;
                    groupControl.AddGroupClick    += groupControl_AddGroupClick;
                    groupControl.DeleteGroupClick += groupControl_DeleteGroupClick;
                    foreach (var childFilter in filter.ChildFilters)
                    {
                        CreateFilterControl(groupControl, childFilter, filteredEntityTypeName, setSelection, rockContext);
                    }
                }
            }
            catch (Exception ex)
            {
                this.LogException(new Exception("Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex));
            }
        }
Example #13
0
 /// <summary>
 /// Registers Javascript to hide/show .js-filter-control child elements of a .js-filter-compare dropdown
 /// see RockWeb\Scripts\Rock\reportingInclude.js
 /// </summary>
 /// <param name="filterControl">The control that serves as the container for the filter controls.</param>
 public void RegisterFilterCompareChangeScript(FilterField filterControl)
 {
     ReportingHelper.RegisterJavascriptInclude(filterControl);
 }
Example #14
0
 /// <summary>
 /// Renders the child controls used to display and edit the filter settings for HTML presentation.
 /// Implement this version of RenderControls if your DataFilterComponent supports different FilterModes
 /// </summary>
 /// <param name="entityType">Type of the entity.</param>
 /// <param name="filterControl">The filter control.</param>
 /// <param name="writer">The writer.</param>
 /// <param name="controls">The controls.</param>
 /// <param name="filterMode">The filter mode.</param>
 public virtual void RenderControls(Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls, FilterMode filterMode)
 {
     RenderControls(entityType, filterControl, writer, controls);
 }
Example #15
0
 /// <summary>
 /// Creates the model representation of the child controls used to display and edit the filter settings.
 /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
 /// </summary>
 /// <returns></returns>
 public virtual Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
 {
     return(CreateChildControls(entityType, filterControl));
 }
Example #16
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var controls = new Control[0];

            return(controls);
        }
Example #17
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the groupTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void groupTypePicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            FilterField filterField = (sender as Control).FirstParentControlOfType <FilterField>();

            PopulateGroupRolesCheckList(filterField);
        }
 public static Filter Create(FilterField field, FilterOperator @operator, FilterValue value)
 {
     return(new Filter(field, @operator, value));
 }
 public StringFilterOperation(FilterField filterField) : base(filterField)
 {
     filterField.Value = filterField.Value == null ?
                         string.Empty :
                         filterField.Value.ToString().ToUpper();
 }
Example #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaNull"/> class.
 /// </summary>
 /// <param name="filterField">The filter field</param>
 public SearchCriteriaNull(FilterField filterField)
 {
     FilterField = filterField;
 }
Example #21
0
 public static void RegisterJavascriptInclude(FilterField filterField)
 {
     // no longer needed since the required javascript is now bundled
 }
Example #22
0
 /// <summary>
 /// Renders the controls.
 /// </summary>
 /// <param name="entityType">Type of the entity.</param>
 /// <param name="filterControl">The filter control.</param>
 /// <param name="writer">The writer.</param>
 /// <param name="controls">The controls.</param>
 public override void RenderControls(Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls)
 {
     controls[0].RenderControl(writer);
     controls[1].RenderControl(writer);
     controls[2].RenderControl(writer);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaIn"/> class.
 /// </summary>
 /// <param name="filterField">The filter field</param>
 /// <param name="filterValues">The filter values</param>
 public SearchCriteriaIn(FilterField filterField, IEnumerable <object> filterValues)
 {
     FilterField    = filterField;
     FilterOperator = SearchConditionOperator.In;
     FilterValue    = filterValues;
 }
Example #24
0
        /// <summary>
        /// Handles the DeleteClick event of the filterControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void filterControl_DeleteClick(object sender, EventArgs e)
        {
            FilterField fieldControl = sender as FilterField;

            fieldControl.Parent.Controls.Remove(fieldControl);
        }
 public InvalidOperatorException(Operator op, FilterField field)
     : base($"{op} is not a valid Operator for {field.Title}")
 {
 }
Example #26
0
        /// <summary>
        /// Renders the entity fields controls.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="filterControl">The filter control.</param>
        /// <param name="writer">The writer.</param>
        /// <param name="entityFields">The entity fields.</param>
        /// <param name="ddlEntityField">The DDL entity field.</param>
        /// <param name="propertyControls">The property controls.</param>
        /// <param name="propertyControlsPrefix">The property controls prefix.</param>
        /// <param name="filterMode">The filter mode.</param>
        public void RenderEntityFieldsControls(Type entityType, FilterField filterControl, HtmlTextWriter writer, List <EntityField> entityFields,
                                               DropDownList ddlEntityField, List <Control> propertyControls, string propertyControlsPrefix, FilterMode filterMode)
        {
            string selectedEntityField = ddlEntityField.SelectedValue;

            writer.AddAttribute("class", "row");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            bool entityFieldPickerIsHidden = filterMode == FilterMode.SimpleFilter;

            if (entityFieldPickerIsHidden)
            {
                ddlEntityField.Style[HtmlTextWriterStyle.Display] = "none";
            }

            if (!entityFieldPickerIsHidden)
            {
                writer.AddAttribute("class", "col-md-3");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                ddlEntityField.AddCssClass("entity-property-selection");
                ddlEntityField.RenderControl(writer);
                writer.RenderEndTag();
            }
            else
            {
                // render it as hidden (we'll need the postback value)
                ddlEntityField.RenderControl(writer);
            }

            writer.AddAttribute("class", entityFieldPickerIsHidden ? "col-md-12" : "col-md-9");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (entityFieldPickerIsHidden && ddlEntityField.SelectedItem != null)
            {
                var filterLabel = filterControl.Label ?? ddlEntityField.SelectedItem.Text;
                if (filterControl.ShowCheckbox)
                {
                    // special case when a filter is a entity field filter: render the checkbox here instead of in FilterField.cs
                    filterControl.cbIncludeFilter.Text = filterLabel;
                    filterControl.cbIncludeFilter.RenderControl(writer);
                }
            }

            // generate result for "none"
            StringBuilder sb         = new StringBuilder();
            string        lineFormat = @"
            case '{0}': {1}; break;";

            int fieldIndex = 0;

            sb.AppendFormat(lineFormat, fieldIndex, "result = ''");
            fieldIndex++;

            // render empty row for "none"
            writer.AddAttribute("class", "row form-row field-criteria");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.RenderEndTag();  // "row form-row field-criteria"

            // render the controls for the selectedEntityField
            string controlId = string.Format("{0}_{1}", propertyControlsPrefix, selectedEntityField);
            var    control   = propertyControls.FirstOrDefault(c => c.ID == controlId);

            if (control != null)
            {
                if (control is IAttributeAccessor)
                {
                    (control as IAttributeAccessor).SetAttribute("data-entity-field-name", selectedEntityField);
                }

                control.RenderControl(writer);
            }

            // create a javascript block for all the possible entityFields which will get rendered once per entityType
            foreach (var entityField in entityFields)
            {
                string clientFormatSelection = entityField.FieldType.Field.GetFilterFormatScript(entityField.FieldConfig, entityField.TitleWithoutQualifier);

                if (clientFormatSelection != string.Empty)
                {
                    sb.AppendFormat(lineFormat, entityField.UniqueName, clientFormatSelection);
                }

                fieldIndex++;
            }

            writer.RenderEndTag();  // col-md-9 or col-md-12

            writer.RenderEndTag();  // "row"

            string scriptFormat = @"
    function {0}PropertySelection($content){{
        var selectedFieldName = $('select.entity-property-selection', $content).find(':selected').val();
        if (!selectedFieldName || selectedFieldName == '') {{
            selectedFieldName = '0'
        }}
        var $selectedContent = $('[data-entity-field-name=' + selectedFieldName + ']', $content)
        var result = '';
        switch(selectedFieldName) {{
            {1}
        }}
        return result;
    }}
";

            string script = string.Format(scriptFormat, entityType.Name, sb.ToString());

            ScriptManager.RegisterStartupScript(filterControl, typeof(FilterField), entityType.Name + "-property-selection", script, true);
        }
Example #27
0
 public void RemoveFilter(FilterField field, string filter)
 {
     try
     {
         Hashtable ht = _filterFields[field.ToString()] as Hashtable;
         if (ht != null)
         {
             if (ht[filter]!=null)
             {
                 ht.Remove(filter);
                 using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFile))
                 {
                     dbcon.ExecuteNonQuery(string.Format("delete from filterfields where field = '{0}' and filter = '{1}'", field.ToString(), filter.Replace("'", "''")));
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #28
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            // Create the field selection dropdown
            var ddlEntityField = new RockDropDownList();

            ddlEntityField.ID           = string.Format("{0}_ddlProperty", filterControl.ID);
            ddlEntityField.ClientIDMode = ClientIDMode.Predictable;

            var entityTypeCache = EntityTypeCache.Get(entityType, true);

            ddlEntityField.Attributes["EntityTypeId"] = entityTypeCache?.Id.ToString();

            containerControl.Controls.Add(ddlEntityField);

            // add Empty option first
            ddlEntityField.Items.Add(new ListItem());
            var rockBlock = filterControl.RockBlock();


            var entityFields = EntityHelper.GetEntityFields(entityType);

            foreach (var entityField in entityFields.OrderBy(a => !a.IsPreviewable).ThenBy(a => a.FieldKind != FieldKind.Property).ThenBy(a => a.Title))
            {
                bool isAuthorized = true;
                bool includeField = true;
                if (entityField.FieldKind == FieldKind.Attribute && entityField.AttributeGuid.HasValue)
                {
                    if (entityType == typeof(Rock.Model.Workflow) && !string.IsNullOrWhiteSpace(entityField.AttributeEntityTypeQualifierName))
                    {
                        // Workflows can contain tons of Qualified Attributes, so let the WorkflowAttributeFilter take care of those
                        includeField = false;
                    }

                    var attribute = AttributeCache.Get(entityField.AttributeGuid.Value);

                    // Don't include the attribute if it isn't active
                    if (attribute.IsActive == false)
                    {
                        includeField = false;
                    }

                    if (includeField && attribute != null && rockBlock != null)
                    {
                        // only show the Attribute field in the drop down if they have VIEW Auth to it
                        isAuthorized = attribute.IsAuthorized(Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson);
                    }
                }

                if (isAuthorized && includeField)
                {
                    var listItem = new ListItem(entityField.Title, entityField.UniqueName);

                    if (entityField.IsPreviewable)
                    {
                        listItem.Attributes["optiongroup"] = "Common";
                    }
                    else if (entityField.FieldKind == FieldKind.Attribute)
                    {
                        listItem.Attributes["optiongroup"] = string.Format("{0} Attributes", entityType.Name);
                    }
                    else
                    {
                        listItem.Attributes["optiongroup"] = string.Format("{0} Fields", entityType.Name);
                    }

                    ddlEntityField.Items.Add(listItem);
                }
            }

            ddlEntityField.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlEntityField.Page.Request.Params[ddlEntityField.UniqueID];

            if (selectedValue != null)
            {
                ddlEntityField.SelectedValue = selectedValue;
                ddlEntityField_SelectedIndexChanged(ddlEntityField, new EventArgs());
            }

            ddlEntityField.SelectedIndexChanged += ddlEntityField_SelectedIndexChanged;

            return(new Control[] { containerControl });
        }
Example #29
0
 /// <summary>
 /// Registers the javascript include needed for reporting client controls
 /// </summary>
 /// <param name="filterField">The filter field.</param>
 public static void RegisterJavascriptInclude(FilterField filterField)
 {
     ScriptManager.RegisterClientScriptInclude(filterField, filterField.GetType(), "reporting-include", filterField.RockBlock().RockPage.ResolveRockUrl("~/Scripts/Rock/reportingInclude.js", true));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaLessEqual"/> class.
 /// </summary>
 /// <param name="filterField">The filter field</param>
 /// <param name="filterValue">The filter value</param>
 public SearchCriteriaLessEqual(FilterField filterField, object filterValue)
 {
     FilterField    = filterField;
     FilterOperator = SearchConditionOperator.LessEqual;
     FilterValue    = filterValue;
 }
Example #31
0
 public void AddFilter(FilterField field, string filter)
 {
     try
     {
         Hashtable ht = _filterFields[field.ToString()] as Hashtable;
         if (ht != null)
         {
             if (ht[filter]==null)
             {
                 ht.Add(filter, true);
                 lock (_core.SettingsProvider)
                 {
                     _core.SettingsProvider.Database.Execute(string.Format("insert into {2} (field, filter) values ('{0}', '{1}')", field.ToString(), filter.Replace("'", "''"), _core.SettingsProvider.GetFullTableName("filterfields")));
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #32
0
        private static void SeedIndex(ElasticClient client)
        {
            var faker = new Faker <PersonDocument>();

            faker
            .RuleFor(r => r.Id, f => Guid.NewGuid().ToString())
            .RuleFor(r => r.Name, f => $"{f.Person.FirstName} {f.Person.LastName}")
            .RuleFor(r => r.Age, f => f.Random.Number(16, 65))
            .RuleFor(r => r.Country, f => FilterField.Create(f.Address.Country(), f.Address.CountryCode().ToLowerInvariant()))
            .RuleFor(r => r.Tags, f => f.Commerce.Categories(5).Select(FilterField.Create))
            .RuleFor(r => r.Location, f => GeoLocation.TryCreate(f.Address.Latitude(), f.Address.Longitude()))
            ;
            var list = faker.Generate(100).ToList();

            list.Add(new PersonDocument {
                Id = Guid.NewGuid().ToString(), Name = "Phil Oyston", Age = 20, Country = FilterField.Create("United Kingdom", "uk"), Tags = new[] { FilterField.Create("Baby") }, Location = GeoLocation.TryCreate(55.9532, -3.1882)
            });
            list.Add(new PersonDocument {
                Id = Guid.NewGuid().ToString(), Name = "John Doe", Age = 30, Country = FilterField.Create("United Kingdom", "uk"), Tags = new[] { FilterField.Create("Grocery") }, Location = GeoLocation.TryCreate(55.9, -3.1)
            });
            list.Add(new PersonDocument {
                Id = Guid.NewGuid().ToString(), Name = "John Smith", Age = 40, Country = FilterField.Create("United Kingdom", "uk"), Tags = new[] { FilterField.Create("Baby"), FilterField.Create("Grocery") }, Location = GeoLocation.TryCreate(55.9, -3.1)
            });

            client.Bulk(b => b.IndexMany(list).Refresh(Refresh.True));
        }
Example #33
0
 public void RemoveFilter(FilterField field, string filter)
 {
     try
     {
         Hashtable ht = _filterFields[field.ToString()] as Hashtable;
         if (ht != null)
         {
             if (ht[filter]!=null)
             {
                 ht.Remove(filter);
                 lock (_core.SettingsProvider)
                 {
                     _core.SettingsProvider.Database.Execute(string.Format("delete from {2} where field = '{0}' and filter = '{1}'", field.ToString(), filter.Replace("'", "''"), _core.SettingsProvider.GetFullTableName("filterfields")));
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaNull"/> class.
 /// </summary>
 /// <param name="filterField">The filter field.</param>
 public SearchCriteriaNull(FilterField filterField)
     : base(filterField, SearchConditionOperator.Null, null)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaBetween"/> class.
 /// </summary>
 /// <param name="filterField">The filter field.</param>
 /// <param name="lowerValue">The lower value.</param>
 /// <param name="upperValue">The upper value.</param>
 public SearchCriteriaBetween(FilterField filterField, object lowerValue, object upperValue)
     : base(filterField, SearchConditionOperator.Between, lowerValue)
 {
     UpperValue = upperValue;
 }
Example #36
0
 /// <summary>
 /// Renders the controls.
 /// </summary>
 /// <param name="entityType">Type of the entity.</param>
 /// <param name="filterControl">The filter control.</param>
 /// <param name="writer">The writer.</param>
 /// <param name="controls">The controls.</param>
 public override void RenderControls(Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls)
 {
     base.RenderControls(entityType, filterControl, writer, controls);
 }
Example #37
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var dataContext = new RockContext();

            // Step Program selection
            var stepProgramPicker = new SingleEntityPicker <StepProgram>();

            stepProgramPicker.ID = filterControl.ID + "_StepProgramPicker";
            stepProgramPicker.AddCssClass("js-step-program-picker");
            stepProgramPicker.Label    = "Step Program";
            stepProgramPicker.Help     = "The Program in which the Step was undertaken.";
            stepProgramPicker.Required = true;

            stepProgramPicker.SelectedIndexChanged += StepProgramPicker_SelectedIndexChanged;
            stepProgramPicker.AutoPostBack          = true;

            var programService = new StepProgramService(dataContext);

            var availablePrograms = programService.Queryable()
                                    .Where(x => x.IsActive)
                                    .OrderBy(a => a.Order)
                                    .ThenBy(a => a.Name)
                                    .ToList();

            stepProgramPicker.InitializeListItems(availablePrograms, x => x.Name, allowEmptySelection: true);


            filterControl.Controls.Add(stepProgramPicker);

            // Step Type selection
            var cblStepType = new RockCheckBoxList();

            cblStepType.ID = filterControl.ID + "_cblStepType";
            cblStepType.AddCssClass("js-step-type");
            cblStepType.Label = "Steps";
            cblStepType.Help  = "If selected, specifies the required Steps that have been undertaken.";

            filterControl.Controls.Add(cblStepType);

            // Step Status selection
            var cblStepStatus = new RockCheckBoxList();

            cblStepStatus.ID = filterControl.ID + "_cblStepStatus";
            cblStepStatus.AddCssClass("js-step-status");
            cblStepStatus.Label = "Statuses";
            cblStepStatus.Help  = "If selected, specifies the required Statuses of the Steps.";

            filterControl.Controls.Add(cblStepStatus);

            // Date Started
            var drpStarted = new SlidingDateRangePicker();

            drpStarted.ID = filterControl.ID + "_drpDateStarted";
            drpStarted.AddCssClass("js-date-started");
            drpStarted.Label = "Date Started";
            drpStarted.Help  = "The date range within which the Step was started";

            filterControl.Controls.Add(drpStarted);

            // Date Completed
            var drpCompleted = new SlidingDateRangePicker();

            drpCompleted.ID = filterControl.ID + "_drpDateCompleted";
            drpCompleted.AddCssClass("js-date-completed");
            drpCompleted.Label = "Date Completed";
            drpCompleted.Help  = "The date range within which the Step was completed";

            filterControl.Controls.Add(drpCompleted);

            // Step Campus selection
            var cblStepCampus = new RockCheckBoxList();

            cblStepCampus.ID = filterControl.ID + "_cblStepCampus";
            cblStepCampus.AddCssClass("js-step-campus");
            cblStepCampus.Label = "Campuses";
            cblStepCampus.Help  = "Select the campuses that the steps were completed at. Not selecting a value will select all campuses.";

            filterControl.Controls.Add(cblStepCampus);

            // Populate lists
            PopulateStepProgramRelatedSelectionLists(filterControl);
            PopulateStepCampuses(cblStepCampus);

            return(new Control[] { stepProgramPicker, cblStepType, cblStepStatus, drpStarted, drpCompleted, cblStepCampus });
        }
Example #38
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the StepProgramPicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void StepProgramPicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            FilterField filterField = (sender as Control).FirstParentControlOfType <FilterField>();

            PopulateStepProgramRelatedSelectionLists(filterField);
        }
 	public disposizione(string pn, string fn) : base(pn, fn) 
 	{
 		_abbreviata = new FilterField<string>(GetFullFieldName(), "abbreviata");
 		_abbreviatissima = new FilterField<string>(GetFullFieldName(), "abbreviatissima");
 		_estesa = new FilterField<string>(GetFullFieldName(), "estesa");
 	}