From b1fb3f075f9d28e6e22b1b496ea30200d9b0f2f8 Mon Sep 17 00:00:00 2001 From: Damodaram Date: Fri, 18 Sep 2020 12:54:31 +0530 Subject: [PATCH] updated additional data for selectors --- MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift | 4 +++- MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift | 6 +++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index 6e52e735..b6a87cd9 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -397,7 +397,9 @@ import MVMCore private func performCheckboxAction(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { if let actionMap = actionModel.toJSON() { - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: checkboxModel?.toJSON(), delegateObject: delegateObject) + var additionalDatatoUpdate = additionalData ?? [:] + additionalDatatoUpdate[KeySourceModel] = checkboxModel + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalDatatoUpdate, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift index 793348c9..46b4cef5 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift @@ -23,6 +23,7 @@ open class RadioBox: Control, MFButtonProtocol { public var subTextLabelHeightConstraint: NSLayoutConstraint? private var delegateObject: MVMCoreUIDelegateObject? + var additionalData: [AnyHashable: Any]? public var radioBoxModel: RadioBoxModel? { return model as? RadioBoxModel @@ -80,6 +81,7 @@ open class RadioBox: Control, MFButtonProtocol { super.set(with: model, delegateObject, additionalData) guard let model = model as? RadioBoxModel else { return } self.delegateObject = delegateObject + self.additionalData = additionalData label.text = model.text subTextLabel.text = model.subText isOutOfStock = model.strikethrough @@ -139,7 +141,9 @@ open class RadioBox: Control, MFButtonProtocol { isSelected = true radioBoxModel?.selected = isSelected if let actionModel = radioBoxModel?.action { - Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: radioBoxModel?.toJSON()) + var additionalData = self.additionalData ?? [:] + additionalData[KeySourceModel] = radioBoxModel + Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData) } layer.setNeedsDisplay() } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift index 30cc4bb8..9e18f936 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift @@ -30,6 +30,7 @@ import UIKit public var enabledColor: UIColor = .mvmBlack public var disabledColor: UIColor = .mvmCoolGray3 public var delegateObject: MVMCoreUIDelegateObject? + var additionalData: [AnyHashable: Any]? public var radioModel: RadioButtonModel? { return model as? RadioButtonModel @@ -100,7 +101,9 @@ import UIKit isSelected = !isSelected } if let actionModel = radioModel?.action, isSelected { - Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: radioModel?.toJSON()) + var additionalData = self.additionalData ?? [:] + additionalData[KeySourceModel] = radioModel + Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData) } _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) setNeedsDisplay() @@ -158,6 +161,7 @@ import UIKit public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) self.delegateObject = delegateObject + self.additionalData = additionalData guard let model = model as? RadioButtonModel else { return } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift index f921616f..e1502515 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift @@ -21,6 +21,7 @@ open class RadioSwatch: Control, MFButtonProtocol { private var maskLayer: CALayer? private var delegateObject: MVMCoreUIDelegateObject? + var additionalData: [AnyHashable: Any]? public var radioSwatchModel: RadioSwatchModel? { return model as? RadioSwatchModel @@ -60,6 +61,7 @@ open class RadioSwatch: Control, MFButtonProtocol { super.set(with: model, delegateObject, additionalData) guard let model = model as? RadioSwatchModel else { return } self.delegateObject = delegateObject + self.additionalData = additionalData bottomText.text = model.text isSelected = model.selected isEnabled = model.enabled @@ -121,7 +123,9 @@ open class RadioSwatch: Control, MFButtonProtocol { isSelected = true radioSwatchModel?.selected = isSelected if let actionModel = radioSwatchModel?.action { - Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: radioSwatchModel?.toJSON()) + var additionalData = self.additionalData ?? [:] + additionalData[KeySourceModel] = radioSwatchModel + Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData) } layer.setNeedsDisplay() }