From 3374912a0383ca389f3bdb6f14ec16e03948ab93 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Thu, 28 Jan 2016 16:14:50 +0300 Subject: [PATCH] [ios] Fixed cuisine editor. --- .../Classes/Editor/MWMEditorViewController.mm | 1 + iphone/Maps/Classes/MWMPlacePageEntity.mm | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm index 120f69a1d8..547c37a328 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm +++ b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm @@ -168,6 +168,7 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) if (!m_edited_cells.empty()) { MWMAuthorizationSetNeedCheck(YES); + self.entity.cuisines = self.cuisines; [self.entity saveEditedCells:m_edited_cells]; } [self onCancel]; diff --git a/iphone/Maps/Classes/MWMPlacePageEntity.mm b/iphone/Maps/Classes/MWMPlacePageEntity.mm index daeee48fea..ddf4ed79c5 100644 --- a/iphone/Maps/Classes/MWMPlacePageEntity.mm +++ b/iphone/Maps/Classes/MWMPlacePageEntity.mm @@ -15,6 +15,18 @@ namespace NSString * const kOSMCuisineSeparator = @";"; NSString * const kMWMCuisineSeparator = @" • "; +NSString * makeOSMCuisineString(NSSet * cuisines) +{ + NSMutableArray * osmCuisines = [NSMutableArray arrayWithCapacity:cuisines.count]; + for (NSString * cuisine in cuisines) + [osmCuisines addObject:cuisine]; + [osmCuisines sortUsingComparator:^NSComparisonResult(NSString * s1, NSString * s2) + { + return [s1 compare:s2]; + }]; + return [osmCuisines componentsJoinedByString:kOSMCuisineSeparator]; +} + array const gMetaFieldsMap{ {MWMPlacePageCellTypePostcode, MWMPlacePageCellTypePhoneNumber, MWMPlacePageCellTypeWebsite, MWMPlacePageCellTypeURL, MWMPlacePageCellTypeEmail, MWMPlacePageCellTypeOpenHours, @@ -49,11 +61,6 @@ void initFieldsMap() ASSERT_EQUAL(kMetaFieldsMap[MWMPlacePageCellTypeSpacer], 0, ()); ASSERT_EQUAL(kMetaFieldsMap[Metadata::FMD_MAXSPEED], 0, ()); } - -NSString * mwmToOSMCuisineString(NSString * mwmCuisine) -{ - return [mwmCuisine stringByReplacingOccurrencesOfString:kMWMCuisineSeparator withString:kOSMCuisineSeparator]; -} } // namespace @interface MWMPlacePageEntity () @@ -400,7 +407,7 @@ NSString * mwmToOSMCuisineString(NSString * mwmCuisine) { Metadata::EType const fmdType = static_cast(kMetaFieldsMap[cell.first]); NSAssert(fmdType > 0 && fmdType < Metadata::FMD_COUNT, @"Incorrect enum value"); - NSString * osmCuisineStr = mwmToOSMCuisineString(@(cell.second.c_str())); + NSString * osmCuisineStr = makeOSMCuisineString(self.cuisines); metadata.Set(fmdType, osmCuisineStr.UTF8String); break; }