Merge branch 'feature/molecule_replacement_behavior' into 'develop'

Fix module mapping

### Summary
Fixes the optional and required module mapping for atomic when RequestParameters are pre-generated as part of the openPage model.

Co-authored-by: Hedden, Kyle Matthew <kyle.hedden@verizonwireless.com>

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core/-/merge_requests/287
This commit is contained in:
Pfeil, Scott Robert 2023-10-19 18:55:15 +00:00
commit c5dab7d70d
2 changed files with 14 additions and 1 deletions

View File

@ -11,9 +11,19 @@ import Foundation
open class ActionOpenPageHandler: MVMCoreJSONActionHandlerProtocol { open class ActionOpenPageHandler: MVMCoreJSONActionHandlerProtocol {
required public init() {} required public init() {}
func requestParamaters(for model: ActionOpenPageModel) -> MVMCoreRequestParameters {
let requestParameters = model.requestParameters.copy() as! MVMCoreRequestParameters
if let pageType = requestParameters.pageType {
// Re-evaluate required & optional modules as action models might have been generated prior to recent additions to the mapping.
requestParameters.modules = MVMCoreViewControllerMappingObject.shared()?.modulesRequired(forPageType: pageType) as? [String]
requestParameters.optionalModules = MVMCoreViewControllerMappingObject.shared()?.modulesOptional(forPageType: pageType) as? [String]
}
return requestParameters
}
open func performAction(with JSON: [AnyHashable : Any], model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { open func performAction(with JSON: [AnyHashable : Any], model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
guard let model = model as? ActionOpenPageModel else { return } guard let model = model as? ActionOpenPageModel else { return }
let requestParameters: MVMCoreRequestParameters = model.requestParameters.copy() as! MVMCoreRequestParameters let requestParameters = requestParamaters(for: model)
do { do {
if let closure = delegateObject?.actionDelegate?.handleOpenPage { if let closure = delegateObject?.actionDelegate?.handleOpenPage {
// Legacy code will use the old handler function and break the task chain here. // Legacy code will use the old handler function and break the task chain here.

View File

@ -299,6 +299,9 @@
if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getJSONForRequestParameters:)]) { if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getJSONForRequestParameters:)]) {
NSDictionary *json = [[MVMCoreObject sharedInstance].globalLoadDelegate getJSONForRequestParameters:requestParameters]; NSDictionary *json = [[MVMCoreObject sharedInstance].globalLoadDelegate getJSONForRequestParameters:requestParameters];
if (json) { if (json) {
#if HARD_CODED_RESPONSE_DELAY > 0
[NSThread sleepForTimeInterval:HARD_CODED_RESPONSE_DELAY];
#endif
completionHandler(json); completionHandler(json);
return; return;
} }