enforce an action

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-08-27 16:38:17 -05:00
parent 484b578568
commit 61f9fb9946
2 changed files with 8 additions and 12 deletions

View File

@ -44,18 +44,14 @@ import VDS
isEnabled = viewModel.enabled
surface = viewModel.surface
breadcrumbModels = viewModel.breadcrumbs.compactMap { [unowned self] breadcrumb in
var onClick: ((BreadcrumbItem) -> Void)?
if let action = breadcrumb.action {
onClick = { _ in
MVMCoreUIActionHandler.performActionUnstructured(with: action,
sourceModel: breadcrumb,
additionalData: self.additionalData,
delegateObject: self.delegateObject)
}
}
return .init(text: breadcrumb.text,
selected: breadcrumb.selected,
onClick: onClick)
onClick: { _ in
MVMCoreUIActionHandler.performActionUnstructured(with: breadcrumb.action,
sourceModel: breadcrumb,
additionalData: self.additionalData,
delegateObject: self.delegateObject)
})
}
}

View File

@ -71,7 +71,7 @@ open class BreadcrumbModel: MoleculeModelProtocol {
open var text: String = ""
open var selected: Bool = false
open var action: ActionModelProtocol?
open var action: ActionModelProtocol
//--------------------------------------------------
@ -92,7 +92,7 @@ open class BreadcrumbModel: MoleculeModelProtocol {
let container = try decoder.container(keyedBy: CodingKeys.self)
text = try container.decode(String.self, forKey: .text)
selected = try container.decodeIfPresent(Bool.self, forKey: .selected) ?? false
action = try container.decodeModelIfPresent(codingKey: .action)
action = try container.decodeModel(codingKey: .action)
}
public func encode(to encoder: Encoder) throws {