Merge branch 'feature/remove_legacy_deprecations' into 'develop'
Deprecated function removal. See merge request BPHV_MIPS/mvm_core_ui!885
This commit is contained in:
commit
85a2debf4e
@ -62,11 +62,4 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors);
|
||||
// Will show this alert in it's appropriate type style.
|
||||
- (void)showAlert;
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
// Creates an alert object for an error with the passed in load object response info
|
||||
+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error actionDelegate:(nullable NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)actionDelegate __deprecated;
|
||||
+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)actionDelegate __deprecated;
|
||||
+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate error:(MVMCoreErrorObject *_Nullable *_Nullable)error __deprecated;
|
||||
|
||||
@end
|
||||
|
||||
@ -195,113 +195,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error actionDelegate:(nullable NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)actionDelegate {
|
||||
|
||||
MVMCoreAlertObject *alert = nil;
|
||||
if (!error || [ErrorDomainServer isEqualToString:error.domain]) {
|
||||
alert = [MVMCoreAlertObject alertObjectForPageType:loadObject.pageType responseInfo:loadObject.responseInfoMap additionalData:loadObject.dataForPage actionDelegate:actionDelegate];
|
||||
} else {
|
||||
alert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO];
|
||||
}
|
||||
|
||||
// only if actions are empty, then go inside and set OK as default action
|
||||
if (alert.type == MFAlertTypePopup && alert.actions.count == 0) {
|
||||
alert.defaultAction = YES;
|
||||
alert.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]];
|
||||
}
|
||||
return alert;
|
||||
}
|
||||
|
||||
+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)actionDelegate {
|
||||
|
||||
__block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init];
|
||||
alert.title = [responseInfo string:KeyErrorHeading] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle];
|
||||
alert.message = [responseInfo string:KeyUserMessage] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess];
|
||||
NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle];
|
||||
if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) {
|
||||
|
||||
// field errors.
|
||||
alert.type = MFAlertTypeField;
|
||||
alert.fieldErrors = [responseInfo array:ValueTypeFieldErrors];
|
||||
} else {
|
||||
|
||||
// Check for top alert (persistent or regular).
|
||||
if ([messageStyle isEqualToString:ValueMessageStyleTopPersistent] || [messageStyle isEqualToString:ValueMessageStyleTop]) {
|
||||
|
||||
alert.topAlertObject = [[MVMCoreTopAlertObject alloc] initWithResponseInfo:responseInfo];
|
||||
if ([actionDelegate conformsToProtocol:@protocol(MVMCoreTopAlertDelegateProtocol)]) {
|
||||
alert.topAlertObject.delegate = (NSObject <MVMCoreTopAlertDelegateProtocol> *)actionDelegate;
|
||||
}
|
||||
alert.topAlertObject.pageType = pageType;
|
||||
alert.type = MFAlertTypeTop;
|
||||
} else if ([messageStyle isEqualToString:ValueMessageStylePopup]) {
|
||||
|
||||
// Perform a popup.
|
||||
alert.type = MFAlertTypePopup;
|
||||
alert.alertStyle = UIAlertControllerStyleAlert;
|
||||
|
||||
// Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button).
|
||||
NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"];
|
||||
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
|
||||
|
||||
MVMCoreErrorObject *error = nil;
|
||||
MVMCoreAlertObject *popupAlert = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegate:actionDelegate error:&error];
|
||||
if (error) {
|
||||
|
||||
// Error, popup page not found for page type.
|
||||
popupAlert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO];
|
||||
}
|
||||
|
||||
if (popupAlert) {
|
||||
alert = popupAlert;
|
||||
}
|
||||
}];
|
||||
} else if (messageStyle.length == 0 && pageType) {
|
||||
|
||||
// No message style!
|
||||
alert.type = MFAlertTypeNone;
|
||||
} else {
|
||||
|
||||
// Default to popup
|
||||
alert.type = MFAlertTypePopup;
|
||||
alert.alertStyle = UIAlertControllerStyleAlert;
|
||||
}
|
||||
}
|
||||
if ([actionDelegate conformsToProtocol:@protocol(MVMCoreAlertDelegateProtocol)]) {
|
||||
alert.alertDelegate = (NSObject <MVMCoreAlertDelegateProtocol> *)actionDelegate;
|
||||
}
|
||||
return alert;
|
||||
}
|
||||
|
||||
+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate error:(MVMCoreErrorObject *_Nullable *_Nullable)error {
|
||||
|
||||
MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init];
|
||||
alert.title = [page string:KeyTitle] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle];
|
||||
alert.pageJson = page;
|
||||
alert.message = [page string:KeyMessage] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess];
|
||||
alert.isGreedy = isGreedy;
|
||||
alert.type = MFAlertTypePopup;
|
||||
alert.alertStyle = UIAlertControllerStyleAlert;
|
||||
|
||||
NSArray <NSDictionary *> *actions = [page array:KeyLinks];
|
||||
NSMutableArray <UIAlertAction *> *actionsForAlert = [NSMutableArray array];
|
||||
for (NSDictionary *actionMap in actions) {
|
||||
[actionsForAlert addObject:[UIAlertAction actionWithTitle:[actionMap stringForKey:KeyTitle] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:delegate];
|
||||
}]];
|
||||
}
|
||||
alert.actions = actionsForAlert;
|
||||
|
||||
if ((alert.title.length > 0 || alert.message.length > 0) && alert.actions.count > 0) {
|
||||
return alert;
|
||||
} else {
|
||||
if (error) {
|
||||
*error = [[MVMCoreErrorObject alloc] initWithTitle:nil messageToLog:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodePopupFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_Popup_pageType:%@",NSStringFromClass([delegate class]),[page stringForKey:KeyPageType]]];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user