Merge branch 'bugfix/release_fixes' into 'develop'

release fixes

See merge request BPHV_MIPS/mvm_core_ui!333
This commit is contained in:
Pan, Xinlei (Ryan) 2020-03-27 14:17:18 -04:00
commit 365b5f1bcd
2 changed files with 24 additions and 1 deletions

View File

@ -8,6 +8,7 @@
import Foundation
@objcMembers public class DropDownListItemModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
@ -17,6 +18,10 @@ import Foundation
public var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]
public var dropDown: ItemDropdownEntryFieldModel
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
/// Defaults to set
public override func setDefaults() {
super.setDefaults()
@ -24,14 +29,25 @@ import Foundation
line = LineModel(type: .none)
style = "sectionFooter"
}
//--------------------------------------------------
// MARK: - Functions
//--------------------------------------------------
public class func verify(dropdown: ItemDropdownEntryFieldModel, molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]) throws {
guard dropdown.options.count == molecules.count else {
throw MolecularError.countImbalance("dropdown.options.count is not equal to molecules.count")
}
}
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) {
public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) throws {
self.molecules = molecules
self.dropDown = dropDown
try Self.verify(dropdown: dropDown, molecules: molecules)
super.init()
}
@ -53,6 +69,7 @@ import Foundation
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
molecules = try typeContainer.decodeModels2DIfPresent(codingKey: .molecules) ?? [[]]
dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown)
try Self.verify(dropdown: dropDown, molecules: molecules)
try super.init(from: decoder)
}

View File

@ -1,6 +1,12 @@
import Foundation
public enum MolecularError: Swift.Error {
case error(String)
case countImbalance(String)
}
public protocol MoleculeModelProtocol: ModelProtocol {
var moleculeName: String { get }
var backgroundColor: Color? { get set }