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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7d2ca40c78b3ef1fd33143dd4f104df6939748f
4
- data.tar.gz: 0061080f432bc5971ebaf2feb67312181f002d44
3
+ metadata.gz: 338e2b3e26b23d7481e436f48478f05b4b257307
4
+ data.tar.gz: 509e356566d12ed77242b056edb3ff4036174617
5
5
  SHA512:
6
- metadata.gz: c6f3773faa42661fe47a1156d02ac1444dc68f1c67fd2242bba37376eeb93e9d0dd62aec930b071e49212d96e99af8433784833febec499b3d19dd23d4c5a184
7
- data.tar.gz: 005e0dd2af0312b7bb81e29c854c366194f576e4dafca8363b26c4808588e7c686e50532a760bf000740801e12d0f7e4b82dfcfdff35aab4871aac880f0f11d5
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)
@@ -1,6 +1,9 @@
1
1
  @import 'dropzone/dropzone'
2
2
 
3
3
  .rails_admin_multiple_file_upload_block
4
+ .rails_admin_multiple_upload
5
+ background-color: #eee
6
+ padding: 20px
4
7
  .file_block_load_already
5
8
  max-width: 120px
6
9
  margin-left: 20px
@@ -68,4 +68,6 @@
68
68
  e.preventDefault();
69
69
  $("##{block_id} .dropzone")[0].dropzone.processQueue();
70
70
  return false
71
- })
71
+ });
72
+
73
+ setCopyAndPasteFor($("##{block_id}")[0]);
@@ -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])
@@ -1,3 +1,3 @@
1
1
  module RailsAdminMultipleFileUpload
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
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.2.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-02-08 00:00:00.000000000 Z
11
+ date: 2016-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler