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:
Damodaram 2020-09-18 12:36:09 +05:30
commit 9bcd35eee1
6 changed files with 30 additions and 1 deletions

View File

@ -27,6 +27,11 @@ import UIKit
return caret
}()
public var baseDropdownEntryFieldModel: BaseDropdownEntryFieldModel? {
return model as? BaseDropdownEntryFieldModel
}
var additionalData: [AnyHashable: Any]?
//--------------------------------------------------
// MARK: - Property Observers
//--------------------------------------------------
@ -39,6 +44,14 @@ import UIKit
}
}
public var isTextChanged: Bool = false {
didSet {
if(isTextChanged) {
performDropdownAction()
}
}
}
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
@ -75,9 +88,17 @@ import UIKit
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
self.additionalData = additionalData
guard let model = model as? BaseDropdownEntryFieldModel else { return }
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)
}
}
}

View File

@ -12,6 +12,7 @@
//--------------------------------------------------
public var caretView: CaretViewModel?
public var action: ActionModelProtocol?
public override class var identifier: String {
return ""
@ -24,6 +25,7 @@
private enum CodingKeys: String, CodingKey {
case moleculeName
case caretView
case action
}
//--------------------------------------------------
@ -34,6 +36,7 @@
try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
caretView = try typeContainer.decodeIfPresent(CaretViewModel.self, forKey: .caretView)
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
}
public override func encode(to encoder: Encoder) throws {
@ -41,5 +44,6 @@
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(caretView, forKey: .caretView)
try container.encodeModelIfPresent(action, forKey: .action)
}
}

View File

@ -101,6 +101,7 @@ import UIKit
} else {
text = dateDropdownModel?.dateFormatter.string(from: date)
}
isTextChanged = true
}
@objc public override func dismissFieldInput(_ sender: Any?) {

View File

@ -138,6 +138,7 @@ extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource {
observeDropdownChange?(text ?? "", pickerData[row])
text = pickerData[row]
itemDropdownEntryFieldModel?.selectedIndex = row
isTextChanged = true
}
}

View File

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

View File

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