glebtv-rails-uploader 0.10.1 → 0.11.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
  SHA256:
3
- metadata.gz: a65fb2766fd2ef01c7cb075ac96549741507a6f3406d83ca6a9bda634c85a4b6
4
- data.tar.gz: e03d0977ea91682aed4977bfc3e0deb2b1b36506962826238b7cd790d3071b73
3
+ metadata.gz: cbee7406edb183e54762046fe990e3c034249a9433af87a7d594154303e449d1
4
+ data.tar.gz: dbc19b1ea0c86c7173d5fce091f998b649a4941c1787cf9585163bd177a4e3a0
5
5
  SHA512:
6
- metadata.gz: b879eacb0c7d40e4484d5b8a5e7f7022f0bb00a4113c8c0282a21d93663d707204c3ec3286d53838065e88857603e9368bc3b67e409e4a4e356c81c0ce78599f
7
- data.tar.gz: 616d64f4e4d5e8d1283101057681a4fa6d80a50e39cbb8244229506e15f228295fe6dd89d7e377b7b94cbe0c353fd1f26d572b09ead526b38df0d0010fc8ff4f
6
+ metadata.gz: 515057b4db2313405c452c6d21b7795092e7fbbb29c9c51e0e8ea3bc28f7c5529825883a42cd3a84d399398283e855c7550581c3525630f7d0c73c1ba10a086b
7
+ data.tar.gz: a334f357b5302110bf2db28a9ce0fe1ca72d94d9912706628d4a0ff7cb334f4a456f5a3783061b8043cfba1b026474a45ff4e492d8fb760ce4aaf51b5f337740
@@ -18,7 +18,5 @@
18
18
  });
19
19
  }
20
20
  });
21
-
22
- container.disableSelection();
23
21
  });
24
- </script>
22
+ </script>
@@ -17,7 +17,7 @@ module Uploader
17
17
  module SingletonMethods
18
18
  # Join ActiveRecord object with uploaded file
19
19
  # Usage:
20
- #
20
+ #
21
21
  # class Article < ActiveRecord::Base
22
22
  # has_one :picture, :as => :assetable, :dependent => :destroy
23
23
  #
@@ -27,30 +27,30 @@ module Uploader
27
27
  #
28
28
  def fileuploads(*args)
29
29
  options = args.extract_options!
30
-
30
+
31
31
  class_attribute :fileuploads_options, :instance_writer => false
32
32
  self.fileuploads_options = options
33
-
33
+
34
34
  class_attribute :fileuploads_columns, :instance_writer => false
35
35
  self.fileuploads_columns = args.map(&:to_sym)
36
-
36
+
37
37
  unless self.is_a?(ClassMethods)
38
38
  include InstanceMethods
39
39
  extend ClassMethods
40
-
40
+
41
41
  after_save :fileuploads_update, :if => :fileupload_changed?
42
-
42
+
43
43
  fileuploads_columns.each { |asset| accepts_nested_attributes_for asset, :allow_destroy => true }
44
44
  end
45
45
  end
46
46
  end
47
-
47
+
48
48
  module ClassMethods
49
49
  # Update reflection klass by guid
50
50
  def fileupload_update(record_id, guid, method)
51
51
  fileupload_scope(method, guid).update_all(:assetable_id => record_id, :guid => nil)
52
52
  end
53
-
53
+
54
54
  # Find asset(s) by guid
55
55
  def fileupload_find(method, guid)
56
56
  query = fileupload_scope(method, guid)
@@ -60,7 +60,7 @@ module Uploader
60
60
  def fileupload_scope(method, guid)
61
61
  fileupload_klass(method).where(:guid => guid, :assetable_type => base_class.name.to_s)
62
62
  end
63
-
63
+
64
64
  # Find class by reflection
65
65
  def fileupload_klass(method)
66
66
  reflect_on_association(method.to_sym).klass
@@ -69,9 +69,12 @@ module Uploader
69
69
  def fileupload_multiple?(method)
70
70
  association = reflect_on_association(method.to_sym)
71
71
 
72
+ return true if association.is_a?(::Mongoid::Association::Referenced::HasMany)
73
+
72
74
  # many? for Mongoid, :collection? for AR
73
75
  method_name = association.respond_to?(:many?) ? :many? : :collection?
74
76
 
