diff --git a/app/main/model/systemmodel.php b/app/main/model/systemmodel.php index 4eda98cc..d0fd8fc2 100644 --- a/app/main/model/systemmodel.php +++ b/app/main/model/systemmodel.php @@ -256,6 +256,7 @@ class SystemModel extends AbstractMapTrackingModel { $systemData->region->id = $this->regionId; $systemData->region->name = $this->region; + $systemData->planets = $this->planets ? : []; $systemData->statics = $this->statics ? : []; // max caching time for a system @@ -454,6 +455,10 @@ class SystemModel extends AbstractMapTrackingModel { return $this->getStaticSystemValue('statics'); } + public function get_planets(){ + return $this->getStaticSystemValue('planets'); + } + /** * Event "Hook" function * @param self $self diff --git a/app/main/model/universe/planetmodel.php b/app/main/model/universe/planetmodel.php index ce890c13..7f60c5bd 100644 --- a/app/main/model/universe/planetmodel.php +++ b/app/main/model/universe/planetmodel.php @@ -67,13 +67,10 @@ class PlanetModel extends BasicUniverseModel { */ public function getData(){ $planetData = (object) []; - $planetData->id = $this->_id; $planetData->name = $this->name; - $planetData->position = (object) []; - $planetData->position->x = $this->x; - $planetData->position->y = $this->y; - $planetData->position->z = $this->z; + $planetData->type = (object) []; + $planetData->type->name = $this->typeId->name; return $planetData; } diff --git a/js/app/map/map.js b/js/app/map/map.js index 1fff99f4..f626c38c 100644 --- a/js/app/map/map.js +++ b/js/app/map/map.js @@ -482,6 +482,7 @@ define([ system.data('region', data.region.name); system.data('constellationId', parseInt(data.constellation.id)); system.data('constellation', data.constellation.name); + system.data('planets', data.planets); system.data('shattered', data.shattered); system.data('statics', data.statics); system.data('updated', parseInt(data.updated.updated)); @@ -3285,6 +3286,7 @@ define([ systemData.rallyUpdated = system.data('rallyUpdated') || 0; systemData.rallyPoke = system.data('rallyPoke') ? 1 : 0; systemData.currentUser = system.data('currentUser'); // if user is currently in this system + systemData.planets = system.data('planets'); systemData.shattered = system.data('shattered') ? 1 : 0; systemData.statics = system.data('statics'); systemData.updated = { diff --git a/js/app/map/util.js b/js/app/map/util.js index b3860d05..6003409d 100644 --- a/js/app/map/util.js +++ b/js/app/map/util.js @@ -1143,6 +1143,36 @@ define([ }); }; + /** + * add system planets tooltip + * @param planets + * @param options + * @returns {*} + */ + $.fn.addSystemPlanetsTooltip = function(planets, options){ + + let content = Util.getSystemPlanetsTable(planets); + + let defaultOptions = { + placement: 'top', + html: true, + trigger: 'hover', + container: 'body', + title: 'Planets', + content: content, + delay: { + show: 150, + hide: 0 + }, + }; + + options = $.extend({}, defaultOptions, options); + + return this.each(function(){ + $(this).popover(options); + }); + }; + /** * add a wormhole tooltip with wh specific data to elements * @param tooltipData diff --git a/js/app/ui/system_info.js b/js/app/ui/system_info.js index 45e4e32e..56452284 100644 --- a/js/app/ui/system_info.js +++ b/js/app/ui/system_info.js @@ -26,8 +26,9 @@ define([ // info table systemInfoTableClass: 'pf-module-table', // class for system info table - systemInfoNameInfoClass: 'pf-system-info-name', // class for "name" information element - systemInfoEffectInfoClass: 'pf-system-info-effect', // class for "effect" information element + systemInfoNameClass: 'pf-system-info-name', // class for "name" information element + systemInfoEffectClass: 'pf-system-info-effect', // class for "effect" information element + systemInfoPlanetsClass: 'pf-system-info-planets', // class for "planets" information element systemInfoStatusLabelClass: 'pf-system-info-status-label', // class for "status" information element systemInfoStatusAttributeName: 'data-status', // attribute name for status label systemInfoWormholeClass: 'pf-system-info-wormhole-', // class prefix for static wormhole element @@ -110,7 +111,7 @@ define([ if(systemId === systemData.id){ // update module - // system status ===================================================================================== + // system status ========================================================================================== let systemStatusLabelElement = moduleElement.find('.' + config.systemInfoStatusLabelClass); let systemStatusId = parseInt( systemStatusLabelElement.attr( config.systemInfoStatusAttributeName ) ); @@ -127,7 +128,7 @@ define([ systemStatusLabelElement.attr( config.systemInfoStatusAttributeName, systemData.status.id); } - // description textarea element ====================================================================== + // description textarea element =========================================================================== let descriptionTextareaElement = moduleElement.find('.' + config.descriptionTextareaElementClass); let description = descriptionTextareaElement.editable('getValue', true); @@ -157,9 +158,8 @@ define([ } } - // created/updated tooltip =========================================================================== - - let nameRowElement = $(moduleElement).find('.' + config.systemInfoNameInfoClass); + // created/updated tooltip ================================================================================ + let nameRowElement = $(moduleElement).find('.' + config.systemInfoNameClass); let tooltipData = { created: systemData.created, @@ -277,7 +277,7 @@ define([ } }); - // on xEditable open ------------------------------------------------------------------------- + // on xEditable open ------------------------------------------------------------------------------ descriptionTextareaElement.on('shown', function(e, editable){ let textarea = editable.input.$input; @@ -298,7 +298,7 @@ define([ }); }); - // on xEditable close ------------------------------------------------------------------------ + // on xEditable close ----------------------------------------------------------------------------- descriptionTextareaElement.on('hidden', function(e){ let value = $(this).editable('getValue', true); if(value.length === 0){ @@ -311,7 +311,7 @@ define([ disableModuleUpdate = false; }); - // enable xEditable field on Button click ---------------------------------------------------- + // enable xEditable field on Button click --------------------------------------------------------- descriptionButton.on('click', function(e){ e.stopPropagation(); let descriptionButton = $(this); @@ -325,20 +325,23 @@ define([ showToolsActionElement(descriptionButton.siblings('.' + config.tableToolsActionClass)); }); - // init tooltips ----------------------------------------------------------------------------- + // init tooltips ---------------------------------------------------------------------------------- let tooltipElements = tempModuleElement.find('[data-toggle="tooltip"]'); tooltipElements.tooltip(); - // init system effect popover ---------------------------------------------------------------- - $(moduleElement).find('.' + config.systemInfoEffectInfoClass).addSystemEffectTooltip(systemData.security, systemData.effect); + // init system effect popover --------------------------------------------------------------------- + $(moduleElement).find('.' + config.systemInfoEffectClass).addSystemEffectTooltip(systemData.security, systemData.effect); - // init static wormhole information ---------------------------------------------------------- + // init planets popover --------------------------------------------------------------------------- + $(moduleElement).find('.' + config.systemInfoPlanetsClass).addSystemPlanetsTooltip(systemData.planets); + + // init static wormhole information --------------------------------------------------------------- for(let staticData of staticsData){ let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name); staticRowElement.addWormholeInfoTooltip(staticData); } - // constellation popover --------------------------------------------------------------------- + // constellation popover -------------------------------------------------------------------------- tempModuleElement.find('a.popup-ajax').popover({ html: true, trigger: 'hover', @@ -369,13 +372,14 @@ define([ } } }; - +console.log(systemData) let moduleData = { system: systemData, static: staticsData, tableClass: config.systemInfoTableClass, - nameInfoClass: config.systemInfoNameInfoClass, - effectInfoClass: config.systemInfoEffectInfoClass, + nameInfoClass: config.systemInfoNameClass, + effectInfoClass: config.systemInfoEffectClass, + planetsInfoClass: config.systemInfoPlanetsClass, wormholePrefixClass: config.systemInfoWormholeClass, statusInfoClass: config.systemInfoStatusLabelClass, @@ -401,6 +405,7 @@ define([ formatUrl: () => { return (val, render) => render(val).replace(/ /g, '_'); }, + planetCount: systemData.planets ? systemData.planets.length : 0, shatteredClass: Util.getSecurityClassForSystem('SH'), diff --git a/js/app/util.js b/js/app/util.js index e6ca7f53..35bab6d1 100644 --- a/js/app/util.js +++ b/js/app/util.js @@ -1640,19 +1640,43 @@ define([ * @param data * @returns {string} */ - let getSystemEffectTable = function(data){ + let getSystemEffectTable = effects => { let table = ''; - - if(data.length > 0){ - + if(effects.length > 0){ table += ''; - for(let i = 0; i < data.length; i++){ + for(let effect of effects){ table += ''; table += ''; table += ''; + table += ''; + } + table += '
'; - table += data[i].effect; + table += effect.effect; table += ''; - table += data[i].value; + table += effect.value; + table += '
'; + } + + return table; + }; + + /** + * get a HTML table with planet names + * e.g. for popover + * @param planets + * @returns {string} + */ + let getSystemPlanetsTable = planets => { + let table = ''; + if(planets.length > 0){ + table += ''; + for(let planet of planets){ + table += ''; + table += ''; + table += ''; table += ''; } @@ -1668,7 +1692,7 @@ define([ * @param data * @returns {string} */ - let getSystemsInfoTable = function(data){ + let getSystemsInfoTable = data => { let table = ''; if(data.length > 0){ @@ -1702,7 +1726,7 @@ define([ * @param sec * @returns {string} */ - let getSecurityClassForSystem = (sec) => { + let getSecurityClassForSystem = sec => { let secClass = ''; if( Init.classes.systemSecurity.hasOwnProperty(sec) ){ secClass = Init.classes.systemSecurity[sec]['class']; @@ -2613,6 +2637,7 @@ define([ getMapModule: getMapModule, getSystemEffectData: getSystemEffectData, getSystemEffectTable: getSystemEffectTable, + getSystemPlanetsTable: getSystemPlanetsTable, getSystemsInfoTable: getSystemsInfoTable, getStatusInfoForCharacter: getStatusInfoForCharacter, getSecurityClassForSystem: getSecurityClassForSystem, diff --git a/public/js/v1.3.6/app/map/map.js b/public/js/v1.3.6/app/map/map.js index 1fff99f4..f626c38c 100644 --- a/public/js/v1.3.6/app/map/map.js +++ b/public/js/v1.3.6/app/map/map.js @@ -482,6 +482,7 @@ define([ system.data('region', data.region.name); system.data('constellationId', parseInt(data.constellation.id)); system.data('constellation', data.constellation.name); + system.data('planets', data.planets); system.data('shattered', data.shattered); system.data('statics', data.statics); system.data('updated', parseInt(data.updated.updated)); @@ -3285,6 +3286,7 @@ define([ systemData.rallyUpdated = system.data('rallyUpdated') || 0; systemData.rallyPoke = system.data('rallyPoke') ? 1 : 0; systemData.currentUser = system.data('currentUser'); // if user is currently in this system + systemData.planets = system.data('planets'); systemData.shattered = system.data('shattered') ? 1 : 0; systemData.statics = system.data('statics'); systemData.updated = { diff --git a/public/js/v1.3.6/app/map/util.js b/public/js/v1.3.6/app/map/util.js index b3860d05..6003409d 100644 --- a/public/js/v1.3.6/app/map/util.js +++ b/public/js/v1.3.6/app/map/util.js @@ -1143,6 +1143,36 @@ define([ }); }; + /** + * add system planets tooltip + * @param planets + * @param options + * @returns {*} + */ + $.fn.addSystemPlanetsTooltip = function(planets, options){ + + let content = Util.getSystemPlanetsTable(planets); + + let defaultOptions = { + placement: 'top', + html: true, + trigger: 'hover', + container: 'body', + title: 'Planets', + content: content, + delay: { + show: 150, + hide: 0 + }, + }; + + options = $.extend({}, defaultOptions, options); + + return this.each(function(){ + $(this).popover(options); + }); + }; + /** * add a wormhole tooltip with wh specific data to elements * @param tooltipData diff --git a/public/js/v1.3.6/app/ui/system_info.js b/public/js/v1.3.6/app/ui/system_info.js index 45e4e32e..56452284 100644 --- a/public/js/v1.3.6/app/ui/system_info.js +++ b/public/js/v1.3.6/app/ui/system_info.js @@ -26,8 +26,9 @@ define([ // info table systemInfoTableClass: 'pf-module-table', // class for system info table - systemInfoNameInfoClass: 'pf-system-info-name', // class for "name" information element - systemInfoEffectInfoClass: 'pf-system-info-effect', // class for "effect" information element + systemInfoNameClass: 'pf-system-info-name', // class for "name" information element + systemInfoEffectClass: 'pf-system-info-effect', // class for "effect" information element + systemInfoPlanetsClass: 'pf-system-info-planets', // class for "planets" information element systemInfoStatusLabelClass: 'pf-system-info-status-label', // class for "status" information element systemInfoStatusAttributeName: 'data-status', // attribute name for status label systemInfoWormholeClass: 'pf-system-info-wormhole-', // class prefix for static wormhole element @@ -110,7 +111,7 @@ define([ if(systemId === systemData.id){ // update module - // system status ===================================================================================== + // system status ========================================================================================== let systemStatusLabelElement = moduleElement.find('.' + config.systemInfoStatusLabelClass); let systemStatusId = parseInt( systemStatusLabelElement.attr( config.systemInfoStatusAttributeName ) ); @@ -127,7 +128,7 @@ define([ systemStatusLabelElement.attr( config.systemInfoStatusAttributeName, systemData.status.id); } - // description textarea element ====================================================================== + // description textarea element =========================================================================== let descriptionTextareaElement = moduleElement.find('.' + config.descriptionTextareaElementClass); let description = descriptionTextareaElement.editable('getValue', true); @@ -157,9 +158,8 @@ define([ } } - // created/updated tooltip =========================================================================== - - let nameRowElement = $(moduleElement).find('.' + config.systemInfoNameInfoClass); + // created/updated tooltip ================================================================================ + let nameRowElement = $(moduleElement).find('.' + config.systemInfoNameClass); let tooltipData = { created: systemData.created, @@ -277,7 +277,7 @@ define([ } }); - // on xEditable open ------------------------------------------------------------------------- + // on xEditable open ------------------------------------------------------------------------------ descriptionTextareaElement.on('shown', function(e, editable){ let textarea = editable.input.$input; @@ -298,7 +298,7 @@ define([ }); }); - // on xEditable close ------------------------------------------------------------------------ + // on xEditable close ----------------------------------------------------------------------------- descriptionTextareaElement.on('hidden', function(e){ let value = $(this).editable('getValue', true); if(value.length === 0){ @@ -311,7 +311,7 @@ define([ disableModuleUpdate = false; }); - // enable xEditable field on Button click ---------------------------------------------------- + // enable xEditable field on Button click --------------------------------------------------------- descriptionButton.on('click', function(e){ e.stopPropagation(); let descriptionButton = $(this); @@ -325,20 +325,23 @@ define([ showToolsActionElement(descriptionButton.siblings('.' + config.tableToolsActionClass)); }); - // init tooltips ----------------------------------------------------------------------------- + // init tooltips ---------------------------------------------------------------------------------- let tooltipElements = tempModuleElement.find('[data-toggle="tooltip"]'); tooltipElements.tooltip(); - // init system effect popover ---------------------------------------------------------------- - $(moduleElement).find('.' + config.systemInfoEffectInfoClass).addSystemEffectTooltip(systemData.security, systemData.effect); + // init system effect popover --------------------------------------------------------------------- + $(moduleElement).find('.' + config.systemInfoEffectClass).addSystemEffectTooltip(systemData.security, systemData.effect); - // init static wormhole information ---------------------------------------------------------- + // init planets popover --------------------------------------------------------------------------- + $(moduleElement).find('.' + config.systemInfoPlanetsClass).addSystemPlanetsTooltip(systemData.planets); + + // init static wormhole information --------------------------------------------------------------- for(let staticData of staticsData){ let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name); staticRowElement.addWormholeInfoTooltip(staticData); } - // constellation popover --------------------------------------------------------------------- + // constellation popover -------------------------------------------------------------------------- tempModuleElement.find('a.popup-ajax').popover({ html: true, trigger: 'hover', @@ -369,13 +372,14 @@ define([ } } }; - +console.log(systemData) let moduleData = { system: systemData, static: staticsData, tableClass: config.systemInfoTableClass, - nameInfoClass: config.systemInfoNameInfoClass, - effectInfoClass: config.systemInfoEffectInfoClass, + nameInfoClass: config.systemInfoNameClass, + effectInfoClass: config.systemInfoEffectClass, + planetsInfoClass: config.systemInfoPlanetsClass, wormholePrefixClass: config.systemInfoWormholeClass, statusInfoClass: config.systemInfoStatusLabelClass, @@ -401,6 +405,7 @@ define([ formatUrl: () => { return (val, render) => render(val).replace(/ /g, '_'); }, + planetCount: systemData.planets ? systemData.planets.length : 0, shatteredClass: Util.getSecurityClassForSystem('SH'), diff --git a/public/js/v1.3.6/app/util.js b/public/js/v1.3.6/app/util.js index e6ca7f53..35bab6d1 100644 --- a/public/js/v1.3.6/app/util.js +++ b/public/js/v1.3.6/app/util.js @@ -1640,19 +1640,43 @@ define([ * @param data * @returns {string} */ - let getSystemEffectTable = function(data){ + let getSystemEffectTable = effects => { let table = ''; - - if(data.length > 0){ - + if(effects.length > 0){ table += '
'; + table += planet.name; + table += ''; + table += planet.type.name; table += '
'; - for(let i = 0; i < data.length; i++){ + for(let effect of effects){ table += ''; table += ''; table += ''; + table += ''; + } + table += '
'; - table += data[i].effect; + table += effect.effect; table += ''; - table += data[i].value; + table += effect.value; + table += '
'; + } + + return table; + }; + + /** + * get a HTML table with planet names + * e.g. for popover + * @param planets + * @returns {string} + */ + let getSystemPlanetsTable = planets => { + let table = ''; + if(planets.length > 0){ + table += ''; + for(let planet of planets){ + table += ''; + table += ''; + table += ''; table += ''; } @@ -1668,7 +1692,7 @@ define([ * @param data * @returns {string} */ - let getSystemsInfoTable = function(data){ + let getSystemsInfoTable = data => { let table = ''; if(data.length > 0){ @@ -1702,7 +1726,7 @@ define([ * @param sec * @returns {string} */ - let getSecurityClassForSystem = (sec) => { + let getSecurityClassForSystem = sec => { let secClass = ''; if( Init.classes.systemSecurity.hasOwnProperty(sec) ){ secClass = Init.classes.systemSecurity[sec]['class']; @@ -2613,6 +2637,7 @@ define([ getMapModule: getMapModule, getSystemEffectData: getSystemEffectData, getSystemEffectTable: getSystemEffectTable, + getSystemPlanetsTable: getSystemPlanetsTable, getSystemsInfoTable: getSystemsInfoTable, getStatusInfoForCharacter: getStatusInfoForCharacter, getSecurityClassForSystem: getSecurityClassForSystem, diff --git a/public/templates/modules/system_info.html b/public/templates/modules/system_info.html index 25599d9e..f76a71d9 100644 --- a/public/templates/modules/system_info.html +++ b/public/templates/modules/system_info.html @@ -9,16 +9,16 @@
+ +
{{systemTypeName}} 
+
{{system.region.name}} 
+
{{system.constellation.name}} 
{{system.name}} {{#system.locked}} {{/system.locked}} -
-
{{system.constellation.name}} 
-
{{system.region.name}} 
-
{{systemTypeName}}
{{#systemIsWormhole}} @@ -57,44 +57,41 @@
'; + table += planet.name; + table += ''; + table += planet.type.name; table += '
- - {{#effectName}} - - + {{/effectName}} + {{#planetCount}} + + + + + + {{/planetCount}} {{#static}} - - + {{/static}}
- - Name {{#system.shattered}}   {{/system.shattered}} - {{system.name}} + {{system.name}} {{system.security}}
Security {{trueSec}}
- - Effect {{effectName}}
Planets{{planetCount}}
- - Static {{name}}{{security}}{{security}}