bullet_train-fields 1.7.7 → 1.7.8

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: e75d6f9f8137d6b25bf218ad3842160e07e2c7311871850c3a2f8061f95a8d16
4
+ data.tar.gz: dc352bbf73529c13962388a8e6c901c714b2462747a53e2cf0f41b7799e25227
5
5
  SHA512:
6
- metadata.gz: 1a8e2dc1c437dd449e62a34cc4728fac75f43731296dfaeca5f4389c3c96efe3048dc87f87e78a607f9ab12be3f5ebe9c182aad9207fa62f79dd84d95b8acb64
7
- data.tar.gz: 7e46ed5537035f427e0ac788931057f915c6c7a28f2af778c7867ecbbec64bfda579cf9008c5c6649726d7078aeb04dbbef7175ce16718b5b1010f0575343a1c
6
+ metadata.gz: 8138c97d819636259443d8a76e8163223152a5ff4de38d4be9ca11db8842275352b2d1242e1039438ac7e111027ad08188c003b4c22d24b42971fa917e3d7a39
7
+ data.tar.gz: efdff41d4b4b909a97d7741ece2b204c6b80373793117d7b012699d3ae3249a4087552623637ddf7fbe065d522646381de221ce349f945df98953ad80000c6a4
@@ -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.8"
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.8
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-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard