field errors start
This commit is contained in:
parent
e6e8b0c605
commit
db424ce04a
@ -156,6 +156,24 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
// MARK: - MoleculeDelegateProtocol
|
// 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) {
|
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
|
||||||
|
|
||||||
if let tableView = tableView {
|
if let tableView = tableView {
|
||||||
|
|||||||
@ -18,12 +18,8 @@ import UIKit
|
|||||||
@objc public var loadObject: MVMCoreLoadObject?
|
@objc public var loadObject: MVMCoreLoadObject?
|
||||||
public var model: MVMControllerModelProtocol?
|
public var model: MVMControllerModelProtocol?
|
||||||
public var pageModel: PageModelProtocol? {
|
public var pageModel: PageModelProtocol? {
|
||||||
get {
|
get { model }
|
||||||
return model
|
set { model = newValue as? MVMControllerModelProtocol }
|
||||||
}
|
|
||||||
set {
|
|
||||||
model = newValue as? MVMControllerModelProtocol
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set if this page is containted in a manager.
|
/// 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
|
/// A temporary iVar backer for delegateObject() until we change the protocol
|
||||||
public lazy var delegateObjectIVar: MVMCoreUIDelegateObject = {
|
public lazy var delegateObjectIVar: MVMCoreUIDelegateObject = {
|
||||||
return MVMCoreUIDelegateObject.create(withDelegateForAll: self)
|
MVMCoreUIDelegateObject.create(withDelegateForAll: self)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
public func delegateObject() -> DelegateObject? {
|
public func delegateObject() -> DelegateObject? { delegateObjectIVar }
|
||||||
return delegateObjectIVar
|
|
||||||
}
|
|
||||||
|
|
||||||
public var formValidator: FormValidator?
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
@ -52,7 +46,7 @@ import UIKit
|
|||||||
|
|
||||||
/// Checks if the screen width has changed
|
/// Checks if the screen width has changed
|
||||||
open func screenSizeChanged() -> Bool {
|
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]? {
|
open func modulesToListenFor() -> [String]? {
|
||||||
return loadObject?.requestParameters?.modules as? [String]
|
loadObject?.requestParameters?.modules as? [String]
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc open func responseJSONUpdated(notification: Notification) {
|
@objc open func responseJSONUpdated(notification: Notification) {
|
||||||
@ -405,7 +399,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
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) {
|
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||||
@ -424,6 +418,7 @@ import UIKit
|
|||||||
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
||||||
pageShown()
|
pageShown()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MVMCoreLoadDelegateProtocol
|
// MARK: - MVMCoreLoadDelegateProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -444,6 +439,9 @@ import UIKit
|
|||||||
open func addFormParams(_ requestParameters: MVMCoreRequestParameters) {
|
open func addFormParams(_ requestParameters: MVMCoreRequestParameters) {
|
||||||
formValidator?.addFormParams(requestParameters: requestParameters)
|
formValidator?.addFormParams(requestParameters: requestParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func handleFieldErrors(_ fieldErrors: [Any]?, loadObject: MVMCoreLoadObject) { }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MVMCoreActionDelegateProtocol
|
// MARK: - MVMCoreActionDelegateProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -484,7 +482,7 @@ import UIKit
|
|||||||
|
|
||||||
// Needed otherwise when subclassed, the extension gets called.
|
// Needed otherwise when subclassed, the extension gets called.
|
||||||
open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { }
|
open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { }
|
||||||
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil }
|
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { nil }
|
||||||
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) { }
|
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) { }
|
||||||
open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { }
|
open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { }
|
||||||
|
|
||||||
@ -514,7 +512,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func showRightPanelForScreenBeforeLaunchApp() -> Bool {
|
open func showRightPanelForScreenBeforeLaunchApp() -> Bool {
|
||||||
return loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false
|
loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make molecular
|
// TODO: make molecular
|
||||||
@ -610,6 +608,6 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func executeBehaviors<T>(_ behaviorBlock:(_ behavior:T)->Void) {
|
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 {
|
extension FormFieldProtocol {
|
||||||
var baseValue: AnyHashable? {
|
|
||||||
return nil
|
var baseValue: AnyHashable? { nil }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user