grapple 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b42d08c946b40036d8cda0fb17ad4c3b82ec3b2c
4
- data.tar.gz: c0882e3d2d3767e26c473bb0f062c43a8cf86de5
3
+ metadata.gz: 553e9009460ce643ba8c5992feed612c915e9469
4
+ data.tar.gz: ed610078de00ec3bb672219308837ad8fe7b5b8a
5
5
  SHA512:
6
- metadata.gz: 69cc209aaf685788d49e6616cd8191c28b36695befe0cbaea11b6ae65e915cc3400d157962b570a4965e0d2be0185c8b2432c312d1508ee5f81007c0dfad4ed5
7
- data.tar.gz: ab70392b8d0c8ff6b7a9aac92dc99550a3ac3cc322f073310c7fe7dc32ae55e8b4056239a5d44e24bf3bdcbd3dc5e476c155cea4e610da683435fd5367958232
6
+ metadata.gz: 1f0351e175116671c9e192bf9699a65a2c8f51003e00027bedd9e52446338f7c200adf5d79f5efb79a05e300eb4eae5d94055a8e6a21054879547b8cd2ec4221
7
+ data.tar.gz: fc10e85ebe940a6420ba2be4750bbcf6a934af79d1b6cdff8ba6699393433abe34aed2391ec5c3cc8918999450135d76e1b054c70c32f6fb06ade6267f3b2f10
data/README.md CHANGED
@@ -88,7 +88,30 @@ app/views/posts/index.html.erb
88
88
  ```
89
89
 
90
90
  ## Sorting
91
- TODO
91
+ Any column that includes a `sort` key will be rendered with a link that adds sorting parameters to the request.
92
+ The default sort parameters are `sort` for the field to sort and `dir` for the direction to sort the results (ASC or DESC).
93
+
94
+ app/views/posts/index.html.erb
95
+ ``` HTML+ERB
96
+ <%
97
+ columns = [
98
+ { label: "Name", sort: "name" },
99
+ { label: "Description", sort: "description" },
100
+ { label: "Created At", sort: "created_at" }
101
+ ]
102
+ %>
103
+ <%= table_for(columns, @posts) do |t| %>
104
+ <%= t.header %>
105
+ <% end %>
106
+ ```
107
+
108
+ app/controllers/posts_controller.rb
109
+ ``` ruby
110
+ def index
111
+ sort = (params[:sort] || "name") + " " + (params[:dir] || "asc")
112
+ @posts = Post.all.order(sort)
113
+ end
114
+ ```
92
115
 
93
116
  ## Pagination (requires will_paginate)
94
117
  app/controllers/posts_controller.rb
@@ -179,4 +202,4 @@ Requires: https://github.com/browserstate/history.js/
179
202
  ```
180
203
 
181
204
  ## Customizing
182
- TODO
205
+ TODO
@@ -17,7 +17,11 @@ module Grapple
17
17
  # in an initializer to enable it by default
18
18
  "grapple-ajax-history" => options[:history] == true ? '1' : '0'
19
19
  }
20
-
20
+
21
+ # The namespace allows the query parameters to be namespaced so
22
+ # multiple tables can exist on the same page
23
+ data["grapple-ajax-namespace"] = options[:namespace] unless options[:namespace].nil?
24
+
21
25
  return {
22
26
  :id => options[:id],
23
27
  :class => css,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grapple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Potocko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-14 00:00:00.000000000 Z
12
+ date: 2016-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack