optimise
This commit is contained in:
parent
c53c76d7f3
commit
2ce25e340c
@ -15,7 +15,7 @@ import MVMCore
|
||||
var extraValidationBlock: (() -> Bool)?
|
||||
var formRules: [FormGroupRule]
|
||||
var delegate: FormHolderProtocol?
|
||||
var fieldMolecules: [FormFieldProtocol] = []
|
||||
var fieldMolecules: [String: FormFieldProtocol] = [:]
|
||||
var formActionMolecules: [FormActionFieldProtocol] = []
|
||||
var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:]
|
||||
|
||||
@ -24,9 +24,10 @@ import MVMCore
|
||||
}
|
||||
|
||||
public func insertMolecule(_ molecule: FormItemProtocol) {
|
||||
if var molecule = molecule as? FormFieldProtocol {
|
||||
if var molecule = molecule as? FormFieldProtocol,
|
||||
let fieldKey = molecule.fieldKey {
|
||||
molecule.baseValue = molecule.formFieldValue()
|
||||
fieldMolecules.append(molecule)
|
||||
fieldMolecules[fieldKey] = molecule
|
||||
}
|
||||
if let molecule = molecule as? FormActionFieldProtocol {
|
||||
formActionMolecules.append(molecule)
|
||||
@ -68,7 +69,7 @@ import MVMCore
|
||||
}
|
||||
|
||||
public func formField(for fieldKey: String) -> FormFieldProtocol? {
|
||||
return fieldMolecules.first(where: { $0.fieldKey == fieldKey })
|
||||
return fieldMolecules[fieldKey]
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,11 +85,10 @@ import MVMCore
|
||||
@objc func getFormParams( forGroup groupName: String) -> [String: Any] {
|
||||
var extraParam: [String: Any] = [:]
|
||||
MVMCoreDispatchUtility.performSyncBlock(onMainThread: {
|
||||
for molecule in self.fieldMolecules {
|
||||
if let formFieldName = molecule.fieldKey,
|
||||
let formFieldValue = molecule.formFieldValue(),
|
||||
for (fieldKey, molecule) in self.fieldMolecules {
|
||||
if let formFieldValue = molecule.formFieldValue(),
|
||||
groupName == molecule.groupName {
|
||||
extraParam[formFieldName] = formFieldValue
|
||||
extraParam[fieldKey] = formFieldValue
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user