table_sortable 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/.rakeTasks +1 -1
- data/.idea/table_sortable.iml +44 -8
- data/README.md +48 -23
- data/lib/table_sortable/column/filter.rb +18 -3
- data/lib/table_sortable/column/sorter.rb +18 -4
- data/lib/table_sortable/column.rb +2 -2
- data/lib/table_sortable/columns.rb +5 -9
- data/lib/table_sortable/concerns/proc.rb +25 -7
- data/lib/table_sortable/controller.rb +18 -32
- data/lib/table_sortable/process.rb +5 -0
- data/lib/table_sortable/query_params.rb +17 -0
- data/lib/table_sortable/version.rb +1 -1
- data/lib/table_sortable.rb +4 -1
- data/spec/concerns/proc_class_spec.rb +4 -1
- data/spec/lib/table_sortable/concerns/proc_spec.rb +9 -5
- data/spec/lib/table_sortable/controller_spec.rb +45 -20
- data/spec/lib/table_sortable/process_spec.rb +7 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/support/factories/user.rb +7 -0
- data/spec/support/factory_girl.rb +4 -0
- data/spec/support/models/user.rb +1 -0
- data/table_sortable.gemspec +3 -1
- metadata +41 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a484255d4071117e14633714581e5392da418bd
|
4
|
+
data.tar.gz: 063b9bcd1e5dab7c85b8473f06d9b9349351df36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff13059ff3aa2f36bed53861db9ce00eef623b90a7fc18a233c4523cba19a724ed5b3fc803fcf5687d4ddc2476f5c8356b7af10ceb42d1438a045aed7db177d
|
7
|
+
data.tar.gz: 847dabaa7a749389d95c0a945e2de623d974732ddcc2a357f0d1ecf7f47f9bba9faf1590fec9121b29208aa02bee1b88f9ef53944b0eefc605711eea92b88554
|
data/.idea/.rakeTasks
CHANGED
@@ -4,4 +4,4 @@ You are allowed to:
|
|
4
4
|
1. Remove rake task
|
5
5
|
2. Add existing rake tasks
|
6
6
|
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
-
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build table_sortable-0.1.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build table_sortable-0.1.8.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install table_sortable-0.1.8.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install table_sortable-0.1.8.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.8 and build and push table_sortable-0.1.8.gem to Rubygems" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run tests" fullCmd="test" taksId="test" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
data/.idea/table_sortable.iml
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
35
35
|
<method />
|
36
36
|
</configuration>
|
37
|
-
<configuration default="false" name="Run spec '
|
37
|
+
<configuration default="false" name="Run spec 'proc_spec': table_sortable" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
38
38
|
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
39
39
|
<module name="table_sortable" />
|
40
40
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
@@ -53,7 +53,7 @@
|
|
53
53
|
</COVERAGE_PATTERN>
|
54
54
|
</EXTENSION>
|
55
55
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
56
|
-
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/
|
56
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/lib/table_sortable/concerns/proc_spec.rb" />
|
57
57
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
58
58
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
59
59
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
@@ -67,7 +67,7 @@
|
|
67
67
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
68
68
|
<method />
|
69
69
|
</configuration>
|
70
|
-
<configuration default="false" name="Run spec '
|
70
|
+
<configuration default="false" name="Run spec 'filter_spec': table_sortable" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
71
71
|
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
72
72
|
<module name="table_sortable" />
|
73
73
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
@@ -86,7 +86,7 @@
|
|
86
86
|
</COVERAGE_PATTERN>
|
87
87
|
</EXTENSION>
|
88
88
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
89
|
-
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/lib/table_sortable/
|
89
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/lib/table_sortable/column/filter_spec.rb" />
|
90
90
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
91
91
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
92
92
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
@@ -100,7 +100,7 @@
|
|
100
100
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
101
101
|
<method />
|
102
102
|
</configuration>
|
103
|
-
<configuration default="false" name="
|
103
|
+
<configuration default="false" name="TableSortable::Controller filter_and_sort filters using a single filter: table_sortable" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
104
104
|
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
105
105
|
<module name="table_sortable" />
|
106
106
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
@@ -118,11 +118,44 @@
|
|
118
118
|
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
119
119
|
</COVERAGE_PATTERN>
|
120
120
|
</EXTENSION>
|
121
|
-
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
122
|
-
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/lib/table_sortable/
|
121
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$/spec" />
|
122
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/lib/table_sortable/controller_spec.rb" />
|
123
123
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
124
124
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
125
|
-
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
125
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="TableSortable::Controller filter_and_sort filters using a single filter" />
|
126
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
127
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
128
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
129
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
130
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
131
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
132
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
133
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
134
|
+
<method />
|
135
|
+
</configuration>
|
136
|
+
<configuration default="false" name="TableSortable::Controller filter_and_sort sorts a record set based on the column to sort: table_sortable" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
137
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
138
|
+
<module name="table_sortable" />
|
139
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
140
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
141
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
142
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
143
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
144
|
+
<envs>
|
145
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
146
|
+
</envs>
|
147
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
148
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
149
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
150
|
+
<COVERAGE_PATTERN ENABLED="true">
|
151
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
152
|
+
</COVERAGE_PATTERN>
|
153
|
+
</EXTENSION>
|
154
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$/spec" />
|
155
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/lib/table_sortable/controller_spec.rb" />
|
156
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
157
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
158
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="TableSortable::Controller filter_and_sort sorts a record set based on the column to sort" />
|
126
159
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
127
160
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
128
161
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
@@ -155,6 +188,8 @@
|
|
155
188
|
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.0.5, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
156
189
|
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
157
190
|
<orderEntry type="library" scope="PROVIDED" name="erubi (v1.6.0, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
191
|
+
<orderEntry type="library" scope="PROVIDED" name="factory_girl (v4.8.0, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
192
|
+
<orderEntry type="library" scope="PROVIDED" name="factory_girl_rails (v4.8.0, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
158
193
|
<orderEntry type="library" scope="PROVIDED" name="globalid (v0.4.0, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
159
194
|
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.8.1, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
160
195
|
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.0.3, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
@@ -180,6 +215,7 @@
|
|
180
215
|
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.6.0, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
181
216
|
<orderEntry type="library" scope="PROVIDED" name="sprockets (v3.7.1, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
182
217
|
<orderEntry type="library" scope="PROVIDED" name="sprockets-rails (v3.2.0, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
218
|
+
<orderEntry type="library" scope="PROVIDED" name="sqlite3 (v1.3.13, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
183
219
|
<orderEntry type="library" scope="PROVIDED" name="thor (v0.19.4, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
184
220
|
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
185
221
|
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.3, RVM: ruby-2.4.1 [tablesortable]) [gem]" level="application" />
|
data/README.md
CHANGED
@@ -2,17 +2,21 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/odedd/table_sortable.svg?branch=master)](https://travis-ci.org/odedd/table_sortable)
|
4
4
|
|
5
|
-
TableSortable
|
5
|
+
TableSortable adds multi-column, **server-side** filtering, sorting and pagination
|
6
|
+
to the **tableSorter jQuery plugin**, so you don't have to worry about interpreting the query parameters,
|
7
|
+
combining multiple queries, columns to sort by, or figuring out how to send the correct page back to the client.
|
6
8
|
|
7
|
-
|
8
|
-
When dealing with lots of rows, we usually want to split the table into multiple pages. tableSorter has a nifty [widget](https://mottie.github.io/tablesorter/docs/example-pager-ajax.html) for that, which requires using [mottie's fork](https://mottie.github.io/tablesorter/docs/index.html) of tableSorter.
|
9
|
+
It is a Rails backend complementation to the frontend tableSorter.js.
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
### The Problem
|
12
|
+
The jQuery tableSorter plugin is an excellent tool for filtering and sorting tables.
|
13
|
+
Often, when dealing with lots of rows, we may want to split the table into multiple pages. tableSorter.js has a nifty [widget](https://mottie.github.io/tablesorter/docs/example-pager-ajax.html) for that, which requires using [mottie's fork](https://mottie.github.io/tablesorter/docs/index.html) of tableSorter.
|
13
14
|
|
14
|
-
|
15
|
+
Usually this is a scenario where we don't want to send our entire set of records to the frontend,
|
16
|
+
which consequently means that the frontend no longer knows the entire set of records to filter and sort through,
|
17
|
+
which eventually requires our *server* to handle all that stuff as well as the pagination of the results.
|
15
18
|
|
19
|
+
### The Solution: TableSortable
|
16
20
|
TableSortable will handle all the backend filtering, sorting and pagination for you.
|
17
21
|
|
18
22
|
NOTICE: This gem is in very early stages of development, and is not yet fully documented. Any input will be more than welcome.
|
@@ -28,13 +32,13 @@ gem 'table_sortable'
|
|
28
32
|
Then run `bundle install` and you're ready to start
|
29
33
|
|
30
34
|
You should also probably be using jquery-tablesorter.
|
31
|
-
For information regarding integration or tableSorter into your Rails project,
|
35
|
+
For information regarding integration or tableSorter.js into your Rails project,
|
32
36
|
please see the [jQuery tablesorter plugin for Rails](https://github.com/themilkman/jquery-tablesorter-rails) page.
|
33
37
|
|
34
38
|
## Usage
|
35
39
|
|
36
|
-
First, we need to setup our controller.
|
37
|
-
Let's
|
40
|
+
First, we need to setup our controller. For this example this will be a users controller.
|
41
|
+
Let's `include TableSortable` so that we can use its methods.
|
38
42
|
|
39
43
|
```ruby
|
40
44
|
#controllers/users_controller.rb
|
@@ -50,7 +54,7 @@ class UsersController < ApplicationController
|
|
50
54
|
|
51
55
|
define_colunns :first_name, :last_name, :email, :created_at
|
52
56
|
```
|
53
|
-
That's the basic setup of columns. For more configuration options, please see [advanced configuration](#advanced-configuration).
|
57
|
+
That's just the basic setup of columns. For more configuration options, please see [advanced configuration](#advanced-configuration).
|
54
58
|
|
55
59
|
Now we need to make sure our `index` action filters, sorts and paginates the records.
|
56
60
|
We can do that using the `filter_and_sort` method.
|
@@ -61,27 +65,50 @@ def index
|
|
61
65
|
@users = filter_and_sort(User.all)
|
62
66
|
|
63
67
|
respond_to do |format|
|
64
|
-
|
65
|
-
|
68
|
+
format.html {}
|
69
|
+
format.json {render layout: false}
|
66
70
|
end
|
67
71
|
end
|
68
72
|
```
|
69
73
|
|
70
|
-
|
74
|
+
Let's write the `index` view. We can use TableSortable's [view helpers](#view-helpers) to render our table.
|
71
75
|
```erb
|
72
|
-
|
73
|
-
<div id="usersPager"
|
76
|
+
<!-- views/users/index.html.erb -->
|
77
|
+
<div id="usersPager">
|
78
|
+
<%= table_sortable_pager %>
|
79
|
+
</div>
|
80
|
+
|
74
81
|
<table id="usersTable" data-query="<%= users_path %>">
|
75
82
|
<thead>
|
76
83
|
<tr>
|
77
84
|
<%= table_sortable_headers %>
|
78
85
|
</tr>
|
79
86
|
</thead>
|
87
|
+
<tbody>
|
88
|
+
</tbody>
|
80
89
|
</table>
|
81
90
|
```
|
91
|
+
Notice how `index.html` doesn't render the actual rows. They will later be polled via ajax by tableSorter.js.
|
82
92
|
|
83
|
-
Let's
|
93
|
+
Let's create `index.json.jbuilder` to send the users' info back to the frontend.
|
94
|
+
```ruby
|
95
|
+
# views/users/index.json.jbuilder
|
96
|
+
# Since we only send out the current page of users,
|
97
|
+
# we must also send the total number of records.
|
98
|
+
# We'll use TableSortable's total_count method for that.
|
99
|
+
json.total @users.total_count
|
100
|
+
json.rows @users.map{|user| render partial: 'user_row.html.erb', locals: {user: user}}.join
|
101
|
+
json.pager_output 'Users {startRow} to {endRow} of {totalRows}'
|
102
|
+
```
|
103
|
+
We should also create the _user_row.html partial. In it, we may also use TableSortable's [helpers](#view-helpers).
|
104
|
+
```erb
|
105
|
+
<!-- views/users/_user_row.html.erb -->
|
106
|
+
<tr>
|
107
|
+
<%= table_sortable_columns user %>
|
108
|
+
</tr>
|
109
|
+
```
|
84
110
|
|
111
|
+
Now that we are done configuring the backend - let's continue to frontend. Here's a simple tableSorter.js configuration example:
|
85
112
|
```javascript
|
86
113
|
var table = $('#usersTable');
|
87
114
|
table.tablesorter({
|
@@ -89,9 +116,7 @@ table.tablesorter({
|
|
89
116
|
widgetOptions: {
|
90
117
|
// show 10 records at a time
|
91
118
|
pager_size: 10,
|
92
|
-
// Poll our users_index_path.
|
93
|
-
// A better practice would be to use the table's
|
94
|
-
// data-query attribute instead, but more on that later)
|
119
|
+
// Poll our users_index_path, which we receive from the table's data-query attribute.
|
95
120
|
pager_ajaxUrl: table.data('query') + '?pagesize={size}&page={page}&{filterList:fcol}&{sortList:scol}',
|
96
121
|
// Parse the incoming result
|
97
122
|
pager_ajaxProcessing: function (data) {
|
@@ -100,15 +125,15 @@ table.tablesorter({
|
|
100
125
|
this.pager_output = data.pager_output;
|
101
126
|
// return total records, the rows HTML data,
|
102
127
|
// and the headers information.
|
103
|
-
return [data.total, $(data.rows)
|
128
|
+
return [data.total, $(data.rows)];
|
104
129
|
}
|
105
130
|
}
|
106
131
|
}
|
107
132
|
});
|
108
133
|
```
|
109
|
-
|
134
|
+
That's it! The results fetched from the server are now filtered, sorted and paginated by TableSortable.
|
110
135
|
|
111
|
-
|
136
|
+
For full documentation of the usage of tableSorter.js please go [here](https://mottie.github.io/tablesorter/docs/index.html) for the very popular fork by mottie, or [here](http://tablesorter.com/docs/) for the original version of the plugin.
|
112
137
|
|
113
138
|
Of course there are many more configuration options that make TableSortable flexible and adaptable. For those, please see [advanced configuration](#advanced-configuration)
|
114
139
|
|
@@ -3,8 +3,10 @@ module TableSortable
|
|
3
3
|
class Filter
|
4
4
|
include TableSortable::Concerns::Proc
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_accessor :query
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
super :filter, *args
|
8
10
|
end
|
9
11
|
|
10
12
|
def array_proc
|
@@ -12,8 +14,21 @@ module TableSortable
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def sql_proc
|
15
|
-
-> (value, col=nil) { where("? LIKE (?)", filter.to_s.underscore, "%#{value}%") }
|
17
|
+
-> (value, col=nil) { where("LOWER(?) LIKE (?)", filter.to_s.underscore, "%#{value.to_s.downcase}%") }
|
18
|
+
end
|
19
|
+
|
20
|
+
def proc_wrapper(proc)
|
21
|
+
-> (value, col=nil) { instance_exec(value, &proc) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def run(records)
|
25
|
+
records.instance_exec(query, column, &proc)
|
26
|
+
end
|
27
|
+
|
28
|
+
def used?
|
29
|
+
!query.nil?
|
16
30
|
end
|
31
|
+
|
17
32
|
end
|
18
33
|
end
|
19
34
|
end
|
@@ -3,16 +3,30 @@ module TableSortable
|
|
3
3
|
class Sorter
|
4
4
|
include TableSortable::Concerns::Proc
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_accessor :sort_order
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
super :sort, *args
|
8
10
|
end
|
9
11
|
|
10
12
|
def array_proc
|
11
|
-
-> (col=nil) { sort{ |a,b| col.value(a) <=> col.value(b) }}
|
13
|
+
-> (sort_order, col=nil) { sort{ |a,b| col.value(sort_order == :asc ? a : b) <=> col.value(sort_order == :asc ? b : a) } }
|
12
14
|
end
|
13
15
|
|
14
16
|
def sql_proc
|
15
|
-
-> (col=nil) { order(sorter) }
|
17
|
+
-> (sort_order, col=nil) { order(sorter => sort_order) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def proc_wrapper(proc)
|
21
|
+
-> (sort_order, col=nil) { instance_exec(sort_order , &proc) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def run(records)
|
25
|
+
records.instance_exec(sort_order, column, &proc)
|
26
|
+
end
|
27
|
+
|
28
|
+
def used?
|
29
|
+
!sort_order.nil?
|
16
30
|
end
|
17
31
|
|
18
32
|
end
|
@@ -16,8 +16,8 @@ module TableSortable
|
|
16
16
|
@label = label
|
17
17
|
@placeholder = placeholder
|
18
18
|
@template = template
|
19
|
-
@filter = TableSortable::Column::Filter.new(options.merge(:
|
20
|
-
@sorter = TableSortable::Column::Sorter.new(options.merge(:
|
19
|
+
@filter = TableSortable::Column::Filter.new(options.merge(:column => self) )
|
20
|
+
@sorter = TableSortable::Column::Sorter.new(options.merge(:column => self) )
|
21
21
|
|
22
22
|
end
|
23
23
|
|
@@ -1,26 +1,22 @@
|
|
1
1
|
module TableSortable
|
2
|
-
class Columns
|
2
|
+
class Columns < Array
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
|
5
|
+
super
|
6
6
|
end
|
7
7
|
|
8
8
|
def add(col_name, *options)
|
9
9
|
options = options.extract_options!
|
10
|
-
|
10
|
+
self << TableSortable::Column.new(col_name, options)
|
11
11
|
end
|
12
12
|
|
13
13
|
def sort_by(sort_key)
|
14
14
|
if sort_key
|
15
|
-
sort_key.map{|c|
|
15
|
+
sort_key.map{|c| self.find{|col| (c.is_a?(String) ? (col.label == c) : col.name == c)}}
|
16
16
|
else
|
17
|
-
|
17
|
+
self
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def sort(&sort_proc)
|
22
|
-
@columns.sort(&sort_proc)
|
23
|
-
end
|
24
|
-
|
25
21
|
end
|
26
22
|
end
|
@@ -4,18 +4,20 @@ module TableSortable
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
attr_reader :proc, :method
|
7
|
+
attr_reader :proc, :method, :column, :type
|
8
8
|
end
|
9
9
|
|
10
10
|
def initialize(option_name, *options)
|
11
11
|
options = options.extract_options!
|
12
12
|
unless options[option_name] == false
|
13
|
-
|
13
|
+
@type = option_name
|
14
|
+
@column = options[:column]
|
15
|
+
the_proc = options[option_name] || @column.name if @column
|
14
16
|
@method = options["#{option_name.to_s}_method".to_sym] || :array
|
15
|
-
if
|
16
|
-
@proc =
|
17
|
+
if the_proc.respond_to? :call
|
18
|
+
@proc = proc_wrapper(the_proc)
|
17
19
|
@method = detect_method(@proc)
|
18
|
-
elsif !
|
20
|
+
elsif !the_proc.nil?
|
19
21
|
case @method
|
20
22
|
when :array
|
21
23
|
@proc = array_proc
|
@@ -27,8 +29,13 @@ module TableSortable
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def detect_method(proc)
|
30
|
-
|
31
|
-
|
32
|
+
begin
|
33
|
+
[].instance_exec('', &proc)
|
34
|
+
method = :array
|
35
|
+
rescue NoMethodError
|
36
|
+
method = :sql
|
37
|
+
end
|
38
|
+
method
|
32
39
|
end
|
33
40
|
|
34
41
|
def disabled?
|
@@ -43,6 +50,17 @@ module TableSortable
|
|
43
50
|
raise NotImplementedError
|
44
51
|
end
|
45
52
|
|
53
|
+
def proc_wrapper(proc)
|
54
|
+
raise NotImplementedError
|
55
|
+
end
|
56
|
+
|
57
|
+
def run(records)
|
58
|
+
raise NotImplementedError
|
59
|
+
end
|
60
|
+
|
61
|
+
def used?
|
62
|
+
raise NotImplementedError
|
63
|
+
end
|
46
64
|
end
|
47
65
|
end
|
48
66
|
end
|
@@ -36,52 +36,38 @@ module TableSortable
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def filter_and_sort(scope)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
sort_order = params[SCOL] ? params[SCOL].values.first : SORT_ASC
|
46
|
-
|
47
|
-
sort_column = cols.at(sort_by_col_data.to_i - column_offset)
|
48
|
-
sort_proc = ->(records) { records.instance_exec(sort_column, &sort_column.sorter.proc)}
|
49
|
-
ordered_sort_proc = ->(records) {sort_order == SORT_ASC ? sort_proc.call(records) : sort_proc.call(records).reverse}
|
50
|
-
|
51
|
-
filters = [->(records) { ordered_sort_proc.call(records) }]
|
52
|
-
|
53
|
-
# a filter exists
|
54
|
-
if params[FCOL]
|
55
|
-
@columns.sort_by(filter_order.reverse).each_with_index do |col, i|
|
56
|
-
column_index = cols.index(col) + column_offset
|
57
|
-
filter_value = params[FCOL][column_index.to_s]
|
58
|
-
filters << ->(records){ filter_value.nil? ? filters[i].call(records) : filters[i].call(records.instance_exec(filter_value, col, &col.filter.proc)) }
|
59
|
-
end
|
39
|
+
def filter_and_sort(scope, params = nil)
|
40
|
+
populate_params(params)
|
41
|
+
|
42
|
+
actions = [->(records) { records }]
|
43
|
+
ordered_actions.reverse.each_with_index do |action, i|
|
44
|
+
actions << ->(records) { action.used? ? actions[i].call(action.run(records)) : actions[i].call(records) }
|
60
45
|
end
|
61
|
-
scope =
|
62
|
-
if page
|
63
|
-
scope = Result.new(scope, page, page_size)
|
46
|
+
scope = actions.last.call(scope)
|
47
|
+
if @query_params.page
|
48
|
+
scope = Result.new(scope, @query_params.page, @query_params.page_size)
|
64
49
|
end
|
50
|
+
|
65
51
|
scope
|
66
52
|
end
|
67
53
|
|
68
54
|
def initialize_table_sortable
|
69
|
-
|
70
|
-
@columns ||= TableSortable::Columns.new
|
55
|
+
@columns = TableSortable::Columns.new
|
71
56
|
self.column_offset = 0
|
72
|
-
|
73
57
|
end
|
74
58
|
|
75
|
-
def columns
|
59
|
+
def columns
|
76
60
|
@columns.sort_by(display_order)
|
77
61
|
end
|
78
62
|
|
79
|
-
def
|
80
|
-
|
63
|
+
def ordered_actions
|
64
|
+
filter_actions = @columns.map{|col| col.filter }
|
65
|
+
sort_actions = @columns.map{|col| col.sorter }
|
66
|
+
(filter_actions+sort_actions).sort{ |a,b| (a.method && b.method) ? (b.method <=> a.method) : a.method ? 1 : -1 }
|
81
67
|
end
|
82
68
|
|
83
|
-
def
|
84
|
-
@
|
69
|
+
def populate_params(params = nil)
|
70
|
+
@query_params = QueryParams.new(params || self.params, columns, column_offset)
|
85
71
|
end
|
86
72
|
|
87
73
|
public
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TableSortable
|
2
|
+
class QueryParams
|
3
|
+
|
4
|
+
attr_reader :page, :page_size
|
5
|
+
def initialize(params, columns, column_offset = 0)
|
6
|
+
@page = params[PAGE].to_i
|
7
|
+
@page_size = params[PAGESIZE].to_i
|
8
|
+
|
9
|
+
# reset column filters and sorters
|
10
|
+
columns.each do |col|
|
11
|
+
col_index = (columns.find_index(col) + column_offset)
|
12
|
+
col.filter.query = params[FCOL] ? params[FCOL][col_index.to_s] : nil
|
13
|
+
col.sorter.sort_order = params[SCOL] && params[SCOL][col_index.to_s] ? ((params[SCOL][col_index.to_s] == SORT_ASC) ? :asc : :desc) : nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/table_sortable.rb
CHANGED
@@ -8,6 +8,8 @@ module TableSortable
|
|
8
8
|
SCOL = 'scol'
|
9
9
|
SORT_ASC = '0'
|
10
10
|
SORT_DESC = '1'
|
11
|
+
PAGE = 'page'
|
12
|
+
PAGESIZE = 'pagesize'
|
11
13
|
|
12
14
|
class Engine < Rails::Engine; end
|
13
15
|
|
@@ -23,4 +25,5 @@ require 'table_sortable/column'
|
|
23
25
|
require 'table_sortable/result'
|
24
26
|
require 'table_sortable/columns'
|
25
27
|
require 'table_sortable/version'
|
26
|
-
require 'table_sortable/controller'
|
28
|
+
require 'table_sortable/controller'
|
29
|
+
require 'table_sortable/query_params'
|
@@ -6,8 +6,11 @@ shared_examples_for 'proc_class' do |parameter_name|
|
|
6
6
|
it 'includes TableSortable::Concerns::Proc' do
|
7
7
|
expect(described_class.included_modules).to include TableSortable::Concerns::Proc
|
8
8
|
end
|
9
|
-
it 'defines
|
9
|
+
it 'defines methods of its own' do
|
10
10
|
expect(dummy_class.array_proc).to respond_to :call
|
11
11
|
expect(dummy_class.sql_proc).to respond_to :call
|
12
|
+
expect(dummy_class.send(:proc_wrapper, -> {x})).to respond_to :call
|
13
|
+
expect(dummy_class).to respond_to :run
|
14
|
+
expect(dummy_class).to respond_to :used?
|
12
15
|
end
|
13
16
|
end
|
@@ -12,23 +12,27 @@ describe TableSortable::Concerns::Proc do
|
|
12
12
|
def sql_proc
|
13
13
|
-> (x) {x * 3}
|
14
14
|
end
|
15
|
+
|
16
|
+
def proc_wrapper(proc)
|
17
|
+
proc
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
22
|
let :dummy_proc do
|
19
|
-
proc_class.new(:proc, proc: dummy_col)
|
23
|
+
proc_class.new(:proc, column: TableSortable::Column.new(:proc), proc: dummy_col)
|
20
24
|
end
|
21
25
|
|
22
26
|
context 'on initialization' do
|
23
27
|
context 'given a proc' do
|
24
28
|
it 'should keep it' do
|
25
29
|
example_proc = -> (x) { x * 100 }
|
26
|
-
proc = proc_class.new(:proc, proc: example_proc )
|
30
|
+
proc = proc_class.new(:proc, column: TableSortable::Column.new(:proc),proc: example_proc )
|
27
31
|
expect(5.instance_eval(&proc.proc)).to eq 500
|
28
32
|
end
|
29
33
|
context 'it is an sql proc' do
|
30
34
|
it 'should detect it as sql' do
|
31
|
-
proc = proc_class.new(:proc, proc: -> (value) { where(name: value) } )
|
35
|
+
proc = proc_class.new(:proc, column: TableSortable::Column.new(:proc), proc: -> (value) { where(name: value) } )
|
32
36
|
expect(proc.method).to eq :sql
|
33
37
|
end
|
34
38
|
end
|
@@ -51,13 +55,13 @@ describe TableSortable::Concerns::Proc do
|
|
51
55
|
end
|
52
56
|
context '== :sql' do
|
53
57
|
it 'should replace it with sql_proc' do
|
54
|
-
dummy_proc = proc_class.new(:proc,
|
58
|
+
dummy_proc = proc_class.new(:proc, column: TableSortable::Column.new(:proc), proc_method: :sql)
|
55
59
|
expect(5.instance_eval(&dummy_proc.proc)).to eq 5.instance_eval(&dummy_proc.sql_proc)
|
56
60
|
end
|
57
61
|
end
|
58
62
|
context '== :array' do
|
59
63
|
it 'should replace it with sql_proc' do
|
60
|
-
dummy_proc = proc_class.new(:proc,
|
64
|
+
dummy_proc = proc_class.new(:proc, column: TableSortable::Column.new(:proc), proc_method: :array)
|
61
65
|
expect(5.instance_eval(&dummy_proc.proc)).to eq 5.instance_eval(&dummy_proc.array_proc)
|
62
66
|
end
|
63
67
|
end
|
@@ -6,22 +6,33 @@ describe TableSortable::Controller do
|
|
6
6
|
controller.instance_eval('initialize_table_sortable')
|
7
7
|
controller
|
8
8
|
end
|
9
|
-
let :
|
9
|
+
let :controller_with_columns do
|
10
|
+
|
10
11
|
controller.send(:define_column,
|
11
|
-
:
|
12
|
-
filter: -> (value) { where(
|
13
|
-
sort: -> { order(:
|
12
|
+
:first_name,
|
13
|
+
filter: -> (value) { where('UPPER(first_name) LIKE (?)', "%#{value.upcase}%") },
|
14
|
+
sort: -> (sort_order) { order(:first_name => sort_order) })
|
15
|
+
|
14
16
|
controller.send(:define_column,
|
15
|
-
:
|
16
|
-
filter: -> (value) { select{|record| record
|
17
|
-
sort: -> (
|
17
|
+
:last_name,
|
18
|
+
filter: -> (value) { select{|record| value.downcase.in? record.last_name.downcase }},
|
19
|
+
sort: -> (sort_order) { sort{ |a,b| (sort_order == :asc ? a : b).last_name <=> (sort_order == :asc ? b : a).last_name }})
|
20
|
+
|
18
21
|
controller.send(:define_column,
|
19
|
-
:
|
20
|
-
filter: -> (value) { where(
|
21
|
-
sort: -> { order(:
|
22
|
+
:email,
|
23
|
+
filter: -> (value) { where('UPPER(email) LIKE (?)', "%#{value.upcase}%") },
|
24
|
+
sort: -> (sort_order) { order(:email => sort_order) })
|
25
|
+
|
22
26
|
controller
|
23
27
|
end
|
24
28
|
|
29
|
+
before(:all) do
|
30
|
+
create :user, first_name: 'Bob', last_name: 'Doe', email: 'misterbob@gmail.com'
|
31
|
+
create :user, first_name: 'David', last_name: 'Copperfield', email: 'alphadavid@gmail.com'
|
32
|
+
create :user, first_name: 'Aaron', last_name: 'Marks', email: 'super_aaron@gmail.com'
|
33
|
+
create :user, first_name: 'Jim', last_name: 'Jones', email: 'aaron_is_not_my_name@gmail.com'
|
34
|
+
end
|
35
|
+
|
25
36
|
context 'initialization' do
|
26
37
|
it 'creates a columns collection' do
|
27
38
|
expect(controller.instance_eval('@columns')).to be_a TableSortable::Columns
|
@@ -37,20 +48,34 @@ describe TableSortable::Controller do
|
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
40
|
-
context '
|
41
|
-
it 'orders sql
|
42
|
-
expect(
|
51
|
+
context 'ordered_actions' do
|
52
|
+
it 'orders sql actions before array filters' do
|
53
|
+
expect(controller_with_columns.send(:ordered_actions).map{|action| action.method}).to eq [:sql, :sql, :sql, :sql, :array, :array]
|
43
54
|
end
|
44
55
|
end
|
45
56
|
|
46
|
-
context '
|
47
|
-
it '
|
48
|
-
|
57
|
+
context 'filter_and_sort' do
|
58
|
+
it 'filters using a single filter' do
|
59
|
+
filter_by_first_name = controller_with_columns.send(:filter_and_sort, User.all, {TableSortable::PAGESIZE => '10', TableSortable::PAGE => '0', TableSortable::FCOL => {'0' => 'a'}, TableSortable::SCOL => {'0' => TableSortable::SORT_ASC}})
|
60
|
+
expect(filter_by_first_name.pluck(:first_name)).to eq %w(Aaron David)
|
61
|
+
end
|
62
|
+
it 'filters using multiple filters' do
|
63
|
+
filter_by_first_name = controller_with_columns.send(:filter_and_sort, User.all, {TableSortable::PAGESIZE => '10', TableSortable::PAGE => '0', TableSortable::FCOL => {'0' => 'a', '1' => 'c'}, TableSortable::SCOL => {'0' => TableSortable::SORT_ASC}})
|
64
|
+
expect(filter_by_first_name.pluck(:first_name)).to eq %w(David)
|
65
|
+
end
|
66
|
+
it 'sorts a record set based on the column to sort' do
|
67
|
+
sort_by_first_name = controller_with_columns.send(:filter_and_sort, User.all, {TableSortable::PAGESIZE => '10', TableSortable::PAGE => '0', TableSortable::SCOL => {'0' => TableSortable::SORT_ASC}})
|
68
|
+
expect(sort_by_first_name.pluck(:first_name)).to eq %w(Aaron Bob David Jim)
|
69
|
+
|
70
|
+
sort_by_email = controller_with_columns.send(:filter_and_sort, User.all, {TableSortable::PAGESIZE => '10', TableSortable::PAGE => '0', TableSortable::SCOL => {'2' => TableSortable::SORT_ASC}})
|
71
|
+
expect(sort_by_email.pluck(:first_name)).to eq %w(Jim David Bob Aaron)
|
72
|
+
end
|
73
|
+
context "sort order parameter equals #{TableSortable::SORT_DESC}" do
|
74
|
+
it 'sorts in descending order' do
|
75
|
+
sort_by_last_name_desc = controller_with_columns.send(:filter_and_sort, User.all, {TableSortable::PAGESIZE => '10', TableSortable::PAGE => '0', TableSortable::SCOL => {'1' => TableSortable::SORT_DESC}})
|
76
|
+
expect(sort_by_last_name_desc.pluck(:first_name)).to eq %w(Aaron Jim Bob David)
|
77
|
+
end
|
49
78
|
end
|
50
|
-
end
|
51
79
|
|
52
|
-
context 'filter_and_sort' do
|
53
|
-
it 'should filter a record_set based on its filters'
|
54
|
-
it 'should sort a record_set based on its filters'
|
55
80
|
end
|
56
81
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,9 +15,23 @@
|
|
15
15
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
16
|
|
17
17
|
require 'table_sortable'
|
18
|
-
require '
|
19
|
-
require '
|
20
|
-
|
18
|
+
require 'factory_girl'
|
19
|
+
require 'active_record'
|
20
|
+
|
21
|
+
Dir['spec/support/**/*.rb'].each {|f| require f.gsub('spec/', '')}
|
22
|
+
# Dir['spec/models/**/*.rb'].each {|f| require f.gsub('spec/', '')}
|
23
|
+
# Dir['spec/factories/**/*.rb'].each {|f| require f.gsub('spec/', '')}
|
24
|
+
|
25
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
26
|
+
ActiveRecord::Schema.define do
|
27
|
+
self.verbose = false
|
28
|
+
|
29
|
+
create_table :users, :force => true do |t|
|
30
|
+
t.string :first_name
|
31
|
+
t.string :last_name
|
32
|
+
t.string :email
|
33
|
+
end
|
34
|
+
end
|
21
35
|
|
22
36
|
RSpec.configure do |config|
|
23
37
|
|
@@ -0,0 +1 @@
|
|
1
|
+
class User < ActiveRecord::Base ; end
|
data/table_sortable.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = 'Use jquery-tablesorter.js with server side filtering, pagination and sorting'
|
13
13
|
spec.description = 'Use jquery-tablesorter.js with server side filtering, pagination and sorting'
|
14
|
-
|
14
|
+
spec.homepage = 'https://github.com/odedd/table_sortable'
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
@@ -32,5 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 1.15"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.4"
|
35
|
+
spec.add_development_dependency "sqlite3", "~> 1.3"
|
36
|
+
spec.add_development_dependency "factory_girl_rails", "~> 4.8"
|
35
37
|
spec.add_dependency "rails", '~> 5.1', '>= 5.1.1'
|
36
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_sortable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oded Davidov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: factory_girl_rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.8'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rails
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,6 +138,8 @@ files:
|
|
110
138
|
- lib/table_sortable/columns.rb
|
111
139
|
- lib/table_sortable/concerns/proc.rb
|
112
140
|
- lib/table_sortable/controller.rb
|
141
|
+
- lib/table_sortable/process.rb
|
142
|
+
- lib/table_sortable/query_params.rb
|
113
143
|
- lib/table_sortable/result.rb
|
114
144
|
- lib/table_sortable/version.rb
|
115
145
|
- spec/concerns/proc_class_spec.rb
|
@@ -118,12 +148,16 @@ files:
|
|
118
148
|
- spec/lib/table_sortable/column/sorter_spec.rb
|
119
149
|
- spec/lib/table_sortable/concerns/proc_spec.rb
|
120
150
|
- spec/lib/table_sortable/controller_spec.rb
|
151
|
+
- spec/lib/table_sortable/process_spec.rb
|
121
152
|
- spec/spec_helper.rb
|
122
153
|
- spec/support/controller_macros.rb
|
154
|
+
- spec/support/factories/user.rb
|
155
|
+
- spec/support/factory_girl.rb
|
123
156
|
- spec/support/matchers/have_filters.rb
|
157
|
+
- spec/support/models/user.rb
|
124
158
|
- spec/support/shared_stuff.rb
|
125
159
|
- table_sortable.gemspec
|
126
|
-
homepage:
|
160
|
+
homepage: https://github.com/odedd/table_sortable
|
127
161
|
licenses:
|
128
162
|
- MIT
|
129
163
|
metadata: {}
|
@@ -154,7 +188,11 @@ test_files:
|
|
154
188
|
- spec/lib/table_sortable/column/sorter_spec.rb
|
155
189
|
- spec/lib/table_sortable/concerns/proc_spec.rb
|
156
190
|
- spec/lib/table_sortable/controller_spec.rb
|
191
|
+
- spec/lib/table_sortable/process_spec.rb
|
157
192
|
- spec/spec_helper.rb
|
158
193
|
- spec/support/controller_macros.rb
|
194
|
+
- spec/support/factories/user.rb
|
195
|
+
- spec/support/factory_girl.rb
|
159
196
|
- spec/support/matchers/have_filters.rb
|
197
|
+
- spec/support/models/user.rb
|
160
198
|
- spec/support/shared_stuff.rb
|