bullet_train-fields 1.7.21 → 1.7.22

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: 65e8278e03d3f13ed7cd648678a5990dd7ef21d7319c02e5c520ed065ae3040b
4
- data.tar.gz: 6eb678c9fd8fd7c3979cfe089cc37b4fb4a7559713f9519c82240ff611b97e68
3
+ metadata.gz: 7ffe79887ec099d98e485ae14820bb0d8720b99ade4d4e35cb606a79f6bb3f6f
4
+ data.tar.gz: 1c1f8eb5bdcf5c69d32ae375b5ef10bdfa99cc2fd6496ee05f398b7a30df753c
5
5
  SHA512:
6
- metadata.gz: edb356f2db85eccebab33e1e2cd84d90cc28f054e7f2d0a227acce29dcd60696654764237e656c07dd929025fb4273227cca42b21065bb91a9e3f0af5768f1d1
7
- data.tar.gz: 502ac8748bf3a1eafeba3b88f8eb505627920911bae9f6872b86e568fd8773cc78a8866734b9a1c582cff514dee6471605021416ecd0cdeecede2e76a89e5729
6
+ metadata.gz: 282a17d2aceede717184e349a2af4d8a24fbecf339429593d7d18e3d5662da04bd7fa79cf4d6b656d361a32e5fee87b9782c4ab9545f7effe0e7070af1707800
7
+ data.tar.gz: eda4dbb76391000a16e7b83c1225c3dbfb09b29d4c79ea9596e2569132cbbd1683386fae9ad725013b0ebc1cd2d6bf05436a3ee863641f4d8f7ee686ddfaec65
@@ -21,7 +21,7 @@ export default class extends Controller {
21
21
  this.disableFieldInputWhileRefreshing()
22
22
 
23
23
  const frame = this.element
24
- frame.src = this.constructNewUrlUpdatingField(field.name, field.value)
24
+ frame.src = this.constructNewUrlUpdatingField(field.name, this.getValueForField(field))
25
25
  }
26
26
 
27
27
  finishFrameUpdate(event) {
@@ -32,7 +32,7 @@ export default class extends Controller {
32
32
  }
33
33
 
34
34
  constructNewUrlUpdatingField(fieldName, fieldValue) {
35
- const url = new URL(this.element.src || window.location.href)
35
+ const url = new URL(window.location.href)
36
36
  url.searchParams.set(fieldName, fieldValue)
37
37
 
38
38
  return url.href
@@ -50,7 +50,7 @@ export default class extends Controller {
50
50
  storeFieldValues() {
51
51
  this.fieldTargets.forEach(field => {
52
52
  let storeUpdate = {}
53
- storeUpdate[field.name] = field.value
53
+ storeUpdate[field.name] = this.getValueForField(field)
54
54
  this.valuesStoreValue = Object.assign(this.valuesStoreValue, storeUpdate)
55
55
  })
56
56
  }
@@ -59,10 +59,26 @@ export default class extends Controller {
59
59
  this.fieldTargets.forEach(field => {
60
60
  const storedValue = this.valuesStoreValue[field.name]
61
61
  if (storedValue === undefined) { return }
62
- field.value = storedValue
62
+ this.setValueForField(field, storedValue)
63
63
  field.dispatchEvent(new Event('change')) // ensures cascading effects, including super-select validating against valid options
64
64
  })
65
65
 
66
66
  this.valuesStoreValue = {}
67
67
  }
68
+
69
+ getValueForField(field) {
70
+ if (field.type === "checkbox") {
71
+ return field.checked
72
+ }
73
+
74
+ return field.value
75
+ }
76
+
77
+ setValueForField(field, value) {
78
+ if (field.type === "checkbox") {
79
+ field.checked = value
80
+ }
81
+
82
+ field.value = value
83
+ }
68
84
  }
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Fields
3
- VERSION = "1.7.21"
3
+ VERSION = "1.7.22"
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.21
4
+ version: 1.7.22
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-08-20 00:00:00.000000000 Z
11
+ date: 2024-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard