From cd2ca3f2a1b32ec2b09294974e0f926ed1cf0ede Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Tue, 5 Dec 2017 20:54:52 +0100 Subject: [PATCH] - added new context menu option for systems, "select connections" --- js/app/map/map.js | 11 +++++-- js/app/map/util.js | 33 ++++++++++----------- js/app/ui/system_signature.js | 2 +- public/js/v1.3.1/app/map/map.js | 11 +++++-- public/js/v1.3.1/app/map/util.js | 33 ++++++++++----------- public/js/v1.3.1/app/ui/system_signature.js | 2 +- 6 files changed, 50 insertions(+), 42 deletions(-) diff --git a/js/app/map/map.js b/js/app/map/map.js index 75a181aa..8dff3596 100644 --- a/js/app/map/map.js +++ b/js/app/map/map.js @@ -725,11 +725,11 @@ define([ if(activeConnections.length > 0) { MapUtil.toggleConnectionActive(map, [connection]); }else{ - MapUtil.showConnectionInfo(map, connection); + MapUtil.showConnectionInfo(map, [connection]); } } }else{ - MapUtil.showConnectionInfo(map, connection); + MapUtil.showConnectionInfo(map, [connection]); } } }.bind(connection); @@ -1899,7 +1899,7 @@ define([ ]}, {divider: true, action: 'delete_connection'}, - {icon: 'fa-trash', action: 'delete_connection', text: 'delete'} + {icon: 'fa-chain-broken', action: 'delete_connection', text: 'detach'} ] }; @@ -1934,6 +1934,7 @@ define([ {icon: 'fa-plus', action: 'add_system', text: 'add system'}, {icon: 'fa-lock', action: 'lock_system', text: 'lock system'}, {icon: 'fa-volume-up', action: 'set_rally', text: 'set rally point'}, + {icon: 'fa-object-group', action: 'select_connections', text: 'select connections'}, {icon: 'fa-tags', text: 'set status', subitems: systemStatus}, {icon: 'fa-reply fa-rotate-180', text: 'waypoints', subitems: [ {subIcon: 'fa-flag-checkered', subAction: 'set_destination', subText: 'set destination'}, @@ -2289,6 +2290,10 @@ define([ currentSystem.markAsChanged(); } break; + case 'select_connections': + let connections = MapUtil.searchConnectionsBySystems(map, [currentSystem], '*'); + MapUtil.showConnectionInfo(map, connections); + break; case 'change_status_unknown': case 'change_status_friendly': case 'change_status_occupied': diff --git a/js/app/map/util.js b/js/app/map/util.js index e66ad305..ce2ecef7 100644 --- a/js/app/map/util.js +++ b/js/app/map/util.js @@ -414,17 +414,15 @@ define([ /** * mark a connection as "active" - * @param connection + * @param connections */ - let setConnectionActive = (map, connection) => { + let setConnectionsActive = (map, connections) => { // set all inactive - for(let tempConnection of getConnectionsByType(map, 'active')){ - if(tempConnection.getParameter('connectionId') !== connection.getParameter('connectionId')){ - tempConnection.removeType('active'); - } + for(let connection of getConnectionsByType(map, 'active')){ + connection.removeType('active'); } - if( !connection.hasType('active') ){ + for(let connection of connections){ connection.addType('active'); } }; @@ -494,17 +492,17 @@ define([ /** * show connection info panels * @param map - * @param connection + * @param connections */ - let showConnectionInfo = (map, connection) => { - setConnectionActive(map, connection); + let showConnectionInfo = (map, connections) => { + setConnectionsActive(map, connections); // get parent Tab Content and fire update event let mapContainer = $(map.getContainer()); let tabContentElement = getTabContentElementByMapElement(mapContainer); $(tabContentElement).trigger('pf:drawConnectionModules', { - connections: [connection], + connections: connections, mapId: parseInt(mapContainer.data('id')) }); }; @@ -528,20 +526,21 @@ define([ /** * search connections by systems - * @param {Object} map - jsPlumb - * @param {JQuery[]} systems - system DOM elements - * @returns {Array} connections - found connection, DOM elements + * @param map + * @param systems + * @param scope + * @returns {Array} */ - let searchConnectionsBySystems = (map, systems) => { + let searchConnectionsBySystems = (map, systems, scope) => { let connections = []; let withBackConnection = true; $.each(systems, function(i, system){ // get connections where system is source - connections = connections.concat( map.getConnections({source: system}) ); + connections = connections.concat( map.getConnections({scope: scope, source: system}) ); if(withBackConnection === true){ // get connections where system is target - connections = connections.concat( map.getConnections({target: system}) ); + connections = connections.concat( map.getConnections({scope: scope, target: system}) ); } }); return connections; diff --git a/js/app/ui/system_signature.js b/js/app/ui/system_signature.js index c2a921ca..76690cc1 100644 --- a/js/app/ui/system_signature.js +++ b/js/app/ui/system_signature.js @@ -1474,7 +1474,7 @@ define([ let getSignatureConnectionOptions = (mapId, systemData) => { let map = Map.getMapInstance( mapId ); let systemId = MapUtil.getSystemId(mapId, systemData.id); - let systemConnections = MapUtil.searchConnectionsBySystems(map, [systemId]); + let systemConnections = MapUtil.searchConnectionsBySystems(map, [systemId], 'wh'); let connectionOptions = []; for(let i = 0; i < systemConnections.length; i++){ diff --git a/public/js/v1.3.1/app/map/map.js b/public/js/v1.3.1/app/map/map.js index 75a181aa..8dff3596 100644 --- a/public/js/v1.3.1/app/map/map.js +++ b/public/js/v1.3.1/app/map/map.js @@ -725,11 +725,11 @@ define([ if(activeConnections.length > 0) { MapUtil.toggleConnectionActive(map, [connection]); }else{ - MapUtil.showConnectionInfo(map, connection); + MapUtil.showConnectionInfo(map, [connection]); } } }else{ - MapUtil.showConnectionInfo(map, connection); + MapUtil.showConnectionInfo(map, [connection]); } } }.bind(connection); @@ -1899,7 +1899,7 @@ define([ ]}, {divider: true, action: 'delete_connection'}, - {icon: 'fa-trash', action: 'delete_connection', text: 'delete'} + {icon: 'fa-chain-broken', action: 'delete_connection', text: 'detach'} ] }; @@ -1934,6 +1934,7 @@ define([ {icon: 'fa-plus', action: 'add_system', text: 'add system'}, {icon: 'fa-lock', action: 'lock_system', text: 'lock system'}, {icon: 'fa-volume-up', action: 'set_rally', text: 'set rally point'}, + {icon: 'fa-object-group', action: 'select_connections', text: 'select connections'}, {icon: 'fa-tags', text: 'set status', subitems: systemStatus}, {icon: 'fa-reply fa-rotate-180', text: 'waypoints', subitems: [ {subIcon: 'fa-flag-checkered', subAction: 'set_destination', subText: 'set destination'}, @@ -2289,6 +2290,10 @@ define([ currentSystem.markAsChanged(); } break; + case 'select_connections': + let connections = MapUtil.searchConnectionsBySystems(map, [currentSystem], '*'); + MapUtil.showConnectionInfo(map, connections); + break; case 'change_status_unknown': case 'change_status_friendly': case 'change_status_occupied': diff --git a/public/js/v1.3.1/app/map/util.js b/public/js/v1.3.1/app/map/util.js index e66ad305..ce2ecef7 100644 --- a/public/js/v1.3.1/app/map/util.js +++ b/public/js/v1.3.1/app/map/util.js @@ -414,17 +414,15 @@ define([ /** * mark a connection as "active" - * @param connection + * @param connections */ - let setConnectionActive = (map, connection) => { + let setConnectionsActive = (map, connections) => { // set all inactive - for(let tempConnection of getConnectionsByType(map, 'active')){ - if(tempConnection.getParameter('connectionId') !== connection.getParameter('connectionId')){ - tempConnection.removeType('active'); - } + for(let connection of getConnectionsByType(map, 'active')){ + connection.removeType('active'); } - if( !connection.hasType('active') ){ + for(let connection of connections){ connection.addType('active'); } }; @@ -494,17 +492,17 @@ define([ /** * show connection info panels * @param map - * @param connection + * @param connections */ - let showConnectionInfo = (map, connection) => { - setConnectionActive(map, connection); + let showConnectionInfo = (map, connections) => { + setConnectionsActive(map, connections); // get parent Tab Content and fire update event let mapContainer = $(map.getContainer()); let tabContentElement = getTabContentElementByMapElement(mapContainer); $(tabContentElement).trigger('pf:drawConnectionModules', { - connections: [connection], + connections: connections, mapId: parseInt(mapContainer.data('id')) }); }; @@ -528,20 +526,21 @@ define([ /** * search connections by systems - * @param {Object} map - jsPlumb - * @param {JQuery[]} systems - system DOM elements - * @returns {Array} connections - found connection, DOM elements + * @param map + * @param systems + * @param scope + * @returns {Array} */ - let searchConnectionsBySystems = (map, systems) => { + let searchConnectionsBySystems = (map, systems, scope) => { let connections = []; let withBackConnection = true; $.each(systems, function(i, system){ // get connections where system is source - connections = connections.concat( map.getConnections({source: system}) ); + connections = connections.concat( map.getConnections({scope: scope, source: system}) ); if(withBackConnection === true){ // get connections where system is target - connections = connections.concat( map.getConnections({target: system}) ); + connections = connections.concat( map.getConnections({scope: scope, target: system}) ); } }); return connections; diff --git a/public/js/v1.3.1/app/ui/system_signature.js b/public/js/v1.3.1/app/ui/system_signature.js index c2a921ca..76690cc1 100644 --- a/public/js/v1.3.1/app/ui/system_signature.js +++ b/public/js/v1.3.1/app/ui/system_signature.js @@ -1474,7 +1474,7 @@ define([ let getSignatureConnectionOptions = (mapId, systemData) => { let map = Map.getMapInstance( mapId ); let systemId = MapUtil.getSystemId(mapId, systemData.id); - let systemConnections = MapUtil.searchConnectionsBySystems(map, [systemId]); + let systemConnections = MapUtil.searchConnectionsBySystems(map, [systemId], 'wh'); let connectionOptions = []; for(let i = 0; i < systemConnections.length; i++){