From e4002d4e8e28c271d240895ecdd804c721e450e0 Mon Sep 17 00:00:00 2001 From: Niv Greenstein Date: Sun, 17 Nov 2024 14:56:16 +0200 Subject: [PATCH 1/7] feat: added sub_type to routes with control cross/point/infrastructure --- devScripts/controlElasticsearchData.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/devScripts/controlElasticsearchData.json b/devScripts/controlElasticsearchData.json index d7aaa615..066465c0 100644 --- a/devScripts/controlElasticsearchData.json +++ b/devScripts/controlElasticsearchData.json @@ -381,6 +381,7 @@ "F_CODE": 8754111, "F_ATT": 951111, "ENTITY_HEB": "control point", + "SUB_TYPE": "CONTROL_POINT", "LAYER_NAME": "CONTROL_GIL_GDB.CTR_CONTROL_POINT_CROSS_N", "TYPE": "ITEM", "regions": [ @@ -406,9 +407,10 @@ "TIED_TO": "olimpiade", "F_CODE": 875411, "F_ATT": 95111, - "ENTITY_HEB": "control point", + "ENTITY_HEB": "control cross", "LAYER_NAME": "CONTROL_GIL_GDB.CTR_CONTROL_POINT_CROSS_N", - "TYPE": "ITEM" + "TYPE": "ITEM", + "SUB_TYPE": "CONTROL_CROSS" } } }, From 39d26ef34629b65fa3805697bfd48d67d22d4beb Mon Sep 17 00:00:00 2001 From: Niv Greenstein Date: Sun, 17 Nov 2024 14:56:56 +0200 Subject: [PATCH 2/7] feat: added CONTROL_POINT CONTROL_CROSS CONTROL_INFRASTRUCTURE to controlObjectDisplayNamePrefixes --- config/test.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/test.json b/config/test.json index 40fdcdb8..8ab26fdd 100644 --- a/config/test.json +++ b/config/test.json @@ -84,7 +84,9 @@ "SUB_TILE": "Sub Tile", "ROUTE": "Route", "ITEM": "Item", - "CONTROL_POINT": "Control Point" + "CONTROL_POINT": "Control Point", + "CONTROL_CROSS": "Control Cross", + "CONTROL_INFRASTRUCTURE": "Control Infrastructure" }, "nameTranslationsKeys": ["en", "fr"], "mainLanguageRegex": "[a-zA-Z]" From e47135dad432e33bde1822c3b2d106d9fec8be3b Mon Sep 17 00:00:00 2001 From: Niv Greenstein Date: Sun, 17 Nov 2024 14:57:22 +0200 Subject: [PATCH 3/7] feat: added properties.SUB_TYPE in order to get it in the control response --- src/control/constants.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/control/constants.ts b/src/control/constants.ts index 54747dc5..170e8fc2 100644 --- a/src/control/constants.ts +++ b/src/control/constants.ts @@ -20,4 +20,5 @@ export const CONTROL_FIELDS = [ 'properties.TIED_TO', 'properties.LAYER_NAME', 'properties.regions', + 'properties.SUB_TYPE', ]; From eb20f51e3e27d91dd30e956515a97c8661630a87 Mon Sep 17 00:00:00 2001 From: Niv Greenstein Date: Sun, 17 Nov 2024 14:57:49 +0200 Subject: [PATCH 4/7] feat: added sub_type type to Item interface --- src/control/item/models/item.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/control/item/models/item.ts b/src/control/item/models/item.ts index b5e49e4e..17e3c83e 100644 --- a/src/control/item/models/item.ts +++ b/src/control/item/models/item.ts @@ -8,5 +8,6 @@ export interface Item extends Feature { OBJECT_COMMAND_NAME: string; LAYER_NAME: string; TIED_TO?: string; + SUB_TYPE?: 'CONTROL_CROSS' | 'CONTROL_INFRASTRUCTURE' | 'CONTROL_POINT'; }; } From 6830aff3c3f935d0ea27749112ec0cca72d501d1 Mon Sep 17 00:00:00 2001 From: Niv Greenstein Date: Sun, 17 Nov 2024 14:58:16 +0200 Subject: [PATCH 5/7] feat: added CONTROL_CROSS CONTROL_INFRASTRUCTURE CONTROL_POINT to generateDisplayName --- src/control/utils.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/control/utils.ts b/src/control/utils.ts index 24204564..bb9b28e7 100644 --- a/src/control/utils.ts +++ b/src/control/utils.ts @@ -18,14 +18,18 @@ const generateDisplayName = ( displayNamePrefixes: IApplication['controlObjectDisplayNamePrefixes'] ): (string | undefined)[] => { const sourceType = - source.properties.TYPE === 'ITEM' && (source as Item).properties.TIED_TO !== undefined ? 'CONTROL_POINT' : source.properties.TYPE; + source.properties.TYPE === 'ITEM' && (source as Item).properties.SUB_TYPE !== undefined + ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + (source as Item).properties.SUB_TYPE! + : source.properties.TYPE; const name: (string | undefined)[] = []; sourceType === 'TILE' && name.unshift((source as Tile).properties.TILE_NAME); sourceType === 'SUB_TILE' && name.unshift((source as Tile).properties.SUB_TILE_ID); sourceType === 'ITEM' && name.unshift((source as Item).properties.OBJECT_COMMAND_NAME); sourceType === 'ROUTE' && name.unshift((source as Route).properties.OBJECT_COMMAND_NAME); - sourceType === 'CONTROL_POINT' && name.unshift((source as Item).properties.OBJECT_COMMAND_NAME); + ['CONTROL_CROSS', 'CONTROL_INFRASTRUCTURE', 'CONTROL_POINT'].find((val) => val === sourceType) !== undefined && + name.unshift((source as Item).properties.OBJECT_COMMAND_NAME); name.unshift(displayNamePrefixes[sourceType]); @@ -34,7 +38,7 @@ const generateDisplayName = ( name.unshift(displayNamePrefixes['TILE']); } - if (sourceType === 'CONTROL_POINT') { + if (['CONTROL_CROSS', 'CONTROL_INFRASTRUCTURE', 'CONTROL_POINT'].find((val) => val === sourceType) !== undefined) { name.unshift((source as Item).properties.TIED_TO); name.unshift(displayNamePrefixes['ROUTE']); } From be74f7c643438a6f8508bdf4f3c515e9cdc1944e Mon Sep 17 00:00:00 2001 From: Niv Greenstein Date: Sun, 17 Nov 2024 14:58:38 +0200 Subject: [PATCH 6/7] feat: added sub_type and translation to tests --- tests/mockObjects/routes.ts | 4 +++- tests/unit/control/route/route.spec.ts | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/mockObjects/routes.ts b/tests/mockObjects/routes.ts index f4d0a0cd..e605d9d4 100644 --- a/tests/mockObjects/routes.ts +++ b/tests/mockObjects/routes.ts @@ -64,6 +64,7 @@ export const CONTROL_POINT_OLIMPIADE_111: Route = { type: 'Point', }, properties: { + SUB_TYPE: 'CONTROL_POINT', OBJECT_COMMAND_NAME: '111', ENTITY_HEB: 'control point', TIED_TO: 'olimpiade', @@ -86,10 +87,11 @@ export const CONTROL_POINT_OLIMPIADE_112: Route = { }, properties: { OBJECT_COMMAND_NAME: '112', - ENTITY_HEB: 'control point', + ENTITY_HEB: 'control cross', TIED_TO: 'olimpiade', TYPE: 'ITEM' as never, LAYER_NAME: 'CONTROL_GIL_GDB.CTR_CONTROL_POINT_CROSS_N', regions: [], + SUB_TYPE: 'CONTROL_CROSS', }, }; diff --git a/tests/unit/control/route/route.spec.ts b/tests/unit/control/route/route.spec.ts index 50378edc..84ecdbce 100644 --- a/tests/unit/control/route/route.spec.ts +++ b/tests/unit/control/route/route.spec.ts @@ -15,7 +15,12 @@ let routeManager: RouteManager; describe('#RouteManager', () => { const getRoutes = jest.fn(); const getControlPointInRoute = jest.fn(); - const controlObjectDisplayNamePrefixes = { ROUTE: 'Route', CONTROL_POINT: 'Control Point' }; + const controlObjectDisplayNamePrefixes = { + ROUTE: 'Route', + CONTROL_POINT: 'Control Point', + CONTROL_CROSS: 'Control Cross', + CONTROL_INFRASTRUCTURE: 'Control Infrastructure', + }; beforeEach(() => { jest.resetAllMocks(); From 0dfad25c82560ec7d8935c9b3c567e9097bc96c9 Mon Sep 17 00:00:00 2001 From: Niv Greenstein Date: Wed, 20 Nov 2024 18:11:13 +0200 Subject: [PATCH 7/7] fix: CONTROL_CROSS, CONTROL_INFRASTRUCTURE don't need TIED TO postfix --- src/control/utils.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/control/utils.ts b/src/control/utils.ts index bb9b28e7..17a63b45 100644 --- a/src/control/utils.ts +++ b/src/control/utils.ts @@ -26,9 +26,7 @@ const generateDisplayName = ( const name: (string | undefined)[] = []; sourceType === 'TILE' && name.unshift((source as Tile).properties.TILE_NAME); sourceType === 'SUB_TILE' && name.unshift((source as Tile).properties.SUB_TILE_ID); - sourceType === 'ITEM' && name.unshift((source as Item).properties.OBJECT_COMMAND_NAME); - sourceType === 'ROUTE' && name.unshift((source as Route).properties.OBJECT_COMMAND_NAME); - ['CONTROL_CROSS', 'CONTROL_INFRASTRUCTURE', 'CONTROL_POINT'].find((val) => val === sourceType) !== undefined && + (<(typeof sourceType)[]>['ITEM', 'ROUTE', 'CONTROL_CROSS', 'CONTROL_INFRASTRUCTURE', 'CONTROL_POINT']).some((val) => val === sourceType) && name.unshift((source as Item).properties.OBJECT_COMMAND_NAME); name.unshift(displayNamePrefixes[sourceType]); @@ -38,7 +36,7 @@ const generateDisplayName = ( name.unshift(displayNamePrefixes['TILE']); } - if (['CONTROL_CROSS', 'CONTROL_INFRASTRUCTURE', 'CONTROL_POINT'].find((val) => val === sourceType) !== undefined) { + if (sourceType === 'CONTROL_POINT') { name.unshift((source as Item).properties.TIED_TO); name.unshift(displayNamePrefixes['ROUTE']); }