admino 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/admino/action_view_extension.rb +9 -4
- data/lib/admino/version.rb +1 -1
- data/spec/admino/integration_spec.rb +10 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddd7bdb139e6946fb8f37eb8d0a83c19e54fe087
|
4
|
+
data.tar.gz: ddadd3a2b601991912cf5b599b715b7775536fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
-
|
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
|
data/lib/admino/version.rb
CHANGED
@@ -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&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
|