funicular-image-uploader 0.1.1 → 0.2.0
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/components/image_uploader_component.rb +20 -20
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7d96598dafc6000559e46d5566c57ce6c8f29fce11ad54bf42e8e50c8f1d66d
|
|
4
|
+
data.tar.gz: d7a265566e97afcc34e0cbd51f0956c31d03693a02aaf58f1a1f3379a9eb17eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c8b0991abf3be88c755af1f386bf45c4f71d60a59c08a0b56cf83480be24b69300941efc8fbe9fc9b4f0ce88e9e245f2bb42122cb3eb017c6cbcff6b6717c5a8
|
|
7
|
+
data.tar.gz: 060b7142d34e350ff73d868406427629dc2338b94b4cfb191f0336d2b601b07646ae335852bcfc556bf8e8511fd5e237e44eea846d0a41f0820dfc0e251710e8
|
|
@@ -84,12 +84,12 @@ class ImageUploaderComponent < Funicular::Component
|
|
|
84
84
|
emit_upload(result)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
def render
|
|
88
|
-
div(class: container_class) do
|
|
89
|
-
render_image
|
|
90
|
-
render_error
|
|
91
|
-
div(class: controls_class) do
|
|
92
|
-
input(
|
|
87
|
+
def render(h)
|
|
88
|
+
h.div(class: container_class) do
|
|
89
|
+
render_image(h)
|
|
90
|
+
render_error(h)
|
|
91
|
+
h.div(class: controls_class) do
|
|
92
|
+
h.input(
|
|
93
93
|
type: "file",
|
|
94
94
|
id: input_id,
|
|
95
95
|
accept: props[:accept] || "image/*",
|
|
@@ -97,18 +97,18 @@ class ImageUploaderComponent < Funicular::Component
|
|
|
97
97
|
class: input_class
|
|
98
98
|
)
|
|
99
99
|
if clearable?
|
|
100
|
-
button(type: "button", class: clear_button_class, onclick: -> { clear }) do
|
|
100
|
+
h.button(type: "button", class: clear_button_class, onclick: -> { clear }) do
|
|
101
101
|
props[:clear_label] || "Clear"
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
if props[:show_upload_button]
|
|
105
|
-
button(
|
|
105
|
+
h.button(
|
|
106
106
|
type: "button",
|
|
107
107
|
class: upload_button_class,
|
|
108
|
-
disabled: state
|
|
108
|
+
disabled: state[:uploading] || @selected_file.nil?,
|
|
109
109
|
onclick: -> { upload }
|
|
110
110
|
) do
|
|
111
|
-
state
|
|
111
|
+
state[:uploading] ? uploading_label : upload_label
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
end
|
|
@@ -117,33 +117,33 @@ class ImageUploaderComponent < Funicular::Component
|
|
|
117
117
|
|
|
118
118
|
private
|
|
119
119
|
|
|
120
|
-
def render_image
|
|
120
|
+
def render_image(h)
|
|
121
121
|
source = image_src
|
|
122
122
|
if source
|
|
123
|
-
div(class: preview_container_class) do
|
|
124
|
-
img(src: source, alt: alt_text, class: image_class)
|
|
123
|
+
h.div(class: preview_container_class) do
|
|
124
|
+
h.img(src: source, alt: alt_text, class: image_class)
|
|
125
125
|
end
|
|
126
126
|
elsif props[:placeholder]
|
|
127
|
-
div(class: placeholder_class) do
|
|
127
|
+
h.div(class: placeholder_class) do
|
|
128
128
|
props[:placeholder]
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
-
def render_error
|
|
134
|
-
return unless state
|
|
133
|
+
def render_error(h)
|
|
134
|
+
return unless state[:error] && props[:show_error] != false
|
|
135
135
|
|
|
136
|
-
div(class: error_class) { state
|
|
136
|
+
h.div(class: error_class) { state[:error] }
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def image_src
|
|
140
|
-
source = state
|
|
140
|
+
source = state[:preview_url] || state[:uploaded_url] || props[:src]
|
|
141
141
|
return nil if source.nil? || source.to_s == ""
|
|
142
142
|
return source if source.to_s.start_with?("blob:", "data:")
|
|
143
143
|
return source unless props[:cache_bust]
|
|
144
144
|
|
|
145
145
|
separator = source.to_s.include?("?") ? "&" : "?"
|
|
146
|
-
"#{source}#{separator}t=#{state
|
|
146
|
+
"#{source}#{separator}t=#{state[:cache_buster]}"
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
def input_id
|
|
@@ -165,7 +165,7 @@ class ImageUploaderComponent < Funicular::Component
|
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
def clearable?
|
|
168
|
-
props[:clearable] && (state
|
|
168
|
+
props[:clearable] && (state[:preview_url] || state[:uploaded_url] || props[:src])
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
def emit_select(file, preview_url)
|
metadata
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: funicular-image-uploader
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- HASUMI Hitoshi
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: funicular
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.3.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.3.0
|
|
12
26
|
executables: []
|
|
13
27
|
extensions: []
|
|
14
28
|
extra_rdoc_files: []
|