admino 0.0.13 → 0.0.14

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: 02804bb71709b2b990d69c156f4bc6e1c1598a13
4
- data.tar.gz: 1cf458d64706709d71ab562730c4b7bfff9e5db9
3
+ metadata.gz: ddd7bdb139e6946fb8f37eb8d0a83c19e54fe087
4
+ data.tar.gz: ddadd3a2b601991912cf5b599b715b7775536fb1
5
5
  SHA512:
6
- metadata.gz: afe27118fbab995ae04dbd9dad10495a347259d601fb375d6c9eceb950b94cf5fcac1f46b5a240f219f556fa99cebb902f23b7832eee6c0fc930af19c171e21b
7
- data.tar.gz: 62e10b186cab528cf6227415b1b1a4a374475220952c157748799efa09de2a88722927f509ba5d2a194faffcc2a0ad3b7a8a8e0dbae627ac66efda91afaa1874
6
+ metadata.gz: 5e30786902a7f5aca949cc5f9ef2f61bb552e54a20b6d38aa230bfb8688e5541523b895ebba7a8344871bb5a9886fb7da792e41eaa96f5d1b50d7822c93f41e3
7
+ data.tar.gz: 4280a8d787aa37665c98ac5cae715dff3936480f50d0a918ae9d2a001a110fedd7c5019f6a50e3c37f0b171931b6dcc20eab6ec5ee2e0a35c35e4039ca2ad76c
@@ -5,17 +5,22 @@ require 'admino/query/base_presenter'
5
5
  module Admino
6
6
  module ActionViewExtension
7
7
  module Internals
8
- def self.present_query(query, context, options)
9
- presenter_klass = options.fetch(:presenter, Admino::Query::BasePresenter)
8
+ def self.present_query(query, context, options, key = :presenter)
9
+ presenter_klass = options.fetch(key, Admino::Query::BasePresenter)
10
10
  presenter_klass.new(query, context)
11
11
  end
12
12
  end
13
13
 
14
14
  def table_for(collection, options = {}, &block)
15
15
  options.symbolize_keys!
16
- options.assert_valid_keys(:presenter, :class, :html)
16
+ options.assert_valid_keys(:presenter, :class, :query, :html)
17
17
  presenter_klass = options.fetch(:presenter, Admino::Table::Presenter)
18
- presenter = presenter_klass.new(collection, options[:class], self)
18
+ query = if options[:query]
19
+ Internals.present_query(options[:query], self, options, :query_presenter)
20
+ else
21
+ nil
22
+ end
23
+ presenter = presenter_klass.new(collection, options[:class], query, self)
19
24
  html_options = options.fetch(:html, {})
20
25
  presenter.to_html(html_options, &block)
21
26
  end
@@ -1,4 +1,4 @@
1
1
  module Admino
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
4
4
 
@@ -7,16 +7,23 @@ describe 'Action View integration' do
7
7
  let(:collection) { [ first_post, second_post ] }
8
8
  let(:first_post) { Post.new('1') }
9
9
  let(:second_post) { Post.new('2') }
10
+ let(:params) {
11
+ {
12
+ sorting: 'by_title',
13
+ sort_order: 'desc'
14
+ }
15
+ }
16
+ let(:query) { TestQuery.new(params) }
10
17
 
11
18
  it 'produces HTML' do
12
- result = context.table_for(collection) do |table, record|
13
- table.column :title
19
+ result = context.table_for(collection, query: query) do |table, record|
20
+ table.column :title, sorting: :by_title
14
21
  table.actions do
15
22
  table.action :show, '/foo', 'Show'
16
23
  end
17
24
  end
18
25
  expect(result).to eq <<-HTML.strip
19
- <table><thead><tr><th role=\"title\">Title</th><th role=\"actions\">Actions</th></tr></thead><tbody><tr class=\"is-even\"><td role=\"title\">Post 1</td><td role=\"actions\"><a href=\"/foo\" role=\"show\">Show</a></td></tr><tr class=\"is-odd\"><td role=\"title\">Post 2</td><td role=\"actions\"><a href=\"/foo\" role=\"show\">Show</a></td></tr></tbody></table>
26
+ <table><thead><tr><th role=\"title\"><a class=\"is-desc\" href=\"/?sort_order=asc&amp;sorting=by_title\">Title</a></th><th role=\"actions\">Actions</th></tr></thead><tbody><tr class=\"is-even\"><td role=\"title\" sorting=\"by_title\">Post 1</td><td role=\"actions\"><a href=\"/foo\" role=\"show\">Show</a></td></tr><tr class=\"is-odd\"><td role=\"title\" sorting=\"by_title\">Post 2</td><td role=\"actions\"><a href=\"/foo\" role=\"show\">Show</a></td></tr></tbody></table>
20
27
  HTML
21
28
  end
22
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna