Skip to content

Commit

Permalink
fix handling of extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
no-dashes committed Dec 5, 2017
1 parent 2b065f7 commit e4badda
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/tabulatr/_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function tabulatrInitialize() {
if (use_ajax)
table_obj.updateTable(params, true);
else
table_obj.sendRequestWithoutAjax(params);
table_obj.sendRequestWithoutAjax(params, a.data('extension'));
}
});

Expand Down
9 changes: 6 additions & 3 deletions app/assets/javascripts/tabulatr/_tabulatr.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ Tabulatr.prototype = {
this.loadDataFromServer(hash);
},

sendRequestWithoutAjax: function(hash) {
sendRequestWithoutAjax: function(hash, extension) {
var data = this.getDataForAjax(hash);
var url;
if ($('table#'+ this.id).data('path') == '#')
url = $(location).attr("pathname") + ".pdf?" + $.param(data)
url = $(location).attr("pathname");
else
url = $('table#'+ this.id).data('path') + ".pdf?" + $.param(data);
url = $('table#'+ this.id).data('path');
if (!extension || extension.length == 0)
extension = 'txt';
url = url.replace(/\/+$/, "") + '.' + extension + '?' + $.param(data);
window.open(url);
},

Expand Down
9 changes: 6 additions & 3 deletions app/views/tabulatr/_tabulatr_batch_actions_menu.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@
ul.dropdown-menu role="menu" aria-labelledby="dLabel" data-confirm-text=t('tabulatr.batch_confirm_text')
- table_options[:batch_actions].each do |key, data|
- if data.is_a?(String)
- label = data
- download = false
- label = data
- download = false
- extension = nil
- else
- label = data[:text]
- download = !!data[:download]
- extension = data[:extension]
li
= link_to label, '#', class: "batch-action-inputs", data: { \
"do-batch-action-name" => iname, \
"do-batch-action" => key, \
"table-id" => table_id, \
"download" => download }
"download" => download, \
"extension" => extension }
4 changes: 2 additions & 2 deletions lib/tabulatr/data/invoker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def method_missing(name, *args, &block)
@result ||= if @batch_action == name
s = yield(@ids)
if s.is_a?(Hash) && s[:data]
Tabulatr::Responses::RawResponse.new(s[:data])
Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
elsif s.is_a?(Hash) && s[:file]
Tabulatr::Responses::FileResponse.new(s[:file], filename: s[:filename])
Tabulatr::Responses::FileResponse.new(s[:file], filename: s[:filename], type: s[:type])
elsif s.is_a?(Hash) && s[:url]
Tabulatr::Responses::RedirectResponse.new(s[:url], ids: @ids)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/tabulatr/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
#++

module Tabulatr
VERSION = "0.9.36"
VERSION = "0.9.37"
end

0 comments on commit e4badda

Please sign in to comment.