77
+ p association
75
78
  !!(association && association.send(method_name))
76
79
  end
77
80
 
@@ -81,26 +84,26 @@ module Uploader
81
84
  end
82
85
  end
83
86
  end
84
-
87
+
85
88
  module InstanceMethods
86
89
  # Generate unique key
87
90
  def fileupload_guid
88
91
  @fileupload_guid ||= Uploader.guid
89
92
  end
90
-
93
+
91
94
  def fileupload_guid=(value)
92
95
  @fileupload_changed = true unless value.blank?
93
96
  @fileupload_guid = value.blank? ? nil : value
94
97
  end
95
-
98
+
96
99
  def fileupload_changed?
97
100
  @fileupload_changed === true
98
101
  end
99
-
102
+
100
103
  def fileupload_multiple?(method)
101
104
  self.class.fileupload_multiple?(method)
102
105
  end
103
-
106
+
104
107
  # Find or build new asset object
105
108
  def fileupload_asset(method)
106
109
  if fileuploads_columns.include?(method.to_sym)
@@ -109,13 +112,13 @@ module Uploader
109
112
  asset
110
113
  end
111
114
  end
112
-
115
+
113
116
  def fileuploads_columns
114
117
  self.class.fileuploads_columns
115
118
  end
116
-
119
+
117
120
  protected
118
-
121
+
119
122
  def fileuploads_update
120
123
  fileuploads_columns.each do |method|
121
124
  self.class.fileupload_update(id, fileupload_guid, method)
@@ -1,3 +1,3 @@
1
1
  module Uploader
2
- VERSION = "0.10.1".freeze
2
+ VERSION = "0.11.0".freeze
3
3
  end
