tagging changes implemented

This commit is contained in:
Damodaram 2020-09-16 15:45:56 +05:30
parent 29c5aa3377
commit 483a50dd98
6 changed files with 33 additions and 0 deletions

View File

@ -27,6 +27,10 @@ import UIKit
return caret return caret
}() }()
public var baseDropdownEntryFieldModel: BaseDropdownEntryFieldModel? {
return model as? BaseDropdownEntryFieldModel
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Property Observers // MARK: - Property Observers
//-------------------------------------------------- //--------------------------------------------------
@ -39,6 +43,14 @@ import UIKit
} }
} }
public var isTextChanged: Bool = false {
didSet {
if(isTextChanged) {
performDropdownAction()
}
}
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//-------------------------------------------------- //--------------------------------------------------
@ -80,4 +92,15 @@ import UIKit
dropDownCaretView.setOptional(with: model.caretView, delegateObject, additionalData) dropDownCaretView.setOptional(with: model.caretView, delegateObject, additionalData)
} }
private func performDropdownAction() {
if let actionModel = baseDropdownEntryFieldModel?.action, var actionMap = actionModel.toJSON() {
if var analyticsData = actionMap[KeyAnalyticsData] as? JSONDictionary {
let taggedValue = (analyticsData[KeyAdobeTrackerLinkName] as? String ?? "") + (text ?? "")
analyticsData[KeyAdobeTrackerLinkName] = taggedValue
actionMap[KeyAnalyticsData] = analyticsData
}
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: delegateObject)
}
}
} }

View File

@ -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)
} }
} }

View File

@ -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?) {

View File

@ -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
} }
} }

View File

@ -42,6 +42,8 @@ extern NSString * const KeyIsOpaque;
extern NSString * const KeyFieldKey; extern NSString * const KeyFieldKey;
extern NSString * const KeyRequired; extern NSString * const KeyRequired;
extern NSString * const KeyAnalyticsData;
extern NSString * const KeyAdobeTrackerLinkName;
#pragma mark - Values #pragma mark - Values

View File

@ -40,6 +40,8 @@ NSString * const KeyTextColor = @"textColor";
NSString * const KeyIsHidden = @"isHidden"; NSString * const KeyIsHidden = @"isHidden";
NSString * const KeyIsOpaque = @"isOpaque"; NSString * const KeyIsOpaque = @"isOpaque";
NSString * const KeyAnalyticsData = @"analyticsData";
NSString * const KeyAdobeTrackerLinkName = @"vzwi.mvmapp.LinkName";
#pragma mark - Values #pragma mark - Values