updating Review comments to decode from Model
This commit is contained in:
parent
3827edcf6e
commit
77be31f47f
@ -18,6 +18,7 @@ import Foundation
|
|||||||
}
|
}
|
||||||
public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]?
|
public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]?
|
||||||
public var line: LineModel?
|
public var line: LineModel?
|
||||||
|
public var closeAction: ActionModelProtocol?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
@ -36,6 +37,7 @@ import Foundation
|
|||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case molecules
|
case molecules
|
||||||
case line
|
case line
|
||||||
|
case closeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -46,6 +48,7 @@ import Foundation
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
molecules = try typeContainer.decodeModelsIfPresent(codingKey: .molecules)
|
molecules = try typeContainer.decodeModelsIfPresent(codingKey: .molecules)
|
||||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||||
|
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +57,7 @@ import Foundation
|
|||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeModelsIfPresent(molecules, forKey: .molecules)
|
try container.encodeModelsIfPresent(molecules, forKey: .molecules)
|
||||||
try container.encode(line, forKey: .line)
|
try container.encode(line, forKey: .line)
|
||||||
|
try container.encodeModelIfPresent(closeAction, forKey: .closeAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,11 +27,11 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate {
|
|||||||
guard let self = self else {
|
guard let self = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let actionMap = self.loadObject?.pageJSON?.optionalDictionaryWithChainOfKeysOrIndexes([KeyButtonMap,"CloseButton"]) else {
|
guard let actionMap = self.templateModel?.closeAction else {
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: ActionBackModel().toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
MVMCoreActionHandler.shared()?.handleAction(with: ActionBackModel().toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObjectIVar)
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap.toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,15 +13,14 @@ open class ModalMoleculeStackTemplate: MoleculeStackTemplate {
|
|||||||
override open func handleNewData() {
|
override open func handleNewData() {
|
||||||
super.handleNewData()
|
super.handleNewData()
|
||||||
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in
|
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in
|
||||||
guard let self = self else {
|
guard let self = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let actionMap = self.loadObject?.pageJSON?.optionalDictionaryWithChainOfKeysOrIndexes([KeyButtonMap,"CloseButton"]) else {
|
guard let actionMap = self.templateModel?.closeAction else {
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: ActionBackModel().toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
MVMCoreActionHandler.shared()?.handleAction(with: ActionBackModel().toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObjectIVar)
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap.toJSON(), additionalData: nil, delegateObject: self.delegateObjectIVar)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import Foundation
|
|||||||
return "stack"
|
return "stack"
|
||||||
}
|
}
|
||||||
public var moleculeStack: StackModel
|
public var moleculeStack: StackModel
|
||||||
|
public var closeAction: ActionModelProtocol?
|
||||||
|
|
||||||
public init(pageType: String, moleculeStack: StackModel) {
|
public init(pageType: String, moleculeStack: StackModel) {
|
||||||
self.moleculeStack = moleculeStack
|
self.moleculeStack = moleculeStack
|
||||||
@ -22,11 +23,13 @@ import Foundation
|
|||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case stack
|
case stack
|
||||||
|
case closeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
moleculeStack = try typeContainer.decode(StackModel.self, forKey: .stack)
|
moleculeStack = try typeContainer.decode(StackModel.self, forKey: .stack)
|
||||||
|
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,5 +37,6 @@ import Foundation
|
|||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeStack, forKey: .stack)
|
try container.encode(moleculeStack, forKey: .stack)
|
||||||
|
try container.encodeModelIfPresent(closeAction, forKey: .closeAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user