@@ -1,8 +1,9 @@
1
- .uploader-dnd-area {
1
+ .uploader-dnd-area {
2
2
  border: 1px dashed #ccc;
3
3
  padding: 15px 0px 15px 20px;
4
4
  color: #b1b1b1;
5
5
  overflow: hidden;
6
+ user-select: none;
6
7
  }
7
8
  .uploader-dnd-area:active {
8
9
  border-color: #d169d9;
@@ -13,7 +14,7 @@
13
14
  .uploader-dnd-hints {
14
15
  text-align: center;
15
16
  padding: 30px 0;
16
- overflow: hidden;
17
+ overflow: hidden;
17
18
  clear: both;
18
19
  }
19
20
  .uploader-dnd-hints .uploader-button {
@@ -37,7 +38,7 @@
37
38
  .uploader-button {
38
39
  display: inline-block;
39
40
  background: #972da0;
40
- background: linear-gradient(left top, left bottom, #982da1, #892891);
41
+ background: linear-gradient(left top, left bottom, #982da1, #892891);
41
42
  border: solid 1px #5f1c65;
42
43
  border-radius: 2px;
43
44
  -moz-border-radius: 2px;
@@ -53,14 +54,14 @@
53
54
  }
54
55
  .uploader-button:hover {
55
56
  background: #972da0;
56
- background: linear-gradient(top, #90179a, #7d2485);
57
+ background: linear-gradient(top, #90179a, #7d2485);
57
58
  -moz-box-shadow: 0 1px 3px #aaa;
58
59
  -webkit-box-shadow: 0 1px 3px #aaa;
59
60
  box-shadow: 0 1px 3px #aaa;
60
61
  }
61
62
  .uploader-button:active {
62
63
  background: #8e1898;
63
- background: linear-gradient(top, #8e1898, #7f2387);
64
+ background: linear-gradient(top, #8e1898, #7f2387);
64
65
  box-shadow: inset 0 0 4px #5f1c65;
65
66
  }
66
67
  .uploader-button::-moz-focus-inner {
@@ -125,7 +126,7 @@ input[disabled].uploader-button.gray {
125
126
  .uploader-dnd-area .attach_item:active {
126
127
  box-shadow: 0 0 5px #d2d2d2;
127
128
  border: solid 1px #cf63d8;
128
- }
129
+ }
129
130
 
130
131
  .uploader-dnd-area .attach_item a.del_btn {
131
132
  width: 19px;
@@ -156,7 +157,7 @@ input[disabled].uploader-button.gray {
156
157
  float: right;
157
158
  width: 130px;
158
159
  overflow: hidden;
159
- }
160
+ }
160
161
  .uploader-dnd-area .attach_item .fileName {
161
162
  color: #000;
162
163
  font-size: 14px;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-rails-uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Galeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-12-24 00:00:00.000000000 Z
13
+ date: 2019-08-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jquery-ui-rails
@@ -166,52 +166,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
- rubyforge_project:
170
- rubygems_version: 2.7.7
169
+ rubygems_version: 3.0.4
171
170
  signing_key:
172
171
  specification_version: 4
173
172
  summary: Rails file upload implementation with jQuery-File-Upload
174
173
  test_files:
175
- - spec/dummy/Rakefile
176
- - spec/dummy/app/models/picture.rb
177
- - spec/dummy/app/models/article.rb
178
- - spec/dummy/app/models/asset.rb
179
- - spec/dummy/app/views/layouts/application.html.erb
174
+ - spec/factories/assets.rb
175
+ - spec/factories/files/rails.png
176
+ - spec/factories/articles.rb
177
+ - spec/requests/attachments_controller_spec.rb
178
+ - spec/mongoid_spec.rb
179
+ - spec/dummy/app/controllers/application_controller.rb
180
180
  - spec/dummy/app/assets/javascripts/application.js
181
181
  - spec/dummy/app/assets/stylesheets/application.css
182
182
  - spec/dummy/app/uploaders/picture_uploader.rb
183
+ - spec/dummy/app/models/picture.rb
184
+ - spec/dummy/app/models/asset.rb
185
+ - spec/dummy/app/models/article.rb
183
186
  - spec/dummy/app/helpers/application_helper.rb
184
- - spec/dummy/app/controllers/application_controller.rb
187
+ - spec/dummy/app/views/layouts/application.html.erb
188
+ - spec/dummy/Rakefile
189
+ - spec/dummy/README.rdoc
185
190
  - spec/dummy/public/404.html
191
+ - spec/dummy/public/favicon.ico
186
192
  - spec/dummy/public/422.html
187
193
  - spec/dummy/public/500.html
188
- - spec/dummy/public/favicon.ico
194
+ - spec/dummy/config.ru
195
+ - spec/dummy/script/rails
189
196
  - spec/dummy/config/locales/en.yml
190
- - spec/dummy/config/application.rb
191
- - spec/dummy/config/routes.rb
192
- - spec/dummy/config/environments/test.rb
193
- - spec/dummy/config/environments/development.rb
194
- - spec/dummy/config/environments/production.rb
195
- - spec/dummy/config/environment.rb
196
- - spec/dummy/config/boot.rb
197
197
  - spec/dummy/config/database.yml
198
198
  - spec/dummy/config/initializers/mime_types.rb
199
- - spec/dummy/config/initializers/secret_token.rb
200
199
  - spec/dummy/config/initializers/backtrace_silencers.rb
201
200
  - spec/dummy/config/initializers/inflections.rb
202
201
  - spec/dummy/config/initializers/session_store.rb
202
+ - spec/dummy/config/initializers/secret_token.rb
203
203
  - spec/dummy/config/initializers/wrap_parameters.rb
204
- - spec/dummy/db/migrate/20120508093416_create_assets.rb
204
+ - spec/dummy/config/environment.rb
205
+ - spec/dummy/config/environments/development.rb
206
+ - spec/dummy/config/environments/production.rb
207
+ - spec/dummy/config/environments/test.rb
208
+ - spec/dummy/config/application.rb
209
+ - spec/dummy/config/boot.rb
210
+ - spec/dummy/config/routes.rb
205
211
  - spec/dummy/db/migrate/20120508093830_create_articles.rb
206
- - spec/dummy/script/rails
207
- - spec/dummy/config.ru
208
- - spec/dummy/README.rdoc
212
+ - spec/dummy/db/migrate/20120508093416_create_assets.rb
209
213
  - spec/fileuploads_spec.rb
210
- - spec/requests/attachments_controller_spec.rb
211
- - spec/factories/files/rails.png
212
- - spec/factories/assets.rb
213
- - spec/factories/articles.rb
214
- - spec/mongoid_spec.rb
215
- - spec/mongoid.yml
216
214
  - spec/spec_helper.rb
215
+ - spec/mongoid.yml
217
216
  - spec/uploader_spec.rb