Textfield key updates: MOBFIRST-20088
This commit is contained in:
parent
10ed8bcb66
commit
7382d9acf5
@ -256,12 +256,12 @@ import UIKit
|
|||||||
title = model.title
|
title = model.title
|
||||||
feedback = model.feedback
|
feedback = model.feedback
|
||||||
errorMessage = model.errorMessage
|
errorMessage = model.errorMessage
|
||||||
isEnabled = model.isEnabled
|
isEnabled = model.enabled
|
||||||
|
|
||||||
if let isLocked = model.isLocked {
|
if let isLocked = model.locked {
|
||||||
self.isLocked = isLocked
|
self.isLocked = isLocked
|
||||||
|
|
||||||
} else if let isSelected = model.isSelected{
|
} else if let isSelected = model.selected {
|
||||||
self.isSelected = isSelected
|
self.isSelected = isSelected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol {
|
@objcMembers public class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol, EnableableModelProtocol {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
@ -23,9 +23,9 @@ import Foundation
|
|||||||
public var title: String?
|
public var title: String?
|
||||||
public var feedback: String?
|
public var feedback: String?
|
||||||
public var errorMessage: String = ""
|
public var errorMessage: String = ""
|
||||||
public var isEnabled: Bool = true
|
public var enabled: Bool = true
|
||||||
public var isLocked: Bool?
|
public var locked: Bool?
|
||||||
public var isSelected: Bool?
|
public var selected: Bool?
|
||||||
public var text: String?
|
public var text: String?
|
||||||
|
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
@ -52,14 +52,12 @@ import Foundation
|
|||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case title = "label"
|
case title
|
||||||
case isEnabled
|
case enabled
|
||||||
case feedback
|
case feedback
|
||||||
case errorMessage = "errorMsg"
|
case errorMessage
|
||||||
case isLocked
|
case locked
|
||||||
case isSelected
|
case selected
|
||||||
case isValid
|
|
||||||
case isRequired = "required"
|
|
||||||
case text
|
case text
|
||||||
case fieldKey
|
case fieldKey
|
||||||
case groupName
|
case groupName
|
||||||
@ -84,10 +82,9 @@ import Foundation
|
|||||||
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
||||||
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
|
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
|
||||||
errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) ?? ""
|
errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) ?? ""
|
||||||
isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? true
|
enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true
|
||||||
isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked)
|
locked = try typeContainer.decodeIfPresent(Bool.self, forKey: .locked)
|
||||||
isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected)
|
selected = try typeContainer.decodeIfPresent(Bool.self, forKey: .selected)
|
||||||
isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid)
|
|
||||||
text = try typeContainer.decodeIfPresent(String.self, forKey: .text)
|
text = try typeContainer.decodeIfPresent(String.self, forKey: .text)
|
||||||
|
|
||||||
baseValue = text
|
baseValue = text
|
||||||
@ -104,12 +101,11 @@ import Foundation
|
|||||||
try container.encodeIfPresent(title, forKey: .title)
|
try container.encodeIfPresent(title, forKey: .title)
|
||||||
try container.encodeIfPresent(feedback, forKey: .feedback)
|
try container.encodeIfPresent(feedback, forKey: .feedback)
|
||||||
try container.encode(errorMessage, forKey: .errorMessage)
|
try container.encode(errorMessage, forKey: .errorMessage)
|
||||||
try container.encode(isEnabled, forKey: .isEnabled)
|
try container.encode(enabled, forKey: .enabled)
|
||||||
try container.encode(isLocked, forKey: .isLocked)
|
try container.encode(locked, forKey: .locked)
|
||||||
try container.encode(isSelected, forKey: .isSelected)
|
try container.encode(selected, forKey: .selected)
|
||||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
|
||||||
try container.encodeIfPresent(isValid, forKey: .isValid)
|
|
||||||
try container.encodeIfPresent(text, forKey: .text)
|
try container.encodeIfPresent(text, forKey: .text)
|
||||||
|
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -308,14 +308,7 @@ import UIKit
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if let regex = model.regex, !regex.isEmpty {
|
defaultValidationBlock()
|
||||||
validationBlock = { enteredValue in
|
|
||||||
guard let value = enteredValue else { return false }
|
|
||||||
return MVMCoreUIUtility.validate(value, withRegularExpression: regex)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
defaultValidationBlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate
|
uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate
|
||||||
observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate
|
observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
public var enabledTextColor: Color?
|
public var enabledTextColor: Color?
|
||||||
public var disabledTextColor: Color?
|
public var disabledTextColor: Color?
|
||||||
public var type: EntryType?
|
public var type: EntryType?
|
||||||
public var regex: String?
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
@ -40,7 +39,6 @@
|
|||||||
case enabledTextColor
|
case enabledTextColor
|
||||||
case disabledTextColor
|
case disabledTextColor
|
||||||
case type
|
case type
|
||||||
case regex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -55,7 +53,6 @@
|
|||||||
enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledTextColor)
|
enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledTextColor)
|
||||||
disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor)
|
disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor)
|
||||||
type = try typeContainer.decodeIfPresent(EntryType.self, forKey: .type)
|
type = try typeContainer.decodeIfPresent(EntryType.self, forKey: .type)
|
||||||
regex = try typeContainer.decodeIfPresent(String.self, forKey: .regex)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
@ -67,6 +64,5 @@
|
|||||||
try container.encodeIfPresent(enabledTextColor, forKey: .enabledTextColor)
|
try container.encodeIfPresent(enabledTextColor, forKey: .enabledTextColor)
|
||||||
try container.encodeIfPresent(disabledTextColor, forKey: .disabledTextColor)
|
try container.encodeIfPresent(disabledTextColor, forKey: .disabledTextColor)
|
||||||
try container.encodeIfPresent(type, forKey: .type)
|
try container.encodeIfPresent(type, forKey: .type)
|
||||||
try container.encodeIfPresent(regex, forKey: .regex)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user