') );
tbody.append(rows[i + 1]);
@@ -87,21 +90,100 @@ define([
rows[i + 1].append( $('', {
class: 'text-right'
}).text( data.value ));
- });
+ }
+ }
+ let colElement = $('', {
+ class: ['col-md-6'].join(' ')
+ }).append(
+ $(' ', {
+ class: [Util.config.dynamicAreaClass].join(' ')
+ }).append(
+ table.append(thead).append(tbody)
+ )
+ );
+ rowElement.append(colElement);
+
+ // add clearfix after even col count
+ if(colCount % 2 === 0){
+ rowElement.append(
+ $(' ', {
+ class: ['clearfix', 'visible-md', 'visible-lg'].join(' ')
+ })
+ );
+ }
+
+ cache.systemEffectDialog = rowElement;
+ }
+
+ let effectsDialog = bootbox.dialog({
+ className: config.systemEffectDialogClass,
+ title: 'System effect information',
+ message: cache.systemEffectDialog,
+ size: 'large',
+ show: false
+ });
+
+ effectsDialog.on('show.bs.modal', function(e){
+ let headerAll = $();
+ let columnsAll = $();
+
+ let removeColumnHighlight = () => {
+ headerAll.removeClass('colHighlight');
+ columnsAll.removeClass('colHighlight');
+ };
+
+ let tableApis = $(this).find('table').DataTable({
+ pageLength: -1,
+ paging: false,
+ lengthChange: false,
+ ordering: false,
+ searching: false,
+ info: false,
+ columnDefs: [],
+ data: null, // use DOM data overwrites [] default -> data.loader.js
+ initComplete: function(settings, json){
+ let tableApi = this.api();
+
+ tableApi.tables().nodes().to$().on('mouseover', 'td', function(){
+ // inside table cell -> get current hover colIndex
+ let colIndex = tableApi.cell(this).index().column;
+
+ if(colIndex !== lastActiveColIndex){
+ removeColumnHighlight();
+
+ lastActiveColIndex = colIndex;
+
+ if(colIndex > 0){
+ // active column changed -> highlight same colIndex on other tables
+ let tableApis = $.fn.dataTable.tables({ visible: false, api: true })
+ .tables('.' + config.systemEffectTableClass);
+
+ let columns = tableApis.columns(colIndex);
+ columns.header().flatten().to$().addClass('colHighlight');
+ columns.nodes().flatten().to$().addClass('colHighlight');
+ }
+ }
+ }).on('mouseleave', function(){
+ // no longer inside table
+ lastActiveColIndex = null;
+ removeColumnHighlight();
+ });
+ }
});
- dialogWrapperElement.append(table.append(thead).append(tbody));
-
- cache.systemEffectDialog = dialogWrapperElement;
+ // table cells will not change so we should cache them once
+ headerAll = tableApis.columns().header().to$();
+ columnsAll = tableApis.cells().nodes().to$();
});
- }
- bootbox.dialog({
- title: 'System effect information',
- message: cache.systemEffectDialog
+ effectsDialog.on('hide.bs.modal', function(e){
+ // destroy logTable
+ $(this).find('table').DataTable().destroy(true);
+ });
+
+ effectsDialog.modal('show');
});
-
};
});
\ No newline at end of file
diff --git a/js/app/ui/form_element.js b/js/app/ui/form_element.js
index 327433b8..061f356f 100644
--- a/js/app/ui/form_element.js
+++ b/js/app/ui/form_element.js
@@ -12,7 +12,8 @@ define([
let config = {
// Select2
- resultOptionImageClass: 'pf-result-image' // class for Select2 result option entry with image
+ resultOptionImageClass: 'pf-result-image', // class for Select2 result option entry with image
+ select2ImageLazyLoadClass: 'pf-select2-image-lazyLoad' // class for Select2 result images that should be lazy loaded
};
/**
@@ -60,7 +61,7 @@ define([
}
if(imagePath){
- thumb = '  ';
+ thumb = ' ![]() ';
}else if(iconName){
thumb = ' ';
}
@@ -150,8 +151,29 @@ define([
let markup = '';
if(parts.length === 2){
// wormhole data -> 2 columns
+
+ let styleClass = ['pf-fake-connection-text'];
+ if(state.metaData){
+ let metaData = state.metaData;
+ if(metaData.type){
+ let type = metaData.type;
+ if(type.includes('wh_eol')){
+ styleClass.push('pf-wh-eol');
+ }
+ if(type.includes('wh_reduced')){
+ styleClass.push('pf-wh-reduced');
+ }
+ if(type.includes('wh_critical')){
+ styleClass.push('pf-wh-critical');
+ }
+ if(type.includes('frigate')){
+ styleClass.push('pf-wh-frig');
+ }
+ }
+ }
+
let securityClass = Util.getSecurityClassForSystem(parts[1]);
- markup += ' ' + parts[0] + ' ';
+ markup += ' ' + parts[0] + ' ';
markup += ' ' + parts[1] + '';
}else{
markup += ' ' + state.text + '';
@@ -564,6 +586,7 @@ define([
return group;
});
},*/
+ disabled: options.hasOwnProperty('disabled') ? options.disabled : false,
allowClear: options.maxSelectionLength <= 1,
maximumSelectionLength: options.maxSelectionLength,
templateResult: formatCategoryTypeResultData
@@ -605,6 +628,7 @@ define([
return {
id: type.id,
text: type.name,
+ mass: type.hasOwnProperty('mass') ? type.mass : null,
groupId: this.groupId,
categoryId: this.categoryId,
categoryType: this.categoryType
@@ -783,6 +807,11 @@ define([
return this.each(function(){
let selectElement = $(this);
+
+ // remove existing from DOM in case "data" is explicit set
+ if(options.data){
+ selectElement.empty();
+ }
selectElement.select2(options);
// initial open dropDown
diff --git a/js/app/ui/module/connection_info.js b/js/app/ui/module/connection_info.js
index b9e4a6a7..81172a10 100644
--- a/js/app/ui/module/connection_info.js
+++ b/js/app/ui/module/connection_info.js
@@ -6,8 +6,9 @@ define([
'jquery',
'app/init',
'app/util',
+ 'bootbox',
'app/map/util'
-], ($, Init, Util, MapUtil) => {
+], ($, Init, Util, bootbox, MapUtil) => {
'use strict';
let config = {
@@ -30,7 +31,6 @@ define([
connectionInfoPanelClass: 'pf-connection-info-panel', // class for connection info panels
connectionInfoPanelId: 'pf-connection-info-panel-', // id prefix for connection info panels
- dynamicAreaClass: 'pf-dynamic-area', // class for "dynamic" areas
controlAreaClass: 'pf-module-control-area', // class for "control" areas
// info table
@@ -47,9 +47,17 @@ define([
connectionInfoTableCellMassLeftClass: 'pf-connection-info-mass-left', // class for "mass left" table cell
// dataTable
+ tableToolbarCondensedClass: 'pf-dataTable-condensed-toolbar', // class for condensed table toolbar
connectionInfoTableClass: 'pf-connection-info-table', // class for connection tables
tableCellImageClass: 'pf-table-image-cell', // class for table "image" cells
tableCellCounterClass: 'pf-table-counter-cell', // class for table "counter" cells
+ tableCellActionClass: 'pf-table-action-cell', // class for "action" cells
+
+ // connection dialog
+ connectionDialogId: 'pf-connection-info-dialog', // id for "connection" dialog
+ typeSelectId: 'pf-connection-info-dialog-type-select', // id for "ship type" select
+ shipMassId: 'pf-connection-info-dialog-mass', // id for "ship mass" input
+ characterSelectId: 'pf-connection-info-dialog-character-select', // id for "character" select
// config
showShip: true // default for "show current ship mass" toggle
@@ -110,7 +118,7 @@ define([
*/
let getInfoPanelControl = (mapId) => {
let connectionElement = getConnectionElement(mapId, 0).append($('', {
- class: [config.dynamicAreaClass, config.controlAreaClass].join(' '),
+ class: [Util.config.dynamicAreaClass, config.controlAreaClass].join(' '),
html: ' add connection ctrl + click'
}));
@@ -128,7 +136,7 @@ define([
let scopeLabel = MapUtil.getScopeInfoForConnection(connectionData.scope, 'label');
let element = $(' ', {
- class: [config.dynamicAreaClass, config.controlAreaClass].join(' ')
+ class: [Util.config.dynamicAreaClass, config.controlAreaClass].join(' ')
}).append(
$(' ', {
class: ['table', 'table-condensed', 'pf-table-fixed', config.moduleTableClass].join(' ')
@@ -512,6 +520,35 @@ define([
return moduleElement.find('.' + config.connectionInfoPanelClass).not('#' + getConnectionElementId(0));
};
+ /**
+ * enrich connectionData with "logs" data (if available) and other "missing" data
+ * @param connectionsData
+ * @param newConnectionsData
+ * @returns {*}
+ */
+ let enrichConnectionsData = (connectionsData, newConnectionsData) => {
+ for(let i = 0; i < connectionsData.length; i++){
+ for(let newConnectionData of newConnectionsData){
+ if(connectionsData[i].id === newConnectionData.id){
+ // copy some missing data
+ connectionsData[i].character = newConnectionData.character;
+ connectionsData[i].created = newConnectionData.created;
+ connectionsData[i].type = newConnectionData.type;
+ // check for mass logs and copy data
+ if(newConnectionData.logs && newConnectionData.logs.length){
+ connectionsData[i].logs = newConnectionData.logs;
+ }
+ // check for signatures and copy data
+ if(newConnectionData.signatures && newConnectionData.signatures.length){
+ connectionsData[i].signatures = newConnectionData.signatures;
+ }
+ break;
+ }
+ }
+ }
+ return connectionsData;
+ };
+
/**
* request connection log data
* @param requestData
@@ -531,24 +568,7 @@ define([
dataType: 'json',
context: context
}).done(function(connectionsData){
- // enrich connectionData with "logs" data (if available) and other "missing" data
- for(let i = 0; i < this.connectionsData.length; i++){
- for(let connectionData of connectionsData){
- if(this.connectionsData[i].id === connectionData.id){
- // copy some missing data
- this.connectionsData[i].created = connectionData.created;
- // check for mass logs and copy data
- if(connectionData.logs && connectionData.logs.length){
- this.connectionsData[i].logs = connectionData.logs;
- }
- // check for signatures and copy data
- if(connectionData.signatures && connectionData.signatures.length){
- this.connectionsData[i].signatures = connectionData.signatures;
- }
- break;
- }
- }
- }
+ this.connectionsData = enrichConnectionsData(this.connectionsData, connectionsData);
callback(this.moduleElement, this.connectionsData);
}).always(function(){
@@ -593,9 +613,9 @@ define([
*/
let addConnectionsData = (moduleElement, connectionsData) => {
- let getRowIndexesByData = (dataTable, colName, value) => {
- return dataTable.rows().eq(0).filter((rowIdx) => {
- return (dataTable.cell(rowIdx, colName + ':name').data() === value);
+ let getRowIndexesByData = (tableApi, colName, value) => {
+ return tableApi.rows().eq(0).filter((rowIdx) => {
+ return (tableApi.cell(rowIdx, colName + ':name').data() === value);
});
};
@@ -608,42 +628,47 @@ define([
connectionInfoElement.data('connectionData', connectionData);
// update dataTable ---------------------------------------------------------------
- let dataTable = connectionElement.find('.dataTable').dataTable().api();
+ let tableApi = connectionElement.find('.dataTable').dataTable().api();
if(connectionData.logs && connectionData.logs.length > 0){
for(let i = 0; i < connectionData.logs.length; i++){
let rowData = connectionData.logs[i];
- let row = null;
+ let rowNew = null;
let animationStatus = null;
- let indexes = getRowIndexesByData(dataTable, 'index', rowData.id);
+ let indexes = getRowIndexesByData(tableApi, 'index', rowData.id);
if(indexes.length === 0){
// row not found -> add new row
- row = dataTable.row.add( rowData );
+ rowNew = tableApi.row.add(rowData);
animationStatus = 'added';
- }
- /* else{
- // we DON´t expect changes -> no row update)
+ }else{
// update row with FIRST index
- //row = dataTable.row( parseInt(indexes[0]) );
- // update row data
- //row.data(connectionData.logs[i]);
- //animationStatus = 'changed';
- } */
+ let row = tableApi.row( parseInt(indexes[0]));
+ let rowDataCurrent = row.data();
+
+ // check if row data changed
+ if(rowDataCurrent.updated.updated !== rowData.updated.updated){
+ // ... row changed -> delete old and re-add
+ // -> cell actions might have changed
+ row.remove();
+ rowNew = tableApi.row.add(rowData);
+ animationStatus = 'changed';
+ }
+ }
if(
animationStatus !== null &&
- row.length > 0
+ rowNew.length > 0
){
- row.nodes().to$().data('animationStatus', animationStatus);
+ rowNew.nodes().to$().data('animationStatus', animationStatus);
}
}
}else{
// clear table or leave empty
- dataTable.clear();
+ tableApi.clear();
}
// redraw dataTable
- dataTable.draw(false);
+ tableApi.draw(false);
}
}
};
@@ -664,11 +689,46 @@ define([
let table = $('', {
class: ['compact', 'stripe', 'order-column', 'row-border', 'nowrap', config.connectionInfoTableClass].join(' ')
- }).append(' | | | | | ');
+ }).append(' | | | | | | | ');
connectionElement.append(table);
// init empty table
let logTable = table.DataTable({
+ dom: '<"container-fluid"' +
+ '<"row ' + config.tableToolbarCondensedClass + '"' +
+ '<"col-xs-5"i><"col-xs-5"p><"col-xs-2 text-right"B>>' +
+ '<"row"tr>>',
+ buttons: {
+ name: 'tableTools',
+ buttons: [
+ {
+ name: 'addLog',
+ className: config.moduleHeadlineIconClass,
+ text: '',
+ action: function(e, tableApi, node, conf){
+ let logData = {};
+
+ // pre-fill form with current character data (if available)
+ let currentUserData = Util.getCurrentUserData();
+ if(currentUserData && currentUserData.character){
+ logData.character = {
+ id: currentUserData.character.id,
+ name: currentUserData.character.name
+ };
+ if(currentUserData.character.log){
+ logData.ship = {
+ id: currentUserData.character.log.ship.typeId,
+ name: currentUserData.character.log.ship.typeName,
+ mass: currentUserData.character.log.ship.mass
+ };
+ }
+ }
+
+ showLogDialog(moduleElement, connectionElement, connectionData, logData);
+ }
+ }
+ ]
+ },
pageLength: 8,
paging: true,
pagingType: 'simple',
@@ -679,11 +739,14 @@ define([
searching: false,
hover: false,
autoWidth: false,
- // rowId: 'systemTo',
language: {
emptyTable: 'No jumps recorded',
- info: '_START_ to _END_ of _MAX_',
- infoEmpty: ''
+ info: '_START_ - _END_ of _MAX_',
+ infoEmpty: '',
+ paginate: {
+ previous: '',
+ next: ''
+ }
},
columnDefs: [
{
@@ -693,10 +756,25 @@ define([
orderable: false,
searchable: false,
width: 20,
- class: 'text-center',
- data: 'id'
+ className: ['text-center', 'txt-color'].join(' '),
+ data: 'id',
+ createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
+ if(
+ !rowData.record ||
+ (rowData.updated.updated !== rowData.created.created)
+ ){
+ // log was manually modified or added
+ $(cell)
+ .addClass(Util.config.helpClass)
+ .addClass( 'txt-color-orange').tooltip({
+ container: 'body',
+ title: 'added/updated manually'
+ });
+ }
+ }
},{
targets: 1,
+ name: 'ship',
title: '',
width: 26,
orderable: false,
@@ -716,16 +794,17 @@ define([
}
},{
targets: 2,
+ name: 'character',
title: '',
width: 26,
orderable: false,
className: [Util.config.helpDefaultClass, 'text-center', config.tableCellImageClass].join(' '),
- data: 'created.character',
+ data: 'character',
render: {
- _: function(data, type, row){
- let value = data.name;
+ _: (cellData, type, rowData, meta) => {
+ let value = cellData.name;
if(type === 'display'){
- value = ' ';
+ value = ' ';
}
return value;
}
@@ -735,20 +814,26 @@ define([
}
},{
targets: 3,
+ name: 'mass',
title: 'mass',
className: ['text-right'].join(' ') ,
data: 'ship.mass',
render: {
- _: function(data, type, row){
- let value = data;
+ _: (cellData, type, rowData, meta) => {
+ let value = cellData;
if(type === 'display'){
value = Util.formatMassValue(value);
+ if(!rowData.active){
+ // log is "deleted"
+ value = '' + value + '';
+ }
}
return value;
}
}
},{
targets: 4,
+ name: 'created',
title: 'log',
width: 55,
className: ['text-right', config.tableCellCounterClass].join(' '),
@@ -756,6 +841,108 @@ define([
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
$(cell).initTimestampCounter('d');
}
+ },{
+ targets: 5,
+ name: 'edit',
+ title: '',
+ orderable: false,
+ searchable: false,
+ width: 10,
+ className: ['text-center', config.tableCellActionClass, config.moduleHeadlineIconClass].join(' '),
+ data: null,
+ render: {
+ display: data => {
+ let icon = '';
+ if(data.active){
+ icon = '';
+ }
+ return icon;
+ }
+ },
+ createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
+ let tableApi = this.api();
+
+ if($(cell).is(':empty')){
+ $(cell).removeClass(config.tableCellActionClass + ' ' + config.moduleHeadlineIconClass);
+ }else{
+ $(cell).on('click', function(e){
+ showLogDialog(moduleElement, connectionElement, connectionData, rowData);
+ });
+ }
+ }
+ },{
+ targets: 6,
+ name: 'delete',
+ title: '',
+ orderable: false,
+ searchable: false,
+ width: 10,
+ className: ['text-center', config.tableCellActionClass].join(' '),
+ data: 'active',
+ render: {
+ display: data => {
+ let val = '';
+ if(data){
+ val = '';
+ }
+ return val;
+ }
+ },
+ createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
+ let tableApi = this.api();
+
+ if(rowData.active){
+ let confirmationSettings = {
+ container: 'body',
+ placement: 'left',
+ btnCancelClass: 'btn btn-sm btn-default',
+ btnCancelLabel: 'cancel',
+ btnCancelIcon: 'fas fa-fw fa-ban',
+ title: 'delete jump log',
+ btnOkClass: 'btn btn-sm btn-danger',
+ btnOkLabel: 'delete',
+ btnOkIcon: 'fas fa-fw fa-times',
+ onConfirm : function(e, target){
+ // get current row data (important!)
+ // -> "rowData" param is not current state, values are "on createCell()" state
+ rowData = tableApi.row($(cell).parents('tr')).data();
+
+ connectionElement.find('table').showLoadingAnimation();
+
+ Util.request('DELETE', 'log', rowData.id, {}, {
+ connectionElement: connectionElement
+ }, requestAlways)
+ .then(
+ payload => {
+ addConnectionsData(moduleElement, enrichConnectionsData([connectionData], payload.data));
+ },
+ Util.handleAjaxErrorResponse
+ );
+ }
+ };
+
+ // init confirmation dialog
+ $(cell).confirmation(confirmationSettings);
+ }else {
+ $(cell).on('click', function(e){
+ connectionElement.find('table').showLoadingAnimation();
+
+ let requestData = {
+ active: 1
+ };
+
+ Util.request('PATCH', 'log', rowData.id, requestData, {
+ connectionElement: connectionElement
+ }, requestAlways)
+ .then(
+ payload => {
+ addConnectionsData(moduleElement, enrichConnectionsData([connectionData], payload.data));
+ },
+ Util.handleAjaxErrorResponse
+ );
+ });
+ }
+ }
}
],
drawCallback: function(settings){
@@ -773,27 +960,34 @@ define([
},
footerCallback: function(row, data, start, end, display ){
-
- let api = this.api();
- let sumColumnIndexes = [3];
+ let tableApi = this.api();
+ let sumColumnIndexes = ['mass:name', 'delete:name'];
// column data for "sum" columns over this page
- let pageTotalColumns = api
+ let pageTotalColumns = tableApi
.columns( sumColumnIndexes, { page: 'all'} )
.data();
// sum columns for "total" sum
- pageTotalColumns.each((colData, index) => {
- pageTotalColumns[index] = colData.reduce((a, b) => {
- return parseInt(a) + parseInt(b);
+ pageTotalColumns.each((colData, colIndex) => {
+ pageTotalColumns[colIndex] = colData.reduce((sum, val, rowIndex) => {
+ // sum "mass" (colIndex 0) only if not "deleted" (colIndex 1)
+ if(colIndex === 0 && pageTotalColumns[1][rowIndex]){
+ return sum + parseInt(val);
+ }else{
+ return sum;
+ }
}, 0);
});
- $(sumColumnIndexes).each((index, value) => {
- $( api.column( value ).footer() ).text( Util.formatMassValue(pageTotalColumns[index]) );
+ sumColumnIndexes.forEach((colSelector, index) => {
+ // only "mass" column footer needs updates
+ if(colSelector === 'mass:name'){
+ $(tableApi.column(colSelector).footer()).text( Util.formatMassValue(pageTotalColumns[index]) );
- // save mass for further reCalculation of "info" table
- connectionElement.find('.' + config.connectionInfoTableCellMassLogClass).data('mass', pageTotalColumns[index]);
+ // save mass for further reCalculation of "info" table
+ connectionElement.find('.' + config.connectionInfoTableCellMassLogClass).data('mass', pageTotalColumns[index]);
+ }
});
// calculate "info" table -----------------------------------------------------
@@ -806,14 +1000,135 @@ define([
logTable.on('order.dt search.dt', function(){
let pageInfo = logTable.page.info();
- logTable.column(0, {search:'applied', order:'applied'}).nodes().each((cell, i) => {
- let content = (pageInfo.recordsTotal - i) + '. ';
+ logTable.column('index:name', {search:'applied', order:'applied'}).nodes().each((cell, i) => {
+ let content = (pageInfo.recordsTotal - i) + '.';
$(cell).html(content);
});
});
}
};
+ /**
+ *
+ * @param context
+ */
+ let requestAlways = (context) => {
+ context.connectionElement.find('table').hideLoadingAnimation();
+ };
+
+ /**
+ * show jump log dialog
+ * @param moduleElement
+ * @param connectionElement
+ * @param connectionData
+ * @param logData
+ */
+ let showLogDialog = (moduleElement, connectionElement, connectionData, logData = {}) => {
+
+ let data = {
+ id: config.connectionDialogId,
+ typeSelectId: config.typeSelectId,
+ shipMassId: config.shipMassId,
+ characterSelectId: config.characterSelectId,
+ logData: logData,
+ massFormat: () => {
+ return (val, render) => {
+ return (parseInt(render(val) || 0) / 1000) || '';
+ };
+ }
+ };
+
+ requirejs(['text!templates/dialog/connection_log.html', 'mustache'], (template, Mustache) => {
+ let content = Mustache.render(template, data);
+
+ let connectionDialog = bootbox.dialog({
+ title: 'Jump log',
+ message: content,
+ show: false,
+ buttons: {
+ close: {
+ label: 'cancel',
+ className: 'btn-default'
+ },
+ success: {
+ label: ' save',
+ className: 'btn-success',
+ callback: function(){
+ let form = this.find('form');
+
+ // validate form
+ form.validator('validate');
+
+ // check whether the form is valid
+ let formValid = form.isValidForm();
+
+ if(formValid){
+ // get form data
+ let formData = form.getFormValues();
+ formData.id = Util.getObjVal(logData, 'id') || 0;
+ formData.connectionId = Util.getObjVal(connectionData, 'id') || 0;
+ formData.shipTypeId = Util.getObjVal(formData, 'shipTypeId') || 0;
+ formData.shipMass = parseInt((Util.getObjVal(formData, 'shipMass') || 0) * 1000);
+ formData.characterId = Util.getObjVal(formData, 'characterId') || 0;
+
+ // we need some "additional" form data from the Select2 dropdown
+ // -> data is required on the backend side
+ let formDataShip = form.find('#' + config.typeSelectId).select2('data');
+ let formDataCharacter = form.find('#' + config.characterSelectId).select2('data');
+ formData.shipTypeName = formDataShip.length ? formDataShip[0].text : '';
+ formData.characterName = formDataCharacter.length ? formDataCharacter[0].text : '';
+
+ let method = formData.id ? 'PATCH' : 'PUT';
+
+ Util.request(method, 'log', formData.id, formData, {
+ connectionElement: connectionElement,
+ formElement: form
+ }, requestAlways)
+ .then(
+ payload => {
+ addConnectionsData(moduleElement, enrichConnectionsData([connectionData], payload.data));
+ this.modal('hide');
+ },
+ Util.handleAjaxErrorResponse
+ );
+
+ }
+
+ return false;
+ }
+ }
+ }
+ });
+
+ connectionDialog.on('show.bs.modal', function(e){
+ let modalContent = $('#' + config.connectionDialogId);
+
+ // init type select live search
+ let selectElementType = modalContent.find('#' + config.typeSelectId);
+ selectElementType.initUniverseTypeSelect({
+ categoryIds: [6],
+ maxSelectionLength: 1,
+ selected: [Util.getObjVal(logData, 'ship.id')]
+ }).on('select2:select select2:unselecting', function(e){
+ // get ship mass from selected ship type and update mass input field
+ let shipMass = e.params.data ? e.params.data.mass / 1000 : '';
+ modalContent.find('#' + config.shipMassId).val(shipMass);
+ });
+
+ // init character select live search
+ let selectElementCharacter = modalContent.find('#' + config.characterSelectId);
+ selectElementCharacter.initUniverseSearch({
+ categoryNames: ['character'],
+ maxSelectionLength: 1
+ });
+
+ });
+
+ // show dialog
+ connectionDialog.modal('show');
+ });
+ };
+
/**
* remove connection Panel from moduleElement
* @param connectionElement
diff --git a/js/app/ui/module/system_info.js b/js/app/ui/module/system_info.js
index 81562a36..e5c84146 100644
--- a/js/app/ui/module/system_info.js
+++ b/js/app/ui/module/system_info.js
@@ -51,44 +51,6 @@ define([
// max character length for system description
let maxDescriptionLength = 9000;
- /**
- * save system (description)
- * @param requestData
- * @param context
- * @param callback
- */
- let saveSystem = (requestData, context, callback) => {
- context.descriptionArea.showLoadingAnimation();
-
- $.ajax({
- type: 'POST',
- url: Init.path.saveSystem,
- data: requestData,
- dataType: 'json',
- context: context
- }).done(function(responseData){
- let newSystemData = responseData.systemData;
-
- if( !$.isEmptyObject(newSystemData) ){
- callback(newSystemData);
- }
-
- if(
- responseData.error &&
- responseData.error.length > 0
- ){
- for(let error of responseData.error){
- Util.showNotify({title: error.field + ' error', text: 'System: ' + error.message, type: error.type});
- }
- }
- }).fail(function(jqXHR, status, error){
- let reason = status + ' ' + error;
- Util.showNotify({title: jqXHR.status + ': saveSystem', text: reason, type: 'warning'});
- }).always(function(){
- this.descriptionArea.hideLoadingAnimation();
- });
- };
-
/**
* update trigger function for this module
* compare data and update module
@@ -307,21 +269,22 @@ define([
if(validDescription){
// ... valid -> save()
- saveSystem({
- mapData: {
- id: mapId
- },
- systemData: {
- id: systemData.id,
- description: description
- }
+ descriptionArea.showLoadingAnimation();
+
+ Util.request('PATCH', 'system', systemData.id, {
+ description: description
}, {
descriptionArea: descriptionArea
- }, (systemData) => {
- // .. save callback
- context.$note.summernote('destroy');
- updateModule(moduleElement, systemData);
- });
+ }, context => {
+ // always do
+ context.descriptionArea.hideLoadingAnimation();
+ }).then(
+ payload => {
+ context.$note.summernote('destroy');
+ updateModule(moduleElement, payload.data);
+ },
+ Util.handleAjaxErrorResponse
+ );
}
}else{
// ... no changes -> no save()
diff --git a/js/app/ui/module/system_intel.js b/js/app/ui/module/system_intel.js
index 64dcc35b..62b5caae 100644
--- a/js/app/ui/module/system_intel.js
+++ b/js/app/ui/module/system_intel.js
@@ -337,7 +337,7 @@ define([
data: statusData
});
- // init character counter
+ // init char counter
let textarea = modalContent.find('#' + config.descriptionTextareaId);
let charCounter = modalContent.find('.' + config.descriptionTextareaCharCounter);
Util.updateCounter(textarea, charCounter, maxDescriptionLength);
diff --git a/js/app/ui/module/system_killboard.js b/js/app/ui/module/system_killboard.js
index eb568d7f..3a0d220e 100644
--- a/js/app/ui/module/system_killboard.js
+++ b/js/app/ui/module/system_killboard.js
@@ -32,7 +32,6 @@ define([
systemKillboardListImgCorp: 'pf-system-killboard-img-corp', // class for all corp logos
labelRecentKillsClass: 'pf-system-killboard-label-recent', // class for "recent kills" label
- dynamicAreaClass: 'pf-dynamic-area', // class for "dynamic" areas
controlAreaClass: 'pf-module-control-area', // class for "control" areas
minCountKills: 5,
@@ -292,7 +291,7 @@ define([
*/
let getControlElement = () => {
let controlElement = $('', {
- class: [config.dynamicAreaClass, config.controlAreaClass, config.moduleHeadlineIconClass].join(' '),
+ class: [Util.config.dynamicAreaClass, config.controlAreaClass, config.moduleHeadlineIconClass].join(' '),
html: ' load more'
});
return controlElement;
diff --git a/js/app/ui/module/system_signature.js b/js/app/ui/module/system_signature.js
index c48866a2..13821487 100644
--- a/js/app/ui/module/system_signature.js
+++ b/js/app/ui/module/system_signature.js
@@ -405,6 +405,32 @@ define([
let newSelectOptions = [];
let connectionOptions = [];
+ /**
+ * get option data for a single connection
+ * @param type
+ * @param connectionData
+ * @param systemData
+ * @returns {{value: *, text: string, metaData: {type: *}}}
+ */
+ let getOption = (type, connectionData, systemData) => {
+ let text = 'UNKNOWN';
+ if(type === 'source'){
+ text = connectionData.sourceAlias + ' - ' + systemData.security;
+ }else if(type === 'target'){
+ text = connectionData.targetAlias + ' - ' + systemData.security;
+ }
+
+ let option = {
+ value: connectionData.id,
+ text: text,
+ metaData: {
+ type: connectionData.type
+ }
+ };
+
+ return option;
+ };
+
for(let systemConnection of systemConnections){
let connectionData = MapUtil.getDataByConnection(systemConnection);
@@ -416,19 +442,13 @@ define([
let targetSystemData = MapUtil.getSystemData(mapId, connectionData.target);
if(targetSystemData){
// take target...
- connectionOptions.push({
- value: connectionData.id,
- text: connectionData.targetAlias + ' - ' + targetSystemData.security
- });
+ connectionOptions.push(getOption('target', connectionData, targetSystemData));
}
}else if(systemData.id !== connectionData.source){
let sourceSystemData = MapUtil.getSystemData(mapId, connectionData.source);
if(sourceSystemData){
// take source...
- connectionOptions.push({
- value: connectionData.id,
- text: connectionData.sourceAlias + ' - ' + sourceSystemData.security
- });
+ connectionOptions.push(getOption('source', connectionData, sourceSystemData));
}
}
}
@@ -1119,7 +1139,14 @@ define([
let editableConnectionOnShown = cell => {
$(cell).on('shown', function(e, editable){
let inputField = editable.input.$input;
- inputField.addClass('pf-select2').initSignatureConnectionSelect();
+
+ // Select2 init would work without passing select options as "data", Select2 would grap data from DOM
+ // -> We want to pass "meta" data for each option into Select2 for formatting
+ let options = {
+ data: Util.convertXEditableOptionsToSelect2(editable)
+ };
+
+ inputField.addClass('pf-select2').initSignatureConnectionSelect(options);
});
};
@@ -1534,7 +1561,10 @@ define([
let selected = $.fn.editableutils.itemsByValue(value, sourceData);
if(selected.length && selected[0].value > 0){
let errorIcon = ' ';
- $(this).html(FormElement.formatSignatureConnectionSelectionData({text: selected[0].text})).prepend(errorIcon);
+ $(this).html(FormElement.formatSignatureConnectionSelectionData({
+ text: selected[0].text,
+ metaData: selected[0].metaData
+ })).prepend(errorIcon);
}else{
$(this).empty();
}
@@ -2150,7 +2180,7 @@ define([
// xEditable field should not open -> on 'click'
// -> therefore disable "pointer-events" on "td" for some ms -> 'click' event is not triggered
$(this).css('pointer-events', 'none');
- $(e.target.parentNode).toggleClass('selected');
+ $(e.target).closest('tr').toggleClass('selected');
// check delete button
checkDeleteSignaturesButton(e.data.tableApi);
diff --git a/js/app/util.js b/js/app/util.js
index 4df9a415..47f8f240 100644
--- a/js/app/util.js
+++ b/js/app/util.js
@@ -8,6 +8,7 @@ define([
'conf/signature_type',
'bootbox',
'localForage',
+ 'lazyload',
'velocity',
'velocityUI',
'customScrollbar',
@@ -65,10 +66,12 @@ define([
mapClass: 'pf-map' , // class for all maps
// util
- userStatusClass: 'pf-user-status', // class for player status
+ userStatusClass: 'pf-user-status', // class for player status
+ dynamicAreaClass: 'pf-dynamic-area', // class for "dynamic" areas
// select2
select2Class: 'pf-select2', // class for all "Select2" |