[ios] Fixed cuisine editor.

This commit is contained in:
Ilya Grechuhin 2016-01-28 16:14:50 +03:00 committed by Sergey Yershov
parent 0de05e707f
commit 3374912a03
2 changed files with 14 additions and 6 deletions

View file

@ -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];

View file

@ -15,6 +15,18 @@ namespace
NSString * const kOSMCuisineSeparator = @";";
NSString * const kMWMCuisineSeparator = @" • ";
NSString * makeOSMCuisineString(NSSet<NSString *> * cuisines)
{
NSMutableArray<NSString *> * 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<MWMPlacePageCellType, 10> 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<Metadata::EType>(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;
}