From f8ea97c8fe910fcf0228b3d61cb56bb075e12d91 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Tue, 20 Mar 2018 19:35:48 +0100 Subject: [PATCH] - added "system type" (e.g. WH, 0.0,..) to signature "leads to" select, #597 --- js/app/map/util.js | 23 +++++++++++ js/app/ui/system_signature.js | 45 +++++++++++++-------- public/js/v1.3.4/app/map/util.js | 23 +++++++++++ public/js/v1.3.4/app/ui/system_signature.js | 45 +++++++++++++-------- 4 files changed, 102 insertions(+), 34 deletions(-) diff --git a/js/app/map/util.js b/js/app/map/util.js index 34e08abe..bce461ee 100644 --- a/js/app/map/util.js +++ b/js/app/map/util.js @@ -162,6 +162,28 @@ define([ return systemInfo; }; + /** + * get system data by mapId and systemid + * @param mapId + * @param systemId + * @returns {boolean} + */ + let getSystemData = (mapId, systemId) => { + let systemData = false; + let mapData = Util.getCurrentMapData(mapId); + + if(mapData){ + for(let j = 0; j < mapData.data.systems.length; j++){ + let systemDataTemp = mapData.data.systems[j]; + if(systemDataTemp.id === systemId){ + systemData = systemDataTemp; + break; + } + } + } + return systemData; + }; + /** * get system type information * @param {number} systemTypeId @@ -1060,6 +1082,7 @@ define([ getMapIcons: getMapIcons, getInfoForMap: getInfoForMap, getInfoForSystem: getInfoForSystem, + getSystemData: getSystemData, getSystemTypeInfo: getSystemTypeInfo, getEffectInfoForSystem: getEffectInfoForSystem, toggleSelectSystem: toggleSelectSystem, diff --git a/js/app/ui/system_signature.js b/js/app/ui/system_signature.js index a5a40e1b..df36b649 100644 --- a/js/app/ui/system_signature.js +++ b/js/app/ui/system_signature.js @@ -1500,6 +1500,7 @@ define([ let map = Map.getMapInstance( mapId ); let systemId = MapUtil.getSystemId(mapId, systemData.id); let systemConnections = MapUtil.searchConnectionsBySystems(map, [systemId], 'wh'); + let newSelectOptions = []; let connectionOptions = []; for(let i = 0; i < systemConnections.length; i++){ @@ -1510,25 +1511,35 @@ define([ // check whether "source" or "target" system is relevant for this connection // -> hint "source" === 'target' --> loop if(systemData.id !== connectionData.target){ - // take target... - connectionOptions.push({ - value: connectionData.id, - text: connectionData.targetAlias - }); + let targetSystemData = MapUtil.getSystemData(mapId, connectionData.target); + if(targetSystemData){ + // take target... + connectionOptions.push({ + value: connectionData.id, + text: connectionData.targetAlias + ' - ' + targetSystemData.security + }); + } }else if(systemData.id !== connectionData.source){ - // take source... - connectionOptions.push({ - value: connectionData.id, - text: connectionData.sourceAlias - }); + let sourceSystemData = MapUtil.getSystemData(mapId, connectionData.source); + if(sourceSystemData){ + // take source... + connectionOptions.push({ + value: connectionData.id, + text: connectionData.sourceAlias + ' - ' + sourceSystemData.security + }); + } } } } - // add empty entry - connectionOptions.unshift({ value: null, text: ''}); + if(connectionOptions.length > 0){ + newSelectOptions.push({ text: 'System', children: connectionOptions}); + } - return connectionOptions; + // add empty entry + newSelectOptions.unshift({ value: null, text: ''}); + + return newSelectOptions; }; /** @@ -1621,7 +1632,7 @@ define([ if(newSelectOptionsCount > 0){ if(groupId === 5){ // "wormhole" selected => multiple available - newSelectOptions.push({ text: 'Wandering WHs', children: fixSelectOptions}); + newSelectOptions.push({ text: 'Wandering WH', children: fixSelectOptions}); }else{ newSelectOptions = fixSelectOptions; } @@ -1645,7 +1656,7 @@ define([ } if(frigateWHData.length > 0){ - newSelectOptions.push({ text: 'Frigate WHs', children: frigateWHData}); + newSelectOptions.push({ text: 'Frigate WH', children: frigateWHData}); } // add possible incoming holes @@ -1661,7 +1672,7 @@ define([ } if(incomingWHData.length > 0){ - newSelectOptions.push({ text: 'Incoming WHs', children: incomingWHData}); + newSelectOptions.push({ text: 'Incoming WH', children: incomingWHData}); } }else{ // groups without "children" (optgroup) should be sorted by "value" @@ -1686,7 +1697,7 @@ define([ } if(staticWHData.length > 0){ - newSelectOptions.unshift({ text: 'Static WHs', children: staticWHData}); + newSelectOptions.unshift({ text: 'Static WH', children: staticWHData}); } } } diff --git a/public/js/v1.3.4/app/map/util.js b/public/js/v1.3.4/app/map/util.js index 34e08abe..bce461ee 100644 --- a/public/js/v1.3.4/app/map/util.js +++ b/public/js/v1.3.4/app/map/util.js @@ -162,6 +162,28 @@ define([ return systemInfo; }; + /** + * get system data by mapId and systemid + * @param mapId + * @param systemId + * @returns {boolean} + */ + let getSystemData = (mapId, systemId) => { + let systemData = false; + let mapData = Util.getCurrentMapData(mapId); + + if(mapData){ + for(let j = 0; j < mapData.data.systems.length; j++){ + let systemDataTemp = mapData.data.systems[j]; + if(systemDataTemp.id === systemId){ + systemData = systemDataTemp; + break; + } + } + } + return systemData; + }; + /** * get system type information * @param {number} systemTypeId @@ -1060,6 +1082,7 @@ define([ getMapIcons: getMapIcons, getInfoForMap: getInfoForMap, getInfoForSystem: getInfoForSystem, + getSystemData: getSystemData, getSystemTypeInfo: getSystemTypeInfo, getEffectInfoForSystem: getEffectInfoForSystem, toggleSelectSystem: toggleSelectSystem, diff --git a/public/js/v1.3.4/app/ui/system_signature.js b/public/js/v1.3.4/app/ui/system_signature.js index a5a40e1b..df36b649 100644 --- a/public/js/v1.3.4/app/ui/system_signature.js +++ b/public/js/v1.3.4/app/ui/system_signature.js @@ -1500,6 +1500,7 @@ define([ let map = Map.getMapInstance( mapId ); let systemId = MapUtil.getSystemId(mapId, systemData.id); let systemConnections = MapUtil.searchConnectionsBySystems(map, [systemId], 'wh'); + let newSelectOptions = []; let connectionOptions = []; for(let i = 0; i < systemConnections.length; i++){ @@ -1510,25 +1511,35 @@ define([ // check whether "source" or "target" system is relevant for this connection // -> hint "source" === 'target' --> loop if(systemData.id !== connectionData.target){ - // take target... - connectionOptions.push({ - value: connectionData.id, - text: connectionData.targetAlias - }); + let targetSystemData = MapUtil.getSystemData(mapId, connectionData.target); + if(targetSystemData){ + // take target... + connectionOptions.push({ + value: connectionData.id, + text: connectionData.targetAlias + ' - ' + targetSystemData.security + }); + } }else if(systemData.id !== connectionData.source){ - // take source... - connectionOptions.push({ - value: connectionData.id, - text: connectionData.sourceAlias - }); + let sourceSystemData = MapUtil.getSystemData(mapId, connectionData.source); + if(sourceSystemData){ + // take source... + connectionOptions.push({ + value: connectionData.id, + text: connectionData.sourceAlias + ' - ' + sourceSystemData.security + }); + } } } } - // add empty entry - connectionOptions.unshift({ value: null, text: ''}); + if(connectionOptions.length > 0){ + newSelectOptions.push({ text: 'System', children: connectionOptions}); + } - return connectionOptions; + // add empty entry + newSelectOptions.unshift({ value: null, text: ''}); + + return newSelectOptions; }; /** @@ -1621,7 +1632,7 @@ define([ if(newSelectOptionsCount > 0){ if(groupId === 5){ // "wormhole" selected => multiple available - newSelectOptions.push({ text: 'Wandering WHs', children: fixSelectOptions}); + newSelectOptions.push({ text: 'Wandering WH', children: fixSelectOptions}); }else{ newSelectOptions = fixSelectOptions; } @@ -1645,7 +1656,7 @@ define([ } if(frigateWHData.length > 0){ - newSelectOptions.push({ text: 'Frigate WHs', children: frigateWHData}); + newSelectOptions.push({ text: 'Frigate WH', children: frigateWHData}); } // add possible incoming holes @@ -1661,7 +1672,7 @@ define([ } if(incomingWHData.length > 0){ - newSelectOptions.push({ text: 'Incoming WHs', children: incomingWHData}); + newSelectOptions.push({ text: 'Incoming WH', children: incomingWHData}); } }else{ // groups without "children" (optgroup) should be sorted by "value" @@ -1686,7 +1697,7 @@ define([ } if(staticWHData.length > 0){ - newSelectOptions.unshift({ text: 'Static WHs', children: staticWHData}); + newSelectOptions.unshift({ text: 'Static WH', children: staticWHData}); } } }