From df1846c2954fa953ac6135d84664efb519e17796 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 22 Aug 2024 14:09:48 -0500 Subject: [PATCH] added parentMoleculeModelProtocol Signed-off-by: Matt Bruce --- .../Atomic/Atoms/Selectors/CheckboxesModel.swift | 5 ++++- .../Atomic/Atoms/Selectors/RadioBoxesModel.swift | 10 ++++------ .../Atomic/Atoms/Selectors/RadioButtonsModel.swift | 11 ++++------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxesModel.swift index b3988944..2eca2503 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxesModel.swift @@ -10,7 +10,8 @@ import Foundation import MVMCore import VDS -public class CheckboxesModel: MoleculeModelProtocol { +public class CheckboxesModel: MoleculeModelProtocol, ParentMoleculeModelProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -30,6 +31,8 @@ public class CheckboxesModel: MoleculeModelProtocol { public var checkboxes: [CheckboxLabelModel] + public var children: [any MoleculeModelProtocol] { checkboxes } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift index f1bf76f4..e2eac3c2 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift @@ -8,7 +8,8 @@ import MVMCore import VDS -public class RadioBoxesModel: FormFieldModel { +public class RadioBoxesModel: FormFieldModel, ParentMoleculeModelProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -17,6 +18,8 @@ public class RadioBoxesModel: FormFieldModel { public var boxes: [RadioBoxModel] + public var children: [any MoleculeModelProtocol] { boxes } + //-------------------------------------------------- // MARK: - Form Validation //-------------------------------------------------- @@ -74,11 +77,6 @@ public class RadioBoxesModel: FormFieldModel { guard super.isEqual(to: model), let model = model as? Self else { return false } return boxes == model.boxes } - - open override func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool { - guard super.isVisuallyEquivalent(to: model), let model = model as? Self else { return false } - return boxes == model.boxes - } } extension Array where Element == RadioBoxModel { diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonsModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonsModel.swift index 86e9f10c..36438e31 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonsModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonsModel.swift @@ -10,7 +10,7 @@ import Foundation import MVMCore import VDS -public class RadioButtonsModel: FormFieldModel { +public class RadioButtonsModel: FormFieldModel, ParentMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -19,6 +19,8 @@ public class RadioButtonsModel: FormFieldModel { public var radioButtons: [RadioButtonLabelModel] + public var children: [any MoleculeModelProtocol] { radioButtons } + //-------------------------------------------------- // MARK: - Form Validation //-------------------------------------------------- @@ -72,11 +74,6 @@ public class RadioButtonsModel: FormFieldModel { open override func isEqual(to model: any ModelComparisonProtocol) -> Bool { guard super.isEqual(to: model), let model = model as? Self else { return false } - return radioButtons == radioButtons - } - - open override func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool { - guard super.isVisuallyEquivalent(to: model), let model = model as? Self else { return false } - return radioButtons == radioButtons + return radioButtons == model.radioButtons } }