Merge branch 'feature/taggingForDropdown' into feature/taggingForSelectors
* feature/taggingForDropdown: sending source model to action updated based on review comments tagging changes implemented
This commit is contained in:
commit
9bcd35eee1
@ -27,6 +27,11 @@ import UIKit
|
|||||||
return caret
|
return caret
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
public var baseDropdownEntryFieldModel: BaseDropdownEntryFieldModel? {
|
||||||
|
return model as? BaseDropdownEntryFieldModel
|
||||||
|
}
|
||||||
|
var additionalData: [AnyHashable: Any]?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Property Observers
|
// MARK: - Property Observers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -39,6 +44,14 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var isTextChanged: Bool = false {
|
||||||
|
didSet {
|
||||||
|
if(isTextChanged) {
|
||||||
|
performDropdownAction()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -75,9 +88,17 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func performDropdownAction() {
|
||||||
|
if let actionModel = baseDropdownEntryFieldModel?.action, let actionMap = actionModel.toJSON() {
|
||||||
|
var additionalData = self.additionalData ?? [:]
|
||||||
|
additionalData[KeySourceModel] = baseDropdownEntryFieldModel
|
||||||
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var caretView: CaretViewModel?
|
public var caretView: CaretViewModel?
|
||||||
|
public var action: ActionModelProtocol?
|
||||||
|
|
||||||
public override class var identifier: String {
|
public override class var identifier: String {
|
||||||
return ""
|
return ""
|
||||||
@ -24,6 +25,7 @@
|
|||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case caretView
|
case caretView
|
||||||
|
case action
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -34,6 +36,7 @@
|
|||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
caretView = try typeContainer.decodeIfPresent(CaretViewModel.self, forKey: .caretView)
|
caretView = try typeContainer.decodeIfPresent(CaretViewModel.self, forKey: .caretView)
|
||||||
|
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
@ -41,5 +44,6 @@
|
|||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(caretView, forKey: .caretView)
|
try container.encode(caretView, forKey: .caretView)
|
||||||
|
try container.encodeModelIfPresent(action, forKey: .action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,7 @@ import UIKit
|
|||||||
} else {
|
} else {
|
||||||
text = dateDropdownModel?.dateFormatter.string(from: date)
|
text = dateDropdownModel?.dateFormatter.string(from: date)
|
||||||
}
|
}
|
||||||
|
isTextChanged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override func dismissFieldInput(_ sender: Any?) {
|
@objc public override func dismissFieldInput(_ sender: Any?) {
|
||||||
|
|||||||
@ -138,6 +138,7 @@ extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource {
|
|||||||
observeDropdownChange?(text ?? "", pickerData[row])
|
observeDropdownChange?(text ?? "", pickerData[row])
|
||||||
text = pickerData[row]
|
text = pickerData[row]
|
||||||
itemDropdownEntryFieldModel?.selectedIndex = row
|
itemDropdownEntryFieldModel?.selectedIndex = row
|
||||||
|
isTextChanged = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user