- added new context menu option for systems, "select connections"
This commit is contained in:
@@ -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':
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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++){
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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++){
|
||||
|
||||
Reference in New Issue
Block a user