Merge branch 'bugfix/checkbox_formvalidation' into 'develop'

form validation fixes

See merge request BPHV_MIPS/mvm_core_ui!165
This commit is contained in:
Pfeil, Scott Robert 2019-10-28 16:41:44 -04:00
commit dffdc29eba
3 changed files with 13 additions and 12 deletions

View File

@ -19,7 +19,8 @@ import MVMCore
// Form Validation
var isRequired = false
var fieldKey: String?
var delegateObject: DelegateObject?
var groupName: String?
var delegateObject: MVMCoreUIDelegateObject?
public static let defaultHeightWidth: CGFloat = 18.0
@ -104,12 +105,8 @@ import MVMCore
layoutIfNeeded()
shapeLayer?.removeAllAnimations()
updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated)
if let delegate = delegateObject as? FormValidationProtocol {
delegate.formValidatorModel?()?.enableByValidation()
}
updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated)
FormValidator.enableByValidationWith(delegate: delegateObject?.formValidationProtocol)
updateAccessibilityLabel()
}
}
@ -211,7 +208,6 @@ import MVMCore
/// This will toggle the state of the Checkbox and execute the actionBlock if provided.
public func toggleAndAction() {
isSelected.toggle()
actionBlock?()
}
@ -409,7 +405,8 @@ import MVMCore
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
guard let dictionary = json else { return }
groupName = dictionary.optionalStringForKey("groupName")
if let fieldKey = dictionary[KeyFieldKey] as? String {
self.fieldKey = fieldKey
}
@ -463,7 +460,11 @@ import MVMCore
}
// MARK:- FormValidationProtocol
extension Checkbox: FormValidationProtocol {
extension Checkbox: FormValidationFormFieldProtocol {
public func formFieldGroupName() -> String? {
return groupName
}
public func isValidField() -> Bool {
return isRequired ? isSelected : true

View File

@ -22,7 +22,7 @@ const CGFloat SwitchKnobWidth = 20;
const CGFloat SwitchKnobHeight = 20;
const CGFloat SwitchShakeIntensity = 2;
@interface MVMCoreUISwitch () <FormValidationProtocol, MVMCoreUIViewConstrainingProtocol>
@interface MVMCoreUISwitch () <FormValidationFormFieldProtocol, MVMCoreUIViewConstrainingProtocol>
@property (weak, nonatomic) UIView *baseView;
@property (weak, nonatomic) UIView *knobView;

View File

@ -33,7 +33,7 @@ import UIKit
}
}
// MARK: - FormValidationProtocol
// MARK: - FormValidationFormFieldProtocol
extension RadioButtonModel: FormValidationFormFieldProtocol {
public func formFieldGroupName() -> String? {
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName