tabulatr2 0.9.32 → 0.9.33
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/CHANGELOG.md +9 -1
- data/app/views/tabulatr/_tabulatr_batch_actions_menu.html.slim +9 -2
- data/lib/tabulatr/data/data.rb +2 -1
- data/lib/tabulatr/data/invoker.rb +12 -2
- data/lib/tabulatr/rails/action_controller.rb +20 -4
- data/lib/tabulatr/responses/direct_response.rb +2 -0
- data/lib/tabulatr/responses/file_response.rb +8 -0
- data/lib/tabulatr/responses/raw_response.rb +8 -0
- data/lib/tabulatr/responses/redirect_response.rb +8 -0
- data/lib/tabulatr/responses/responses.rb +7 -0
- data/lib/tabulatr/version.rb +1 -1
- data/lib/tabulatr.rb +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62d761945606d57007db863163a4674d08d41bb6
|
|
4
|
+
data.tar.gz: d4ab3323e85d5b46cb5595d1d712b3fadb1b672e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13ec315f26b5ca9f02b904ae5ddbcb25acd4a96043a3354135f4b37e43fff755714701f3b1fbaff91973c0decfe8ecee4718ada6a85c1c5eddb48c4d76aaa806
|
|
7
|
+
data.tar.gz: 3a2f82c463b13993a5e6de5fbec54a83164dde8d9a698ab457d7745d952de7e7d9a11422b3a999b87cd54480b4f1e9cec6d7b825c4110c23a056b60c400cd8ef
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
##
|
|
1
|
+
## 0.9.33
|
|
2
|
+
|
|
3
|
+
* allow batch actions to return files, data or redirects
|
|
4
|
+
|
|
5
|
+
## 0.9.32
|
|
6
|
+
|
|
7
|
+
* define default order by giving `default_order: '<sql order>'` option to `tabulatr_for`
|
|
8
|
+
|
|
9
|
+
## 0.9.21?
|
|
2
10
|
* Rename `filter` option of `table_for` to `filters` to not conceal the
|
|
3
11
|
`table_option` also named `filter`.
|
|
4
12
|
|
|
@@ -26,9 +26,16 @@
|
|
|
26
26
|
i.icon-cog.glyphicon.glyphicon-cog.fa.fa-cog>
|
|
27
27
|
i.icon-caret-down.glyphicon.glyphicon-chevron-down.fa.fa-caret-down
|
|
28
28
|
ul.dropdown-menu role="menu" aria-labelledby="dLabel" data-confirm-text=t('tabulatr.batch_confirm_text')
|
|
29
|
-
- table_options[:batch_actions].each do |key,
|
|
29
|
+
- table_options[:batch_actions].each do |key, data|
|
|
30
|
+
- if data.is_a?(String)
|
|
31
|
+
- label = data
|
|
32
|
+
- download = false
|
|
33
|
+
- else
|
|
34
|
+
- label = data[:text]
|
|
35
|
+
- download = !!data[:download]
|
|
30
36
|
li
|
|
31
37
|
= link_to label, '#', class: "batch-action-inputs", data: { \
|
|
32
38
|
"do-batch-action-name" => iname, \
|
|
33
39
|
"do-batch-action" => key, \
|
|
34
|
-
"table-id" => table_id
|
|
40
|
+
"table-id" => table_id, \
|
|
41
|
+
"download" => download }
|
data/lib/tabulatr/data/data.rb
CHANGED
|
@@ -55,7 +55,8 @@ class Tabulatr::Data
|
|
|
55
55
|
apply_sorting(sort_params params)
|
|
56
56
|
join_required_tables(params)
|
|
57
57
|
|
|
58
|
-
execute_batch_actions(batch_params(params), check_params(params))
|
|
58
|
+
batch_result = execute_batch_actions(batch_params(params), check_params(params))
|
|
59
|
+
return batch_result if batch_result.is_a? Tabulatr::Responses::DirectResponse
|
|
59
60
|
|
|
60
61
|
pagination = compute_pagination(params[:page], params[:pagesize])
|
|
61
62
|
apply_pagination(pagination.slice(:offset, :pagesize))
|
|
@@ -25,11 +25,21 @@ class Tabulatr::Data::Invoker
|
|
|
25
25
|
def initialize(batch_action, ids)
|
|
26
26
|
@batch_action = batch_action.to_sym
|
|
27
27
|
@ids = ids
|
|
28
|
+
@result = nil
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
def method_missing(name, *args, &block)
|
|
31
|
-
if @batch_action == name
|
|
32
|
-
yield(@ids)
|
|
32
|
+
@result ||= if @batch_action == name
|
|
33
|
+
s = yield(@ids)
|
|
34
|
+
if s.is_a?(Hash) && s[:data]
|
|
35
|
+
Tabulatr::Responses::RawResponse.new(s[:data])
|
|
36
|
+
elsif s.is_a?(Hash) && s[:file]
|
|
37
|
+
Tabulatr::Responses::FileResponse.new(s[:file], filename: s[:filename])
|
|
38
|
+
elsif s.is_a?(Hash) && s[:url]
|
|
39
|
+
Tabulatr::Responses::RedirectResponse.new(s[:url], ids: @ids)
|
|
40
|
+
else
|
|
41
|
+
s
|
|
42
|
+
end
|
|
33
43
|
end
|
|
34
44
|
end
|
|
35
45
|
end
|
|
@@ -28,17 +28,33 @@ class ActionController::Base
|
|
|
28
28
|
|
|
29
29
|
def tabulatr_for(relation, tabulatr_data_class: nil, serializer: nil, render_action: nil, default_order: nil, locals: {}, &block)
|
|
30
30
|
klass = relation.respond_to?(:klass) ? relation.klass : relation
|
|
31
|
+
locals[:current_user] ||= current_user if respond_to?(:current_user)
|
|
32
|
+
if batch_params(klass, params).present?
|
|
33
|
+
response = klass.tabulatr(relation, tabulatr_data_class).data_for_table(params, locals: locals, controller: self, &block)
|
|
34
|
+
case response
|
|
35
|
+
when Tabulatr::Responses::RawResponse
|
|
36
|
+
return send_data response.data, response.options
|
|
37
|
+
when Tabulatr::Responses::FileResponse
|
|
38
|
+
return send_file response.file, response.options
|
|
39
|
+
when Tabulatr::Responses::RedirectResponse
|
|
40
|
+
return redirect_to response.url, ids: response.ids
|
|
41
|
+
else records = response
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
31
45
|
respond_to do |format|
|
|
32
46
|
format.json {
|
|
33
|
-
locals
|
|
34
|
-
records = klass.tabulatr(relation, tabulatr_data_class).data_for_table(params, locals: locals, controller: self, default_order: default_order, &block)
|
|
47
|
+
records ||= klass.tabulatr(relation, tabulatr_data_class).data_for_table(params, locals: locals, controller: self, &block)
|
|
35
48
|
render json: records.to_tabulatr_json(serializer)
|
|
36
|
-
records
|
|
37
49
|
}
|
|
38
50
|
format.html {
|
|
39
51
|
render action: render_action || action_name
|
|
40
|
-
nil
|
|
41
52
|
}
|
|
42
53
|
end
|
|
43
54
|
end
|
|
55
|
+
|
|
56
|
+
def batch_params(klass, params)
|
|
57
|
+
params["#{Tabulatr::Utility.formatted_name(klass.name)}_batch"]
|
|
58
|
+
end
|
|
59
|
+
|
|
44
60
|
end
|
data/lib/tabulatr/version.rb
CHANGED
data/lib/tabulatr.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tabulatr2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.33
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Horn
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2017-
|
|
13
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rails
|
|
@@ -165,6 +165,11 @@ files:
|
|
|
165
165
|
- lib/tabulatr/renderer/columns_from_block.rb
|
|
166
166
|
- lib/tabulatr/renderer/filter.rb
|
|
167
167
|
- lib/tabulatr/renderer/renderer.rb
|
|
168
|
+
- lib/tabulatr/responses/direct_response.rb
|
|
169
|
+
- lib/tabulatr/responses/file_response.rb
|
|
170
|
+
- lib/tabulatr/responses/raw_response.rb
|
|
171
|
+
- lib/tabulatr/responses/redirect_response.rb
|
|
172
|
+
- lib/tabulatr/responses/responses.rb
|
|
168
173
|
- lib/tabulatr/utility/request_data_not_included_error.rb
|
|
169
174
|
- lib/tabulatr/utility/unexpected_search_result_error.rb
|
|
170
175
|
- lib/tabulatr/utility/utility.rb
|