diff --git a/iphone/Maps/UI/Editor/MWMEditorViewController.mm b/iphone/Maps/UI/Editor/MWMEditorViewController.mm index fa7f871798..d2ac79f392 100644 --- a/iphone/Maps/UI/Editor/MWMEditorViewController.mm +++ b/iphone/Maps/UI/Editor/MWMEditorViewController.mm @@ -37,8 +37,8 @@ NSString * const kCategoryEditorSegue = @"Editor2CategoryEditorSegue"; NSString * const kUDEditorPersonalInfoWarninWasShown = @"PersonalInfoWarningAlertWasShown"; -CGFloat const kDefaultHeaderHeight = 28.; -CGFloat const kDefaultFooterHeight = 32.; +CGFloat constexpr kDefaultHeaderHeight = 28.; +CGFloat constexpr kDefaultFooterHeight = 32.; typedef NS_ENUM(NSUInteger, MWMEditorSection) { MWMEditorSectionCategory, @@ -57,8 +57,7 @@ std::vector const kSectionAddressCellTypes { std::vector const kSectionNoteCellTypes { MWMEditorCellTypeNote }; std::vector const kSectionButtonCellTypes { MWMEditorCellTypeReportButton }; -using MWMEditorCellTypeClassMap = std::map; -MWMEditorCellTypeClassMap const kCellType2Class { +std::map const kCellType2Class { {MWMEditorCellTypeCategory, [MWMEditorCategoryCell class]}, {MWMEditorCellTypeAdditionalName, [MWMEditorAdditionalNameTableViewCell class]}, {MWMEditorCellTypeAddAdditionalName, [MWMEditorAddAdditionalNameTableViewCell class]}, @@ -327,10 +326,15 @@ void registerCellsForTableView(std::vector const & cells, UITab registerCellsForTableView(kSectionCategoryCellTypes, self.tableView); BOOL const isNameEditable = m_mapObject.IsNameEditable(); BOOL const isAddressEditable = m_mapObject.IsAddressEditable(); - BOOL const areEditablePropertiesEmpty = m_mapObject.GetEditableProperties().empty(); + auto editableProperties = m_mapObject.GetEditableProperties(); + // Remove fields that are already displayed in the Address section. + editableProperties.erase(std::remove_if(editableProperties.begin(), editableProperties.end(), [](osm::MapObject::MetadataID mid) + { + return mid == MetadataID::FMD_POSTCODE || mid == MetadataID::FMD_BUILDING_LEVELS; + }), editableProperties.end()); BOOL const isCreating = self.isCreating; BOOL const isThereNotes = - !isCreating && areEditablePropertiesEmpty && !isAddressEditable && !isNameEditable; + !isCreating && editableProperties.empty() && !isAddressEditable && !isNameEditable; if (isNameEditable) { @@ -355,16 +359,12 @@ void registerCellsForTableView(std::vector const & cells, UITab registerCellsForTableView(kSectionAddressCellTypes, self.tableView); } - if (!areEditablePropertiesEmpty) + if (!editableProperties.empty()) { - auto const cells = m_mapObject.GetEditableProperties(); - if (!cells.empty()) - { - m_sections.push_back(MWMEditorSectionDetails); - auto & v = m_cells[MWMEditorSectionDetails]; - v.assign(cells.begin(), cells.end()); - registerCellsForTableView(v, self.tableView); - } + m_sections.push_back(MWMEditorSectionDetails); + auto & v = m_cells[MWMEditorSectionDetails]; + v.assign(editableProperties.begin(), editableProperties.end()); + registerCellsForTableView(v, self.tableView); } if (isThereNotes)