From 5233777a25448ccbaddbeac86c159700d9510d46 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 16 Dec 2021 10:48:16 -0600 Subject: [PATCH] updated formFieldValue to look for enabled property Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift | 1 + MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift | 3 ++- MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonModel.swift | 5 ++++- .../Atoms/Selectors/RadioButtonSelectionHelper.swift | 5 ++++- MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift | 1 + MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift | 5 ++++- MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift | 8 ++++++-- MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift | 2 ++ 8 files changed, 24 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift index 05d916e3..1614f3ec 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift @@ -28,6 +28,7 @@ /// Returns the fieldValue of the selected box, otherwise the text of the selected box. public func formFieldValue() -> AnyHashable? { + guard enabled else { return nil } let selectedBox = boxes.first { (box) -> Bool in return box.selected } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift index 1098ad3d..c6e1e049 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift @@ -118,7 +118,8 @@ import UIKit } public func formFieldValue() -> AnyHashable? { - radioModel?.fieldValue + guard let radioModel = radioModel, radioModel.enabled else { return nil } + return radioModel.fieldValue } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonModel.swift index 239a8d41..445fd2a3 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonModel.swift @@ -57,7 +57,10 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { // MARK: - Validation //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { fieldValue } + public func formFieldValue() -> AnyHashable? { + guard enabled else { return nil } + return fieldValue + } //-------------------------------------------------- // MARK: - Codec diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonSelectionHelper.swift index 71f7a828..41f709c0 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonSelectionHelper.swift @@ -77,5 +77,8 @@ // MARK: - FormValidationFormFieldProtocol extension RadioButtonSelectionHelper { - public func formFieldValue() -> AnyHashable? { selectedRadioButtonModel?.fieldValue } + public func formFieldValue() -> AnyHashable? { + guard enabled else { return nil } + return selectedRadioButtonModel?.fieldValue + } } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift index 47cb3051..3fb6ec19 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift @@ -27,6 +27,7 @@ /// Returns the fieldValue of the selected swatch, otherwise the text of selected swatch. public func formFieldValue() -> AnyHashable? { + guard enabled else { return nil } let selectedSwatch = swatches.first { (swatch) -> Bool in return swatch.selected } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index b4c4c906..22961e3f 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -56,7 +56,10 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { // MARK: - Form Valdiation //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { selected } + public func formFieldValue() -> AnyHashable? { + guard enabled else { return nil } + return selected + } //-------------------------------------------------- // MARK: - Initializer diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift index 1d55cec3..ce62d174 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift @@ -7,7 +7,7 @@ // -@objcMembers open class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol { +@objcMembers open class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -18,8 +18,12 @@ public var peakingArrowColor: Color? public var analyticsData: JSONValueDictionary? 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 diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index 494184bc..35d29020 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -47,6 +47,8 @@ import UIKit } public func formFieldValue() -> AnyHashable? { + guard enabled else { return nil } + guard selectable else { // Use visible item value, else index if let fieldValue = molecules[index].formFieldValue() {