field errors start
This commit is contained in:
parent
e6e8b0c605
commit
db424ce04a
@ -156,6 +156,24 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
// MARK: - MoleculeDelegateProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
public override func handleFieldErrors(_ fieldErrors: [Any]?, loadObject: MVMCoreLoadObject) {
|
||||
super.handleFieldErrors(fieldErrors, loadObject: loadObject)
|
||||
|
||||
for case let fieldError as [AnyHashable: Any] in fieldErrors ?? [] {
|
||||
|
||||
guard let fieldKey = fieldError["fieldKey"] as? String,
|
||||
let userError = fieldError["userMessage"] as? String,
|
||||
let entryFieldModel = formValidator?.fields[fieldKey] as? EntryFieldModel
|
||||
else { continue }
|
||||
|
||||
entryFieldModel.errorMessage = userError
|
||||
|
||||
DispatchQueue.main.async {
|
||||
let c = self.tableView.cellForRow(at: IndexPath(row: 0, section: 0))?.layoutSubviews()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
|
||||
|
||||
if let tableView = tableView {
|
||||
|
||||
@ -18,12 +18,8 @@ import UIKit
|
||||
@objc public var loadObject: MVMCoreLoadObject?
|
||||
public var model: MVMControllerModelProtocol?
|
||||
public var pageModel: PageModelProtocol? {
|
||||
get {
|
||||
return model
|
||||
}
|
||||
set {
|
||||
model = newValue as? MVMControllerModelProtocol
|
||||
}
|
||||
get { model }
|
||||
set { model = newValue as? MVMControllerModelProtocol }
|
||||
}
|
||||
|
||||
/// Set if this page is containted in a manager.
|
||||
@ -31,12 +27,10 @@ import UIKit
|
||||
|
||||
/// A temporary iVar backer for delegateObject() until we change the protocol
|
||||
public lazy var delegateObjectIVar: MVMCoreUIDelegateObject = {
|
||||
return MVMCoreUIDelegateObject.create(withDelegateForAll: self)
|
||||
MVMCoreUIDelegateObject.create(withDelegateForAll: self)
|
||||
}()
|
||||
|
||||
public func delegateObject() -> DelegateObject? {
|
||||
return delegateObjectIVar
|
||||
}
|
||||
public func delegateObject() -> DelegateObject? { delegateObjectIVar }
|
||||
|
||||
public var formValidator: FormValidator?
|
||||
|
||||
@ -52,7 +46,7 @@ import UIKit
|
||||
|
||||
/// Checks if the screen width has changed
|
||||
open func screenSizeChanged() -> Bool {
|
||||
return !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
||||
!MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -80,7 +74,7 @@ import UIKit
|
||||
}
|
||||
|
||||
open func modulesToListenFor() -> [String]? {
|
||||
return loadObject?.requestParameters?.modules as? [String]
|
||||
loadObject?.requestParameters?.modules as? [String]
|
||||
}
|
||||
|
||||
@objc open func responseJSONUpdated(notification: Notification) {
|
||||
@ -405,7 +399,7 @@ import UIKit
|
||||
}
|
||||
|
||||
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||
return MVMCoreGetterUtility.isOnIPad() ? UIInterfaceOrientationMask.all : UIInterfaceOrientationMask.portrait
|
||||
MVMCoreGetterUtility.isOnIPad() ? UIInterfaceOrientationMask.all : UIInterfaceOrientationMask.portrait
|
||||
}
|
||||
|
||||
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
@ -424,6 +418,7 @@ import UIKit
|
||||
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
||||
pageShown()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MVMCoreLoadDelegateProtocol
|
||||
//--------------------------------------------------
|
||||
@ -444,6 +439,9 @@ import UIKit
|
||||
open func addFormParams(_ requestParameters: MVMCoreRequestParameters) {
|
||||
formValidator?.addFormParams(requestParameters: requestParameters)
|
||||
}
|
||||
|
||||
public func handleFieldErrors(_ fieldErrors: [Any]?, loadObject: MVMCoreLoadObject) { }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MVMCoreActionDelegateProtocol
|
||||
//--------------------------------------------------
|
||||
@ -483,8 +481,8 @@ import UIKit
|
||||
}
|
||||
|
||||
// Needed otherwise when subclassed, the extension gets called.
|
||||
open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {}
|
||||
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil }
|
||||
open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { }
|
||||
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { nil }
|
||||
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) { }
|
||||
open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { }
|
||||
|
||||
@ -514,7 +512,7 @@ import UIKit
|
||||
}
|
||||
|
||||
open func showRightPanelForScreenBeforeLaunchApp() -> Bool {
|
||||
return loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false
|
||||
loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false
|
||||
}
|
||||
|
||||
// TODO: make molecular
|
||||
@ -610,6 +608,6 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
|
||||
func executeBehaviors<T>(_ behaviorBlock:(_ behavior:T)->Void) {
|
||||
model?.behaviors?.compactMap({ $0 as? T }).forEach { behaviorBlock($0) }
|
||||
model?.behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ public protocol FormFieldProtocol: FormItemProtocol {
|
||||
}
|
||||
|
||||
extension FormFieldProtocol {
|
||||
var baseValue: AnyHashable? {
|
||||
return nil
|
||||
}
|
||||
|
||||
var baseValue: AnyHashable? { nil }
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user