rails_admin_multiple_file_upload 0.5.0.1 → 0.5.1

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: b1ea913f8cfb693e6eb6ce4fbc4ae5aa7f811027
4
- data.tar.gz: b8ef6b8154e654de2ee5b90216733f329282ba22
3
+ metadata.gz: ca6dcc705629abcc17e40a1903635a6d61e05e23
4
+ data.tar.gz: bb7323449dd41a1040e1c717808871add957d16f
5
5
  SHA512:
6
- metadata.gz: ade0f3d65df254d58c35fc131e043628e23c586d98a03c2ab4d05616519cc2e99a634afaf11ab7de15d17d2b6ffbf20a5c059e5ed362915b9691f8f7d5346840
7
- data.tar.gz: dde4fc1f14b7988fa08070121fef63fddfc8518ddf8e5a4178dfc635a00e9bf265e5b586cf6f1da04a362bdf90815622c9046719c4c132bb15e0552de84ba988
6
+ metadata.gz: f381311096003b013ca388fe61342bb55ee152f6e253b667d1d894c1ee46cfe1b662a823421b975271a03c673850c3b132a50ff93b7e868f36da38c684db9b4e
7
+ data.tar.gz: 8c585fe2c20098a53dd8263d1293af2de64af142349d2cee70fc75e0f9a8c4a5466c34b9dfc74221c0d4a42c0059c6b4ccad3a8dbad227eddf2329b37512e4ef
data/README.md CHANGED
@@ -8,7 +8,7 @@ rails_admin + dropzone.js + mongoid(embedded)
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'rails_admin_multiple_file_upload', '~> 0.5.0'
11
+ gem 'rails_admin_multiple_file_upload', '~> 0.5.1'
12
12
 
13
13
  And then execute:
14
14
 
@@ -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.5.0.1".freeze
2
+ VERSION = "0.5.1".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.5.0.1
4
+ version: 0.5.1
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