[ios] Added dialog for unsaved changes on delete.

This commit is contained in:
Ilya Grechuhin 2016-03-03 17:42:08 +03:00 committed by Sergey Yershov
parent 998283c2af
commit 73004c7793
11 changed files with 49 additions and 19 deletions

View file

@ -21,6 +21,7 @@
- (void)presentLocationAlert;
- (void)presentLocationServiceNotSupportedAlert;
- (void)presentNoConnectionAlert;
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock;
- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name okBlock:(nullable TMWMVoidBlock)okBlock;
- (void)presentPedestrianToastAlert:(BOOL)isFirstLaunch;
- (void)presentInternalErrorAlert;

View file

@ -81,6 +81,11 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
[self displayAlert:[MWMAlert noConnectionAlert]];
}
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock
{
[self displayAlert:[MWMAlert unsavedEditsAlertWithOkBlock:okBlock]];
}
- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name okBlock:(nullable TMWMVoidBlock)okBlock
{
[self displayAlert:[MWMAlert noWiFiAlertWithName:name okBlock:okBlock]];

View file

@ -17,6 +17,7 @@
+ (MWMAlert *)disabledLocationAlert;
+ (MWMAlert *)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock;
+ (MWMAlert *)noConnectionAlert;
+ (MWMAlert *)unsavedEditsAlertWithOkBlock:(TMWMVoidBlock)okBlock;
+ (MWMAlert *)locationServiceNotSupportedAlert;
+ (MWMAlert *)pedestrianToastShareAlert:(BOOL)isFirstLaunch;
+ (MWMAlert *)internalErrorAlert;

View file

@ -51,6 +51,11 @@
return [MWMDefaultAlert noConnectionAlert];
}
+ (MWMAlert *)unsavedEditsAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
return [MWMDefaultAlert unsavedEditsAlertWithOkBlock:okBlock];
}
+ (MWMAlert *)locationServiceNotSupportedAlert
{
return [MWMDefaultAlert locationServiceNotSupportedAlert];

View file

@ -14,6 +14,7 @@
+ (instancetype)disabledLocationAlert;
+ (instancetype)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock;
+ (instancetype)noConnectionAlert;
+ (instancetype)unsavedEditsAlertWithOkBlock:(TMWMVoidBlock)okBlock;
+ (instancetype)locationServiceNotSupportedAlert;
+ (instancetype)point2PointAlertWithOkBlock:(TMWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild;
+ (instancetype)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock;

View file

@ -74,6 +74,16 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
return alert;
}
+ (instancetype)unsavedEditsAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
kStatisticsEvent = @"Editor unsaved changes on delete";
return [self defaultAlertWithTitle:@"editor_unsavde_changes"
message:nil
rightButtonTitle:@"delete"
leftButtonTitle:nil
rightButtonAction:okBlock];
}
+ (instancetype)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock
{
kStatisticsEvent = @"No WiFi Alert";

View file

@ -56,6 +56,17 @@ using namespace storage;
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return NO;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
[self.delegate deleteNode:[self countryIdForIndexPath:indexPath]];
}
#pragma mark - MWMMapDownloaderDataSource
- (BOOL)isParentRoot

View file

@ -196,21 +196,6 @@ using namespace storage;
return (status == NodeStatus::OnDisk || status == NodeStatus::OnDiskOutOfDate || nodeAttrs.m_localMwmCounter != 0);
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatDelete,
kStatIsAuto : kStatNo,
kStatFrom : kStatDownloader,
kStatScenario : kStatDelete
}];
[MWMStorage deleteNode:[self countryIdForIndexPath:indexPath]];
}
}
#pragma mark - MWMMapDownloaderDataSource
- (TCountryId)parentCountryId

View file

@ -486,7 +486,7 @@ using namespace storage;
kStatFrom : kStatDownloader,
kStatScenario : kStatDelete
}];
[MWMStorage deleteNode:countryId];
[MWMStorage deleteNode:countryId alertController:self.alertController];
}
- (void)cancelNode:(storage::TCountryId const &)countryId

View file

@ -7,7 +7,7 @@
+ (void)downloadNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess;
+ (void)retryDownloadNode:(storage::TCountryId const &)countryId;
+ (void)updateNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController;
+ (void)deleteNode:(storage::TCountryId const &)countryId;
+ (void)deleteNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController;
+ (void)cancelDownloadNode:(storage::TCountryId const &)countryId;
@end

View file

@ -30,9 +30,20 @@
}];
}
+ (void)deleteNode:(storage::TCountryId const &)countryId
+ (void)deleteNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController
{
GetFramework().Storage().DeleteNode(countryId);
auto & f = GetFramework();
if (f.HasUnsavedEdits(countryId))
{
[alertController presentUnsavedEditsAlertWithOkBlock:^
{
f.Storage().DeleteNode(countryId);
}];
}
else
{
f.Storage().DeleteNode(countryId);
}
}
+ (void)cancelDownloadNode:(storage::TCountryId const &)countryId