|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Collections.Specialized; |
| 4 | +using System.Linq; |
| 5 | +using System.Linq.Expressions; |
| 6 | +using System.Web; |
| 7 | +using System.Web.Helpers; |
| 8 | +using System.Web.Mvc; |
| 9 | +using System.Web.Routing; |
| 10 | + |
| 11 | +namespace Griddly.Mvc |
| 12 | +{ |
| 13 | + public class GriddlyFilterBarSettings |
| 14 | + { |
| 15 | + public GriddlyFilterBarSettings() |
| 16 | + { |
| 17 | + Filters = new List<GriddlyFilter>(); |
| 18 | + } |
| 19 | + |
| 20 | + public List<GriddlyFilter> Filters { get; set; } |
| 21 | + |
| 22 | + public GriddlyFilterBarSettings FilterBox(string field, string caption, FilterDataType dataType = FilterDataType.Decimal, string htmlClass = null, string captionPlural = null) |
| 23 | + { |
| 24 | + return Add(GriddlyFilterExtensions.FilterBox(null, dataType, field, caption, htmlClass, captionPlural)); |
| 25 | + } |
| 26 | + |
| 27 | + public GriddlyFilterBarSettings FilterRange(string field, string fieldEnd, string caption, FilterDataType dataType = FilterDataType.Decimal, string htmlClass = null, string captionPlural = null) |
| 28 | + { |
| 29 | + return Add(GriddlyFilterExtensions.FilterRange(null, dataType, field, fieldEnd, caption, htmlClass, captionPlural)); |
| 30 | + } |
| 31 | + |
| 32 | + public GriddlyFilterBarSettings FilterList(string field, string caption, IEnumerable<SelectListItem> items, bool isMultiple = true, bool defaultSelectAll = false, string nullItemText = null, bool isNoneAll = true, string htmlClass = null, string captionPlural = null, bool displayIncludeCaption = false) |
| 33 | + { |
| 34 | + return Add(GriddlyFilterExtensions.FilterList(null, items, isMultiple, defaultSelectAll, nullItemText, isNoneAll, field, caption, htmlClass, captionPlural, displayIncludeCaption)); |
| 35 | + } |
| 36 | + |
| 37 | + public GriddlyFilterBarSettings FilterEnum<T>(string field, string caption, bool isMultiple = true, bool defaultSelectAll = false, string nullItemText = null, bool isNoneAll = true, string htmlClass = null, string captionPlural = null, bool displayIncludeCaption = false) |
| 38 | + where T : struct |
| 39 | + { |
| 40 | + return Add(GriddlyFilterExtensions.FilterEnum<T>(null, isMultiple, defaultSelectAll, nullItemText, isNoneAll, field, caption, htmlClass, captionPlural, displayIncludeCaption)); |
| 41 | + } |
| 42 | + |
| 43 | + public GriddlyFilterBarSettings FilterEnum<T>(string field, string caption, IEnumerable<T> items, bool isMultiple = true, bool defaultSelectAll = false, string nullItemText = null, bool isNoneAll = true, string htmlClass = null, string captionPlural = null, bool displayIncludeCaption = false) |
| 44 | + where T : struct |
| 45 | + { |
| 46 | + return Add(GriddlyFilterExtensions.FilterEnum<T>(null, items, isMultiple, defaultSelectAll, nullItemText, isNoneAll, field, caption, htmlClass, captionPlural, displayIncludeCaption)); |
| 47 | + } |
| 48 | + |
| 49 | + public GriddlyFilterBarSettings FilterBool(string field, string caption, string trueLabel = "Yes", string falseLabel = "No", string nullItemText = null, bool isMultiple = false, bool defaultSelectAll = false, bool isNoneAll = false, string htmlClass = null, string captionPlural = null, bool displayIncludeCaption = true) |
| 50 | + { |
| 51 | + return Add(GriddlyFilterExtensions.FilterBool(null, trueLabel, falseLabel, nullItemText, isMultiple, defaultSelectAll, isNoneAll, field, caption, htmlClass, captionPlural, displayIncludeCaption)); |
| 52 | + } |
| 53 | + |
| 54 | + public GriddlyFilterBarSettings Add(GriddlyFilter filter) |
| 55 | + { |
| 56 | + Filters.Add(filter); |
| 57 | + |
| 58 | + return this; |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments