rails_admin_multiple_file_upload 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/rails_admin/main/multiple_file_upload.html.slim +20 -20
- data/app/views/rails_admin/main/multiple_file_upload_collection.html.slim +27 -23
- data/lib/rails_admin_multiple_file_upload/action.rb +4 -4
- data/lib/rails_admin_multiple_file_upload/helper.rb +7 -7
- data/lib/rails_admin_multiple_file_upload/version.rb +1 -1
- data/rails_admin_multiple_file_upload.gemspec +2 -1
- data/release.sh +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31ee5459a7b85f88190c65dd22f367c08a9b8558
|
4
|
+
data.tar.gz: 9f2191857b686e202bde0b86cb59b72c77ef87b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b1f2b5837d25042d3f5fcf9b33d386527419f7705fe3080566e743bd1fa028c8449860b9c10812d5fd9784d57f90ce6c78cce65b3a1e58519b450b50189b5a1
|
7
|
+
data.tar.gz: 5bf02c72735d1b28132876e57713a6aee945b950dfea47dc03ff50da7a3251344b244fdc9ffa1648dd2d812dc4562c24de597c13167c1a9bee1e9495501e4ca1
|
@@ -9,20 +9,20 @@
|
|
9
9
|
ruby:
|
10
10
|
if f.is_a?(Hash)
|
11
11
|
next if f.empty?
|
12
|
-
child_field = f.keys.first
|
13
|
-
child_model_upload_field = f.values.first
|
12
|
+
child_field = f.keys.first.freeze
|
13
|
+
child_model_upload_field = f.values.first.freeze
|
14
14
|
child_model_upload_field = child_model_upload_field.last if child_model_upload_field.is_a?(Array)
|
15
15
|
|
16
|
-
i18n_path = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{child_field}.#{child_model_upload_field}"
|
17
|
-
i18n_path_default = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{child_field}"
|
16
|
+
i18n_path = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{child_field}.#{child_model_upload_field}".freeze
|
17
|
+
i18n_path_default = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{child_field}".freeze
|
18
18
|
|
19
|
-
link = "#multiple_file_upload_#{child_field}_#{child_model_upload_field}"
|
19
|
+
link = "#multiple_file_upload_#{child_field}_#{child_model_upload_field}".freeze
|
20
20
|
title = I18n.t(i18n_path, default: I18n.t(i18n_path_default))
|
21
21
|
|
22
22
|
else
|
23
|
-
i18n_path = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{f}.image"
|
24
|
-
i18n_path_default = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{f}"
|
25
|
-
link = "#multiple_file_upload_#{f}_image"
|
23
|
+
i18n_path = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{f}.image".freeze
|
24
|
+
i18n_path_default = "rails_admin.multiple_file_upload.#{@object.class.name.tableize}.#{f}".freeze
|
25
|
+
link = "#multiple_file_upload_#{f}_image".freeze
|
26
26
|
title = I18n.t(i18n_path, default: I18n.t(i18n_path_default))
|
27
27
|
end
|
28
28
|
|
@@ -33,28 +33,28 @@
|
|
33
33
|
- multiple_file_upload_fields.each do |f|
|
34
34
|
- if f.is_a?(Hash)
|
35
35
|
- next if f.empty?
|
36
|
-
- child_field = f.keys.first
|
37
|
-
- child_model_upload_field = f.values.first
|
36
|
+
- child_field = f.keys.first.freeze
|
37
|
+
- child_model_upload_field = f.values.first.freeze
|
38
38
|
- else
|
39
|
-
- child_field = f
|
40
|
-
- child_model_upload_field = "image"
|
39
|
+
- child_field = f.freeze
|
40
|
+
- child_model_upload_field = "image".freeze
|
41
41
|
|
42
42
|
- child_objects = @object.send(child_field)
|
43
|
-
- child_model_ordered_scope = ""
|
43
|
+
- child_model_ordered_scope = "".freeze
|
44
44
|
- if child_objects.respond_to?("sorted")
|
45
|
-
- child_model_ordered_scope = "sorted"
|
45
|
+
- child_model_ordered_scope = "sorted".freeze
|
46
46
|
|
47
47
|
- if child_objects.respond_to?("ordered") and child_model_ordered_scope.blank?
|
48
|
-
- child_model_ordered_scope = "ordered"
|
48
|
+
- child_model_ordered_scope = "ordered".freeze
|
49
49
|
|
50
|
-
.tab-pane{id="multiple_file_upload_#{child_field}_#{child_model_upload_field}"}
|
50
|
+
.tab-pane{id="multiple_file_upload_#{child_field}_#{child_model_upload_field}".freeze}
|
51
51
|
.row-fluid
|
52
|
-
- block_id = "rails_admin_multiple_upload_#{child_field}_#{child_model_upload_field}"
|
53
|
-
- button_id = "rails_admin_multiple_upload_#{child_field}_#{child_model_upload_field}_button"
|
54
|
-
.span12.rails_admin_multiple_upload{id=
|
52
|
+
- block_id = "rails_admin_multiple_upload_#{child_field}_#{child_model_upload_field}".freeze
|
53
|
+
- button_id = "rails_admin_multiple_upload_#{child_field}_#{child_model_upload_field}_button".freeze
|
54
|
+
.span12.rails_admin_multiple_upload{id=block_id}
|
55
55
|
= rails_admin_multiple_file_upload child_objects.send(child_model_ordered_scope).to_a, {child_field: child_field, child_model_upload_field: child_model_upload_field}
|
56
56
|
|
57
|
-
= button_tag "Загрузить", id: button_id
|
57
|
+
= button_tag "Загрузить".freeze, id: button_id
|
58
58
|
javascript:
|
59
59
|
$("##{block_id} .dropzone").dropzone({
|
60
60
|
paramName: "#{child_field}[#{child_model_upload_field}]",
|
@@ -6,43 +6,46 @@
|
|
6
6
|
ul.nav.nav-tabs
|
7
7
|
- if multiple_file_upload_fields.blank?
|
8
8
|
ruby:
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
_escape_tableize = @model.name.tableize.gsub("/", "_")
|
10
|
+
upload_field = "image".freeze
|
11
|
+
i18n_path = "rails_admin.multiple_file_upload_collection.#{@model.name.tableize}.#{upload_field}"v
|
12
|
+
i18n_path_default = "rails_admin.multiple_file_upload_collection.#{@model.name.tableize}".freeze
|
12
13
|
|
13
|
-
link = "#multiple_file_upload_collection_#{
|
14
|
-
title = I18n.t(i18n_path, default: I18n.t(i18n_path_default))
|
14
|
+
link = "#multiple_file_upload_collection_#{_escape_tableize}_#{upload_field}".freeze
|
15
|
+
title = I18n.t(i18n_path, default: I18n.t(i18n_path_default)).freeze
|
15
16
|
li
|
16
17
|
= link_to I18n.t(i18n_path, default: I18n.t(i18n_path_default)), link, title: title, "data-toggle" => "tab"
|
17
18
|
|
18
19
|
- else
|
19
20
|
- multiple_file_upload_fields.each do |f|
|
20
21
|
ruby:
|
21
|
-
upload_field = f
|
22
|
+
upload_field = f.freeze
|
23
|
+
_escape_tableize = @model.name.tableize.gsub("/", "_").freeze
|
22
24
|
|
23
|
-
i18n_path = "rails_admin.multiple_file_upload_collection.#{@model.name.tableize}.#{upload_field}"
|
24
|
-
i18n_path_default = "rails_admin.multiple_file_upload_collection.#{@model.name.tableize}"
|
25
|
-
|
26
|
-
link = "#multiple_file_upload_collection_#{
|
25
|
+
i18n_path = "rails_admin.multiple_file_upload_collection.#{@model.name.tableize}.#{upload_field}".freeze
|
26
|
+
i18n_path_default = "rails_admin.multiple_file_upload_collection.#{@model.name.tableize}".freeze
|
27
|
+
|
28
|
+
link = "#multiple_file_upload_collection_#{_escape_tableize}_#{upload_field}".freeze
|
27
29
|
title = I18n.t(i18n_path, default: I18n.t(i18n_path_default))
|
28
30
|
li
|
29
31
|
= link_to I18n.t(i18n_path, default: I18n.t(i18n_path_default)), link, title: title, "data-toggle" => "tab"
|
30
32
|
|
31
33
|
.tab-content
|
32
34
|
- if multiple_file_upload_fields.blank?
|
33
|
-
- upload_field = "image"
|
35
|
+
- upload_field = "image".freeze
|
34
36
|
- if @model.respond_to?("sorted")
|
35
37
|
- objects = @model.sorted.to_a
|
36
38
|
- elsif child_objects.respond_to?("ordered")
|
37
39
|
- objects = @model.ordered.to_a
|
38
|
-
-else
|
40
|
+
- else
|
39
41
|
- objects = @model.all.to_a
|
40
|
-
|
41
|
-
|
42
|
+
|
43
|
+
- _escape_tableize = @model.name.tableize.gsub("/", "_").freeze
|
44
|
+
.tab-pane{id="multiple_file_upload_collection_#{_escape_tableize}_#{upload_field}".freeze}
|
42
45
|
.row-fluid
|
43
|
-
- block_id = "rails_admin_multiple_upload_collection_#{
|
44
|
-
- button_id = "rails_admin_multiple_upload_collection_#{
|
45
|
-
.span12.rails_admin_multiple_upload_collection{id=
|
46
|
+
- block_id = "rails_admin_multiple_upload_collection_#{_escape_tableize}_#{upload_field}".freeze
|
47
|
+
- button_id = "rails_admin_multiple_upload_collection_#{_escape_tableize}_#{upload_field}_button".freeze
|
48
|
+
.span12.rails_admin_multiple_upload_collection{id=block_id}
|
46
49
|
= rails_admin_multiple_file_upload_collection objects, {upload_field: upload_field}
|
47
50
|
|
48
51
|
= button_tag "Загрузить", id: button_id
|
@@ -64,7 +67,8 @@
|
|
64
67
|
|
65
68
|
- else
|
66
69
|
- multiple_file_upload_fields.each do |f|
|
67
|
-
- upload_field = f
|
70
|
+
- upload_field = f.freeze
|
71
|
+
- _escape_tableize = @model.name.tableize.gsub("/", "_").freeze
|
68
72
|
- if @model.respond_to?("sorted")
|
69
73
|
- objects = @model.sorted.to_a
|
70
74
|
- elsif child_objects.respond_to?("ordered")
|
@@ -72,14 +76,14 @@
|
|
72
76
|
-else
|
73
77
|
- objects = @model.all.to_a
|
74
78
|
|
75
|
-
.tab-pane{id="
|
79
|
+
.tab-pane{id="multiple_file_upload_collection_#{_escape_tableize}_#{upload_field}".freeze}
|
76
80
|
.row-fluid
|
77
|
-
- block_id = "rails_admin_multiple_upload_collection_#{
|
78
|
-
- button_id = "rails_admin_multiple_upload_collection_#{
|
79
|
-
.span12.rails_admin_multiple_upload{id=
|
81
|
+
- block_id = "rails_admin_multiple_upload_collection_#{_escape_tableize}_#{upload_field}".freeze
|
82
|
+
- button_id = "rails_admin_multiple_upload_collection_#{_escape_tableize}_#{upload_field}_button".freeze
|
83
|
+
.span12.rails_admin_multiple_upload{id=block_id}
|
80
84
|
= rails_admin_multiple_file_upload_collection objects, {upload_field: upload_field}
|
81
85
|
|
82
|
-
= button_tag "Загрузить", id: button_id
|
86
|
+
= button_tag "Загрузить".freeze, id: button_id
|
83
87
|
javascript:
|
84
88
|
$("##{block_id} .dropzone").dropzone({
|
85
89
|
paramName: "#{upload_field}",
|
@@ -43,7 +43,7 @@ module RailsAdmin
|
|
43
43
|
_file = params[child_field][child_model_upload_field]
|
44
44
|
if ["undefined", "blob", '', nil].include?(_file.original_filename)
|
45
45
|
ext = ".#{_file.content_type.split("/").last}"
|
46
|
-
_file.original_filename = "#{(Time.new.to_f*1_000_000).to_i}#{ext}"
|
46
|
+
_file.original_filename = "#{(Time.new.to_f*1_000_000).to_i}#{ext}".freeze
|
47
47
|
else
|
48
48
|
ext = File.extname(_file.original_filename)
|
49
49
|
end
|
@@ -53,13 +53,13 @@ module RailsAdmin
|
|
53
53
|
child.name = File.basename(_file.original_filename, ext) if @conf.options[:name_from_filename]
|
54
54
|
child.send(child_model_upload_field + "=", _file)
|
55
55
|
if child.save
|
56
|
-
message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.success')}!</strong>"
|
56
|
+
message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.success')}!</strong>".freeze
|
57
57
|
else
|
58
|
-
message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.save_error')}</strong>: #{child.errors.full_messages}"
|
58
|
+
message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.save_error')}</strong>: #{child.errors.full_messages}".freeze
|
59
59
|
end
|
60
60
|
|
61
61
|
rescue Exception => e
|
62
|
-
message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.error')}</strong>: #{e}"
|
62
|
+
message = "<strong>#{I18n.t('admin.actions.multiple_file_upload.error')}</strong>: #{e}".freeze
|
63
63
|
end
|
64
64
|
|
65
65
|
render text: message
|
@@ -15,14 +15,14 @@ module RailsAdminMultipleFileUpload
|
|
15
15
|
m.send(_meth).to_i
|
16
16
|
end
|
17
17
|
end
|
18
|
-
id = "ns_#{rand(100_000_000..999_999_999)}"
|
18
|
+
id = "ns_#{rand(100_000_000..999_999_999)}".freeze
|
19
19
|
config = {
|
20
20
|
update_url: multiple_file_upload_path(model_name: @abstract_model),
|
21
21
|
child_field: opts[:child_field],
|
22
22
|
child_model_upload_field: opts[:child_model_upload_field] || "image",
|
23
23
|
child_model: @abstract_model.model.new.send(opts[:child_field]).new.class.name
|
24
24
|
}
|
25
|
-
content_tag(:div, rails_admin_multiple_file_upload_builder(files, config), id: id, class: 'rails_admin_multiple_file_upload')
|
25
|
+
content_tag(:div, rails_admin_multiple_file_upload_builder(files, config), id: id, class: 'rails_admin_multiple_file_upload'.freeze)
|
26
26
|
end
|
27
27
|
|
28
28
|
def rails_admin_multiple_file_upload_builder(files, config)
|
@@ -65,12 +65,12 @@ module RailsAdminMultipleFileUpload
|
|
65
65
|
|
66
66
|
def rails_admin_multiple_file_upload_collection(files, opts= {})
|
67
67
|
|
68
|
-
id = "ns_#{rand(100_000_000..999_999_999)}"
|
68
|
+
id = "ns_#{rand(100_000_000..999_999_999)}".freeze
|
69
69
|
config = {
|
70
70
|
update_url: multiple_file_upload_collection_path(model_name: @abstract_model),
|
71
71
|
upload_field: opts[:upload_field]
|
72
72
|
}
|
73
|
-
content_tag(:div, rails_admin_multiple_file_upload_collection_builder(files, config), id: id, class: 'rails_admin_multiple_file_upload_collection')
|
73
|
+
content_tag(:div, rails_admin_multiple_file_upload_collection_builder(files, config), id: id, class: 'rails_admin_multiple_file_upload_collection'.freeze)
|
74
74
|
end
|
75
75
|
|
76
76
|
def rails_admin_multiple_file_upload_collection_builder(files, config)
|
@@ -81,21 +81,21 @@ module RailsAdminMultipleFileUpload
|
|
81
81
|
if multiple_file_upload_paperclip?
|
82
82
|
if ef.send(_upload_field + "_content_type") =~ /\Aimage/
|
83
83
|
file_url = ef.send(_upload_field).url(multiple_file_upload_thumbnail_size)
|
84
|
-
_ret << content_tag(:span, image_tag(file_url), class: "file_block_load_already")
|
84
|
+
_ret << content_tag(:span, image_tag(file_url), class: "file_block_load_already".freeze)
|
85
85
|
|
86
86
|
else
|
87
87
|
if ef.respond_to?(:name)
|
88
88
|
file_name = ef.name
|
89
89
|
end
|
90
90
|
file_name = ef.send(_upload_field + "_file_name") if file_name.blank?
|
91
|
-
_ret << content_tag(:span, link_to(ef.name), class: "file_block_load_already")
|
91
|
+
_ret << content_tag(:span, link_to(ef.name), class: "file_block_load_already".freeze)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
95
95
|
ret << content_tag(:div, _ret.join.html_safe)
|
96
96
|
ret << content_tag(:div, "", class: "clearfix")
|
97
97
|
@object = @abstract_model.model.new
|
98
|
-
ret << rails_admin_form_for(@object, url: config[:update_url], html: {method: :post, multipart: true, class: "form-horizontal denser dropzone"})do |f|
|
98
|
+
ret << rails_admin_form_for(@object, url: config[:update_url], html: {method: :post, multipart: true, class: "form-horizontal denser dropzone".freeze})do |f|
|
99
99
|
_ret = []
|
100
100
|
_ret << hidden_field_tag(:upload_field, _upload_field)
|
101
101
|
_ret.join.html_safe
|
@@ -8,9 +8,10 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = RailsAdminMultipleFileUpload::VERSION
|
9
9
|
gem.authors = ["Alexander Kiseliev"]
|
10
10
|
gem.email = ["i43ack@gmail.com"]
|
11
|
+
|
11
12
|
gem.description = %q{Rails admin multiple file upload with AJAX and DnD}
|
12
13
|
gem.summary = %q{Interface for uploading files for rails_admin}
|
13
|
-
gem.homepage = "https://github.com/
|
14
|
+
gem.homepage = "https://github.com/red-rocks/rails_admin_multiple_file_upload"
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/release.sh
CHANGED
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.
|
4
|
+
version: 0.4.2
|
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-
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- lib/rails_admin_multiple_file_upload/version.rb
|
95
95
|
- rails_admin_multiple_file_upload.gemspec
|
96
96
|
- release.sh
|
97
|
-
homepage: https://github.com/
|
97
|
+
homepage: https://github.com/red-rocks/rails_admin_multiple_file_upload
|
98
98
|
licenses: []
|
99
99
|
metadata: {}
|
100
100
|
post_install_message:
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.4.
|
116
|
+
rubygems_version: 2.4.8
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Interface for uploading files for rails_admin
|