rails_admin_multiple_file_upload 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/assets/javascripts/rails_admin/rails_admin_multiple_file_upload.coffee +31 -0
- data/app/assets/stylesheets/rails_admin/rails_admin_multiple_file_upload.sass +3 -0
- data/app/views/rails_admin/main/multiple_file_upload.html.slim +3 -1
- data/lib/rails_admin_multiple_file_upload/action.rb +6 -1
- data/lib/rails_admin_multiple_file_upload/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 338e2b3e26b23d7481e436f48478f05b4b257307
|
4
|
+
data.tar.gz: 509e356566d12ed77242b056edb3ff4036174617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644cb48ae756bd9a60f7769541d5754f58ef38ef76c75edac8b965c0749b30c56ad59ca7cf3b36e1f55be01bf659aec777f79ce505a9903a53b704ef13345163
|
7
|
+
data.tar.gz: 2b64d8c73880b83cc632876762883dad9483b347ce983b0185d284e632ba9d7fe0ee5d6a0c70946222f7807555471d099d6b0edbb08f81994a585cf6292000bd
|
data/README.md
CHANGED
@@ -69,6 +69,14 @@ I18n:
|
|
69
69
|
|
70
70
|
```
|
71
71
|
|
72
|
+
## Copy and paste support
|
73
|
+
|
74
|
+
After clicking on grey area around dropzone block You can use clipboard.
|
75
|
+
You can paste screenshots (or any images if clipboard) and URL.
|
76
|
+
System add it to dropzone as image (if it`s a really image)
|
77
|
+
|
78
|
+
|
79
|
+
|
72
80
|
## TODO
|
73
81
|
|
74
82
|
* Documentation fixes
|
@@ -18,3 +18,34 @@ window.Dropzone.dictRemoveFile = "Удалить"
|
|
18
18
|
window.Dropzone.dictRemoveFileConfirmation = null
|
19
19
|
|
20
20
|
window.Dropzone.dictMaxFilesExceeded = "Загрузка невозможна. Достигнут максимум количества загружаемых файлов."
|
21
|
+
|
22
|
+
|
23
|
+
link_regexp = /^\s*https?:\/\/[^\s]+\s*$/
|
24
|
+
|
25
|
+
if window.FileReader
|
26
|
+
window.setCopyAndPasteFor = (el)->
|
27
|
+
dropzone = el.getElementsByClassName('dropzone')[0].dropzone
|
28
|
+
el.onpaste = (event) ->
|
29
|
+
items = (event.clipboardData or event.originalEvent.clipboardData).items
|
30
|
+
blob = null
|
31
|
+
i = 0
|
32
|
+
while i < items.length
|
33
|
+
if items[i].type.indexOf('image') == 0
|
34
|
+
blob = items[i].getAsFile()
|
35
|
+
|
36
|
+
else
|
37
|
+
if items[i].kind == "string"
|
38
|
+
items[i].getAsString (text)->
|
39
|
+
if link_regexp.test(text)
|
40
|
+
xhr = new XMLHttpRequest()
|
41
|
+
xhr.open("GET", text)
|
42
|
+
xhr.responseType = "blob"
|
43
|
+
xhr.onload = ()->
|
44
|
+
_blob = xhr.response
|
45
|
+
if _blob != null
|
46
|
+
dropzone.addFile(_blob)
|
47
|
+
xhr.send()
|
48
|
+
|
49
|
+
i++
|
50
|
+
if blob != null
|
51
|
+
dropzone.addFile(blob)
|
@@ -29,7 +29,7 @@ module RailsAdmin
|
|
29
29
|
if params['id'].present?
|
30
30
|
if request.get?
|
31
31
|
# @nodes = list_entries(@model_config, :index, nil, nil).sort { |a,b| a.lft <=> b.lft }
|
32
|
-
@files =
|
32
|
+
@files = []
|
33
33
|
render action: @action.template_name
|
34
34
|
|
35
35
|
elsif request.post?
|
@@ -40,6 +40,11 @@ module RailsAdmin
|
|
40
40
|
embedded_model_upload_field = params[:embedded_model_upload_field].to_s
|
41
41
|
embedded_model_upload_field = "image" if embedded_model_upload_field.blank?
|
42
42
|
|
43
|
+
if params[embedded_field][embedded_model_upload_field].original_filename == "undefined"
|
44
|
+
ext = params[embedded_field][embedded_model_upload_field].content_type.split("/").last
|
45
|
+
params[embedded_field][embedded_model_upload_field].original_filename = "#{Time.new.to_f*1_000_000}.#{ext}"
|
46
|
+
end
|
47
|
+
|
43
48
|
main_obj = @object
|
44
49
|
embedded = main_obj.send(embedded_field).new
|
45
50
|
embedded.send(embedded_model_upload_field + "=", params[embedded_field][embedded_model_upload_field])
|
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
|
+
version: 0.3.0
|
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-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|