close #66 added "additional wormhole info" popover to system info module

This commit is contained in:
Exodus4D
2015-11-15 15:31:13 +01:00
parent 0dd58a681f
commit 5588ca9c28
10 changed files with 181 additions and 44 deletions

View File

@@ -307,8 +307,8 @@ class SystemModel extends BasicModel {
// check if this system is a wormhole
if($this->isWormhole()){
$systemStaticModel = self::getNew('SystemStaticModel');
$systemStatics = $systemStaticModel->find([
$systemWormholeModel = self::getNew('SystemWormholeModel');
$systemStatics = $systemWormholeModel->find([
'constellationId = :constellationId',
':constellationId' => $this->constellationId
]);

View File

@@ -1,28 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 07.06.15
* Time: 18:16
*/
namespace Model;
class SystemStaticModel extends BasicModel {
protected $table = 'system_static';
/**
* get systemStatic data as object
* @return object
*/
public function getData(){
$systemStaticData = (object) [];
$systemStaticData->security = $this->security;
$systemStaticData->name = $this->name;
return $systemStaticData;
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 07.06.15
* Time: 18:16
*/
namespace Model;
class SystemWormholeModel extends BasicModel {
protected $table = 'system_wormhole';
protected $fieldConf = [
'wormholeId' => [
'belongs-to-one' => 'Model\WormholeModel'
]
];
/**
* get wormhole data as object
* @return object
*/
public function getData(){
$systemWormholeData = $this->wormholeId->getData();
return $systemWormholeData;
}
}

View File

@@ -17,9 +17,9 @@ class UserModel extends BasicModel {
protected $table = 'user';
protected $fieldConf = [
'lastLogin' => array(
'lastLogin' => [
'type' => Schema::DT_TIMESTAMP
),
],
'apis' => [
'has-many' => ['Model\UserApiModel', 'userId']
],

View File

@@ -0,0 +1,60 @@
<?php
/**
* Created by PhpStorm.
* User: Exodus
* Date: 14.11.2015
* Time: 22:21
*/
namespace Model;
class WormholeModel extends BasicModel {
protected $table = 'wormhole';
/**
* format mass values
* - no decimal separator
* - char '.' for thousands separator
* @param $value
* @return string
*/
static function formatMassValue($value){
return number_format( $value, 0, '', '.' );
}
/**
* get wormhole data as object
* @return object
*/
public function getData(){
$systemStaticData = (object) [];
$systemStaticData->name = $this->name;
$systemStaticData->security = $this->security;
// total (max) available wormhole mass
$systemStaticData->massTotal = (object) [];
$systemStaticData->massTotal->value = $this->massTotal;
$systemStaticData->massTotal->format = self::formatMassValue($this->massTotal) . ' Kg';
// individual jump mass (max) per jump
$systemStaticData->massIndividual = (object) [];
$systemStaticData->massIndividual->value = $this->massIndividual;
$systemStaticData->massIndividual->format = self::formatMassValue($this->massIndividual) . ' Kg';
// lifetime (max) for this wormhole
$systemStaticData->maxStableTime = (object) [];
$systemStaticData->maxStableTime->value = $this->maxStableTime;
$systemStaticData->maxStableTime->format = $this->maxStableTime . ' h';
// mass regeneration value per day
if($this->massRegeneration > 0){
$systemStaticData->massRegeneration = (object) [];
$systemStaticData->massRegeneration->value = $this->massRegeneration;
$systemStaticData->massRegeneration->format = self::formatMassValue($this->massRegeneration) . ' Kg/day';
}
return $systemStaticData;
}
}

View File

@@ -28,6 +28,7 @@ define([
systemInfoEffectInfoClass: 'pf-system-info-effect', // class for "effect" 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
// description field
descriptionArea: 'pf-system-info-description-area', // class for "description" area
@@ -56,6 +57,7 @@ define([
});
};
/**
* shows the tool action element by animation
*/
@@ -192,6 +194,14 @@ define([
parentElement.prepend(moduleElement);
// add security class for statics
if(systemData.statics){
for(var i = 0; i < systemData.statics.length; i++){
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
}
}
var effectName = Util.getEffectInfoForSystem(systemData.effect, 'name');
var effectClass = Util.getEffectInfoForSystem(systemData.effect, 'class');
@@ -338,6 +348,15 @@ define([
});
}
// init static wormhole information ----------------------------------------------------------
if(systemData.statics){
for(var i = 0; i < systemData.statics.length; i++){
var staticData = systemData.statics[i];
var staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
staticRowElement.addWormholeInfoTooltip(staticData);
}
}
// constellation popover ---------------------------------------------------------------------
tempModuleElement.find('a.popup-ajax').popover({
html: true,
@@ -350,7 +369,6 @@ define([
}
});
function details_in_popup(popoverElement){
popoverElement = $(popoverElement);
var popover = popoverElement.data('bs.popover');
@@ -373,18 +391,12 @@ define([
}
};
// add security class for statics
if(systemData.statics){
for(var i = 0; i < systemData.statics.length; i++){
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
}
}
var moduleData = {
system: systemData,
tableClass: config.systemInfoTableClass,
nameInfoClass: config.systemInfoNameInfoClass,
effectInfoClass: config.systemInfoEffectInfoClass,
wormholePrefixClass: config.systemInfoWormholeClass,
statusInfoClass: config.systemInfoStatusLabelClass,
systemTypeName: Util.getSystemTypeInfo(systemData.type.id, 'name'),

View File

@@ -522,7 +522,6 @@ define([
};
requirejs(['text!templates/tooltip/character_info.html', 'mustache'], function(template, Mustache) {
var content = Mustache.render(template, data);
element.popover({
@@ -541,13 +540,46 @@ define([
// set new popover content
var popover = element.data('bs.popover');
popover.options.content = content;
});
}
}
};
/**
* add a wormhole tooltip with wh specific data to elements
* @param tooltipData
* @returns {*}
*/
$.fn.addWormholeInfoTooltip = function(tooltipData){
return this.each(function() {
var element = $(this);
requirejs(['text!templates/tooltip/wormhole_info.html', 'mustache'], function (template, Mustache) {
var content = Mustache.render(template, tooltipData);
element.popover({
placement: 'top',
html: true,
trigger: 'hover',
content: '',
container: 'body',
title: tooltipData.name +
'<span class="pull-right ' + tooltipData.class +'">' + tooltipData.security + '</span>',
delay: {
show: 250,
hide: 0
}
});
// set new popover content
var popover = element.data('bs.popover');
popover.options.content = content;
});
});
};
/**
* display a custom message (info/warning/error) to a container element
* check: $.fn.showFormMessage() for an other way of showing messages

View File

@@ -87,7 +87,9 @@
{{/effectName}}
{{#system.statics}}
<tr>
<td></td>
<td class="text-right pf-help {{wormholePrefixClass}}{{name}}">
<i class="fa fa-fw fa-question-circle"></i>
</td>
<td>Static</td>
<td class="text-right">{{name}}</td>
<td class="text-right {{class}}">{{security}}</td>

View File

@@ -0,0 +1,27 @@
<table>
{{#massTotal}}
<tr>
<td>Max Stable Mass</td>
<td class="text-right">{{format}}</td>
</tr>
{{/massTotal}}
{{#massIndividual}}
<tr>
<td>Max Jump Mass</td>
<td class="text-right">{{format}}</td>
</tr>
{{/massIndividual}}
{{#massRegeneration}}
<tr>
<td>Max Mass Regeneration</td>
<td class="text-right">{{format}}</td>
</tr>
{{/massRegeneration}}
{{#maxStableTime}}
<tr>
<td>Max Lifetime</td>
<td class="text-right">{{format}}</td>
</tr>
{{/maxStableTime}}
</table>

View File

@@ -42,7 +42,7 @@
// system info table
.pf-system-info-table{
font-size: 11px;
white-space: nowrap
white-space: nowrap;
}
}