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: e39376f831723e321d38d62294c048bc4f88480610a05553dac06a6925c21926
4
- data.tar.gz: 70c3d6bbfa9837ccfd713ed26d5f5f767830572fdcb5f560f9b3b86182b94cae
3
+ metadata.gz: cb92e312b511eae35234bf6c3d108ff574c324f81fe3481d1898dbade5a4f201
4
+ data.tar.gz: da4960abf158b18ddabe9f36a7b55e21cae746621df69d9c667ded90407ead3c
5
5
  SHA512:
6
- metadata.gz: 1a8e2dc1c437dd449e62a34cc4728fac75f43731296dfaeca5f4389c3c96efe3048dc87f87e78a607f9ab12be3f5ebe9c182aad9207fa62f79dd84d95b8acb64
7
- data.tar.gz: 7e46ed5537035f427e0ac788931057f915c6c7a28f2af778c7867ecbbec64bfda579cf9008c5c6649726d7078aeb04dbbef7175ce16718b5b1010f0575343a1c
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
- $.ajax({
61
- url: this.signaturesUrlValue,
62
- type: "GET",
63
- dataType: "text",
64
- data: {data: paramsToSign},
65
- complete: function() { console.log("complete") },
66
- success: function(signature, textStatus, xhr) { callback(signature) },
67
- error: function(xhr, status, error) { console.log(xhr, status, error) }
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
- var $imageElement = $(`<img src="${url}" width="${this.widthValue}" height="${this.heightValue}" data-${this.identifier}-target="thumbnail" />`)
89
- $(this.uploadButtonTarget).prepend($imageElement)
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)
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Fields
3
- VERSION = "1.7.7"
3
+ VERSION = "1.7.9"
4
4
  end
5
5
  end
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.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-23 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard