enhancements
This commit is contained in:
parent
15388abe2e
commit
e90b4c299e
@ -8,7 +8,6 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; };
|
||||
01004F322273972F00991ECC /* MFView+FormValidation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F312273972F00991ECC /* MFView+FormValidation.swift */; };
|
||||
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; };
|
||||
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; };
|
||||
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; };
|
||||
@ -171,7 +170,6 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
01004F2F22721C3800991ECC /* RadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = "<group>"; };
|
||||
01004F312273972F00991ECC /* MFView+FormValidation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+FormValidation.swift"; sourceTree = "<group>"; };
|
||||
0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = "<group>"; };
|
||||
0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = "<group>"; };
|
||||
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = "<group>"; };
|
||||
@ -325,10 +323,10 @@
|
||||
D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = "<group>"; };
|
||||
D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = "<group>"; };
|
||||
D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = "<group>"; };
|
||||
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
|
||||
D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = "<group>"; };
|
||||
D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = "<group>"; };
|
||||
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
|
||||
DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
|
||||
DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = "<group>"; };
|
||||
DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = "<group>"; };
|
||||
@ -578,7 +576,6 @@
|
||||
DBC4391622442196001AB423 /* CaretView.swift */,
|
||||
DBC4391722442197001AB423 /* DashLine.swift */,
|
||||
D29DF17E21E69E2E003B2FB9 /* MFView.h */,
|
||||
01004F312273972F00991ECC /* MFView+FormValidation.swift */,
|
||||
D29DF17F21E69E2E003B2FB9 /* MFView.m */,
|
||||
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
|
||||
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
|
||||
@ -899,7 +896,6 @@
|
||||
D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */,
|
||||
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */,
|
||||
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
|
||||
01004F322273972F00991ECC /* MFView+FormValidation.swift in Sources */,
|
||||
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
||||
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
|
||||
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
//
|
||||
// MFView+FormValidation.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 4/26/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
fileprivate struct FormValidatorHolder {
|
||||
static var formValidator: FormValidator?
|
||||
}
|
||||
|
||||
extension FormValidationProtocol where Self: MFView {
|
||||
|
||||
var formValidator: FormValidator? {
|
||||
get {
|
||||
return FormValidatorHolder.formValidator
|
||||
}
|
||||
set(newValue) {
|
||||
FormValidatorHolder.formValidator = newValue
|
||||
}
|
||||
}
|
||||
|
||||
func setupFormValidation(delegateObject: DelegateObject?) {
|
||||
if let delegateObject = delegateObject as? MVMCoreUIDelegateObject,
|
||||
let formValidationProtocol = delegateObject.formValidationProtocol {
|
||||
FormValidator.setupValidation(molecule: self, delegate:formValidationProtocol)
|
||||
formValidator = FormValidator.getFormValidatorFor(delegate:formValidationProtocol)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
|
||||
@property (nonatomic) BOOL isRequired;
|
||||
@property (nullable, strong, nonatomic) NSString *fieldKey;
|
||||
@property (nullable, strong, nonatomic) DelegateObject *delegate;
|
||||
@property (nullable, strong, nonatomic) MVMCoreUIDelegateObject *delegateObject;
|
||||
|
||||
@end
|
||||
|
||||
@ -61,7 +61,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
|
||||
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
|
||||
self.delegate = delegateObject;
|
||||
self.delegateObject = (MVMCoreUIDelegateObject *) delegateObject;
|
||||
self.fieldKey = [json stringForKey:KeyFieldKey];
|
||||
self.isRequired = [json boolForKey:KeyRequired];
|
||||
|
||||
@ -342,10 +342,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
[self.checkMark updateCheckSelected:NO animated:animated];
|
||||
}
|
||||
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(formValidationProtocol)] && [[self.delegate performSelector:@selector(formValidationProtocol)] respondsToSelector:@selector(formValidatorModel)]) {
|
||||
FormValidator *formValidator = [[self.delegate performSelector:@selector(formValidationProtocol)] performSelector:@selector(formValidatorModel)];
|
||||
[formValidator enableByValidation];
|
||||
}
|
||||
[FormValidator enableByValidationWithDelegate:((MVMCoreUIDelegateObject *)self.delegateObject).formValidationProtocol];
|
||||
}
|
||||
|
||||
- (void)setColor:(nullable UIColor *)color forState:(UIControlState)state {
|
||||
|
||||
@ -17,12 +17,9 @@ import Foundation
|
||||
var extraParam: [String: Any] = [:]
|
||||
MVMCoreDispatchUtility.performSyncBlock(onMainThread: {
|
||||
for molecule in self.molecules {
|
||||
if let formFieldName = molecule.formFieldName,
|
||||
let formFieldValue = molecule.formFieldValue,
|
||||
let fieldName = formFieldName(),
|
||||
let fieldValue = formFieldValue() {
|
||||
|
||||
extraParam[fieldName] = fieldValue
|
||||
if let formFieldName = molecule.formFieldName?(),
|
||||
let formFieldValue = molecule.formFieldValue?() {
|
||||
extraParam[formFieldName] = formFieldValue
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -19,19 +19,19 @@ import UIKit
|
||||
molecules.append(molecule)
|
||||
}
|
||||
|
||||
public static func getFormValidatorFor(delegate: FormValidationProtocol) -> FormValidator? {
|
||||
if let delegateFormValidatorModel = delegate.formValidatorModel,
|
||||
let validator = delegateFormValidatorModel() {
|
||||
return validator
|
||||
} else {
|
||||
return nil
|
||||
public static func enableByValidationWith(delegate: FormValidationProtocol?) {
|
||||
if let delegate = delegate {
|
||||
let formValidator = FormValidator.getFormValidatorFor(delegate: delegate)
|
||||
formValidator?.enableByValidation()
|
||||
}
|
||||
}
|
||||
|
||||
public static func getFormValidatorFor(delegate: FormValidationProtocol) -> FormValidator? {
|
||||
return delegate.formValidatorModel?()
|
||||
}
|
||||
|
||||
public static func setupValidation(molecule: UIView & FormValidationProtocol, delegate: FormValidationProtocol?) {
|
||||
if let delegateFormValidatorModel = delegate?.formValidatorModel,
|
||||
let validator = delegateFormValidatorModel() {
|
||||
|
||||
if let validator = delegate?.formValidatorModel?() {
|
||||
validator.delegate = delegate
|
||||
validator.insertMolecule(molecule)
|
||||
}
|
||||
|
||||
@ -81,7 +81,6 @@ import UIKit
|
||||
} else {
|
||||
radioButton.isSelected = !radioButton.isSelected
|
||||
}
|
||||
formValidator?.enableByValidation()
|
||||
}
|
||||
|
||||
func getColor( _ json: [AnyHashable: Any], _ key: String) -> UIColor? {
|
||||
|
||||
@ -17,6 +17,8 @@ import UIKit
|
||||
|
||||
var selectedRadioButton: RadioButton?
|
||||
var selectedValue: String?
|
||||
var delegateObject:MVMCoreUIDelegateObject?
|
||||
|
||||
|
||||
// MARK: - Inits
|
||||
public init() {
|
||||
@ -35,7 +37,8 @@ import UIKit
|
||||
selectedRadioButton?.radioButton.isSelected = false
|
||||
selectedRadioButton = radioButton
|
||||
selectedRadioButton?.radioButton.isSelected = true
|
||||
formValidator?.enableByValidation()
|
||||
|
||||
FormValidator.enableByValidationWith(delegate: self.delegateObject?.formValidationProtocol)
|
||||
}
|
||||
|
||||
open override func setupView() {
|
||||
@ -56,7 +59,7 @@ extension RadioButtonList: FormValidationProtocol {
|
||||
|
||||
// The Field name key value pair for sending to server
|
||||
@objc public func formFieldName() -> String? {
|
||||
return selectedRadioButton?.formFieldName()
|
||||
return json?.optionalStringForKey("fieldKey")
|
||||
}
|
||||
|
||||
// The Feild value key value paid for sending to server
|
||||
@ -78,7 +81,8 @@ extension RadioButtonList {
|
||||
return
|
||||
}
|
||||
|
||||
setupFormValidation(delegateObject: delegateObject)
|
||||
self.delegateObject = delegateObject
|
||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject.formValidationProtocol)
|
||||
|
||||
StackableViewController.remove(self.subviews)
|
||||
|
||||
|
||||
@ -33,8 +33,7 @@
|
||||
@"caretView": CaretView.class,
|
||||
@"caretButton": CaretButton.class,
|
||||
@"textField" : MFTextField.class,
|
||||
@"radioButtonList": RadioButtonList.class,
|
||||
@"radioButton": RadioButton.class,
|
||||
@"radioButton": RadioButtonList.class,
|
||||
@"checkbox" : MVMCoreUICheckBox.class
|
||||
} mutableCopy];
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user