Skip to content

Commit c1b583c

Browse files
committed
Support M3
camelCase auto filter field
1 parent 1414615 commit c1b583c

File tree

8 files changed

+80
-127
lines changed

8 files changed

+80
-127
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("1.0.11.0")]
19-
[assembly: AssemblyFileVersion("1.0.11.0")]
18+
[assembly: AssemblyVersion("1.0.12.0")]
19+
[assembly: AssemblyFileVersion("1.0.12.0")]

Griddly.Mvc/Griddly.Mvc.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
<Reference Include="System.Xml" />
8686
</ItemGroup>
8787
<ItemGroup>
88+
<Compile Include="..\Build\CommonAssemblyInfo.cs">
89+
<Link>Properties\CommonAssemblyInfo.cs</Link>
90+
</Compile>
8891
<Compile Include="DapperGriddlyResult.cs" />
8992
<Compile Include="GriddlyFilterExtensions.cs" />
9093
<Compile Include="InternalExtensions.cs" />

Griddly.Mvc/GriddlyFilterExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static GriddlyFilterBox FilterBox(this GriddlyColumn column, FilterDataTy
1313
name = column.Caption;
1414

1515
if (field == null && column.SortField != null && !column.SortField.Contains("."))
16-
field = column.SortField;
16+
field = column.SortField.Substring(0, 1).ToLower() + column.SortField.Substring(1);
1717

1818
if (string.IsNullOrWhiteSpace(name))
1919
throw new ArgumentNullException("name", "Name must be specified.");
@@ -36,8 +36,8 @@ public static GriddlyFilterRange FilterRange(this GriddlyColumn column, FilterDa
3636

3737
if (field == null && column.SortField != null && !column.SortField.Contains("."))
3838
{
39-
field = column.SortField + "Start";
40-
fieldEnd = column.SortField + "End";
39+
field = column.SortField.Substring(0, 1).ToLower() + column.SortField.Substring(1) + "Start";
40+
fieldEnd = column.SortField.Substring(0, 1).ToLower() + column.SortField.Substring(1) + "End";
4141
}
4242

4343
if (string.IsNullOrWhiteSpace(name))
@@ -64,7 +64,7 @@ public static GriddlyFilterList FilterList(this GriddlyColumn column, IEnumerabl
6464
name = column.Caption;
6565

6666
if (field == null && column.SortField != null && !column.SortField.Contains("."))
67-
field = column.SortField;
67+
field = column.SortField.Substring(0, 1).ToLower() + column.SortField.Substring(1);
6868

6969
if (string.IsNullOrWhiteSpace(name))
7070
throw new ArgumentNullException("name", "Name must be specified.");
Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.InteropServices;
32

4-
// General Information about an assembly is controlled through the following
5-
// set of attributes. Change these attribute values to modify the information
6-
// associated with an assembly.
73
[assembly: AssemblyTitle("Griddly.Mvc")]
8-
[assembly: AssemblyDescription("")]
9-
[assembly: AssemblyConfiguration("")]
10-
[assembly: AssemblyCompany("")]
11-
[assembly: AssemblyProduct("Griddly.Mvc")]
12-
[assembly: AssemblyCopyright("Copyright © 2013")]
13-
[assembly: AssemblyTrademark("")]
14-
[assembly: AssemblyCulture("")]
15-
16-
// Setting ComVisible to false makes the types in this assembly not visible
17-
// to COM components. If you need to access a type in this assembly from
18-
// COM, set the ComVisible attribute to true on that type.
19-
[assembly: ComVisible(false)]
20-
21-
// The following GUID is for the ID of the typelib if this project is exposed to COM
22-
[assembly: Guid("cf2df3eb-121e-43fd-bffa-50ef31bee12c")]
23-
24-
// Version information for an assembly consists of the following four values:
25-
//
26-
// Major Version
27-
// Minor Version
28-
// Build Number
29-
// Revision
30-
//
31-
// You can specify all the values or you can default the Build and Revision Numbers
32-
// by using the '*' as shown below:
33-
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.9.0")]
35-
[assembly: AssemblyFileVersion("1.0.9.0")]
4+
[assembly: AssemblyDescription("")]

Griddly.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{5CC20399-D191-4DD0-8BBA-30BAE95D4356}"
1111
ProjectSection(SolutionItems) = preProject
1212
Build\build.proj = Build\build.proj
13+
Build\CommonAssemblyInfo.cs = Build\CommonAssemblyInfo.cs
1314
Build\Griddly.Core.nuspec = Build\Griddly.Core.nuspec
1415
Build\Griddly.nuspec = Build\Griddly.nuspec
1516
Build\publish-nuget.ps1 = Build\publish-nuget.ps1

Griddly/Griddly.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
<Folder Include="App_Data\" />
118118
</ItemGroup>
119119
<ItemGroup>
120+
<Compile Include="..\Build\CommonAssemblyInfo.cs">
121+
<Link>Properties\CommonAssemblyInfo.cs</Link>
122+
</Compile>
120123
<Compile Include="App_Start\BundleConfig.cs" />
121124
<Compile Include="App_Start\FilterConfig.cs" />
122125
<Compile Include="App_Start\RouteConfig.cs" />

Griddly/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.InteropServices;
32

4-
// General Information about an assembly is controlled through the following
5-
// set of attributes. Change these attribute values to modify the information
6-
// associated with an assembly.
73
[assembly: AssemblyTitle("Griddly")]
8-
[assembly: AssemblyDescription("")]
9-
[assembly: AssemblyConfiguration("")]
10-
[assembly: AssemblyCompany("")]
11-
[assembly: AssemblyProduct("Griddly")]
12-
[assembly: AssemblyCopyright("Copyright © 2013")]
13-
[assembly: AssemblyTrademark("")]
14-
[assembly: AssemblyCulture("")]
15-
16-
// Setting ComVisible to false makes the types in this assembly not visible
17-
// to COM components. If you need to access a type in this assembly from
18-
// COM, set the ComVisible attribute to true on that type.
19-
[assembly: ComVisible(false)]
20-
21-
// The following GUID is for the ID of the typelib if this project is exposed to COM
22-
[assembly: Guid("abe24a70-0327-415b-b467-07e9ba41cd8b")]
23-
24-
// Version information for an assembly consists of the following four values:
25-
//
26-
// Major Version
27-
// Minor Version
28-
// Build Number
29-
// Revision
30-
//
31-
// You can specify all the values or you can default the Revision and Build Numbers
32-
// by using the '*' as shown below:
33-
[assembly: AssemblyVersion("1.0.9.0")]
34-
[assembly: AssemblyFileVersion("1.0.9.0")]
4+
[assembly: AssemblyDescription("")]

Griddly/Scripts/griddly.js

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,9 @@
490490
return str;
491491
}
492492

493-
this.$inlineFilters = $(".griddly-filters-inline input, .griddly-filters-inline select", this.$element);
493+
this.$inlineFilters = $(".griddly-filters-inline .filter-content input", this.$element);
494494

495-
$(".griddly-filters-inline input, .griddly-filters-inline select", this.$element).on("change", $.proxy(function (event)
495+
$(".griddly-filters-inline .filter-content input", this.$element).on("change", $.proxy(function (event)
496496
{
497497
var filter = $(event.currentTarget).data("griddly-filter");
498498
var content = filter.data("griddly-filter-content");
@@ -501,75 +501,82 @@
501501
var dataType = filter.data("filter-datatype");
502502
var display = null;
503503

504-
// ignore unselect change events on single selection lists
505-
//if (!filter.hasClass("griddly-filter-list") || filter.data("griddly-filter-ismultiple") || $(event.currentTarget).prop("checked"))
506-
//{
507-
if (filter.hasClass("griddly-filter-box"))
508-
{
509-
filter.find(".filter-trigger").popover("hide");
504+
if (filter.hasClass("griddly-filter-box"))
505+
{
506+
filter.find(".filter-trigger").popover("hide");
510507

511-
var val = trimToNull(content.find("input").first().val());
508+
var val = trimToNull(content.find("input").first().val());
512509

513-
if (val != null)
514-
{
515-
if (dataType == "String")
516-
display = 'Contains "' + getFormattedValue(val, dataType) + '"';
517-
else
518-
display = getFormattedValue(val, dataType);
519-
}
510+
if (val != null)
511+
{
512+
if (dataType == "String")
513+
display = 'Contains "' + getFormattedValue(val, dataType) + '"';
520514
else
521-
{
522-
display = "Any " + filter.data("filter-name");
523-
524-
content.find("input").first().val("");
525-
}
515+
display = getFormattedValue(val, dataType);
526516
}
527-
else if (filter.hasClass("griddly-filter-range"))
517+
else
528518
{
529-
var val = trimToNull(content.find("input").first().val());
530-
var valEnd = trimToNull(content.find("input").last().val());
531-
532-
if (val != null && valEnd != null)
533-
display = getFormattedValue(val, dataType) + " - " + getFormattedValue(valEnd, dataType);
534-
else if (val != null)
535-
display = (dataType == "Date" ? "After " : ">= ") + getFormattedValue(val, dataType);
536-
else if (valEnd != null)
537-
display = (dataType == "Date" ? "Before " : "<= ") + getFormattedValue(valEnd, dataType);
538-
else
539-
{
540-
display = "All " + filter.data("filter-name-plural");
519+
display = "Any " + filter.data("filter-name");
541520

542-
content.find("input").first().val("");
543-
content.find("input").last().val("");
544-
}
521+
content.find("input").first().val("");
545522
}
546-
else if (filter.hasClass("griddly-filter-list"))
523+
}
524+
else if (filter.hasClass("griddly-filter-range"))
525+
{
526+
var val = trimToNull(content.find("input").first().val());
527+
var valEnd = trimToNull(content.find("input").last().val());
528+
529+
if (val != null && valEnd != null)
530+
display = getFormattedValue(val, dataType) + " - " + getFormattedValue(valEnd, dataType);
531+
else if (val != null)
532+
display = (dataType == "Date" ? "After " : ">= ") + getFormattedValue(val, dataType);
533+
else if (valEnd != null)
534+
display = (dataType == "Date" ? "Before " : "<= ") + getFormattedValue(valEnd, dataType);
535+
else
547536
{
548-
var allItems = content.find("li");
549-
var selectedItems = allItems.filter(".griddly-filter-selected");
550-
551-
if (selectedItems.length == allItems.length || (selectedItems.length == 0 && filter.data("griddly-filter-isnoneall")))
552-
display = (allItems.length == 2 ? "Both " : "All ") + filter.data("filter-name-plural");
553-
else if (selectedItems.length > 1)
554-
display = selectedItems.length + " " + filter.data("filter-name-plural");
555-
else if (selectedItems.length == 1)
556-
display = selectedItems.find("a").text();
557-
else
558-
display = "No " + filter.data("filter-name-plural");
537+
display = "All " + filter.data("filter-name-plural");
538+
539+
content.find("input").first().val("");
540+
content.find("input").last().val("");
559541
}
542+
}
543+
else if (filter.hasClass("griddly-filter-list"))
544+
{
545+
var allItems = content.find("li");
546+
var selectedItems = allItems.filter(".griddly-filter-selected");
547+
548+
if (selectedItems.length == allItems.length || (selectedItems.length == 0 && filter.data("griddly-filter-isnoneall")))
549+
display = (allItems.length == 2 ? "Both " : "All ") + filter.data("filter-name-plural");
550+
else if (selectedItems.length > 1)
551+
display = selectedItems.length + " " + filter.data("filter-name-plural");
552+
else if (selectedItems.length == 1)
553+
display = selectedItems.find("a").text();
554+
else
555+
display = "No " + filter.data("filter-name-plural");
556+
}
560557

561-
if (display)
562-
displayEl.text(display);
558+
if (display)
559+
displayEl.text(display);
563560

564-
this.refresh(true);
565-
//}
561+
// TODO: remove below once M3 compat fixed
562+
// this.refresh(true);
563+
}, this));
564+
565+
$(".griddly-filters-inline input, .griddly-filters-inline select", this.$element).on("change", $.proxy(function (event)
566+
{
567+
this.refresh(true);
566568
}, this));
567569

568-
$(".griddly-filters-inline input", this.$element).keyup(function (event)
570+
$(".griddly-filters-inline .filter-content input", this.$element).keyup(function (event)
569571
{
570-
// TODO: instead, fire blur and hide the popover so we don't get double change events
571572
if (event.which == 13)
572-
$(this).change();
573+
{
574+
$(this).blur();
575+
576+
var filter = $(this).data("griddly-filter");
577+
578+
filter.find(".filter-trigger").popover("hide");
579+
}
573580
});
574581

575582
$(".griddly-filters-inline .filter-trigger", this.$element).each($.proxy(function (i, el)
@@ -608,7 +615,7 @@
608615
});
609616
}, this));
610617

611-
$(".griddly-filters-inline .dropdown-menu", this.$element).each($.proxy(function (i, el)
618+
$(".griddly-filters-inline .filter-content .dropdown-menu", this.$element).each($.proxy(function (i, el)
612619
{
613620
var self = this;
614621

@@ -681,7 +688,7 @@
681688

682689
buildRequest: function(paging)
683690
{
684-
var filters = $(".griddly-filters input[type=text], .griddly-filters input[type=hidden], .griddly-filters select", this.$element);
691+
var filters = $(".griddly-filters input, .griddly-filters select", this.$element);
685692

686693
filters = filters.add(this.$inlineFilters);
687694

0 commit comments

Comments
 (0)