modeling entryField

This commit is contained in:
Kevin G Christiano 2020-01-22 14:51:27 -05:00
parent 1eec90e8e1
commit 86ce3c9d4f
12 changed files with 24 additions and 20 deletions

View File

@ -12,7 +12,7 @@
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String {
return "DateDropdownEntryField" return "dateDropdownEntryField"
} }
public var dateFormat: String? public var dateFormat: String?

View File

@ -8,13 +8,12 @@
@objcMembers public class DigitEntryFieldModel: TextEntryFieldModel { @objcMembers public class DigitEntryFieldModel: TextEntryFieldModel {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String {
return "DigitEntryField" return "digitTextField"
} }
public var digits: Int? public var digits: Int?

View File

@ -119,6 +119,7 @@ import UIKit
feedbackLabel.text = newFeedback feedbackLabel.text = newFeedback
feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true
entryFieldContainer.refreshUI() entryFieldContainer.refreshUI()
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
} }
} }

View File

@ -10,7 +10,6 @@ import Foundation
@objcMembers public class EntryFieldModel: MoleculeModelProtocol { @objcMembers public class EntryFieldModel: MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
@ -28,7 +27,9 @@ import Foundation
public var isSelected: Bool? public var isSelected: Bool?
public var fieldKey: String? public var fieldKey: String?
public var isValid: Bool?
public var isRequired: Bool?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys
//-------------------------------------------------- //--------------------------------------------------
@ -38,10 +39,12 @@ import Foundation
case title case title
case isDisabled case isDisabled
case feedback case feedback
case errorMessage case errorMessage = "errorMsg"
case isLocked case isLocked
case isSelected case isSelected
case fieldKey case fieldKey
case isValid
case isRequired = "required"
} }
//-------------------------------------------------- //--------------------------------------------------
@ -58,6 +61,7 @@ import Foundation
isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked) isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked)
isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected)
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid)
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
@ -70,5 +74,6 @@ import Foundation
try container.encodeIfPresent(isLocked, forKey: .isLocked) try container.encodeIfPresent(isLocked, forKey: .isLocked)
try container.encodeIfPresent(isSelected, forKey: .isSelected) try container.encodeIfPresent(isSelected, forKey: .isSelected)
try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
try container.encodeIfPresent(isValid, forKey: .isValid)
} }
} }

View File

@ -12,7 +12,7 @@
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String {
return "ItemDropdownEntryField" return "dropDown"
} }
public var options: [String]? public var options: [String]?

View File

@ -12,6 +12,6 @@
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String {
return "MdnEntryField" return "mdnEntryField"
} }
} }

View File

@ -308,9 +308,7 @@ import UIKit
break break
} }
let regex = model.regex ?? "" if let regex = model.regex, !regex.isEmpty {
if !regex.isEmpty {
validationBlock = { enteredValue in validationBlock = { enteredValue in
guard let value = enteredValue else { return false } guard let value = enteredValue else { return false }
return MVMCoreUIUtility.validate(value, withRegularExpression: regex) return MVMCoreUIUtility.validate(value, withRegularExpression: regex)

View File

@ -8,13 +8,12 @@
@objcMembers public class TextEntryFieldModel: EntryFieldModel { @objcMembers public class TextEntryFieldModel: EntryFieldModel {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String {
return "TextEntryField" return "textField"
} }
public var text: String? public var text: String?

View File

@ -29,6 +29,10 @@ extension MFViewController: MoleculeDelegateProtocol {
} }
return nil return nil
} }
@objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
}
} }
public extension MFViewController { public extension MFViewController {

View File

@ -35,12 +35,10 @@
@"footer": FooterView.class, @"footer": FooterView.class,
@"caretView": CaretView.class, @"caretView": CaretView.class,
@"caretLink": CaretButton.class, @"caretLink": CaretButton.class,
@"textField": MFTextField.class, @"digitTextField": DigitEntryField.class,
@"digitTextField": MFDigitTextField.class, @"textField": TextEntryField.class,
@"digitEntryField": DigitEntryField.class,
@"textEntryField": TextEntryField.class,
@"mdnEntryField": MdnEntryField.class, @"mdnEntryField": MdnEntryField.class,
@"itemDropdownEntryField": ItemDropdownEntryField.class, @"dropDown": ItemDropdownEntryField.class,
@"dateDropdownEntryField": DateDropdownEntryField.class, @"dateDropdownEntryField": DateDropdownEntryField.class,
@"checkbox": Checkbox.class, @"checkbox": Checkbox.class,
@"checkboxLabel": CheckboxWithLabelView.class, @"checkboxLabel": CheckboxWithLabelView.class,

View File

@ -33,7 +33,7 @@ import Foundation
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretButton.self, viewModelClass: CaretLinkModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretButton.self, viewModelClass: CaretLinkModel.self)
// Entry Field // Entry Field
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextFieldModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextEntryFieldModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MdnEntryField.self, viewModelClass: MdnEntryFieldModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MdnEntryField.self, viewModelClass: MdnEntryFieldModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DigitEntryField.self, viewModelClass: DigitEntryFieldModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DigitEntryField.self, viewModelClass: DigitEntryFieldModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ItemDropdownEntryField.self, viewModelClass: ItemDropdownEntryFieldModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ItemDropdownEntryField.self, viewModelClass: ItemDropdownEntryFieldModel.self)

View File

@ -123,7 +123,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
} }
// MARK: - MoleculeDelegateProtocol // MARK: - MoleculeDelegateProtocol
open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { open override func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
if let tableView = tableView { if let tableView = tableView {
let point = molecule.convert(molecule.bounds.origin, to: tableView) let point = molecule.convert(molecule.bounds.origin, to: tableView)
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {