Merge branch 'bugfix/release_fixes' into 'develop'
release fixes See merge request BPHV_MIPS/mvm_core_ui!333
This commit is contained in:
commit
365b5f1bcd
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class DropDownListItemModel: ListItemModel, MoleculeModelProtocol {
|
@objcMembers public class DropDownListItemModel: ListItemModel, MoleculeModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
@ -17,6 +18,10 @@ import Foundation
|
|||||||
public var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]
|
public var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]
|
||||||
public var dropDown: ItemDropdownEntryFieldModel
|
public var dropDown: ItemDropdownEntryFieldModel
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Methods
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Defaults to set
|
/// Defaults to set
|
||||||
public override func setDefaults() {
|
public override func setDefaults() {
|
||||||
super.setDefaults()
|
super.setDefaults()
|
||||||
@ -24,14 +29,25 @@ import Foundation
|
|||||||
line = LineModel(type: .none)
|
line = LineModel(type: .none)
|
||||||
style = "sectionFooter"
|
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
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) {
|
public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) throws {
|
||||||
self.molecules = molecules
|
self.molecules = molecules
|
||||||
self.dropDown = dropDown
|
self.dropDown = dropDown
|
||||||
|
try Self.verify(dropdown: dropDown, molecules: molecules)
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +69,7 @@ import Foundation
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
molecules = try typeContainer.decodeModels2DIfPresent(codingKey: .molecules) ?? [[]]
|
molecules = try typeContainer.decodeModels2DIfPresent(codingKey: .molecules) ?? [[]]
|
||||||
dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown)
|
dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown)
|
||||||
|
try Self.verify(dropdown: dropDown, molecules: molecules)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public enum MolecularError: Swift.Error {
|
||||||
|
case error(String)
|
||||||
|
case countImbalance(String)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public protocol MoleculeModelProtocol: ModelProtocol {
|
public protocol MoleculeModelProtocol: ModelProtocol {
|
||||||
var moleculeName: String { get }
|
var moleculeName: String { get }
|
||||||
var backgroundColor: Color? { get set }
|
var backgroundColor: Color? { get set }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user