List template change to molecules not required (for now)
This commit is contained in:
parent
a2b62767bd
commit
abc854e152
@ -17,7 +17,7 @@ import Foundation
|
|||||||
public var isAtomicTabs: Bool?
|
public var isAtomicTabs: Bool?
|
||||||
|
|
||||||
public var header: MoleculeModelProtocol?
|
public var header: MoleculeModelProtocol?
|
||||||
public var molecules: [ListItemModelProtocol]
|
public var molecules: [ListItemModelProtocol]?
|
||||||
public var footer: MoleculeModelProtocol?
|
public var footer: MoleculeModelProtocol?
|
||||||
public var line: LineModel?
|
public var line: LineModel?
|
||||||
|
|
||||||
@ -42,11 +42,7 @@ import Foundation
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
||||||
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
||||||
|
molecules = try typeContainer.decodeMoleculesIfPresent(codingKey: .molecules) as? [ListItemModelProtocol]
|
||||||
guard let molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as? [ListItemModelProtocol] else {
|
|
||||||
throw JSONError.pathNotFound
|
|
||||||
}
|
|
||||||
self.molecules = molecules
|
|
||||||
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
||||||
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
||||||
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
||||||
@ -57,7 +53,7 @@ import Foundation
|
|||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(pageType, forKey: .pageType)
|
try container.encode(pageType, forKey: .pageType)
|
||||||
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
|
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
|
||||||
try container.encodeModels(molecules, forKey: .molecules)
|
try container.encodeModelsIfPresent(molecules, forKey: .molecules)
|
||||||
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
|
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
|
||||||
try container.encodeModelIfPresent(header, forKey: .header)
|
try container.encodeModelIfPresent(header, forKey: .header)
|
||||||
try container.encodeModelIfPresent(footer, forKey: .footer)
|
try container.encodeModelIfPresent(footer, forKey: .footer)
|
||||||
|
|||||||
@ -53,6 +53,19 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
return molecule
|
return molecule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject>) -> Bool {
|
||||||
|
let shouldFinish = super.shouldFinishProcessingLoad(loadObject, error: error)
|
||||||
|
// This template requires atleast one of the three layers.
|
||||||
|
if templateModel?.header == nil,
|
||||||
|
templateModel?.molecules?.count ?? 0 == 0,
|
||||||
|
templateModel?.footer == nil,
|
||||||
|
let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), messageToLog: "List template requires atleast one of the following: header, footer, molecules", code: CoreUIErrorCode.ErrorCodeListMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) {
|
||||||
|
error.pointee = errorObject
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return shouldFinish
|
||||||
|
}
|
||||||
|
|
||||||
open override func newDataBuildScreen() {
|
open override func newDataBuildScreen() {
|
||||||
super.newDataBuildScreen()
|
super.newDataBuildScreen()
|
||||||
setup()
|
setup()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user