tessa 1.1.1 → 1.2.1
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 +4 -4
- data/lib/tessa/simple_form/asset_input.rb +44 -0
- data/lib/tessa/simple_form.rb +5 -0
- data/lib/tessa/version.rb +1 -1
- data/lib/tessa.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15c6d96fed1ca44a1fa33fb67071070c8728e9741fd06189a73de667143caba0
|
4
|
+
data.tar.gz: 2e186558c431ca8c919f248777e8765ffba15d1ff08c03e28b3f3ad864d611dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf25db44cd56243f10b22963acdb05bc86e4fb584446c171bf611307f0170cbf43fa53324d2acce63555b6d81b8982c5d72486fe8b17d29dc8e990d95ed4206
|
7
|
+
data.tar.gz: 8b92c3f631850f076e850c02aed81c611706509ebb4484d9141da1ec80c6734336e6380cacdcf9e4a73b20dc518b4c9fd9a87e3a494cfa099f1301a1427c7218
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Tessa
|
2
|
+
class AssetInput < SimpleForm::Inputs::Base
|
3
|
+
def input(wrapper_options=nil)
|
4
|
+
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
|
5
|
+
field = object.class.tessa_fields[attribute_name]
|
6
|
+
|
7
|
+
template.content_tag(
|
8
|
+
:div,
|
9
|
+
hidden_fields_for(object.public_send(attribute_name)),
|
10
|
+
"class" => "tessa-upload dropzone #{"multiple" if field.multiple?}",
|
11
|
+
"data-asset-field-prefix" => tessa_field_prefix,
|
12
|
+
"data-dropzone-options" => (options[:dropzone] || {}).to_json,
|
13
|
+
"data-tessa-params" => (options[:tessa_params] || {}).to_json,
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def tessa_field_prefix
|
20
|
+
@tessa_field_prefix ||= "#{lookup_model_names.reduce { |str, item| "#{str}[#{item}]" }}[#{attribute_name}]"
|
21
|
+
end
|
22
|
+
|
23
|
+
def hidden_fields_for(assets)
|
24
|
+
[*assets].collect do |asset|
|
25
|
+
template.hidden_field_tag(
|
26
|
+
"#{tessa_field_prefix}[#{asset.id}][action]",
|
27
|
+
"add",
|
28
|
+
"data-meta" => meta_for_asset(asset),
|
29
|
+
"id" => "tessa_asset_action_#{asset.id}"
|
30
|
+
)
|
31
|
+
end.join.html_safe
|
32
|
+
end
|
33
|
+
|
34
|
+
def meta_for_asset(asset)
|
35
|
+
{
|
36
|
+
"assetID" => asset.id,
|
37
|
+
"name" => asset.meta[:name],
|
38
|
+
"size" => asset.meta[:size],
|
39
|
+
"mimeType" => asset.meta[:mime_type],
|
40
|
+
"url" => asset.private_url,
|
41
|
+
}.to_json
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/tessa/version.rb
CHANGED
data/lib/tessa.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tessa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Powell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -167,6 +167,8 @@ files:
|
|
167
167
|
- lib/tessa/model/field.rb
|
168
168
|
- lib/tessa/rack_upload_proxy.rb
|
169
169
|
- lib/tessa/response_factory.rb
|
170
|
+
- lib/tessa/simple_form.rb
|
171
|
+
- lib/tessa/simple_form/asset_input.rb
|
170
172
|
- lib/tessa/upload.rb
|
171
173
|
- lib/tessa/upload/uploads_file.rb
|
172
174
|
- lib/tessa/version.rb
|