refactored to convertToXXXModel
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
d8c83f9230
commit
aeabee2666
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
}
|
||||
|
||||
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user