bullet_train-fields 1.7.21 → 1.7.23

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: 1966e7a0b35f9d33d71e51cd536f973c253f4912eb1efedba776b206635afaad
4
+ data.tar.gz: c626423751d8fd31ebdf4fd890ceeefbb0215ff8095c82c439bb3b4d3b3cdd89
5
5
  SHA512:
6
- metadata.gz: edb356f2db85eccebab33e1e2cd84d90cc28f054e7f2d0a227acce29dcd60696654764237e656c07dd929025fb4273227cca42b21065bb91a9e3f0af5768f1d1
7
- data.tar.gz: 502ac8748bf3a1eafeba3b88f8eb505627920911bae9f6872b86e568fd8773cc78a8866734b9a1c582cff514dee6471605021416ecd0cdeecede2e76a89e5729
6
+ metadata.gz: '049d73c3da83d9f2254f15265867ef01fffa8184160fb754f87136b9fc4e238137fda6cc1a9564b3e51cd739fb911cb86be0459536caf8d4bbdd617a506eb7f0'
7
+ data.tar.gz: 1627b3dbda3d11d6586ca4ebd2336a22d911e4effb829fe03a28260ceec582361c7b3e18841f920586d1ab50da64bd718e069ce7e64556b99ef50f7027465b1a
@@ -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.23"
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.23
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-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard