sending source model to action

This commit is contained in:
Damodaram 2020-09-18 12:34:57 +05:30
parent 4923d6eac0
commit 81aa0da7cb
3 changed files with 7 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import UIKit
public var baseDropdownEntryFieldModel: BaseDropdownEntryFieldModel? { public var baseDropdownEntryFieldModel: BaseDropdownEntryFieldModel? {
return model as? BaseDropdownEntryFieldModel return model as? BaseDropdownEntryFieldModel
} }
var additionalData: [AnyHashable: Any]?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Property Observers // MARK: - Property Observers
@ -87,7 +88,7 @@ import UIKit
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData) super.set(with: model, delegateObject, additionalData)
self.additionalData = additionalData
guard let model = model as? BaseDropdownEntryFieldModel else { return } guard let model = model as? BaseDropdownEntryFieldModel else { return }
dropDownCaretView.setOptional(with: model.caretView, delegateObject, additionalData) dropDownCaretView.setOptional(with: model.caretView, delegateObject, additionalData)
@ -95,7 +96,9 @@ import UIKit
private func performDropdownAction() { private func performDropdownAction() {
if let actionModel = baseDropdownEntryFieldModel?.action, let actionMap = actionModel.toJSON() { if let actionModel = baseDropdownEntryFieldModel?.action, let actionMap = actionModel.toJSON() {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: baseDropdownEntryFieldModel?.toJSON(), delegateObject: delegateObject) var additionalData = self.additionalData ?? [:]
additionalData[KeySourceModel] = baseDropdownEntryFieldModel
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
} }
} }
} }

View File

@ -42,6 +42,7 @@ extern NSString * const KeyIsOpaque;
extern NSString * const KeyFieldKey; extern NSString * const KeyFieldKey;
extern NSString * const KeyRequired; extern NSString * const KeyRequired;
extern NSString * const KeySourceModel;
#pragma mark - Values #pragma mark - Values

View File

@ -40,6 +40,7 @@ NSString * const KeyTextColor = @"textColor";
NSString * const KeyIsHidden = @"isHidden"; NSString * const KeyIsHidden = @"isHidden";
NSString * const KeyIsOpaque = @"isOpaque"; NSString * const KeyIsOpaque = @"isOpaque";
NSString * const KeySourceModel = @"sourceModel";
#pragma mark - Values #pragma mark - Values