rails_admin_multiple_file_upload 0.4.2.1 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 297aca7f3a23683c66a77d3f2573ed060cd73808
4
- data.tar.gz: babaa3dc034776b1da95279dc997e8740fd3b99c
3
+ metadata.gz: a2a765d2be198c84cb26e18b6288a89b731e36f5
4
+ data.tar.gz: 07987f6026a8d1eea9da12f106f34f6f9fa4544a
5
5
  SHA512:
6
- metadata.gz: e9e621afb60201f6e8165ddf6cfb6aa93f80bada283e10e6f9355f9b13e7f30fa7e8bcd768a21e9c07da5ce1b938d635831fab6e916a83b16880dd4bb066307c
7
- data.tar.gz: 723813b8e39f5d2c8df922760be8e44a1a7fa14ff76b66bc51bfcf3fd5ca5d6473dba7d3a99e5f91351e8c09a36dd53ead0136b802d62b58f0c7c8febac1dc83
6
+ metadata.gz: f11695f8218aef92861d9526065f764ac9320673aacb9a58424fc3b1776735cfedb146b1c5836b900fc3da0fa00b0586a4c20e303eb7544826a884dd57c11258
7
+ data.tar.gz: 6990653615e7178bce343ff624fff94671091700ae8fc6a75bde2a70d862cc3e8f8974ce4ad8da71a10636870bb3a6318d97294a2aa7613ece08827a2f0c43c1
data/README.md CHANGED
@@ -6,7 +6,7 @@ rails_admin + dropzone.js + mongoid(embedded)
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'rails_admin_multiple_file_upload'
9
+ gem 'rails_admin_multiple_file_upload', '~> 0.4.3'
10
10
 
11
11
  And then execute:
12
12
 
@@ -59,7 +59,8 @@
59
59
  $("##{block_id} .dropzone").dropzone({
60
60
  paramName: "#{child_field}[#{child_model_upload_field}]",
61
61
  autoProcessQueue: false,
62
- addRemoveLinks: true
62
+ addRemoveLinks: true,
63
+ parallelUploads: 1
63
64
  });
64
65
  $("##{block_id} .dropzone")[0].dropzone.on('success', function(){
65
66
  $("##{button_id}").click();
@@ -53,7 +53,8 @@
53
53
  $("##{block_id} .dropzone").dropzone({
54
54
  paramName: "#{upload_field}",
55
55
  autoProcessQueue: false,
56
- addRemoveLinks: true
56
+ addRemoveLinks: true,
57
+ parallelUploads: 1
57
58
  });
58
59
  $("##{block_id} .dropzone")[0].dropzone.on('success', function(){
59
60
  $("##{button_id}").click();
@@ -88,7 +89,8 @@
88
89
  $("##{block_id} .dropzone").dropzone({
89
90
  paramName: "#{upload_field}",
90
91
  autoProcessQueue: false,
91
- addRemoveLinks: true
92
+ addRemoveLinks: true,
93
+ parallelUploads: 1
92
94
  });
93
95
  $("##{block_id} .dropzone")[0].dropzone.on('success', function(){
94
96
  $("##{button_id}").click();
@@ -49,9 +49,25 @@ module RailsAdmin
49
49
  end
50
50
 
51
51
  main_obj = @object
52
- child = main_obj.send(child_field).new
52
+ child_scope = main_obj.send(child_field)
53
+ child = child_scope.new
53
54
  child.name = File.basename(_file.original_filename, ext) if @conf.options[:name_from_filename]
54
55
  child.send(child_model_upload_field + "=", _file)
56
+ if @conf.options[:set_order_as_max_plus_one]
57
+ begin
58
+ if @conf.options[:set_order_as_max_plus_one].is_a?(Symbol) or @conf.options[:set_order_as_max_plus_one].is_a?(String)
59
+ f_name = @conf.options[:set_order_as_max_plus_one]
60
+ else
61
+ f_name = :order
62
+ end
63
+ if child.respond_to?(f_name) and child.respond_to?("#{f_name}=") and child_scope.respond_to?(f_name)
64
+ current_max = child_scope.max(f_name).to_i
65
+ child.send("#{f_name}=", current_max + 1)
66
+ end
67
+ rescue Exception => ex
68
+ puts ex.inspect
69
+ end
70
+ end
55
71
  if child.save
56
72
  message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.success')}!</strong>".freeze
57
73
  else
@@ -62,7 +78,7 @@ module RailsAdmin
62
78
  message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.error')}</strong>: #{e}".freeze
63
79
  end
64
80
 
65
- render text: message
81
+ render plain: message
66
82
  end
67
83
  end
68
84
  end
@@ -141,7 +157,7 @@ module RailsAdmin
141
157
  message = "<strong>#{I18n.t('admin.actions.multiple_file_upload_collection.error')}</strong>: #{e}"
142
158
  end
143
159
 
144
- render text: message
160
+ render plain: message
145
161
  end
146
162
  end
147
163
  end
@@ -9,7 +9,8 @@ module RailsAdminMultipleFileUpload
9
9
  fields: [{}],
10
10
  thumbnail_size: :thumb,
11
11
  upload_gem: :paperclip,
12
- name_from_filename: true
12
+ name_from_filename: true,
13
+ set_order_as_max_plus_one: true
13
14
  }.merge(config || {})
14
15
  end
15
16
 
@@ -1,3 +1,3 @@
1
1
  module RailsAdminMultipleFileUpload
2
- VERSION = "0.4.2.1".freeze
2
+ VERSION = "0.4.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_multiple_file_upload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler