- fixed "lazy copy&paste" for signature table

This commit is contained in:
Exodus4D
2017-03-25 16:25:46 +01:00
parent 32ac55b0f9
commit b44861ad10
16 changed files with 721 additions and 515 deletions

View File

@@ -332,6 +332,10 @@ class ConnectionModel extends BasicModel{
return $signatures;
}
/**
* get all signature data linked to this connection
* @return array
*/
public function getSignaturesData(){
$signaturesData = [];
$signatures = $this->getSignatures();

View File

@@ -119,7 +119,7 @@ define([
firstCell.drawSystemGraphModule(currentSystemData.systemData);
// draw signature table module
firstCell.drawSignatureTableModule(currentSystemData.systemData);
firstCell.drawSignatureTableModule(currentSystemData.mapId, currentSystemData.systemData);
// draw system routes module
secondCell.drawSystemRouteModule(currentSystemData.mapId, currentSystemData.systemData);

View File

@@ -8,6 +8,7 @@ define([
'app/util',
'app/logging',
'mustache',
'app/map/util',
'text!img/logo.svg!strip',
'text!templates/modules/header.html',
'text!templates/modules/footer.html',
@@ -24,7 +25,7 @@ define([
'dialog/credit',
'slidebars',
'app/module_map'
], function($, Init, Util, Logging, Mustache, TplLogo, TplHead, TplFooter) {
], function($, Init, Util, Logging, Mustache, MapUtil, TplLogo, TplHead, TplFooter) {
'use strict';
@@ -135,26 +136,27 @@ define([
});
body.watchKey('signaturePaste', (e) => {
let moduleElement = $('.' + config.systemSigModuleClass);
// check if there is a signature module active (system clicked)
if(moduleElement.length){
e = e.originalEvent;
let targetElement = $(e.target);
// do not read clipboard if pasting into form elements
if(
targetElement.prop('tagName').toLowerCase() !== 'input' &&
targetElement.prop('tagName').toLowerCase() !== 'textarea' || (
targetElement.is('input[type="search"]') // Datatables "search" field bubbles `paste.DT` event :(
)
){
let clipboard = (e.originalEvent || e).clipboardData.getData('text/plain');
moduleElement.trigger('pf:updateSystemSignatureModuleByClipboard', [clipboard]);
// just send event to the current active map
let activeMap = Util.getMapModule().getActiveMap();
if(activeMap){
// look for active signature module (active system)
let signatureModuleElement = MapUtil.getTabContentElementByMapElement(activeMap).find('.' + config.systemSigModuleClass);
if(signatureModuleElement.length){
e = e.originalEvent;
let targetElement = $(e.target);
// do not read clipboard if pasting into form elements
if(
targetElement.prop('tagName').toLowerCase() !== 'input' &&
targetElement.prop('tagName').toLowerCase() !== 'textarea' || (
targetElement.is('input[type="search"]') // Datatables "search" field bubbles `paste.DT` event :(
)
){
let clipboard = (e.originalEvent || e).clipboardData.getData('text/plain');
signatureModuleElement.trigger('pf:updateSystemSignatureModuleByClipboard', [clipboard]);
}
}
}
});
});
};

View File

@@ -9,7 +9,7 @@ define([
'app/util',
'app/render',
'bootbox'
], function($, Init, Util, Render, bootbox, MapUtil) {
], function($, Init, Util, Render, bootbox) {
'use strict';
let config = {

View File

@@ -11,7 +11,7 @@ define([
], function($, Init, Util, Render, MapUtil) {
'use strict';
var config = {
let config = {
// module info
moduleClass: 'pf-module', // class for each module
@@ -35,41 +35,38 @@ define([
descriptionArea: 'pf-system-info-description-area', // class for "description" area
addDescriptionButtonClass: 'pf-system-info-description-button', // class for "add description" button
moduleElementToolbarClass: 'pf-table-tools', // class for "module toolbar" element
moduleToolbarActionId: 'pf-system-info-collapse-container', // id for "module toolbar action" element
tableToolsActionClass: 'pf-table-tools-action', // class for "edit" action
descriptionTextareaElementClass: 'pf-system-info-description', // class for "description" textarea element (xEditable)
descriptionTextareaCharCounter: 'pf-form-field-char-count' // class for "character counter" element for form field
};
// disable Module update temporary (until. some requests/animations) are finished
var disableModuleUpdate = true;
let disableModuleUpdate = true;
// animation speed values
var animationSpeedToolbarAction = 200;
let animationSpeedToolbarAction = 200;
// max character length for system description
var maxDescriptionLength = 512;
let maxDescriptionLength = 512;
/**
* set module observer and look for relevant system data to update
*/
var setModuleObserver = function(moduleElement){
let setModuleObserver = function(moduleElement){
$(document).off('pf:updateSystemInfoModule').on('pf:updateSystemInfoModule', function(e, data){
if(data){
moduleElement.updateSystemInfoModule(data);
}
});
};
/**
* shows the tool action element by animation
* @param toolsActionElement
*/
var showToolsActionElement = function(){
// "toolbar action" element
var toolsActionElement = $('#' + config.moduleToolbarActionId);
let showToolsActionElement = function(toolsActionElement){
toolsActionElement.velocity('stop').velocity({
opacity: 1,
height: '100%'
@@ -82,12 +79,9 @@ define([
/**
* hides the tool action element by animation
* @param toolsActionElement
*/
var hideToolsActionElement = function(){
// "toolbar action" element
var toolsActionElement = $('#' + config.moduleToolbarActionId);
let hideToolsActionElement = function(toolsActionElement){
toolsActionElement.velocity('stop').velocity('reverse', {
display: 'none',
visibility: 'hidden'
@@ -106,24 +100,23 @@ define([
return;
}
var moduleElement = $(this);
let moduleElement = $(this);
var systemId = moduleElement.data('id');
let systemId = moduleElement.data('id');
if(systemId === systemData.id){
// update module
// system status =====================================================================================
var systemStatusLabelElement = moduleElement.find('.' + config.systemInfoStatusLabelClass);
var systemStatusId = parseInt( systemStatusLabelElement.attr( config.systemInfoStatusAttributeName ) );
let systemStatusLabelElement = moduleElement.find('.' + config.systemInfoStatusLabelClass);
let systemStatusId = parseInt( systemStatusLabelElement.attr( config.systemInfoStatusAttributeName ) );
if(systemStatusId !== systemData.status.id){
// status changed
var currentStatusClass = Util.getStatusInfoForSystem(systemStatusId, 'class');
var newStatusClass = Util.getStatusInfoForSystem(systemData.status.id, 'class');
var newStatusLabel = Util.getStatusInfoForSystem(systemData.status.id, 'label');
let currentStatusClass = Util.getStatusInfoForSystem(systemStatusId, 'class');
let newStatusClass = Util.getStatusInfoForSystem(systemData.status.id, 'class');
let newStatusLabel = Util.getStatusInfoForSystem(systemData.status.id, 'label');
systemStatusLabelElement.removeClass(currentStatusClass).addClass(newStatusClass).text(newStatusLabel);
@@ -132,43 +125,40 @@ define([
}
// description textarea element ======================================================================
var descriptionTextareaElement = moduleElement.find('.' + config.descriptionTextareaElementClass);
var description = descriptionTextareaElement.editable('getValue', true);
let descriptionTextareaElement = moduleElement.find('.' + config.descriptionTextareaElementClass);
let description = descriptionTextareaElement.editable('getValue', true);
if(description !== systemData.description){
// description changed
// description button
var descriptionButton = moduleElement.find('.' + config.addDescriptionButtonClass);
let descriptionButton = moduleElement.find('.' + config.addDescriptionButtonClass);
// set new value
descriptionTextareaElement.editable('setValue', systemData.description);
let actionElement = descriptionButton.siblings('.' + config.tableToolsActionClass);
if(systemData.description.length === 0){
// show/activate description field
// show button if value is empty
descriptionButton.show();
hideToolsActionElement();
hideToolsActionElement(actionElement);
}else{
// hide/disable description field
// hide tool button
descriptionButton.hide();
showToolsActionElement();
showToolsActionElement(actionElement);
}
}
// created/updated tooltip ===========================================================================
var nameRowElement = $(moduleElement).find('.' + config.systemInfoNameInfoClass);
let nameRowElement = $(moduleElement).find('.' + config.systemInfoNameInfoClass);
var tooltipData = {
let tooltipData = {
created: systemData.created,
updated: systemData.updated
};
@@ -176,7 +166,7 @@ define([
nameRowElement.addCharacterInfoTooltip( tooltipData );
}
$('.' + config.descriptionArea).hideLoadingAnimation();
moduleElement.find('.' + config.descriptionArea).hideLoadingAnimation();
};
/**
@@ -185,13 +175,13 @@ define([
* @param charCounterElement
* @param maxCharLength
*/
var updateCounter = function(field, charCounterElement, maxCharLength){
var value = field.val();
var inputLength = value.length;
let updateCounter = function(field, charCounterElement, maxCharLength){
let value = field.val();
let inputLength = value.length;
// line breaks are 2 characters!
var newLines = value.match(/(\r\n|\n|\r)/g);
var addition = 0;
let newLines = value.match(/(\r\n|\n|\r)/g);
let addition = 0;
if (newLines != null) {
addition = newLines.length;
}
@@ -212,10 +202,10 @@ define([
* @param mapId
* @param systemData
*/
var drawModule = function(parentElement, mapId, systemData){
let drawModule = function(parentElement, mapId, systemData){
// create new module container
var moduleElement = $('<div>', {
let moduleElement = $('<div>', {
class: [config.moduleClass, config.systemInfoModuleClass].join(' '),
css: {opacity: 0}
});
@@ -226,14 +216,14 @@ define([
parentElement.prepend(moduleElement);
// shattered wormhole info data
var shatteredWormholeInfo = false;
let shatteredWormholeInfo = false;
// add security class for statics
if(
systemData.statics &&
systemData.statics.length > 0
){
for(var i = 0; i < systemData.statics.length; i++){
for(let i = 0; i < systemData.statics.length; i++){
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
}
}else if(systemData.type.id === 1){
@@ -241,27 +231,26 @@ define([
shatteredWormholeInfo = true;
}
var effectName = MapUtil.getEffectInfoForSystem(systemData.effect, 'name');
var effectClass = MapUtil.getEffectInfoForSystem(systemData.effect, 'class');
let effectName = MapUtil.getEffectInfoForSystem(systemData.effect, 'name');
let effectClass = MapUtil.getEffectInfoForSystem(systemData.effect, 'class');
// systemInfo template config
var moduleConfig = {
let moduleConfig = {
name: 'modules/system_info',
position: moduleElement,
link: 'append',
functions: {
after: function(){
let tempModuleElement = parentElement.find('.' + config.systemInfoModuleClass);
// lock "description" field until first update
$('.' + config.descriptionArea).showLoadingAnimation();
var tempModuleElement = $('.' + config.systemInfoModuleClass);
tempModuleElement.find('.' + config.descriptionArea).showLoadingAnimation();
// "add description" button
var descriptionButton = tempModuleElement.find('.' + config.addDescriptionButtonClass);
let descriptionButton = tempModuleElement.find('.' + config.addDescriptionButtonClass);
// description textarea element
var descriptionTextareaElement = tempModuleElement.find('.' + config.descriptionTextareaElementClass);
let descriptionTextareaElement = tempModuleElement.find('.' + config.descriptionTextareaElementClass);
// init description textarea
descriptionTextareaElement.editable({
@@ -304,9 +293,8 @@ define([
Util.showNotify({title: 'System updated', text: 'Name: ' + response.name, type: 'success'});
},
error: function(jqXHR, newValue){
var reason = '';
var status = '';
let reason = '';
let status = '';
if(jqXHR.name){
// save error new sig (mass save)
reason = jqXHR.name;
@@ -324,13 +312,13 @@ define([
// on xEditable open -------------------------------------------------------------------------
descriptionTextareaElement.on('shown', function(e, editable){
var textarea = editable.input.$input;
let textarea = editable.input.$input;
// disable module update until description field is open
disableModuleUpdate = true;
// create character counter
var charCounter = $('<kbd>', {
let charCounter = $('<kbd>', {
class: [config.descriptionTextareaCharCounter, 'txt-color', 'text-right'].join(' ')
});
textarea.parent().next().append(charCounter);
@@ -345,11 +333,10 @@ define([
// on xEditable close ------------------------------------------------------------------------
descriptionTextareaElement.on('hidden', function(e){
var value = $(this).editable('getValue', true);
let value = $(this).editable('getValue', true);
if(value.length === 0){
// show button if value is empty
hideToolsActionElement();
hideToolsActionElement(descriptionButton.siblings('.' + config.tableToolsActionClass));
descriptionButton.show();
}
@@ -360,6 +347,7 @@ define([
// enable xEditable field on Button click ----------------------------------------------------
descriptionButton.on('click', function(e){
e.stopPropagation();
let descriptionButton = $(this);
// hide tool buttons
descriptionButton.hide();
@@ -367,24 +355,23 @@ define([
// show field *before* showing the element
descriptionTextareaElement.editable('show');
showToolsActionElement();
showToolsActionElement(descriptionButton.siblings('.' + config.tableToolsActionClass));
});
// init tooltips -----------------------------------------------------------------------------
var tooltipElements = $('.' + config.systemInfoModuleClass + ' [data-toggle="tooltip"]');
let tooltipElements = tempModuleElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
// init system effect popover ----------------------------------------------------------------
var infoEffectElement = $(moduleElement).find('.' + config.systemInfoEffectInfoClass);
let infoEffectElement = $(moduleElement).find('.' + config.systemInfoEffectInfoClass);
if(infoEffectElement.length){
// effect row exists -> get effect data
var systemEffectData = Util.getSystemEffectData( systemData.security, systemData.effect);
let systemEffectData = Util.getSystemEffectData( systemData.security, systemData.effect);
if(systemEffectData !== false){
// transform data into table
var systemEffectTable = Util.getSystemEffectTable( systemEffectData );
let systemEffectTable = Util.getSystemEffectTable( systemEffectData );
infoEffectElement.popover({
html: true,
@@ -403,9 +390,9 @@ 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);
for(let i = 0; i < systemData.statics.length; i++){
let staticData = systemData.statics[i];
let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
staticRowElement.addWormholeInfoTooltip(staticData);
}
}
@@ -424,13 +411,13 @@ define([
function details_in_popup(popoverElement){
popoverElement = $(popoverElement);
var popover = popoverElement.data('bs.popover');
let popover = popoverElement.data('bs.popover');
$.ajax({
url: popoverElement.data('url'),
success: function(data){
var systemEffectTable = Util.getSystemsInfoTable( data.systemData );
let systemEffectTable = Util.getSystemsInfoTable( data.systemData );
popover.options.content = systemEffectTable;
// reopen popover (new content size)
popover.show();
@@ -444,7 +431,7 @@ define([
}
};
var moduleData = {
let moduleData = {
system: systemData,
tableClass: config.systemInfoTableClass,
nameInfoClass: config.systemInfoNameInfoClass,
@@ -463,7 +450,7 @@ define([
effectClass: effectClass,
moduleToolbarClass: config.moduleElementToolbarClass,
descriptionButtonClass: config.addDescriptionButtonClass,
moduleToolbarActionId: config.moduleToolbarActionId,
tableToolsActionClass: config.tableToolsActionClass,
descriptionTextareaClass: config.descriptionTextareaElementClass,
shatteredWormholeInfo: shatteredWormholeInfo,
@@ -483,7 +470,7 @@ define([
* show system info module with animation
* @param moduleElement
*/
var showModule = function(moduleElement){
let showModule = function(moduleElement){
moduleElement.velocity('transition.slideDownIn', {
duration: Init.animationSpeed.mapModule,
delay: Init.animationSpeed.mapModule,
@@ -504,10 +491,10 @@ define([
*/
$.fn.drawSystemInfoModule = function(mapId, systemData){
var parentElement = $(this);
let parentElement = $(this);
// check if module already exists
var moduleElement = parentElement.find('.' + config.systemInfoModuleClass);
let moduleElement = parentElement.find('.' + config.systemInfoModuleClass);
if(moduleElement.length > 0){
moduleElement.velocity('transition.slideDownOut', {

View File

@@ -64,8 +64,8 @@ define([
// disable "copy&paste" from clipboard (until request finished)
let disableCopyFromClipboard = false;
// cache for dataTable object
let signatureTable = null;
// cache for dataTable object6
let dataTableInstances = {};
// empty signatureData object -> for "add row" table
let emptySignatureData = {
@@ -106,16 +106,117 @@ define([
let signatureGroupsLabels = Util.getSignatureGroupInfo('label');
let signatureGroupsNames = Util.getSignatureGroupInfo('name');
/**
* check whether a dataTable API instance exists in the global cache
* args: 1. mapId, 2. systemId, 3, tableType (primary/secondary) string
* @param args
* @returns {boolean}
*/
let checkDataTableInstance = (...args) => {
let obj = dataTableInstances;
for(let arg of args){
if ( !obj || !obj.hasOwnProperty(arg) ){
return false;
}
obj = obj[arg];
}
return true;
};
/**
* stores a dataTableApi instance to global cache ( overwrites existing)
* @param mapId
* @param systemId
* @param tableType
* @param instance
*/
let setDataTableInstance = (mapId, systemId, tableType, instance) => {
let tmpObj = {
[mapId]: {
[systemId]: {
[tableType]: instance
}
}
};
$.extend(true, dataTableInstances, tmpObj);
};
/**
* get a dataTableApi instance from global cache
* @param mapId
* @param systemId
* @param tableType
* @returns {*}
*/
let getDataTableInstance = (mapId, systemId, tableType) => {
let instance = null;
if( checkDataTableInstance(mapId, systemId, tableType) ){
instance = dataTableInstances[mapId][systemId][tableType];
}
return instance;
};
/**
* get dataTable instance from "moduleElement" (DOM node)
* @param moduleElement
* @param tableType
* @returns {*}
*/
let getDataTableInstanceByModuleElement = (moduleElement, tableType) => {
return getDataTableInstance(moduleElement.data('mapId'), moduleElement.data('systemId'), tableType);
};
/**
* delete a dataTableApi instance from global cache
* -> see checkDataTableInstance() for parameter order
* @param args
*/
let deleteDataTableInstance = (...args) => {
// check if instance exists
if( checkDataTableInstance.apply(null, args) ){
// callback for "leaf" delete callback
let deleteCallback = (dataTableApi) => {
dataTableApi.destroy();
};
// recursive delete from dataTableInstances Object cache
let deepDelete = (target, obj, callback) => {
if(target.length > 1){
// remove first target param for next recursive call
let currentTarget = target.shift();
deepDelete(target, obj[currentTarget], callback);
// delete "parent" key when current key became empty
if( !Object.keys( obj[currentTarget] ).length ){
delete obj[currentTarget];
}
}else{
// check for callback function
if( typeof callback === 'function' ){
callback(obj[target]);
}
delete obj[target];
}
};
deepDelete(args, dataTableInstances, deleteCallback);
}
};
/**
* collect all data of all editable fields in a signature table
* @param tableApi
* @returns {Array}
*/
let getSignatureTableData = function(){
let signatureTableApi = signatureTable.api();
let getTableData = function(tableApi){
let tableData = [];
signatureTableApi.rows().eq(0).each(function(idx){
let row = signatureTableApi.row(idx);
tableApi.rows().eq(0).each(function(idx){
let row = tableApi.row(idx);
// default row data
let defaultRowData = row.data();
let rowElement = row.nodes().to$();
@@ -151,16 +252,14 @@ define([
/**
* updates a single cell with new data (e.g. "updated" cell)
* @param tableApi
* @param rowElement
* @param cellIndex
* @param data
*/
let updateSignatureCell = function(rowElement, cellIndex, data){
let signatureTableApi = signatureTable.api();
let rowIndex = signatureTableApi.row( rowElement ).index();
let updateCell = signatureTableApi.cell( rowIndex, cellIndex );
let updateSignatureCell = function(tableApi, rowElement, cellIndex, data){
let rowIndex = tableApi.row( rowElement ).index();
let updateCell = tableApi.cell( rowIndex, cellIndex );
let updateCellElement = updateCell.nodes().to$();
if(cellIndex === 7){
@@ -184,7 +283,6 @@ define([
* @param deleteOutdatedSignatures -> set to "true" if signatures should be deleted that are not included in "signatureData"
*/
$.fn.updateSignatureTable = function(signatureDataOrig, deleteOutdatedSignatures){
// check if table update is allowed
if(disableTableUpdate === true){
return;
@@ -199,13 +297,12 @@ define([
let moduleElement = $(this);
// get signature table API
let signatureTableApi = signatureTable.api();
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
// get current system data
let currentSystemData = Util.getCurrentSystemData();
let tableData = getSignatureTableData();
let tableData = getTableData(signatureTableApi);
let notificationCounter = {
added: 0,
@@ -229,7 +326,7 @@ define([
signatureTableApi.row(currentRowElement).remove().draw();
// and add "new" row
let changedRowElement = addSignatureRow(currentSystemData.systemData, signatureData[i], false);
let changedRowElement = addSignatureRow(signatureTableApi, currentSystemData.systemData, signatureData[i], false);
// highlight
changedRowElement.pulseTableRow('changed');
@@ -272,7 +369,7 @@ define([
// add new signatures -----------------------------------------------------------------------------------------
for(let k = 0; k < signatureData.length; k++){
// and add "new" row
let newRowElement = addSignatureRow(currentSystemData.systemData, signatureData[k], false);
let newRowElement = addSignatureRow(signatureTableApi, currentSystemData.systemData, signatureData[k], false);
// highlight
newRowElement.pulseTableRow('added');
@@ -333,15 +430,15 @@ define([
* @param options
*/
$.fn.updateScannedSignaturesBar = function(options){
let moduleElement = $(this);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
// get progress bar
let progressBarWrapper = moduleElement.find('.' + config.signatureScannedProgressBarClass);
let progressBar = $(progressBarWrapper).find('.progress-bar');
let progressBarLabel = $(progressBarWrapper).find('.progress-label-right');
let tableData = getSignatureTableData();
let tableData = getTableData(signatureTableApi);
let sigCount = 0;
let percent = 0;
@@ -392,7 +489,6 @@ define([
}
}, 100);
};
/**
@@ -478,12 +574,15 @@ define([
type: 'POST',
url: Init.path.saveSignatureData,
data: requestData,
dataType: 'json'
dataType: 'json',
context: {
moduleElement: moduleElement
}
}).done(function(responseData){
unlockSignatureTable(true);
// updates table with new/updated signature information
moduleElement.updateSignatureTable(responseData.signatures, false);
this.moduleElement.updateSignatureTable(responseData.signatures, false);
}).fail(function( jqXHR, status, error) {
let reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': Update signatures', text: reason, type: 'warning'});
@@ -816,47 +915,45 @@ define([
/**
* get all rows of a table
* @param table
* @param tableApi
* @returns {*}
*/
let getRows = function(table){
let tableApi = table.api();
let getRows = function(tableApi){
let rows = tableApi.rows();
return rows;
};
/**
* get all selected rows of a table
* @param table
* @param tableApi
* @returns {*}
*/
let getSelectedRows = function(table){
let tableApi = table.api();
let getSelectedRows = function(tableApi){
let selectedRows = tableApi.rows('.selected');
return selectedRows;
};
/**
* check the "delete signature" button. show/hide the button if a signature is selected
* @param moduleElement
*/
let checkDeleteSignaturesButton = function(){
let checkDeleteSignaturesButton = function(moduleElement){
moduleElement = $(moduleElement);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
let selectedRows = getSelectedRows(signatureTable);
let selectedRows = getSelectedRows(signatureTableApi);
let selectedRowCount = selectedRows.data().length;
let clearButton = $('.' + config.sigTableClearButtonClass);
let clearButton = moduleElement.find('.' + config.sigTableClearButtonClass);
if(selectedRowCount > 0){
let allRows = getRows(signatureTable);
let allRows = getRows(signatureTableApi);
let rowCount = allRows.data().length;
let badgetText = selectedRowCount;
let badgeText = selectedRowCount;
if(selectedRowCount >= rowCount){
badgetText = 'all';
badgeText = 'all';
}
clearButton.find('.badge').text( badgetText );
clearButton.find('.badge').text( badgeText );
// update clear signatures button text
clearButton.velocity('stop');
@@ -882,10 +979,10 @@ define([
/**
* draw signature table toolbar (add signature button, scan progress bar
* @param mapId
* @param systemData
*/
$.fn.drawSignatureTableToolbar = function(systemData){
$.fn.drawSignatureTableToolbar = function(mapId, systemData){
let moduleElement = $(this);
// add toolbar buttons for table ------------------------------------------------------------------------------
@@ -930,8 +1027,10 @@ define([
label: 'select all',
icon: 'fa-check-square',
onClick: function(){
let allRows = getRows(signatureTable);
let selectedRows = getSelectedRows(signatureTable);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
let allRows = getRows(signatureTableApi);
let selectedRows = getSelectedRows(signatureTableApi);
let allRowElements = allRows.nodes().to$();
if(allRows.data().length === selectedRows.data().length){
@@ -941,7 +1040,7 @@ define([
}
// check delete button
checkDeleteSignaturesButton();
checkDeleteSignaturesButton(moduleElement);
}
})
).append(
@@ -955,12 +1054,12 @@ define([
},
onClick: function(){
// delete all rows
let selectedRows = getSelectedRows(signatureTable);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
let selectedRows = getSelectedRows(signatureTableApi);
bootbox.confirm('Delete ' + selectedRows.data().length + ' signature?', function(result) {
if(result){
deleteSignatures(selectedRows);
deleteSignatures(signatureTableApi, selectedRows);
}
});
}
@@ -984,15 +1083,18 @@ define([
tableToolbar.after(tableToolbarAction);
let signatureData = formatSignatureData(systemData, [emptySignatureData], emptySignatureOptions);
table.dataTable( {
let signatureTable = table.dataTable( {
data: signatureData,
paging: false,
ordering: false,
info: false,
searching: false
} );
let signatureTableApi = signatureTable.api();
table.makeEditable(systemData);
setDataTableInstance(mapId, systemData.id, 'secondary', signatureTableApi);
table.makeEditable(signatureTableApi, systemData);
// scanned signatures progress bar ----------------------------------------------------------------------------
let moduleConfig = {
@@ -1019,18 +1121,16 @@ define([
* @param title
*/
let updateTooltip = function(element, title){
element = $(element);
element.attr('data-container', 'body').attr('title', title.toUpperCase()).tooltip('fixTitle')
$(element).attr('data-container', 'body').attr('title', title.toUpperCase()).tooltip('fixTitle')
.tooltip('setContent');
};
/**
* make a table or row editable
* @param tableApi
* @param systemData
*/
$.fn.makeEditable = function(systemData){
$.fn.makeEditable = function(tableApi, systemData){
// table element OR row element
let tableElement = $(this);
@@ -1055,7 +1155,7 @@ define([
// the current field is in the "primary" table (not the "add" new sig row)
if(
$(e.target).hasClass(config.sigTableEditSigGroupSelect) &&
tableElement.hasClass(config.sigTablePrimaryClass)
$(e.target).parents('.' + config.sigTableClass).hasClass(config.sigTablePrimaryClass)
){
currentField.parents('.' + config.moduleClass).updateScannedSignaturesBar({showNotice: true});
}
@@ -1142,7 +1242,7 @@ define([
updateTooltip(columnElement, newValue);
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1179,7 +1279,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
// find related "type" select (same row) and change options
@@ -1250,7 +1350,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1273,7 +1373,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1328,7 +1428,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1628,15 +1728,14 @@ define([
/**
* deletes signature rows from signature table
* @param tableApi
* @param rows
*/
let deleteSignatures = function(rows){
let deleteSignatures = function(tableApi, rows){
let deletedSignatures = 0;
let moduleElement = $('.' + config.systemSigModuleClass);
let data = rows.data();
let signatureTableApi = signatureTable.api();
let rowElements = rows.nodes().to$();
let signatureCount = data.length;
@@ -1652,7 +1751,7 @@ define([
// animation callback function
let removeCallback = function(rowElement){
// delete signature row
signatureTableApi.row(rowElement).remove().draw();
tableApi.row(rowElement).remove().draw();
deletedSignatures++;
@@ -1686,25 +1785,20 @@ define([
Util.showNotify({title: jqXHR.status + ': Delete signature', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
};
/**
* adds a new row to signature Table
* @param signatureTableApi
* @param systemData
* @param signatureData
* @param animate
* @returns {*}
*/
let addSignatureRow = function(systemData, signatureData, animate){
let addSignatureRow = function(signatureTableApi, systemData, signatureData, animate){
let newSignatureData = formatSignatureData(systemData, [signatureData], fullSignatureOptions);
// insert new row in main signature table
let tablePrimaryElement = $('.' + config.sigTablePrimaryClass);
let dataTablePrimary = tablePrimaryElement.DataTable();
let newRowNode = dataTablePrimary.row.add(newSignatureData.shift()).draw().nodes();
let newRowNode = signatureTableApi.row.add(newSignatureData.shift()).draw().nodes();
let newRowElement = newRowNode.to$();
if(animate === true){
@@ -1713,13 +1807,13 @@ define([
newRowElement.toggleTableRow(function(newRowElement){
// make new row editable
newRowElement.makeEditable(systemData);
newRowElement.makeEditable(signatureTableApi, systemData);
// update scan progress bar
newRowElement.parents('.' + config.moduleClass).updateScannedSignaturesBar({showNotice: true});
});
}else{
newRowElement.makeEditable(systemData);
newRowElement.makeEditable(signatureTableApi, systemData);
}
return newRowElement;
@@ -1732,10 +1826,8 @@ define([
$.fn.toggleTableRow = function(callback){
let rowElement = $(this);
let cellElements = rowElement.children('td');
let duration = 100;
// wrap each <td> into a container (for better animation performance)
// slideUp new wrapper divs
if(rowElement.is(':visible')){
@@ -1815,11 +1907,11 @@ define([
/**
* draw a signature table with data
* @param mapId
* @param signatureData
* @param systemData
* @returns {*}
*/
$.fn.drawSignatureTable = function(signatureData, systemData){
$.fn.drawSignatureTable = function(mapId, signatureData, systemData){
let moduleElement = $(this);
// setup filter select in footer
@@ -1886,14 +1978,14 @@ define([
};
// create signature table and store the jquery object global for this module
signatureTable = table.dataTable(dataTableOptions);
let signatureTable = table.dataTable(dataTableOptions);
let signatureTableApi = signatureTable.api();
setDataTableInstance(mapId, systemData.id, 'primary', signatureTableApi);
// make Table editable
signatureTable.makeEditable(systemData);
signatureTable.makeEditable(signatureTableApi, systemData);
moduleElement.updateScannedSignaturesBar({showNotice: true});
return signatureTable;
};
/**
@@ -2093,6 +2185,12 @@ define([
// submit all fields within a table row
let formFields = rowElement.find('.editable');
// get the current "primary table" for insert row on ajax callback
// -> important: in case of long response, target table might have changed...
let moduleElement = $(e.target).parents('.' + config.moduleClass);
let primaryTable = moduleElement.find('.' + config.sigTablePrimaryClass);
let secondaryTable = moduleElement.find('.' + config.sigTableSecondaryClass);
// the "hide" makes sure to take care about open editable fields (e.g. description)
// otherwise, changes would not be submitted in this field (not necessary)
formFields.editable('hide');
@@ -2104,6 +2202,10 @@ define([
dataType: 'json', //assuming json response
beforeSend: function( xhr, settings ){
lockSignatureTable();
},
context: {
primaryTable: primaryTable,
secondaryTable: secondaryTable
}
},
data: {
@@ -2112,21 +2214,22 @@ define([
},
error: $.fn.editable.defaults.error, // user default xEditable error function
success: function (data, editableConfig) {
let context = editableConfig.ajaxOptions.context;
let primaryTableApi = context.primaryTable.DataTable();
let secondaryTableApi = context.secondaryTable.DataTable();
unlockSignatureTable(false);
let newRowElement = addSignatureRow(systemData, data.signatures[0], true);
let newRowElement = addSignatureRow(primaryTableApi, systemData, data.signatures[0], true);
// highlight
newRowElement.pulseTableRow('added');
// prepare "add signature" table for new entry -> reset -------------------
let signatureData = formatSignatureData(systemData, [emptySignatureData], emptySignatureOptions);
let newAddRowElement = secondaryTableApi.clear().row.add(signatureData.shift()).draw().nodes();
let dataSecondaryElement = $('.' + config.sigTableSecondaryClass);
let dataTableSecondary = dataSecondaryElement.DataTable();
let newAddRowElement = dataTableSecondary.clear().row.add(signatureData.shift()).draw().nodes();
newAddRowElement.to$().makeEditable(systemData);
newAddRowElement.to$().makeEditable(secondaryTableApi, systemData);
Util.showNotify({
title: 'Signature added',
@@ -2153,16 +2256,17 @@ define([
// top scroll to top
e.preventDefault();
let tableApi = tempTableElement.DataTable();
let deleteRowElement = $(target).parents('tr');
let row = tempTableElement.DataTable().rows(deleteRowElement);
deleteSignatures(row);
let row = tableApi.rows(deleteRowElement);
deleteSignatures(tableApi, row);
}
};
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
break;
}
@@ -2178,31 +2282,29 @@ define([
* @param systemData
*/
let setModuleObserver = function(moduleElement, systemData){
let tablePrimaryElement = $('.' + config.sigTablePrimaryClass);
let dataTablePrimary = signatureTable.DataTable();
let signatureTableApi = signatureTable.api();
let tablePrimaryElement = moduleElement.find('.' + config.sigTablePrimaryClass);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
$(document).off('pf:updateSystemSignatureModule').on('pf:updateSystemSignatureModule', function(e, data){
if(data.signatures){
moduleElement.updateSignatureTable(data.signatures, true);
}
});
// set multi row select ---------------------------------------------------------------------------------------
tablePrimaryElement.on('click', 'tr', function(e){
tablePrimaryElement.on('click', 'tr', {moduleElement: moduleElement}, function(e){
if(e.ctrlKey) {
$(this).toggleClass('selected');
// check delete button
checkDeleteSignaturesButton();
checkDeleteSignaturesButton(e.data.moduleElement);
}
});
// draw event for signature table -----------------------------------------------------------------------------
signatureTableApi.on('draw.dt', function(){
signatureTableApi.on('draw.dt', {moduleElement: moduleElement}, function(e, settings){
// check delete button
checkDeleteSignaturesButton();
checkDeleteSignaturesButton(e.data.moduleElement);
});
// event listener for global "paste" signatures into the page -------------------------------------------------
@@ -2214,10 +2316,11 @@ define([
/**
* get module element
* @param parentElement
* @param mapId
* @param systemData
* @returns {*|HTMLElement}
* @returns {*|jQuery|HTMLElement}
*/
let getModule = function(parentElement, systemData){
let getModule = function(parentElement, mapId, systemData){
// create new module container
let moduleElement = $('<div>', {
@@ -2225,6 +2328,9 @@ define([
css: {opacity: 0}
});
moduleElement.data('mapId', mapId);
moduleElement.data('systemId', systemData.id);
// headline
let headline = $('<h5>', {
text: 'Signatures'
@@ -2239,7 +2345,7 @@ define([
// draw "new signature" add table -----------------------------------------------------------------------------
moduleElement.drawSignatureTableToolbar(systemData);
moduleElement.drawSignatureTableToolbar(mapId, systemData);
// request signature data for system --------------------------------------------------------------------------
@@ -2253,14 +2359,14 @@ define([
data: requestData,
dataType: 'json',
context: {
mapId: mapId,
systemData: systemData
}
}).done(function(signatureData){
let signatureTableData = formatSignatureData(this.systemData, signatureData, fullSignatureOptions);
// draw signature table
moduleElement.drawSignatureTable(signatureTableData, this.systemData);
moduleElement.drawSignatureTable(this.mapId, signatureTableData, this.systemData);
// set module observer
setModuleObserver(moduleElement, this.systemData);
@@ -2275,9 +2381,10 @@ define([
/**
* main module load function
* @param mapId
* @param systemData
*/
$.fn.drawSignatureTableModule = function(systemData){
$.fn.drawSignatureTableModule = function(mapId, systemData){
let parentElement = $(this);
// show module
@@ -2317,13 +2424,17 @@ define([
moduleElement.velocity('transition.slideDownOut', {
duration: Init.animationSpeed.mapModule,
complete: function(tempElement){
tempElement = $(tempElement);
// Destroying the data tables throws
// save remove of all dataTables
signatureTable.api().destroy();
let mapId = tempElement.data('mapId');
let systemId = tempElement.data('systemId');
deleteDataTableInstance(mapId, systemId, 'primary');
deleteDataTableInstance(mapId, systemId, 'secondary');
$(tempElement).remove();
tempElement.remove();
moduleElement = getModule(parentElement, systemData);
moduleElement = getModule(parentElement, mapId, systemData);
// make modules appear "nice"
moduleElement.delay(150);
showModule(moduleElement);
@@ -2333,7 +2444,7 @@ define([
// init array prototype functions
initArrayFunctions();
moduleElement = getModule(parentElement, systemData);
moduleElement = getModule(parentElement, mapId, systemData);
showModule(moduleElement);
}
};

View File

@@ -79,40 +79,41 @@ define([
* displays a loading indicator on an element
*/
$.fn.showLoadingAnimation = function(options){
let loadingElement = $(this);
return this.each(function(){
let loadingElement = $(this);
let iconSize = 'fa-lg';
let iconSize = 'fa-lg';
// disable all events
loadingElement.css('pointer-events', 'none');
// disable all events
loadingElement.css('pointer-events', 'none');
if(options){
if(options.icon){
if(options.icon.size){
iconSize = options.icon.size;
if(options){
if(options.icon){
if(options.icon.size){
iconSize = options.icon.size;
}
}
}
}
let overlay = $('<div>', {
class: config.ajaxOverlayClass
}).append(
$('<div>', {
class: [config.ajaxOverlayWrapperClass].join(' ')
let overlay = $('<div>', {
class: config.ajaxOverlayClass
}).append(
$('<i>', {
class: ['fa', 'fa-fw', iconSize, 'fa-refresh', 'fa-spin'].join(' ')
})
)
);
$('<div>', {
class: [config.ajaxOverlayWrapperClass].join(' ')
}).append(
$('<i>', {
class: ['fa', 'fa-fw', iconSize, 'fa-refresh', 'fa-spin'].join(' ')
})
)
);
loadingElement.append(overlay);
loadingElement.append(overlay);
// fade in
$(overlay).velocity({
opacity: 0.6
},{
duration: 120
// fade in
$(overlay).velocity({
opacity: 0.6
},{
duration: 120
});
});
};
@@ -120,16 +121,20 @@ define([
* removes a loading indicator
*/
$.fn.hideLoadingAnimation = function(){
let loadingElement = $(this);
let overlay = loadingElement.find('.' + config.ajaxOverlayClass );
return this.each(function(){
let loadingElement = $(this);
let overlay = loadingElement.find('.' + config.ajaxOverlayClass );
// important: "stop" is required to stop "show" animation
// -> otherwise "complete" callback is not fired!
$(overlay).velocity('stop').velocity('reverse', {
complete: function(){
$(this).remove();
// enable all events
loadingElement.css('pointer-events', 'auto');
if(overlay.length){
// important: "stop" is required to stop "show" animation
// -> otherwise "complete" callback is not fired!
overlay.velocity('stop').velocity('reverse', {
complete: function(){
$(this).remove();
// enable all events
loadingElement.css('pointer-events', 'auto');
}
});
}
});
};

File diff suppressed because one or more lines are too long

View File

@@ -119,7 +119,7 @@ define([
firstCell.drawSystemGraphModule(currentSystemData.systemData);
// draw signature table module
firstCell.drawSignatureTableModule(currentSystemData.systemData);
firstCell.drawSignatureTableModule(currentSystemData.mapId, currentSystemData.systemData);
// draw system routes module
secondCell.drawSystemRouteModule(currentSystemData.mapId, currentSystemData.systemData);

View File

@@ -8,6 +8,7 @@ define([
'app/util',
'app/logging',
'mustache',
'app/map/util',
'text!img/logo.svg!strip',
'text!templates/modules/header.html',
'text!templates/modules/footer.html',
@@ -24,7 +25,7 @@ define([
'dialog/credit',
'slidebars',
'app/module_map'
], function($, Init, Util, Logging, Mustache, TplLogo, TplHead, TplFooter) {
], function($, Init, Util, Logging, Mustache, MapUtil, TplLogo, TplHead, TplFooter) {
'use strict';
@@ -135,26 +136,27 @@ define([
});
body.watchKey('signaturePaste', (e) => {
let moduleElement = $('.' + config.systemSigModuleClass);
// check if there is a signature module active (system clicked)
if(moduleElement.length){
e = e.originalEvent;
let targetElement = $(e.target);
// do not read clipboard if pasting into form elements
if(
targetElement.prop('tagName').toLowerCase() !== 'input' &&
targetElement.prop('tagName').toLowerCase() !== 'textarea' || (
targetElement.is('input[type="search"]') // Datatables "search" field bubbles `paste.DT` event :(
)
){
let clipboard = (e.originalEvent || e).clipboardData.getData('text/plain');
moduleElement.trigger('pf:updateSystemSignatureModuleByClipboard', [clipboard]);
// just send event to the current active map
let activeMap = Util.getMapModule().getActiveMap();
if(activeMap){
// look for active signature module (active system)
let signatureModuleElement = MapUtil.getTabContentElementByMapElement(activeMap).find('.' + config.systemSigModuleClass);
if(signatureModuleElement.length){
e = e.originalEvent;
let targetElement = $(e.target);
// do not read clipboard if pasting into form elements
if(
targetElement.prop('tagName').toLowerCase() !== 'input' &&
targetElement.prop('tagName').toLowerCase() !== 'textarea' || (
targetElement.is('input[type="search"]') // Datatables "search" field bubbles `paste.DT` event :(
)
){
let clipboard = (e.originalEvent || e).clipboardData.getData('text/plain');
signatureModuleElement.trigger('pf:updateSystemSignatureModuleByClipboard', [clipboard]);
}
}
}
});
});
};

View File

@@ -9,7 +9,7 @@ define([
'app/util',
'app/render',
'bootbox'
], function($, Init, Util, Render, bootbox, MapUtil) {
], function($, Init, Util, Render, bootbox) {
'use strict';
let config = {

View File

@@ -11,7 +11,7 @@ define([
], function($, Init, Util, Render, MapUtil) {
'use strict';
var config = {
let config = {
// module info
moduleClass: 'pf-module', // class for each module
@@ -35,41 +35,38 @@ define([
descriptionArea: 'pf-system-info-description-area', // class for "description" area
addDescriptionButtonClass: 'pf-system-info-description-button', // class for "add description" button
moduleElementToolbarClass: 'pf-table-tools', // class for "module toolbar" element
moduleToolbarActionId: 'pf-system-info-collapse-container', // id for "module toolbar action" element
tableToolsActionClass: 'pf-table-tools-action', // class for "edit" action
descriptionTextareaElementClass: 'pf-system-info-description', // class for "description" textarea element (xEditable)
descriptionTextareaCharCounter: 'pf-form-field-char-count' // class for "character counter" element for form field
};
// disable Module update temporary (until. some requests/animations) are finished
var disableModuleUpdate = true;
let disableModuleUpdate = true;
// animation speed values
var animationSpeedToolbarAction = 200;
let animationSpeedToolbarAction = 200;
// max character length for system description
var maxDescriptionLength = 512;
let maxDescriptionLength = 512;
/**
* set module observer and look for relevant system data to update
*/
var setModuleObserver = function(moduleElement){
let setModuleObserver = function(moduleElement){
$(document).off('pf:updateSystemInfoModule').on('pf:updateSystemInfoModule', function(e, data){
if(data){
moduleElement.updateSystemInfoModule(data);
}
});
};
/**
* shows the tool action element by animation
* @param toolsActionElement
*/
var showToolsActionElement = function(){
// "toolbar action" element
var toolsActionElement = $('#' + config.moduleToolbarActionId);
let showToolsActionElement = function(toolsActionElement){
toolsActionElement.velocity('stop').velocity({
opacity: 1,
height: '100%'
@@ -82,12 +79,9 @@ define([
/**
* hides the tool action element by animation
* @param toolsActionElement
*/
var hideToolsActionElement = function(){
// "toolbar action" element
var toolsActionElement = $('#' + config.moduleToolbarActionId);
let hideToolsActionElement = function(toolsActionElement){
toolsActionElement.velocity('stop').velocity('reverse', {
display: 'none',
visibility: 'hidden'
@@ -106,24 +100,23 @@ define([
return;
}
var moduleElement = $(this);
let moduleElement = $(this);
var systemId = moduleElement.data('id');
let systemId = moduleElement.data('id');
if(systemId === systemData.id){
// update module
// system status =====================================================================================
var systemStatusLabelElement = moduleElement.find('.' + config.systemInfoStatusLabelClass);
var systemStatusId = parseInt( systemStatusLabelElement.attr( config.systemInfoStatusAttributeName ) );
let systemStatusLabelElement = moduleElement.find('.' + config.systemInfoStatusLabelClass);
let systemStatusId = parseInt( systemStatusLabelElement.attr( config.systemInfoStatusAttributeName ) );
if(systemStatusId !== systemData.status.id){
// status changed
var currentStatusClass = Util.getStatusInfoForSystem(systemStatusId, 'class');
var newStatusClass = Util.getStatusInfoForSystem(systemData.status.id, 'class');
var newStatusLabel = Util.getStatusInfoForSystem(systemData.status.id, 'label');
let currentStatusClass = Util.getStatusInfoForSystem(systemStatusId, 'class');
let newStatusClass = Util.getStatusInfoForSystem(systemData.status.id, 'class');
let newStatusLabel = Util.getStatusInfoForSystem(systemData.status.id, 'label');
systemStatusLabelElement.removeClass(currentStatusClass).addClass(newStatusClass).text(newStatusLabel);
@@ -132,43 +125,40 @@ define([
}
// description textarea element ======================================================================
var descriptionTextareaElement = moduleElement.find('.' + config.descriptionTextareaElementClass);
var description = descriptionTextareaElement.editable('getValue', true);
let descriptionTextareaElement = moduleElement.find('.' + config.descriptionTextareaElementClass);
let description = descriptionTextareaElement.editable('getValue', true);
if(description !== systemData.description){
// description changed
// description button
var descriptionButton = moduleElement.find('.' + config.addDescriptionButtonClass);
let descriptionButton = moduleElement.find('.' + config.addDescriptionButtonClass);
// set new value
descriptionTextareaElement.editable('setValue', systemData.description);
let actionElement = descriptionButton.siblings('.' + config.tableToolsActionClass);
if(systemData.description.length === 0){
// show/activate description field
// show button if value is empty
descriptionButton.show();
hideToolsActionElement();
hideToolsActionElement(actionElement);
}else{
// hide/disable description field
// hide tool button
descriptionButton.hide();
showToolsActionElement();
showToolsActionElement(actionElement);
}
}
// created/updated tooltip ===========================================================================
var nameRowElement = $(moduleElement).find('.' + config.systemInfoNameInfoClass);
let nameRowElement = $(moduleElement).find('.' + config.systemInfoNameInfoClass);
var tooltipData = {
let tooltipData = {
created: systemData.created,
updated: systemData.updated
};
@@ -176,7 +166,7 @@ define([
nameRowElement.addCharacterInfoTooltip( tooltipData );
}
$('.' + config.descriptionArea).hideLoadingAnimation();
moduleElement.find('.' + config.descriptionArea).hideLoadingAnimation();
};
/**
@@ -185,13 +175,13 @@ define([
* @param charCounterElement
* @param maxCharLength
*/
var updateCounter = function(field, charCounterElement, maxCharLength){
var value = field.val();
var inputLength = value.length;
let updateCounter = function(field, charCounterElement, maxCharLength){
let value = field.val();
let inputLength = value.length;
// line breaks are 2 characters!
var newLines = value.match(/(\r\n|\n|\r)/g);
var addition = 0;
let newLines = value.match(/(\r\n|\n|\r)/g);
let addition = 0;
if (newLines != null) {
addition = newLines.length;
}
@@ -212,10 +202,10 @@ define([
* @param mapId
* @param systemData
*/
var drawModule = function(parentElement, mapId, systemData){
let drawModule = function(parentElement, mapId, systemData){
// create new module container
var moduleElement = $('<div>', {
let moduleElement = $('<div>', {
class: [config.moduleClass, config.systemInfoModuleClass].join(' '),
css: {opacity: 0}
});
@@ -226,14 +216,14 @@ define([
parentElement.prepend(moduleElement);
// shattered wormhole info data
var shatteredWormholeInfo = false;
let shatteredWormholeInfo = false;
// add security class for statics
if(
systemData.statics &&
systemData.statics.length > 0
){
for(var i = 0; i < systemData.statics.length; i++){
for(let i = 0; i < systemData.statics.length; i++){
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
}
}else if(systemData.type.id === 1){
@@ -241,27 +231,26 @@ define([
shatteredWormholeInfo = true;
}
var effectName = MapUtil.getEffectInfoForSystem(systemData.effect, 'name');
var effectClass = MapUtil.getEffectInfoForSystem(systemData.effect, 'class');
let effectName = MapUtil.getEffectInfoForSystem(systemData.effect, 'name');
let effectClass = MapUtil.getEffectInfoForSystem(systemData.effect, 'class');
// systemInfo template config
var moduleConfig = {
let moduleConfig = {
name: 'modules/system_info',
position: moduleElement,
link: 'append',
functions: {
after: function(){
let tempModuleElement = parentElement.find('.' + config.systemInfoModuleClass);
// lock "description" field until first update
$('.' + config.descriptionArea).showLoadingAnimation();
var tempModuleElement = $('.' + config.systemInfoModuleClass);
tempModuleElement.find('.' + config.descriptionArea).showLoadingAnimation();
// "add description" button
var descriptionButton = tempModuleElement.find('.' + config.addDescriptionButtonClass);
let descriptionButton = tempModuleElement.find('.' + config.addDescriptionButtonClass);
// description textarea element
var descriptionTextareaElement = tempModuleElement.find('.' + config.descriptionTextareaElementClass);
let descriptionTextareaElement = tempModuleElement.find('.' + config.descriptionTextareaElementClass);
// init description textarea
descriptionTextareaElement.editable({
@@ -304,9 +293,8 @@ define([
Util.showNotify({title: 'System updated', text: 'Name: ' + response.name, type: 'success'});
},
error: function(jqXHR, newValue){
var reason = '';
var status = '';
let reason = '';
let status = '';
if(jqXHR.name){
// save error new sig (mass save)
reason = jqXHR.name;
@@ -324,13 +312,13 @@ define([
// on xEditable open -------------------------------------------------------------------------
descriptionTextareaElement.on('shown', function(e, editable){
var textarea = editable.input.$input;
let textarea = editable.input.$input;
// disable module update until description field is open
disableModuleUpdate = true;
// create character counter
var charCounter = $('<kbd>', {
let charCounter = $('<kbd>', {
class: [config.descriptionTextareaCharCounter, 'txt-color', 'text-right'].join(' ')
});
textarea.parent().next().append(charCounter);
@@ -345,11 +333,10 @@ define([
// on xEditable close ------------------------------------------------------------------------
descriptionTextareaElement.on('hidden', function(e){
var value = $(this).editable('getValue', true);
let value = $(this).editable('getValue', true);
if(value.length === 0){
// show button if value is empty
hideToolsActionElement();
hideToolsActionElement(descriptionButton.siblings('.' + config.tableToolsActionClass));
descriptionButton.show();
}
@@ -360,6 +347,7 @@ define([
// enable xEditable field on Button click ----------------------------------------------------
descriptionButton.on('click', function(e){
e.stopPropagation();
let descriptionButton = $(this);
// hide tool buttons
descriptionButton.hide();
@@ -367,24 +355,23 @@ define([
// show field *before* showing the element
descriptionTextareaElement.editable('show');
showToolsActionElement();
showToolsActionElement(descriptionButton.siblings('.' + config.tableToolsActionClass));
});
// init tooltips -----------------------------------------------------------------------------
var tooltipElements = $('.' + config.systemInfoModuleClass + ' [data-toggle="tooltip"]');
let tooltipElements = tempModuleElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
// init system effect popover ----------------------------------------------------------------
var infoEffectElement = $(moduleElement).find('.' + config.systemInfoEffectInfoClass);
let infoEffectElement = $(moduleElement).find('.' + config.systemInfoEffectInfoClass);
if(infoEffectElement.length){
// effect row exists -> get effect data
var systemEffectData = Util.getSystemEffectData( systemData.security, systemData.effect);
let systemEffectData = Util.getSystemEffectData( systemData.security, systemData.effect);
if(systemEffectData !== false){
// transform data into table
var systemEffectTable = Util.getSystemEffectTable( systemEffectData );
let systemEffectTable = Util.getSystemEffectTable( systemEffectData );
infoEffectElement.popover({
html: true,
@@ -403,9 +390,9 @@ 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);
for(let i = 0; i < systemData.statics.length; i++){
let staticData = systemData.statics[i];
let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
staticRowElement.addWormholeInfoTooltip(staticData);
}
}
@@ -424,13 +411,13 @@ define([
function details_in_popup(popoverElement){
popoverElement = $(popoverElement);
var popover = popoverElement.data('bs.popover');
let popover = popoverElement.data('bs.popover');
$.ajax({
url: popoverElement.data('url'),
success: function(data){
var systemEffectTable = Util.getSystemsInfoTable( data.systemData );
let systemEffectTable = Util.getSystemsInfoTable( data.systemData );
popover.options.content = systemEffectTable;
// reopen popover (new content size)
popover.show();
@@ -444,7 +431,7 @@ define([
}
};
var moduleData = {
let moduleData = {
system: systemData,
tableClass: config.systemInfoTableClass,
nameInfoClass: config.systemInfoNameInfoClass,
@@ -463,7 +450,7 @@ define([
effectClass: effectClass,
moduleToolbarClass: config.moduleElementToolbarClass,
descriptionButtonClass: config.addDescriptionButtonClass,
moduleToolbarActionId: config.moduleToolbarActionId,
tableToolsActionClass: config.tableToolsActionClass,
descriptionTextareaClass: config.descriptionTextareaElementClass,
shatteredWormholeInfo: shatteredWormholeInfo,
@@ -483,7 +470,7 @@ define([
* show system info module with animation
* @param moduleElement
*/
var showModule = function(moduleElement){
let showModule = function(moduleElement){
moduleElement.velocity('transition.slideDownIn', {
duration: Init.animationSpeed.mapModule,
delay: Init.animationSpeed.mapModule,
@@ -504,10 +491,10 @@ define([
*/
$.fn.drawSystemInfoModule = function(mapId, systemData){
var parentElement = $(this);
let parentElement = $(this);
// check if module already exists
var moduleElement = parentElement.find('.' + config.systemInfoModuleClass);
let moduleElement = parentElement.find('.' + config.systemInfoModuleClass);
if(moduleElement.length > 0){
moduleElement.velocity('transition.slideDownOut', {

View File

@@ -64,8 +64,8 @@ define([
// disable "copy&paste" from clipboard (until request finished)
let disableCopyFromClipboard = false;
// cache for dataTable object
let signatureTable = null;
// cache for dataTable object6
let dataTableInstances = {};
// empty signatureData object -> for "add row" table
let emptySignatureData = {
@@ -106,16 +106,117 @@ define([
let signatureGroupsLabels = Util.getSignatureGroupInfo('label');
let signatureGroupsNames = Util.getSignatureGroupInfo('name');
/**
* check whether a dataTable API instance exists in the global cache
* args: 1. mapId, 2. systemId, 3, tableType (primary/secondary) string
* @param args
* @returns {boolean}
*/
let checkDataTableInstance = (...args) => {
let obj = dataTableInstances;
for(let arg of args){
if ( !obj || !obj.hasOwnProperty(arg) ){
return false;
}
obj = obj[arg];
}
return true;
};
/**
* stores a dataTableApi instance to global cache ( overwrites existing)
* @param mapId
* @param systemId
* @param tableType
* @param instance
*/
let setDataTableInstance = (mapId, systemId, tableType, instance) => {
let tmpObj = {
[mapId]: {
[systemId]: {
[tableType]: instance
}
}
};
$.extend(true, dataTableInstances, tmpObj);
};
/**
* get a dataTableApi instance from global cache
* @param mapId
* @param systemId
* @param tableType
* @returns {*}
*/
let getDataTableInstance = (mapId, systemId, tableType) => {
let instance = null;
if( checkDataTableInstance(mapId, systemId, tableType) ){
instance = dataTableInstances[mapId][systemId][tableType];
}
return instance;
};
/**
* get dataTable instance from "moduleElement" (DOM node)
* @param moduleElement
* @param tableType
* @returns {*}
*/
let getDataTableInstanceByModuleElement = (moduleElement, tableType) => {
return getDataTableInstance(moduleElement.data('mapId'), moduleElement.data('systemId'), tableType);
};
/**
* delete a dataTableApi instance from global cache
* -> see checkDataTableInstance() for parameter order
* @param args
*/
let deleteDataTableInstance = (...args) => {
// check if instance exists
if( checkDataTableInstance.apply(null, args) ){
// callback for "leaf" delete callback
let deleteCallback = (dataTableApi) => {
dataTableApi.destroy();
};
// recursive delete from dataTableInstances Object cache
let deepDelete = (target, obj, callback) => {
if(target.length > 1){
// remove first target param for next recursive call
let currentTarget = target.shift();
deepDelete(target, obj[currentTarget], callback);
// delete "parent" key when current key became empty
if( !Object.keys( obj[currentTarget] ).length ){
delete obj[currentTarget];
}
}else{
// check for callback function
if( typeof callback === 'function' ){
callback(obj[target]);
}
delete obj[target];
}
};
deepDelete(args, dataTableInstances, deleteCallback);
}
};
/**
* collect all data of all editable fields in a signature table
* @param tableApi
* @returns {Array}
*/
let getSignatureTableData = function(){
let signatureTableApi = signatureTable.api();
let getTableData = function(tableApi){
let tableData = [];
signatureTableApi.rows().eq(0).each(function(idx){
let row = signatureTableApi.row(idx);
tableApi.rows().eq(0).each(function(idx){
let row = tableApi.row(idx);
// default row data
let defaultRowData = row.data();
let rowElement = row.nodes().to$();
@@ -151,16 +252,14 @@ define([
/**
* updates a single cell with new data (e.g. "updated" cell)
* @param tableApi
* @param rowElement
* @param cellIndex
* @param data
*/
let updateSignatureCell = function(rowElement, cellIndex, data){
let signatureTableApi = signatureTable.api();
let rowIndex = signatureTableApi.row( rowElement ).index();
let updateCell = signatureTableApi.cell( rowIndex, cellIndex );
let updateSignatureCell = function(tableApi, rowElement, cellIndex, data){
let rowIndex = tableApi.row( rowElement ).index();
let updateCell = tableApi.cell( rowIndex, cellIndex );
let updateCellElement = updateCell.nodes().to$();
if(cellIndex === 7){
@@ -184,7 +283,6 @@ define([
* @param deleteOutdatedSignatures -> set to "true" if signatures should be deleted that are not included in "signatureData"
*/
$.fn.updateSignatureTable = function(signatureDataOrig, deleteOutdatedSignatures){
// check if table update is allowed
if(disableTableUpdate === true){
return;
@@ -199,13 +297,12 @@ define([
let moduleElement = $(this);
// get signature table API
let signatureTableApi = signatureTable.api();
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
// get current system data
let currentSystemData = Util.getCurrentSystemData();
let tableData = getSignatureTableData();
let tableData = getTableData(signatureTableApi);
let notificationCounter = {
added: 0,
@@ -229,7 +326,7 @@ define([
signatureTableApi.row(currentRowElement).remove().draw();
// and add "new" row
let changedRowElement = addSignatureRow(currentSystemData.systemData, signatureData[i], false);
let changedRowElement = addSignatureRow(signatureTableApi, currentSystemData.systemData, signatureData[i], false);
// highlight
changedRowElement.pulseTableRow('changed');
@@ -272,7 +369,7 @@ define([
// add new signatures -----------------------------------------------------------------------------------------
for(let k = 0; k < signatureData.length; k++){
// and add "new" row
let newRowElement = addSignatureRow(currentSystemData.systemData, signatureData[k], false);
let newRowElement = addSignatureRow(signatureTableApi, currentSystemData.systemData, signatureData[k], false);
// highlight
newRowElement.pulseTableRow('added');
@@ -333,15 +430,15 @@ define([
* @param options
*/
$.fn.updateScannedSignaturesBar = function(options){
let moduleElement = $(this);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
// get progress bar
let progressBarWrapper = moduleElement.find('.' + config.signatureScannedProgressBarClass);
let progressBar = $(progressBarWrapper).find('.progress-bar');
let progressBarLabel = $(progressBarWrapper).find('.progress-label-right');
let tableData = getSignatureTableData();
let tableData = getTableData(signatureTableApi);
let sigCount = 0;
let percent = 0;
@@ -392,7 +489,6 @@ define([
}
}, 100);
};
/**
@@ -478,12 +574,15 @@ define([
type: 'POST',
url: Init.path.saveSignatureData,
data: requestData,
dataType: 'json'
dataType: 'json',
context: {
moduleElement: moduleElement
}
}).done(function(responseData){
unlockSignatureTable(true);
// updates table with new/updated signature information
moduleElement.updateSignatureTable(responseData.signatures, false);
this.moduleElement.updateSignatureTable(responseData.signatures, false);
}).fail(function( jqXHR, status, error) {
let reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': Update signatures', text: reason, type: 'warning'});
@@ -816,47 +915,45 @@ define([
/**
* get all rows of a table
* @param table
* @param tableApi
* @returns {*}
*/
let getRows = function(table){
let tableApi = table.api();
let getRows = function(tableApi){
let rows = tableApi.rows();
return rows;
};
/**
* get all selected rows of a table
* @param table
* @param tableApi
* @returns {*}
*/
let getSelectedRows = function(table){
let tableApi = table.api();
let getSelectedRows = function(tableApi){
let selectedRows = tableApi.rows('.selected');
return selectedRows;
};
/**
* check the "delete signature" button. show/hide the button if a signature is selected
* @param moduleElement
*/
let checkDeleteSignaturesButton = function(){
let checkDeleteSignaturesButton = function(moduleElement){
moduleElement = $(moduleElement);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
let selectedRows = getSelectedRows(signatureTable);
let selectedRows = getSelectedRows(signatureTableApi);
let selectedRowCount = selectedRows.data().length;
let clearButton = $('.' + config.sigTableClearButtonClass);
let clearButton = moduleElement.find('.' + config.sigTableClearButtonClass);
if(selectedRowCount > 0){
let allRows = getRows(signatureTable);
let allRows = getRows(signatureTableApi);
let rowCount = allRows.data().length;
let badgetText = selectedRowCount;
let badgeText = selectedRowCount;
if(selectedRowCount >= rowCount){
badgetText = 'all';
badgeText = 'all';
}
clearButton.find('.badge').text( badgetText );
clearButton.find('.badge').text( badgeText );
// update clear signatures button text
clearButton.velocity('stop');
@@ -882,10 +979,10 @@ define([
/**
* draw signature table toolbar (add signature button, scan progress bar
* @param mapId
* @param systemData
*/
$.fn.drawSignatureTableToolbar = function(systemData){
$.fn.drawSignatureTableToolbar = function(mapId, systemData){
let moduleElement = $(this);
// add toolbar buttons for table ------------------------------------------------------------------------------
@@ -930,8 +1027,10 @@ define([
label: 'select all',
icon: 'fa-check-square',
onClick: function(){
let allRows = getRows(signatureTable);
let selectedRows = getSelectedRows(signatureTable);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
let allRows = getRows(signatureTableApi);
let selectedRows = getSelectedRows(signatureTableApi);
let allRowElements = allRows.nodes().to$();
if(allRows.data().length === selectedRows.data().length){
@@ -941,7 +1040,7 @@ define([
}
// check delete button
checkDeleteSignaturesButton();
checkDeleteSignaturesButton(moduleElement);
}
})
).append(
@@ -955,12 +1054,12 @@ define([
},
onClick: function(){
// delete all rows
let selectedRows = getSelectedRows(signatureTable);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
let selectedRows = getSelectedRows(signatureTableApi);
bootbox.confirm('Delete ' + selectedRows.data().length + ' signature?', function(result) {
if(result){
deleteSignatures(selectedRows);
deleteSignatures(signatureTableApi, selectedRows);
}
});
}
@@ -984,15 +1083,18 @@ define([
tableToolbar.after(tableToolbarAction);
let signatureData = formatSignatureData(systemData, [emptySignatureData], emptySignatureOptions);
table.dataTable( {
let signatureTable = table.dataTable( {
data: signatureData,
paging: false,
ordering: false,
info: false,
searching: false
} );
let signatureTableApi = signatureTable.api();
table.makeEditable(systemData);
setDataTableInstance(mapId, systemData.id, 'secondary', signatureTableApi);
table.makeEditable(signatureTableApi, systemData);
// scanned signatures progress bar ----------------------------------------------------------------------------
let moduleConfig = {
@@ -1019,18 +1121,16 @@ define([
* @param title
*/
let updateTooltip = function(element, title){
element = $(element);
element.attr('data-container', 'body').attr('title', title.toUpperCase()).tooltip('fixTitle')
$(element).attr('data-container', 'body').attr('title', title.toUpperCase()).tooltip('fixTitle')
.tooltip('setContent');
};
/**
* make a table or row editable
* @param tableApi
* @param systemData
*/
$.fn.makeEditable = function(systemData){
$.fn.makeEditable = function(tableApi, systemData){
// table element OR row element
let tableElement = $(this);
@@ -1055,7 +1155,7 @@ define([
// the current field is in the "primary" table (not the "add" new sig row)
if(
$(e.target).hasClass(config.sigTableEditSigGroupSelect) &&
tableElement.hasClass(config.sigTablePrimaryClass)
$(e.target).parents('.' + config.sigTableClass).hasClass(config.sigTablePrimaryClass)
){
currentField.parents('.' + config.moduleClass).updateScannedSignaturesBar({showNotice: true});
}
@@ -1142,7 +1242,7 @@ define([
updateTooltip(columnElement, newValue);
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1179,7 +1279,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
// find related "type" select (same row) and change options
@@ -1250,7 +1350,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1273,7 +1373,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1328,7 +1428,7 @@ define([
let newRowData = response.signatures[0];
// update "updated" cell
updateSignatureCell(rowElement, 7, newRowData.updated);
updateSignatureCell(tableApi, rowElement, 7, newRowData.updated);
}
}
});
@@ -1628,15 +1728,14 @@ define([
/**
* deletes signature rows from signature table
* @param tableApi
* @param rows
*/
let deleteSignatures = function(rows){
let deleteSignatures = function(tableApi, rows){
let deletedSignatures = 0;
let moduleElement = $('.' + config.systemSigModuleClass);
let data = rows.data();
let signatureTableApi = signatureTable.api();
let rowElements = rows.nodes().to$();
let signatureCount = data.length;
@@ -1652,7 +1751,7 @@ define([
// animation callback function
let removeCallback = function(rowElement){
// delete signature row
signatureTableApi.row(rowElement).remove().draw();
tableApi.row(rowElement).remove().draw();
deletedSignatures++;
@@ -1686,25 +1785,20 @@ define([
Util.showNotify({title: jqXHR.status + ': Delete signature', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
};
/**
* adds a new row to signature Table
* @param signatureTableApi
* @param systemData
* @param signatureData
* @param animate
* @returns {*}
*/
let addSignatureRow = function(systemData, signatureData, animate){
let addSignatureRow = function(signatureTableApi, systemData, signatureData, animate){
let newSignatureData = formatSignatureData(systemData, [signatureData], fullSignatureOptions);
// insert new row in main signature table
let tablePrimaryElement = $('.' + config.sigTablePrimaryClass);
let dataTablePrimary = tablePrimaryElement.DataTable();
let newRowNode = dataTablePrimary.row.add(newSignatureData.shift()).draw().nodes();
let newRowNode = signatureTableApi.row.add(newSignatureData.shift()).draw().nodes();
let newRowElement = newRowNode.to$();
if(animate === true){
@@ -1713,13 +1807,13 @@ define([
newRowElement.toggleTableRow(function(newRowElement){
// make new row editable
newRowElement.makeEditable(systemData);
newRowElement.makeEditable(signatureTableApi, systemData);
// update scan progress bar
newRowElement.parents('.' + config.moduleClass).updateScannedSignaturesBar({showNotice: true});
});
}else{
newRowElement.makeEditable(systemData);
newRowElement.makeEditable(signatureTableApi, systemData);
}
return newRowElement;
@@ -1732,10 +1826,8 @@ define([
$.fn.toggleTableRow = function(callback){
let rowElement = $(this);
let cellElements = rowElement.children('td');
let duration = 100;
// wrap each <td> into a container (for better animation performance)
// slideUp new wrapper divs
if(rowElement.is(':visible')){
@@ -1815,11 +1907,11 @@ define([
/**
* draw a signature table with data
* @param mapId
* @param signatureData
* @param systemData
* @returns {*}
*/
$.fn.drawSignatureTable = function(signatureData, systemData){
$.fn.drawSignatureTable = function(mapId, signatureData, systemData){
let moduleElement = $(this);
// setup filter select in footer
@@ -1886,14 +1978,14 @@ define([
};
// create signature table and store the jquery object global for this module
signatureTable = table.dataTable(dataTableOptions);
let signatureTable = table.dataTable(dataTableOptions);
let signatureTableApi = signatureTable.api();
setDataTableInstance(mapId, systemData.id, 'primary', signatureTableApi);
// make Table editable
signatureTable.makeEditable(systemData);
signatureTable.makeEditable(signatureTableApi, systemData);
moduleElement.updateScannedSignaturesBar({showNotice: true});
return signatureTable;
};
/**
@@ -2093,6 +2185,12 @@ define([
// submit all fields within a table row
let formFields = rowElement.find('.editable');
// get the current "primary table" for insert row on ajax callback
// -> important: in case of long response, target table might have changed...
let moduleElement = $(e.target).parents('.' + config.moduleClass);
let primaryTable = moduleElement.find('.' + config.sigTablePrimaryClass);
let secondaryTable = moduleElement.find('.' + config.sigTableSecondaryClass);
// the "hide" makes sure to take care about open editable fields (e.g. description)
// otherwise, changes would not be submitted in this field (not necessary)
formFields.editable('hide');
@@ -2104,6 +2202,10 @@ define([
dataType: 'json', //assuming json response
beforeSend: function( xhr, settings ){
lockSignatureTable();
},
context: {
primaryTable: primaryTable,
secondaryTable: secondaryTable
}
},
data: {
@@ -2112,21 +2214,22 @@ define([
},
error: $.fn.editable.defaults.error, // user default xEditable error function
success: function (data, editableConfig) {
let context = editableConfig.ajaxOptions.context;
let primaryTableApi = context.primaryTable.DataTable();
let secondaryTableApi = context.secondaryTable.DataTable();
unlockSignatureTable(false);
let newRowElement = addSignatureRow(systemData, data.signatures[0], true);
let newRowElement = addSignatureRow(primaryTableApi, systemData, data.signatures[0], true);
// highlight
newRowElement.pulseTableRow('added');
// prepare "add signature" table for new entry -> reset -------------------
let signatureData = formatSignatureData(systemData, [emptySignatureData], emptySignatureOptions);
let newAddRowElement = secondaryTableApi.clear().row.add(signatureData.shift()).draw().nodes();
let dataSecondaryElement = $('.' + config.sigTableSecondaryClass);
let dataTableSecondary = dataSecondaryElement.DataTable();
let newAddRowElement = dataTableSecondary.clear().row.add(signatureData.shift()).draw().nodes();
newAddRowElement.to$().makeEditable(systemData);
newAddRowElement.to$().makeEditable(secondaryTableApi, systemData);
Util.showNotify({
title: 'Signature added',
@@ -2153,16 +2256,17 @@ define([
// top scroll to top
e.preventDefault();
let tableApi = tempTableElement.DataTable();
let deleteRowElement = $(target).parents('tr');
let row = tempTableElement.DataTable().rows(deleteRowElement);
deleteSignatures(row);
let row = tableApi.rows(deleteRowElement);
deleteSignatures(tableApi, row);
}
};
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
break;
}
@@ -2178,36 +2282,33 @@ define([
* @param systemData
*/
let setModuleObserver = function(moduleElement, systemData){
let tablePrimaryElement = $('.' + config.sigTablePrimaryClass);
let dataTablePrimary = signatureTable.DataTable();
let signatureTableApi = signatureTable.api();
let tablePrimaryElement = moduleElement.find('.' + config.sigTablePrimaryClass);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
$(document).off('pf:updateSystemSignatureModule').on('pf:updateSystemSignatureModule', function(e, data){
if(data.signatures){
moduleElement.updateSignatureTable(data.signatures, true);
}
});
// set multi row select ---------------------------------------------------------------------------------------
tablePrimaryElement.on('click', 'tr', function(e){
tablePrimaryElement.on('click', 'tr', {moduleElement: moduleElement}, function(e){
if(e.ctrlKey) {
$(this).toggleClass('selected');
// check delete button
checkDeleteSignaturesButton();
checkDeleteSignaturesButton(e.data.moduleElement);
}
});
// draw event for signature table -----------------------------------------------------------------------------
signatureTableApi.on('draw.dt', function(){
signatureTableApi.on('draw.dt', {moduleElement: moduleElement}, function(e, settings){
// check delete button
checkDeleteSignaturesButton();
checkDeleteSignaturesButton(e.data.moduleElement);
});
console.log('set obs') ;
// event listener for global "paste" signatures into the page -------------------------------------------------
moduleElement.on('pf:updateSystemSignatureModuleByClipboard', function(e, clipboard){
console.log('paste');
$(this).updateSignatureTableByClipboard(systemData, clipboard, {});
});
};
@@ -2215,10 +2316,11 @@ console.log('set obs') ;
/**
* get module element
* @param parentElement
* @param mapId
* @param systemData
* @returns {*|HTMLElement}
* @returns {*|jQuery|HTMLElement}
*/
let getModule = function(parentElement, systemData){
let getModule = function(parentElement, mapId, systemData){
// create new module container
let moduleElement = $('<div>', {
@@ -2226,6 +2328,9 @@ console.log('set obs') ;
css: {opacity: 0}
});
moduleElement.data('mapId', mapId);
moduleElement.data('systemId', systemData.id);
// headline
let headline = $('<h5>', {
text: 'Signatures'
@@ -2240,7 +2345,7 @@ console.log('set obs') ;
// draw "new signature" add table -----------------------------------------------------------------------------
moduleElement.drawSignatureTableToolbar(systemData);
moduleElement.drawSignatureTableToolbar(mapId, systemData);
// request signature data for system --------------------------------------------------------------------------
@@ -2254,14 +2359,14 @@ console.log('set obs') ;
data: requestData,
dataType: 'json',
context: {
mapId: mapId,
systemData: systemData
}
}).done(function(signatureData){
let signatureTableData = formatSignatureData(this.systemData, signatureData, fullSignatureOptions);
// draw signature table
moduleElement.drawSignatureTable(signatureTableData, this.systemData);
moduleElement.drawSignatureTable(this.mapId, signatureTableData, this.systemData);
// set module observer
setModuleObserver(moduleElement, this.systemData);
@@ -2276,9 +2381,10 @@ console.log('set obs') ;
/**
* main module load function
* @param mapId
* @param systemData
*/
$.fn.drawSignatureTableModule = function(systemData){
$.fn.drawSignatureTableModule = function(mapId, systemData){
let parentElement = $(this);
// show module
@@ -2318,13 +2424,17 @@ console.log('set obs') ;
moduleElement.velocity('transition.slideDownOut', {
duration: Init.animationSpeed.mapModule,
complete: function(tempElement){
tempElement = $(tempElement);
// Destroying the data tables throws
// save remove of all dataTables
signatureTable.api().destroy();
let mapId = tempElement.data('mapId');
let systemId = tempElement.data('systemId');
deleteDataTableInstance(mapId, systemId, 'primary');
deleteDataTableInstance(mapId, systemId, 'secondary');
$(tempElement).remove();
tempElement.remove();
moduleElement = getModule(parentElement, systemData);
moduleElement = getModule(parentElement, mapId, systemData);
// make modules appear "nice"
moduleElement.delay(150);
showModule(moduleElement);
@@ -2334,7 +2444,7 @@ console.log('set obs') ;
// init array prototype functions
initArrayFunctions();
moduleElement = getModule(parentElement, systemData);
moduleElement = getModule(parentElement, mapId, systemData);
showModule(moduleElement);
}
};

View File

@@ -79,40 +79,41 @@ define([
* displays a loading indicator on an element
*/
$.fn.showLoadingAnimation = function(options){
let loadingElement = $(this);
return this.each(function(){
let loadingElement = $(this);
let iconSize = 'fa-lg';
let iconSize = 'fa-lg';
// disable all events
loadingElement.css('pointer-events', 'none');
// disable all events
loadingElement.css('pointer-events', 'none');
if(options){
if(options.icon){
if(options.icon.size){
iconSize = options.icon.size;
if(options){
if(options.icon){
if(options.icon.size){
iconSize = options.icon.size;
}
}
}
}
let overlay = $('<div>', {
class: config.ajaxOverlayClass
}).append(
$('<div>', {
class: [config.ajaxOverlayWrapperClass].join(' ')
let overlay = $('<div>', {
class: config.ajaxOverlayClass
}).append(
$('<i>', {
class: ['fa', 'fa-fw', iconSize, 'fa-refresh', 'fa-spin'].join(' ')
})
)
);
$('<div>', {
class: [config.ajaxOverlayWrapperClass].join(' ')
}).append(
$('<i>', {
class: ['fa', 'fa-fw', iconSize, 'fa-refresh', 'fa-spin'].join(' ')
})
)
);
loadingElement.append(overlay);
loadingElement.append(overlay);
// fade in
$(overlay).velocity({
opacity: 0.6
},{
duration: 120
// fade in
$(overlay).velocity({
opacity: 0.6
},{
duration: 120
});
});
};
@@ -120,16 +121,20 @@ define([
* removes a loading indicator
*/
$.fn.hideLoadingAnimation = function(){
let loadingElement = $(this);
let overlay = loadingElement.find('.' + config.ajaxOverlayClass );
return this.each(function(){
let loadingElement = $(this);
let overlay = loadingElement.find('.' + config.ajaxOverlayClass );
// important: "stop" is required to stop "show" animation
// -> otherwise "complete" callback is not fired!
$(overlay).velocity('stop').velocity('reverse', {
complete: function(){
$(this).remove();
// enable all events
loadingElement.css('pointer-events', 'auto');
if(overlay.length){
// important: "stop" is required to stop "show" animation
// -> otherwise "complete" callback is not fired!
overlay.velocity('stop').velocity('reverse', {
complete: function(){
$(this).remove();
// enable all events
loadingElement.css('pointer-events', 'auto');
}
});
}
});
};

View File

@@ -34,7 +34,7 @@
<div class="pf-dynamic-area pf-system-info-description-area">
<i class="fa fa-fw fa-lg fa-pencil pull-right pf-module-icon-button {{descriptionButtonClass}}" data-toggle="tooltip" data-container="body" title="edit description"></i>
<div id="{{moduleToolbarActionId}}" class="pf-table-tools-action">
<div class="{{tableToolsActionClass}}">
<a href="#" class="{{descriptionTextareaClass}}"></a>
</div>
</div>

View File

@@ -867,30 +867,23 @@ input[type="email"]{
overflow: hidden;
height: 18px;
background: $gray-lighter;
box-shadow: 0 1px 0 transparent, 0 0 0 1px lighten( $gray-light, 29%) inset;
-webkit-box-shadow: 0 1px 0 transparent, 0 0 0 1px lighten( $gray-light, 29%) inset;
-moz-box-shadow: 0 1px 0 transparent, 0 0 0 1px lighten( $gray-light, 29%) inset;
border-radius:$progressbar-radius;
-moz-border-radius:$progressbar-radius;
-webkit-border-radius:$progressbar-radius;
@include box-shadow( 0 1px 0 transparent, 0 0 0 1px lighten( $gray-light, 29%) inset);
@include border-radius($progressbar-radius);
}
.progress-bar {
float: left;
width: 0;
height: 100%;
font-size: 11px;
color: $white;
text-align: center;
background-color: $blue;
-webkit-box-shadow: inset 0 -1px 0 rgba(red($black), green($black), blue($black), 0.15);
box-shadow: inset 0 -1px 0 rgba(red($black), green($black), blue($black), 0.15);
font-weight:bold;
text-shadow: 0 -1px 0 rgba(red($black), green($black), blue($black), 0.25);
//background-image:url("#{$base-url}/overlay-pattern.png");
-webkit-transition: width 1.5s ease-in-out;
transition: width 1.5s ease-in-out;
float: left;
width: 0;
height: 100%;
font-size: 11px;
color: $white;
text-align: center;
background-color: $blue;
font-weight: bold;
text-shadow: 0 -1px 0 rgba(red($black), green($black), blue($black), 0.25);
//background-image:url("#{$base-url}/overlay-pattern.png");
@include box-shadow( inset 0 -1px 0 rgba(red($black), green($black), blue($black), 0.15));
@include transition(width 1s ease-in-out) ;
}
.progress-striped .progress-bar {