This commit is contained in:
Kevin G Christiano 2020-12-23 12:20:38 -05:00
parent b84aeac3c1
commit 1e4963f58e
6 changed files with 52 additions and 10 deletions

View File

@ -98,6 +98,7 @@
0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */; };
0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */; };
0A849EFE246F1775009F277F /* RuleEqualsIgnoreCaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A849EFD246F1775009F277F /* RuleEqualsIgnoreCaseModel.swift */; };
0A9394892593AC9D00D2791F /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9394882593AC9D00D2791F /* UIView+Extension.swift */; };
0A9D091D2433796500D2E6C0 /* BarsCarouselIndicatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9D09172433796500D2E6C0 /* BarsCarouselIndicatorModel.swift */; };
0A9D091E2433796500D2E6C0 /* NumericCarouselIndicatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9D09182433796500D2E6C0 /* NumericCarouselIndicatorModel.swift */; };
0A9D091F2433796500D2E6C0 /* NumericIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9D09192433796500D2E6C0 /* NumericIndicatorView.swift */; };
@ -641,6 +642,7 @@
0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryFieldModel.swift; sourceTree = "<group>"; };
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = "<group>"; };
0A849EFD246F1775009F277F /* RuleEqualsIgnoreCaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleEqualsIgnoreCaseModel.swift; sourceTree = "<group>"; };
0A9394882593AC9D00D2791F /* UIView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; };
0A9D09172433796500D2E6C0 /* BarsCarouselIndicatorModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarsCarouselIndicatorModel.swift; sourceTree = "<group>"; };
0A9D09182433796500D2E6C0 /* NumericCarouselIndicatorModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumericCarouselIndicatorModel.swift; sourceTree = "<group>"; };
0A9D09192433796500D2E6C0 /* NumericIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumericIndicatorView.swift; sourceTree = "<group>"; };
@ -1386,6 +1388,7 @@
0AB764D224460FA400E7FE72 /* UIPickerView+Extension.swift */,
D2ED27E6254B0CE600A1C293 /* UIAlertActionStyle+Codable.swift */,
D2ED27E7254B0CE600A1C293 /* UIAlertControllerStyle+Extension.swift */,
0A9394882593AC9D00D2791F /* UIView+Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -2798,6 +2801,7 @@
0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */,
0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */,
D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */,
0A9394892593AC9D00D2791F /* UIView+Extension.swift in Sources */,
0A51F3E32475CB73002E08B6 /* LoadingSpinner.swift in Sources */,
BB2FB3BB247E7EBC00DF73CD /* TagCollectionViewCell.swift in Sources */,
012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */,

View File

@ -78,8 +78,8 @@ import UIKit
}
}
var errorMessage: String {
(entryFieldModel?.dynamicErrorMessage != nil ? entryFieldModel?.dynamicErrorMessage : entryFieldModel?.errorMessage) ?? ""
var errorMessage: String? {
entryFieldModel?.dynamicErrorMessage ?? entryFieldModel?.errorMessage
}
/// Toggles original or locked UI.
@ -320,6 +320,7 @@ import UIKit
feedback = model.feedback
isEnabled = model.enabled
entryFieldContainer.disableAllBorders = model.hideBorders
accessibilityIdentifier = model.accessibilityIdentifier ?? model.fieldKey
if let isLocked = model.locked {
self.isLocked = isLocked

View File

@ -19,6 +19,7 @@ import Foundation
}
public var backgroundColor: Color?
public var accessibilityIdentifier: String?
public var title: String?
public var feedback: String?
public var dynamicErrorMessage: String?
@ -49,6 +50,7 @@ import Foundation
private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
case accessibilityIdentifier
case title
case enabled
case feedback
@ -98,6 +100,7 @@ import Foundation
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage)
@ -119,6 +122,7 @@ import Foundation
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
try container.encodeIfPresent(title, forKey: .title)
try container.encodeIfPresent(feedback, forKey: .feedback)
try container.encodeIfPresent(text, forKey: .text)

View File

@ -0,0 +1,35 @@
//
// UIView+Extension.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 12/23/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
extension UIView {
public class func findByAccessibility(identifier: String) -> UIView? {
guard let window = UIApplication.shared.keyWindow else { return nil }
func findByID(view: UIView, _ id: String) -> UIView? {
if view.accessibilityIdentifier == id {
return view
}
for v in view.subviews {
if let a = findByID(view: v, id) {
return a
}
}
return nil
}
return findByID(view: window, identifier)
}
}

View File

@ -156,14 +156,6 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
// MARK: - MoleculeDelegateProtocol
//--------------------------------------------------
public override func handleFieldErrors(_ fieldErrors: [Any]?, loadObject: MVMCoreLoadObject) {
super.handleFieldErrors(fieldErrors, loadObject: loadObject)
DispatchQueue.main.async { [self] in
tableView.reloadData()
}
}
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
if let tableView = tableView {

View File

@ -452,6 +452,12 @@ import UIKit
entryFieldModel.dynamicErrorMessage = userError
entryFieldModel.isValid = true
entryFieldModel.text = ""
if let view = UIView.findByAccessibility(identifier: fieldKey), let moleculeView = view as? MoleculeViewProtocol {
DispatchQueue.main.async { [self] in
moleculeView.set(with: entryFieldModel, delegateObjectIVar, nil)
}
}
}
}