updated formFieldValue to look for enabled property

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2021-12-16 10:48:16 -06:00
parent 3137c1fead
commit 5233777a25
8 changed files with 24 additions and 6 deletions

View File

@ -28,6 +28,7 @@
/// Returns the fieldValue of the selected box, otherwise the text of the selected box. /// Returns the fieldValue of the selected box, otherwise the text of the selected box.
public func formFieldValue() -> AnyHashable? { public func formFieldValue() -> AnyHashable? {
guard enabled else { return nil }
let selectedBox = boxes.first { (box) -> Bool in let selectedBox = boxes.first { (box) -> Bool in
return box.selected return box.selected
} }

View File

@ -118,7 +118,8 @@ import UIKit
} }
public func formFieldValue() -> AnyHashable? { public func formFieldValue() -> AnyHashable? {
radioModel?.fieldValue guard let radioModel = radioModel, radioModel.enabled else { return nil }
return radioModel.fieldValue
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -57,7 +57,10 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
// MARK: - Validation // MARK: - Validation
//-------------------------------------------------- //--------------------------------------------------
public func formFieldValue() -> AnyHashable? { fieldValue } public func formFieldValue() -> AnyHashable? {
guard enabled else { return nil }
return fieldValue
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Codec // MARK: - Codec

View File

@ -77,5 +77,8 @@
// MARK: - FormValidationFormFieldProtocol // MARK: - FormValidationFormFieldProtocol
extension RadioButtonSelectionHelper { extension RadioButtonSelectionHelper {
public func formFieldValue() -> AnyHashable? { selectedRadioButtonModel?.fieldValue } public func formFieldValue() -> AnyHashable? {
guard enabled else { return nil }
return selectedRadioButtonModel?.fieldValue
}
} }

View File

@ -27,6 +27,7 @@
/// Returns the fieldValue of the selected swatch, otherwise the text of selected swatch. /// Returns the fieldValue of the selected swatch, otherwise the text of selected swatch.
public func formFieldValue() -> AnyHashable? { public func formFieldValue() -> AnyHashable? {
guard enabled else { return nil }
let selectedSwatch = swatches.first { (swatch) -> Bool in let selectedSwatch = swatches.first { (swatch) -> Bool in
return swatch.selected return swatch.selected
} }

View File

@ -56,7 +56,10 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
// MARK: - Form Valdiation // MARK: - Form Valdiation
//-------------------------------------------------- //--------------------------------------------------
public func formFieldValue() -> AnyHashable? { selected } public func formFieldValue() -> AnyHashable? {
guard enabled else { return nil }
return selected
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer

View File

@ -7,7 +7,7 @@
// //
@objcMembers open class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol { @objcMembers open class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol, EnableableModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
@ -18,8 +18,12 @@
public var peakingArrowColor: Color? public var peakingArrowColor: Color?
public var analyticsData: JSONValueDictionary? public var analyticsData: JSONValueDictionary?
public var fieldValue: String? public var fieldValue: String?
public var enabled: Bool = true
public func formFieldValue() -> AnyHashable? { fieldValue } public func formFieldValue() -> AnyHashable? {
guard enabled else { return nil }
return fieldValue
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys

View File

@ -47,6 +47,8 @@ import UIKit
} }
public func formFieldValue() -> AnyHashable? { public func formFieldValue() -> AnyHashable? {
guard enabled else { return nil }
guard selectable else { guard selectable else {
// Use visible item value, else index // Use visible item value, else index
if let fieldValue = molecules[index].formFieldValue() { if let fieldValue = molecules[index].formFieldValue() {