From 16e9079b8cea0297e6fd5b164b52e4ca2bd2038e Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 18 Jul 2022 18:54:11 -0400 Subject: [PATCH] Action modernization --- MVMCoreUI.xcodeproj/project.pbxproj | 32 ++++ MVMCoreUI/Alerts/MVMCoreAlertObject.m | 4 +- .../Atomic/Actions/ActionAlertHandler.swift | 26 +++ .../ActionCollapseNotificationHandler.swift | 19 ++ .../Actions/ActionOpenPanelHandler.swift | 25 +++ .../Atomic/Actions/ActionPopupHandler.swift | 31 ++++ .../Actions/ActionTopAlertHandler.swift | 31 ++++ .../ActionTopNotificationHandler.swift | 20 ++ .../MVMCoreUIActionOpenPageHandler.swift | 19 ++ .../Atomic/Atoms/Views/Label/Label.swift | 2 +- .../Items/DropDownFilterTableViewCell.swift | 24 +-- .../OtherContainers/ModuleMolecule.swift | 2 +- .../BaseControllers/ViewController.swift | 9 +- MVMCoreUI/FormUIHelpers/FormValidator.swift | 2 +- .../SubNav/SubNavManagerController.swift | 5 +- .../OtherHandlers/CoreUIModelMapping.swift | 13 +- .../MVMCoreUIActionHandler+Extension.swift | 34 ++++ .../OtherHandlers/MVMCoreUIActionHandler.h | 49 ++--- .../OtherHandlers/MVMCoreUIActionHandler.m | 174 +++++------------- .../MVMCoreUITopAlertView+Extension.swift | 6 +- 20 files changed, 337 insertions(+), 190 deletions(-) create mode 100644 MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index aac7bf51..e90dff6f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -275,6 +275,14 @@ AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; + AF1C33652883B5A4006B1001 /* ActionTopNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33642883B5A4006B1001 /* ActionTopNotificationHandler.swift */; }; + AF1C33672883B712006B1001 /* ActionPopupHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33662883B712006B1001 /* ActionPopupHandler.swift */; }; + AF1C336928859778006B1001 /* ActionAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336828859778006B1001 /* ActionAlertHandler.swift */; }; + AF1C336B28859C73006B1001 /* ActionTopAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */; }; + AF1C336D28859EE1006B1001 /* ActionOpenPanelHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */; }; + AF1C336F2885A16A006B1001 /* ActionCollapseNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */; }; + AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */; }; + AF1C33732885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */; }; AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; @@ -865,6 +873,14 @@ AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; + AF1C33642883B5A4006B1001 /* ActionTopNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopNotificationHandler.swift; sourceTree = ""; }; + AF1C33662883B712006B1001 /* ActionPopupHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionPopupHandler.swift; sourceTree = ""; }; + AF1C336828859778006B1001 /* ActionAlertHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionAlertHandler.swift; sourceTree = ""; }; + AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopAlertHandler.swift; sourceTree = ""; }; + AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPanelHandler.swift; sourceTree = ""; }; + AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCollapseNotificationHandler.swift; sourceTree = ""; }; + AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIActionHandler+Extension.swift"; sourceTree = ""; }; + AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIActionOpenPageHandler.swift; sourceTree = ""; }; AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; @@ -1475,12 +1491,19 @@ isa = PBXGroup; children = ( 94C0150924215643005811A9 /* ActionTopAlertModel.swift */, + AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */, 94C0150B2421564A005811A9 /* ActionCollapseNotificationModel.swift */, + AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */, D2C78CD124228BBD00B69FDE /* ActionOpenPanelModel.swift */, + AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */, D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */, D2ED27EA254B0CE700A1C293 /* AlertModel.swift */, + AF1C336828859778006B1001 /* ActionAlertHandler.swift */, D2ED27E8254B0CE600A1C293 /* ActionPopupModel.swift */, + AF1C33662883B712006B1001 /* ActionPopupHandler.swift */, C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */, + AF1C33642883B5A4006B1001 /* ActionTopNotificationHandler.swift */, + AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */, ); path = Actions; sourceTree = ""; @@ -2280,6 +2303,7 @@ D2ED2817254B112900A1C293 /* MVMCoreUIActionDelegateProtocol.h */, D2ED281B254B119D00A1C293 /* MVMCoreUIActionHandler.h */, D2ED281C254B119D00A1C293 /* MVMCoreUIActionHandler.m */, + AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */, D23A90672614B0B4007E14CE /* CoreUIModelMapping.swift */, ); path = OtherHandlers; @@ -2732,6 +2756,7 @@ AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, 011D9602240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift in Sources */, + AF1C33672883B712006B1001 /* ActionPopupHandler.swift in Sources */, D23A900926125FFB007E14CE /* GetContactBehavior.swift in Sources */, D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */, AA617AB22453012400910B8F /* ListDeviceComplexLinkSmallModel.swift in Sources */, @@ -2796,6 +2821,7 @@ 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, 943820842432382400B43AF3 /* WebView.swift in Sources */, 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, + AF1C336F2885A16A006B1001 /* ActionCollapseNotificationHandler.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A25209624645AFD000FA9F6 /* TextViewEntryField.swift in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, @@ -2828,6 +2854,7 @@ 0A9D091D2433796500D2E6C0 /* BarsCarouselIndicatorModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, + AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift in Sources */, 0A7ECC5D243CE85300C828E8 /* DoughnutChartItemModel.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, @@ -2929,6 +2956,7 @@ D2E2A99623D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift in Sources */, C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */, 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */, + AF1C336B28859C73006B1001 /* ActionTopAlertHandler.swift in Sources */, 011D958524042432000E3791 /* RulesProtocol.swift in Sources */, 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */, D23118B325124E18001C8440 /* Notification.swift in Sources */, @@ -2949,8 +2977,10 @@ 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, 0A9D091E2433796500D2E6C0 /* NumericCarouselIndicatorModel.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, + AF1C336928859778006B1001 /* ActionAlertHandler.swift in Sources */, 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */, 011D95A5240455DC000E3791 /* FormGroupRule.swift in Sources */, + AF1C33732885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift in Sources */, D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, @@ -3055,6 +3085,7 @@ 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */, D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, D270E5672642F77300CDBED2 /* AddRemoveMoleculeBehavior.swift in Sources */, + AF1C33652883B5A4006B1001 /* ActionTopNotificationHandler.swift in Sources */, BB2BF0EC2452A9D5001D0FC2 /* ListDeviceComplexButtonSmallModel.swift in Sources */, 943784F6236B77BB006A1E82 /* WheelAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, @@ -3148,6 +3179,7 @@ AAB7EDEF246ADA1600E54929 /* ListProgressBarThinModel.swift in Sources */, D21B7F75243BAC8900051ABF /* CarouselItem.swift in Sources */, C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, + AF1C336D28859EE1006B1001 /* ActionOpenPanelHandler.swift in Sources */, 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, 011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */, diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject.m b/MVMCoreUI/Alerts/MVMCoreAlertObject.m index 7c61dd08..8b1bc248 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject.m @@ -151,9 +151,9 @@ + (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error { MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [page string:KeyTitle] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle]; + alert.title = [page string:KeyTitle]; alert.pageJson = page; - alert.message = [page string:KeyMessage] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess]; + alert.message = [page string:KeyMessage]; alert.isGreedy = isGreedy; alert.type = MFAlertTypePopup; alert.alertStyle = UIAlertControllerStyleAlert; diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift new file mode 100644 index 00000000..f3996ab1 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift @@ -0,0 +1,26 @@ +// +// ActionAlertHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows an alert using the model. +open class ActionAlertHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionAlertModel else { return } + let json = try MVMCoreActionHandler.convertActionToJSON(model) + var error: MVMCoreErrorObject? = nil + guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: json, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { + throw MVMCoreError.errorObject(error!) + } + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json) + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift new file mode 100644 index 00000000..f12b2db9 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift @@ -0,0 +1,19 @@ +// +// ActionCollapseNotificationHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Collapse the current top notification. +open class ActionCollapseNotificationHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + CoreUIObject.sharedInstance()?.globalTopAlertDelegate?.getTopAlertView?().collapseNotification?() + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift new file mode 100644 index 00000000..5493f128 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift @@ -0,0 +1,25 @@ +// +// ActionOpenPanelHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows the panel. +open class ActionOpenPanelHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionOpenPanelModel else { return } + switch model.panel { + case .left, .menu: + await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true) + case .right, .support: + await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true) + } + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift new file mode 100644 index 00000000..d0efc18e --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift @@ -0,0 +1,31 @@ +// +// ActionPopupHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/16/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows a popup alert by grabbing the content from a Page in the cache using the pageType. +open class ActionPopupHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionPopupModel else { return } + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + MVMCoreCache.shared()?.fetchJSON(forPageType: model.pageType, queue: nil, waitUntilFinished: true, completionHandler: { json in + var error: MVMCoreErrorObject? = nil + guard let alertObject = MVMCoreAlertObject(page: json, isGreedy: false, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { + continuation.resume(throwing: MVMCoreError.errorObject(error!)) + return + } + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!) + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + continuation.resume() + }) + } + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift new file mode 100644 index 00000000..83a58273 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift @@ -0,0 +1,31 @@ +// +// ActionTopAlertHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Creates and shows an alert using the ResponseInfo of a Page found in the cache. +open class ActionTopAlertHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionTopAlertModel else { return } + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + MVMCoreCache.shared()?.fetchJSON(forPageType: model.pageType, queue: nil, waitUntilFinished: true, completionHandler: { json in + guard let responseInfo = json?.optionalDictionaryForKey(KeyResponseInfo) else { + continuation.resume(throwing: ModelRegistry.Error.decoderOther(message: "Alert Page \(model.pageType) missing ResponseInfo")) + return + } + let alertObject = MVMCoreAlertObject(forPageType: model.pageType, responseInfo: responseInfo, additionalData: additionalData, delegateObject: delegateObject)! + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!) + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + continuation.resume() + }) + } + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift new file mode 100644 index 00000000..89762268 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift @@ -0,0 +1,20 @@ +// +// ActionTopNotificationHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/16/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows a top notification/alert with the model. +open class ActionTopNotificationHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionTopNotificationModel else { return } + await MVMCoreUITopAlertView.sharedGlobal()?.showTopAlert(with: model.topNotification) + } +} diff --git a/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift new file mode 100644 index 00000000..550badf5 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift @@ -0,0 +1,19 @@ +// +// MVMCoreUIActionOpenPageHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +open class MVMCoreUIActionOpenPageHandler: ActionOpenPageHandler { + public override func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). + var additionalData = additionalData + additionalData?.removeValue(forKey: KeySourceModel) + try await super.performAction(model, delegateObject: delegateObject, additionalData: additionalData) + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index c524b7b3..7641b8f6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -227,7 +227,7 @@ public typealias ActionBlock = () -> () documentAttributes: nil) } catch { if let coreErrorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "LabelHTMLParse") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: coreErrorObject) + MVMCoreUILoggingHandler.addError(toLog: coreErrorObject) } } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift index b6de93d1..d157bce1 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift @@ -24,18 +24,20 @@ import UIKit addMolecule(dropDown) dropDown.observeDropdownChange = { [weak self] oldValue, newValue in - guard newValue != oldValue, - let self = self, - let model = self.listItemModel as? DropDownListItemModel - else { return } - MVMCoreDispatchUtility.performBlock(inBackground: { - if let oldValue = oldValue, - oldValue.count > 0 { - MVMCoreActionHandler.shared()?.syncHandleAction(with: RemoveMoleculesActionModel(.fade), additionalData: [KeySourceModel: model], delegateObject: self.delegateObject) - } - MVMCoreActionHandler.shared()?.syncHandleAction(with: AddMoleculesActionModel(.fade), additionalData: [KeySourceModel: model], delegateObject: self.delegateObject) - }) + let self = self, + let model = self.listItemModel as? DropDownListItemModel else { return } + + let additionData = [KeySourceModel: model] + var actions: [ActionModelProtocol] = [] + if let oldValue = oldValue, + oldValue.count > 0 { + actions.append(RemoveMoleculesActionModel(.fade)) + } + actions.append(AddMoleculesActionModel(.fade)) + let actionsModel = ActionActionsModel(actions: actions) + actionsModel.concurrent = false + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift index ce76d379..6083ac5e 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift @@ -75,7 +75,7 @@ open class ModuleMolecule: Container { let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { error?.pointee = errorObject - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return nil } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 772742b4..be917ab2 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import MVMCore @objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { @@ -401,6 +402,10 @@ import UIKit //-------------------------------------------------- // MARK: - MVMCoreActionDelegateProtocol //-------------------------------------------------- + open func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionData: [AnyHashable : Any]? = nil) throws -> MVMCoreRequestParameters { + let json = try MVMCoreActionHandler.convertActionToJSON(model) + return MVMCoreRequestParameters(actionMap: json)! + } open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { addFormParams(requestParameters: requestParameters, actionInformation: actionInformation, additionalData: additionalData) @@ -412,7 +417,7 @@ import UIKit pageForwardedData.merge(dataMap) { current, _ in current } } - MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: pageForwardedData, delegateObject: delegateObject()) + //MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: pageForwardedData, delegateObject: delegateObject()) } open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { @@ -429,7 +434,7 @@ import UIKit } if !handled { - MVMCoreUIActionHandler.defaultHandleUnknownActionType(actionType, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObjectIVar) + //MVMCoreUIActionHandler.defaultHandleUnknownActionType(actionType, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObjectIVar) } } diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index bf2f8c2f..64e3843c 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -95,7 +95,7 @@ import MVMCore groupValid = try validateGroup(group) } catch { if let err = MVMCoreErrorObject.createErrorObject(for: error, location: "FormValidator"){ - MVMCoreLoggingHandler.shared()?.addError(toLog: err) + MVMCoreLoggingHandler.addError(toLog: err) fatalError(err.description) } } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index f5c4023a..8f8ced86 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -154,9 +154,8 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Logs the action for the selected tab. open func trackSelectTab() { - guard let action = tabs.tabsModel?.tabs[tabs.selectedIndex].action, - let json = MVMCoreUIActionHandler.shared()?.convertActionToJSON(action, delegateObject: delegateObjectIVar) else { return } - MVMCoreUIActionHandler.shared()?.logAction(json, additionalData: getAdditionalDataForNewTabLoad(indexPath: IndexPath(row: tabs.selectedIndex, section: 0)), delegateObject: delegateObjectIVar) + guard let action = tabs.tabsModel?.tabs[tabs.selectedIndex].action else { return } + MVMCoreUIActionHandler.shared()?.logAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: IndexPath(row: tabs.selectedIndex, section: 0)), delegateObject: delegateObjectIVar) } /// Allow override of additioonal data for tab press action diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index ef051b88..04d10423 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -228,12 +228,13 @@ open class CoreUIModelMapping: ModelMapping { open override class func registerActions() { super.registerActions() - ModelRegistry.register(ActionPopupModel.self) - ModelRegistry.register(ActionAlertModel.self) - ModelRegistry.register(ActionTopAlertModel.self) - ModelRegistry.register(ActionCollapseNotificationModel.self) - ModelRegistry.register(ActionOpenPanelModel.self) - ModelRegistry.register(ActionTopNotificationModel.self) + ModelRegistry.register(handler: ActionPopupHandler.self, for: ActionPopupModel.self) + ModelRegistry.register(handler: ActionAlertHandler.self, for: ActionAlertModel.self) + ModelRegistry.register(handler: ActionTopAlertHandler.self, for: ActionTopAlertModel.self) + ModelRegistry.register(handler: ActionCollapseNotificationHandler.self, for: ActionCollapseNotificationModel.self) + ModelRegistry.register(handler: ActionOpenPanelHandler.self, for: ActionOpenPanelModel.self) + ModelRegistry.register(handler: ActionTopNotificationHandler.self, for: ActionTopNotificationModel.self) + ModelRegistry.register(handler: MVMCoreUIActionOpenPageHandler.self, for: ActionOpenPageModel.self, allowsReplace: true) } open class func registerRules() { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift new file mode 100644 index 00000000..00682f88 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift @@ -0,0 +1,34 @@ +// +// MVMCoreUIActionHandler+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore +import SafariServices + +@objc open class MVMCoreUIActionHandler: MVMCoreActionHandler { + + /// Logs the error and shows a popup if the error is not silent. + open override func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable : Any]?) { + super.defaultHandleActionError(error, additionalData: additionalData) + guard !error.silentError else { return } + Task { + // TODO: Verify if necessary. + await MainActor.run { + // Show alert + let alertObject = MVMCoreAlertObject.init(popupAlertWithError: error, isGreedy: false)! + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + } + } + } + + @objc(openURLInSafariWebView:) + @MainActor open func openURL(inSafariWebView url: URL) { + let safariViewController = SFSafariViewController(url: url) + MVMCoreNavigationHandler.shared()?.present(safariViewController, animated: true) + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h index 60a24646..b78088bc 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h @@ -1,35 +1,20 @@ +//// +//// MVMCoreUIActionHandler.h +//// MVMCoreUI +//// +//// Created by Scott Pfeil on 10/28/20. +//// Copyright © 2020 Verizon Wireless. All rights reserved. +//// // -// MVMCoreUIActionHandler.h -// MVMCoreUI +//@import MVMCore.MVMCoreActionHandler; // -// Created by Scott Pfeil on 10/28/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. +//NS_ASSUME_NONNULL_BEGIN // - -@import MVMCore.MVMCoreActionHandler; - -NS_ASSUME_NONNULL_BEGIN - -@interface MVMCoreUIActionHandler : MVMCoreActionHandler - -// Shows a popup alert by grabbing the content from the page map. -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Shows popup alert from the alert object in the action map. The actionType of the action is 'alert' -- (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Shows a top alert -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Collapses the current top notification -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Shows a topnotification new molecular -- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -/// Legacy in app safari webview load -- (void)openURLInSafariWebView:(nonnull NSURL *)url; - -@end - -NS_ASSUME_NONNULL_END +//@interface MVMCoreUIActionHandler : MVMCoreActionHandler +// +///// Legacy in app safari webview load +//- (void)openURLInSafariWebView:(nonnull NSURL *)url; +// +//@end +// +//NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index 9425547c..8f01a766 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -1,131 +1,49 @@ +//// +//// MVMCoreUIActionHandler.m +//// MVMCoreUI +//// +//// Created by Scott Pfeil on 10/28/20. +//// Copyright © 2020 Verizon Wireless. All rights reserved. +//// // -// MVMCoreUIActionHandler.m -// MVMCoreUI +//#import "MVMCoreUIActionHandler.h" +//#import "MVMCoreUIConstants.h" +//#import "MVMCoreAlertObject.h" +//#import +//#import +//@import MVMCore.MVMCoreActionHandler; +//@import MVMCore.NSDictionary_MFConvenience; +//@import MVMCore.MVMCoreJSONConstants; +//@import MVMCore.MVMCoreCache; +//@import SafariServices; // -// Created by Scott Pfeil on 10/28/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. +//@implementation MVMCoreUIActionHandler // - -#import "MVMCoreUIActionHandler.h" -#import "MVMCoreUIConstants.h" -#import "MVMCoreAlertObject.h" -#import -#import -@import MVMCore.MVMCoreActionHandler; -@import MVMCore.NSDictionary_MFConvenience; -@import MVMCore.MVMCoreJSONConstants; -@import MVMCore.MVMCoreCache; -@import SafariServices; - -@implementation MVMCoreUIActionHandler - -- (BOOL)handleOtherActions:(NSString *)actionType actionInformation:(NSDictionary *)actionInformation additionalData:(NSDictionary *)additionalData delegateObject:(DelegateObject *)delegateObject { - if ([actionType isEqualToString:KeyActionTypePopup]) { - [self popupAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeTopAlert]) { - [self topAlertAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) { - [self collapseNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeAlert]) { - [self showAlert:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeTopNotification]) { - [self topNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } - return [super handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; -} - -- (void)openPageAction:(NSDictionary *)actionInformation additionalData:(NSDictionary *)additionalData delegateObject:(DelegateObject *)delegateObject { - // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). - if (additionalData[KeySourceModel]) { - NSMutableDictionary *cleanedData = [additionalData mutableCopy]; - [cleanedData removeObjectForKey:KeySourceModel]; - additionalData = cleanedData; - } - [super openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; -} - -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Perform a popup. - NSString *pageTypeForPopup = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegateObject:delegateObject error:&error]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowPopupWithAlertObject:alertObject alertJson:jsonDictionary]; - } - - if (alertObject) { - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - } else { - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject ]; - } - }]; -} - -- (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectWithAction:actionInformation additionalData:additionalData delegateObject:delegateObject error:&error]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowPopupWithAlertObject:alertObject alertJson:actionInformation]; - } - - if (alertObject) { - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - } else { - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } -} - -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Perform a top alert. - NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; - } - [alertObject showAlert]; - } - }]; -} - -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Collapse the current notification. - if ([[CoreUIObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { - [[[CoreUIObject sharedInstance].globalTopAlertDelegate getTopAlertView] collapseNotification]; - } -} - -- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - //Handle molecular topnotification - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}]; -} - -- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { - [super defaultHandleActionError:error additionalData:additionalData]; - if (!error.silentError) { - - // Show alert - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - MVMCoreAlertObject *alertObject = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - }]; - } -} - -- (void)openURLInSafariWebView:(nonnull NSURL *)url { - SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; -} - -@end +//- (void)openPageAction:(NSDictionary *)actionInformation additionalData:(NSDictionary *)additionalData delegateObject:(DelegateObject *)delegateObject { +// // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). +// if (additionalData[KeySourceModel]) { +// NSMutableDictionary *cleanedData = [additionalData mutableCopy]; +// [cleanedData removeObjectForKey:KeySourceModel]; +// additionalData = cleanedData; +// } +// //[super openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; +//} +// +//- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { +// [super defaultHandleActionError:error additionalData:additionalData]; +// if (!error.silentError) { +// +// // Show alert +// [MVMCoreDispatchUtility performBlockOnMainThread:^{ +// MVMCoreAlertObject *alertObject = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; +// [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; +// }]; +// } +//} +// +//- (void)openURLInSafariWebView:(nonnull NSURL *)url { +// SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; +// [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; +//} +// +//@end diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 46765385..d7747383 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -47,7 +47,7 @@ public extension MVMCoreUITopAlertView { return try TopNotificationModel.decode(json: json, delegateObject: delegateObject) } catch { if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "\(self)") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return nil } @@ -96,7 +96,7 @@ public extension MVMCoreUITopAlertView { let molecule = currentAlert as? MoleculeViewProtocol else { // Log that we couldn't update. if let errorObject = MVMCoreErrorObject(title: nil, message: nil, messageToLog: nil, code: ErrorCode.parsingJSON.rawValue, domain: ErrorDomainNative, location: "TopNotification update \(String(describing: topAlertObject.type))") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return } @@ -132,7 +132,7 @@ public extension MVMCoreUITopAlertView { return molecule } catch { if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "\(self)") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return nil }