From c99b04134105c452d6d775e8b48d65556e2e348a Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Mon, 19 Mar 2018 19:06:02 +0300 Subject: [PATCH] [editor] Inherit editing properties for long types --- editor/editor_config.cpp | 8 ++++++++ editor/editor_tests/editor_config_test.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/editor/editor_config.cpp b/editor/editor_config.cpp index 39898031c2..d28c34822e 100644 --- a/editor/editor_config.cpp +++ b/editor/editor_config.cpp @@ -119,6 +119,7 @@ bool EditorConfig::GetTypeDescription(vector classificatorTypes, TypeAggregatedDescription & outDesc) const { bool isBuilding = false; + vector addTypes; for (auto it = classificatorTypes.begin(); it != classificatorTypes.end(); ++it) { if (*it == "building") @@ -129,7 +130,14 @@ bool EditorConfig::GetTypeDescription(vector classificatorTypes, classificatorTypes.erase(it); break; } + // Adding partial types for 2..N-1 parts of a N-part type. + auto hyphenPos = it->find('-'); + while ((hyphenPos = it->find('-', hyphenPos+1)) != string::npos) + { + addTypes.push_back(it->substr(0, hyphenPos)); + } } + classificatorTypes.insert(classificatorTypes.end(), addTypes.begin(), addTypes.end()); auto const typeNodes = GetPrioritizedTypes(m_document); auto const it = find_if(begin(typeNodes), end(typeNodes), diff --git a/editor/editor_tests/editor_config_test.cpp b/editor/editor_tests/editor_config_test.cpp index 3edf440291..c8fbd02f4a 100644 --- a/editor/editor_tests/editor_config_test.cpp +++ b/editor/editor_tests/editor_config_test.cpp @@ -60,6 +60,20 @@ UNIT_TEST(EditorConfig_TypeDescription) my::SortUnique(fields); TEST_EQUAL(desc.GetEditableFields(), fields, ()); } + { + // Testing type inheritance + editor::TypeAggregatedDescription desc; + TEST(config.GetTypeDescription({"amenity-place_of_worship-christian"}, desc), ()); + TEST(desc.IsNameEditable(), ()); + TEST_EQUAL(desc.GetEditableFields(), poi, ()); + } + { + // Testing long type inheritance on a fake object + editor::TypeAggregatedDescription desc; + TEST(config.GetTypeDescription({"tourism-artwork-impresionism-monet"}, desc), ()); + TEST(desc.IsNameEditable(), ()); + TEST_EQUAL(desc.GetEditableFields(), TFields {}, ()); + } // TODO(mgsergio): Test case with priority="high" when there is one on editor.config. }