List template fix

This commit is contained in:
Pfeil, Scott Robert 2020-01-13 10:40:53 -05:00
parent fe9131f3c6
commit f9620e4bc7
2 changed files with 9 additions and 17 deletions

View File

@ -16,12 +16,12 @@ import Foundation
public var screenHeading: String?
public var isAtomicTabs: Bool?
public var header: HeaderModel?
public var header: MoleculeProtocol?
public var molecules: [ListItemModelProtocol]
public var footer: MoleculeStackModel?
public var footer: MoleculeProtocol?
public var line: LineModel?
public init(pageType: String, screenHeading: String, molecules: [ListItemModelProtocol]) {
public init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol]) {
self.pageType = pageType
self.screenHeading = screenHeading
self.molecules = molecules
@ -48,8 +48,8 @@ import Foundation
}
self.molecules = molecules
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
header = try typeContainer.decodeIfPresent(HeaderModel.self, forKey: .header)
footer = try typeContainer.decodeIfPresent(MoleculeStackModel.self, forKey: .footer)
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
}
@ -59,8 +59,8 @@ import Foundation
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
try container.encodeModels(molecules, forKey: .molecules)
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
try container.encodeIfPresent(header, forKey: .header)
try container.encodeIfPresent(footer, forKey: .footer)
try container.encodeModelIfPresent(header, forKey: .header)
try container.encodeModelIfPresent(footer, forKey: .footer)
try container.encode(line, forKey: .line)
}
}

View File

@ -167,7 +167,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? {
guard let listItem = listItem,
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem),
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) else {
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else {
return nil
}
return (moleculeName, moleculeClass, listItem)
@ -188,15 +188,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
/// Sets up the header, footer, molecule list and ensures no errors loading all content.
func setup() {
var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)] = []
if let molecules = templateModel?.molecules {
for molecule in molecules {
if let info = getMoleculeInfo(with: molecule) {
moleculeList.append(info)
}
}
}
moleculesInfo = moleculeList
moleculesInfo = getMoleculeInfoList()
}
/// Adds modules from requiredModules() to the MVMCoreViewControllerMapping.requiredModules map.