some checks for analytics change
This commit is contained in:
parent
44dad67961
commit
68274505fb
@ -32,6 +32,8 @@ open class ItemDropdownEntryField: BaseDropdownEntryField {
|
|||||||
return model as? ItemDropdownEntryFieldModel
|
return model as? ItemDropdownEntryFieldModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var systemWillSetItem = false
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -109,8 +111,10 @@ open class ItemDropdownEntryField: BaseDropdownEntryField {
|
|||||||
pickerData = model.options
|
pickerData = model.options
|
||||||
setPickerDelegates(delegate: self)
|
setPickerDelegates(delegate: self)
|
||||||
|
|
||||||
if let pickerView = pickerView {
|
if let pickerView = pickerView, let index = model.selectedIndex {
|
||||||
self.pickerView(pickerView, didSelectRow: model.selectedIndex, inComponent: 0)
|
systemWillSetItem = true
|
||||||
|
self.pickerView(pickerView, didSelectRow: index, inComponent: 0)
|
||||||
|
systemWillSetItem = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +142,9 @@ extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource {
|
|||||||
observeDropdownChange?(text ?? "", pickerData[row])
|
observeDropdownChange?(text ?? "", pickerData[row])
|
||||||
text = pickerData[row]
|
text = pickerData[row]
|
||||||
itemDropdownEntryFieldModel?.selectedIndex = row
|
itemDropdownEntryFieldModel?.selectedIndex = row
|
||||||
performDropdownAction()
|
if !systemWillSetItem {
|
||||||
|
performDropdownAction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,11 +16,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var options: [String] = []
|
public var options: [String] = []
|
||||||
public var selectedIndex: Int = 0
|
public var selectedIndex: Int?
|
||||||
|
|
||||||
public override func formFieldValue() -> AnyHashable? {
|
public override func formFieldValue() -> AnyHashable? {
|
||||||
guard !options.isEmpty else { return nil }
|
guard !options.isEmpty,
|
||||||
return options[selectedIndex]
|
let index = selectedIndex
|
||||||
|
else { return nil }
|
||||||
|
|
||||||
|
return options[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -45,13 +48,16 @@
|
|||||||
if let selectedIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) {
|
if let selectedIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) {
|
||||||
self.selectedIndex = selectedIndex
|
self.selectedIndex = selectedIndex
|
||||||
}
|
}
|
||||||
baseValue = options.indices.contains(selectedIndex) ? options[selectedIndex] : nil
|
|
||||||
|
if let index = selectedIndex {
|
||||||
|
baseValue = options.indices.contains(index) ? options[index] : nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(options, forKey: .options)
|
try container.encode(options, forKey: .options)
|
||||||
try container.encode(options, forKey: .selectedIndex)
|
try container.encodeIfPresent(options, forKey: .selectedIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user