diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift index 3cd6cd1d..87a755a6 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift @@ -36,7 +36,7 @@ open class Checkboxes: VDS.CheckboxGroup, VDSMoleculeViewProtocol { FormValidator.setupValidation(for: $0.checkbox, delegate: delegateObject?.formHolderDelegate) } - selectorModels = viewModel.checkboxes.toVDSCheckboxItemModel(surface: surface, + selectorModels = viewModel.checkboxes.convertToVDSCheckboxItemModel(surface: surface, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 7216ef54..88a0fb34 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -30,7 +30,7 @@ open class RadioBoxes: VDS.RadioBoxGroup, VDSMoleculeViewProtocol { public func viewModelDidUpdate() { boxes = viewModel.boxes surface = viewModel.surface - selectorModels = viewModel.boxes.toVDSRadioBoxModel(surface: surface) + selectorModels = viewModel.boxes.convertToVDSRadioBoxModel(surface: surface) FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift index 463afde3..f86d595f 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift @@ -16,20 +16,7 @@ import VDS public override static var identifier: String { "radioBoxes" } public var boxes: [RadioBoxModel] - - public var selectorModels: [VDS.RadioBoxGroup.RadioBoxItemModel] { - boxes.compactMap({ item in - var radioBox = RadioBoxGroup.RadioBoxItemModel() - radioBox.text = item.text - radioBox.subText = item.subText - radioBox.subTextRight = item.subTextRight - radioBox.surface = surface - radioBox.selected = item.selected - radioBox.strikethrough = item.strikethrough - radioBox.disabled = !(item.enabled && !item.readOnly) - return radioBox - }) - } + //-------------------------------------------------- // MARK: - Form Validation //-------------------------------------------------- @@ -83,3 +70,19 @@ import VDS try container.encode(boxes, forKey: .boxes) } } + +extension Array where Element == RadioBoxModel { + internal func convertToVDSRadioBoxModel(surface: Surface) -> [RadioBoxGroup.RadioBoxItemModel] { + compactMap({ item in + var radioBox = RadioBoxGroup.RadioBoxItemModel() + radioBox.text = item.text + radioBox.subText = item.subText + radioBox.subTextRight = item.subTextRight + radioBox.surface = surface + radioBox.selected = item.selected + radioBox.strikethrough = item.strikethrough + radioBox.disabled = !(item.enabled && !item.readOnly) + return radioBox + }) + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift index 24d1dee7..3e1d9204 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift @@ -33,7 +33,7 @@ open class RadioButtons: VDS.RadioButtonGroup, VDSMoleculeViewProtocol { surface = viewModel.surface radioButtons = viewModel.radioButtons - selectorModels = viewModel.radioButtons.toVDSRadioButtonItemModel(surface: surface, + selectorModels = viewModel.radioButtons.convertToVDSRadioButtonItemModel(surface: surface, delegateObject: delegateObject, additionalData: additionalData) FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift index faa13e60..0d09a97f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift @@ -36,5 +36,27 @@ import VDS self.label = label self.subTitle = subTitle } - +} + +extension Array where Element == CheckboxLabelModel { + internal func convertToVDSCheckboxItemModel(surface: Surface, + delegateObject: MVMCoreUIDelegateObject?, + additionalData: [AnyHashable: Any]?) -> [CheckboxGroup.CheckboxItemModel] { + return compactMap({ model in + var item = CheckboxGroup.CheckboxItemModel() + item.inputId = model.checkbox.fieldKey + item.labelText = model.label.text + if let attributes = model.label.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData) { + item.labelTextAttributes = attributes + } + item.childText = model.subTitle?.text + if let attributes = model.subTitle?.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData) { + item.childTextAttributes = attributes + } + item.surface = surface + item.selected = model.checkbox.selected + item.disabled = !(model.checkbox.enabled && !model.checkbox.readOnly) + return item + }) + } }