anaconda 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 663eda1a92d9c737c550bb80b4dbe0635be9c76f
4
- data.tar.gz: f84f4bb950d328fc9de359ca67e5089cd5659c3b
3
+ metadata.gz: eced0a901d48850eb806a212759556c4f4ffc0dc
4
+ data.tar.gz: fd53ac40c05633eeb002b0de82709216847c4806
5
5
  SHA512:
6
- metadata.gz: f94bcab3e2bbcd472e26c273d9da195727fac3f8c58ad69b41650048b50fd617fe7665f1fe7d1cba8f08cba101a8e6c92a9d930c8676a8345379a7036ecc0445
7
- data.tar.gz: 8b32f114820d488f6bb1d5953dbff223b702c2d40a729180af1df2ac3033e0bcaf61be8451d7bc3c096dacf9369b34d5085a83fde3944dc64090f900999be89d
6
+ metadata.gz: 610eb68af269acc79b22a43b90782968c86585c582e3c648142176da8bf64820baacb99c40d3eb735738aefd0e3672bc1d8325f7a34e268b14fc9a5a6f43bd04
7
+ data.tar.gz: 9156173ec7fb018e8f4bac93495151f2804ee5c93717db1ca2b5d7840bc3083e663376acb5f0dfc29b443c4457d93ed4056a0e784187a777decba33b0bbf4149
@@ -136,6 +136,7 @@ We highly recommend the `figaro` gem [https://github.com/laserlemon/figaro](http
136
136
  * `upload_details_container` - An element id you would like the upload details located in. Defaults to `<resource>_<attribtue>_details` ex: `post_media_asset_details`
137
137
  * `auto_upload` - If set to true, upload will begin as soon as a file is selected. Default: *false*
138
138
  * `auto_submit` - If set to true, form will submit automatically when upload is completed. Useful when mixed with `auto_upload: true`, especially if the file field is the only field on the form. Default: *true* when auto_upload is false; *false* when auto_upload is true.
139
+ * `base_key` - If supplied, this will be the base_key used for this upload
139
140
 
140
141
  * Fields
141
142
 
@@ -151,8 +152,13 @@ We highly recommend the `figaro` gem [https://github.com/laserlemon/figaro](http
151
152
  The magic method is asset_url which will return a signed S3 URL if the file is stored with an ACL of `private` and will return a non-signed URL if the file is stored with public access.
152
153
 
153
154
  ## Changelog
155
+ * 0.9.8
156
+ * Add `base_key` option
157
+ * Change the way we identify hidden elements to work when we're using this in a nested form.
158
+
154
159
  * 0.9.7
155
160
  * Add percent sign to progress-percent div
161
+
156
162
  * 0.9.6
157
163
  * Fix `auto_upload` and `auto_submit` options.
158
164
 
@@ -239,11 +239,13 @@ class @AnacondaUploadField
239
239
  # DLog "will now fill form #{@upload_complete_form_to_fill}"
240
240
 
241
241
  DLog "#{@resource}_#{@attribute}_file_path"
242
-
243
- $( @element_id ).siblings( '#' + "#{@resource}_#{@attribute}_file_path" ).val( @key.replace("${filename}", @file.name) )
244
- $( @element_id ).siblings( '#' + "#{@resource}_#{@attribute}_filename" ).val( @file.name )
245
- $( @element_id ).siblings( '#' + "#{@resource}_#{@attribute}_size" ).val( @file.size )
246
- $( @element_id ).siblings( '#' + "#{@resource}_#{@attribute}_type" ).val( @file.type )
242
+ hyphenated_resource = @resource.replace("_", "-")
243
+ hyphenated_attribute = @attribute.replace("_", "-")
244
+
245
+ $( @element_id ).siblings( "input[data-#{hyphenated_resource}-#{hyphenated_attribute}-file-path]" ).val( @key.replace("${filename}", @file.name) )
246
+ $( @element_id ).siblings( "input[data#{hyphenated_resource}-#{hyphenated_attribute}-filename]" ).val( @file.name )
247
+ $( @element_id ).siblings( "input[data#{hyphenated_resource}-#{hyphenated_attribute}-size]" ).val( @file.size )
248
+ $( @element_id ).siblings( "input[data#{hyphenated_resource}-#{hyphenated_attribute}-type]" ).val( @file.type )
247
249
 
248
250
  @upload_in_progress = false;
249
251
  @upload_completed = true;
@@ -17,24 +17,26 @@ module Anaconda
17
17
  rescue
18
18
  raise AnacondaError, "attribute options not set for column #{anaconda_field_name}. Did you add `anaconda_for :#{anaconda_field_name}` to the model?"
19
19
  end
20
- options[:base_key] = instance.send(options[:base_key].to_s) if options[:base_key].kind_of? Symbol
20
+ if form_options[:base_key]
21
+ options[:base_key] = form_options[:base_key]
22
+ else
23
+ options[:base_key] = instance.send(options[:base_key].to_s) if options[:base_key].kind_of? Symbol
24
+ end
21
25
 
22
26
  uploader = S3Uploader.new(options)
23
27
 
24
28
  output += self.input_field "file", name: "file", id: element_id, as: :file, data: {url: uploader.url, form_data: uploader.fields.to_json, media_types: Anaconda.js_file_types}
25
29
  end
26
30
 
27
- output += self.hidden_field "#{anaconda_field_name}_filename".to_sym
28
- output += self.hidden_field "#{anaconda_field_name}_file_path".to_sym
29
- output += self.hidden_field "#{anaconda_field_name}_size".to_sym
30
- output += self.hidden_field "#{anaconda_field_name}_original_filename".to_sym
31
- output += self.hidden_field "#{anaconda_field_name}_stored_privately".to_sym
32
- output += self.hidden_field "#{anaconda_field_name}_type".to_sym
33
-
31
+ output += self.hidden_field "#{anaconda_field_name}_filename".to_sym, data: {"#{instance.class.to_s.underscore}_#{anaconda_field_name}_filename" => true}
32
+ output += self.hidden_field "#{anaconda_field_name}_file_path".to_sym, data: {"#{instance.class.to_s.underscore}_#{anaconda_field_name}_file_path" => true}
33
+ output += self.hidden_field "#{anaconda_field_name}_size".to_sym, data: {"#{instance.class.to_s.underscore}_#{anaconda_field_name}_size" => true}
34
+ output += self.hidden_field "#{anaconda_field_name}_original_filename".to_sym, data: {"#{instance.class.to_s.underscore}_#{anaconda_field_name}_original_filename" => true}
35
+ output += self.hidden_field "#{anaconda_field_name}_stored_privately".to_sym, data: {"#{instance.class.to_s.underscore}_#{anaconda_field_name}_stored_privately" => true}
36
+ output += self.hidden_field "#{anaconda_field_name}_type".to_sym, data: {"#{instance.class.to_s.underscore}_#{anaconda_field_name}_type" => true}
34
37
  # output += render(:template =>"anaconda/_uploader_form_for.html.haml", :locals => {resource: instance, options: options.merge(as: anaconda_field_name, form_options: form_options, element_id: element_id )}, layout: false).to_s
35
38
 
36
39
  options = options.merge(as: anaconda_field_name, form_options: form_options, element_id: element_id )
37
-
38
40
  output += <<-END
39
41
  <div id="#{instance.class.to_s.underscore}_#{anaconda_field_name}_details"></div>
40
42
 
@@ -1,5 +1,5 @@
1
1
  module Anaconda
2
2
  module Rails
3
- VERSION = "0.9.7"
3
+ VERSION = "0.9.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anaconda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben McFadden