bullet_train-fields 1.7.7 → 1.7.9
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb92e312b511eae35234bf6c3d108ff574c324f81fe3481d1898dbade5a4f201
|
4
|
+
data.tar.gz: da4960abf158b18ddabe9f36a7b55e21cae746621df69d9c667ded90407ead3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a62350f9c67c7b0345e5784d2870e5ed69cca95e9f07aa4451a4bc988af64472e6558bc175982861c4133e034824444440d374e622cc78de15eecdad1f3c11
|
7
|
+
data.tar.gz: 5fbeb747d0698e005e3e75aedce0e7a38af6955e363c4a688b799a07feabaf9b89a9ff72d6e6e61c56517970898fc0830ec7f46042c8338c5559a8f0a61f0009
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { get } from "@rails/request.js"
|
2
3
|
|
3
4
|
export default class extends Controller {
|
4
5
|
static targets = [ "uploadButton", "hiddenField", "thumbnail" ]
|
@@ -56,16 +57,31 @@ export default class extends Controller {
|
|
56
57
|
this.removeThumbnail()
|
57
58
|
}
|
58
59
|
|
59
|
-
getCloudinarySignature(callback, paramsToSign) {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
60
|
+
async getCloudinarySignature(callback, paramsToSign) {
|
61
|
+
const queryData = new URLSearchParams();
|
62
|
+
|
63
|
+
for (const key in paramsToSign) {
|
64
|
+
queryData.append(`data[${key}]`, paramsToSign[key]);
|
65
|
+
}
|
66
|
+
|
67
|
+
try {
|
68
|
+
const response = await get(this.signaturesUrlValue, {
|
69
|
+
responseKind: 'text',
|
70
|
+
query: queryData
|
71
|
+
});
|
72
|
+
|
73
|
+
if (response.ok) {
|
74
|
+
const signature = await response.text;
|
75
|
+
console.log('signature', signature)
|
76
|
+
callback(signature);
|
77
|
+
} else {
|
78
|
+
console.log('Request failed:', response.statusText);
|
79
|
+
}
|
80
|
+
} catch (error) {
|
81
|
+
console.error('Request error:', error);
|
82
|
+
} finally {
|
83
|
+
console.log('complete');
|
84
|
+
}
|
69
85
|
}
|
70
86
|
|
71
87
|
handleWidgetResponse(error, response) {
|
@@ -85,8 +101,13 @@ export default class extends Controller {
|
|
85
101
|
}
|
86
102
|
|
87
103
|
addThumbnail(url) {
|
88
|
-
|
89
|
-
|
104
|
+
const imageElement = document.createElement('img');
|
105
|
+
imageElement.src = url;
|
106
|
+
imageElement.width = this.widthValue;
|
107
|
+
imageElement.height = this.heightValue;
|
108
|
+
imageElement.setAttribute(`data-${this.identifier}-target`, 'thumbnail');
|
109
|
+
|
110
|
+
this.uploadButtonTarget.prepend(imageElement);
|
90
111
|
|
91
112
|
// mark the image as present.
|
92
113
|
this.uploadButtonTarget.classList.add(this.thumbnailShownClass)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|