diff --git a/js/app/ui/module/system_route.js b/js/app/ui/module/system_route.js index 90604c8a..28916515 100644 --- a/js/app/ui/module/system_route.js +++ b/js/app/ui/module/system_route.js @@ -211,7 +211,7 @@ define([ // get current row data (important!) // -> "rowData" param is not current state, values are "on createCell()" state rowData = tableApi.row( $(cell).parents('tr')).data(); - let routeData = module.getRouteRequestDataFromRowData(rowData); + let routeData = module.getRouteRequestDataFromRowData(rowData, module._systemData.mapId); // overwrite some params routeData.skipSearch = 0; @@ -242,7 +242,7 @@ define([ // get current row data (important!) // -> "rowData" param is not current state, values are "on createCell()" state rowData = tableApi.row( $(cell).parents('tr')).data(); - let routeData = module.getRouteRequestDataFromRowData(rowData); + let routeData = module.getRouteRequestDataFromRowData(rowData, module._systemData.mapId); // overwrite some params routeData.skipSearch = 0; @@ -318,6 +318,8 @@ define([ // add "Rally Point" systems to table let systemsToData = module.getRallySystemsData(module._systemData.mapId); systemsToData.push(...systemsTo); + + // set global routeSettings module.drawRouteTable(module._systemData.mapId, module._systemFromData, systemsToData); }); @@ -441,7 +443,7 @@ define([ skipSearch: requestRouteData.length >= defaultRoutesCount }; - requestRouteData.push(this.getRouteRequestDataFromRowData(searchData)); + requestRouteData.push(this.getRouteRequestDataFromRowData(searchData, mapId)); } } } @@ -481,7 +483,23 @@ define([ * @param {Object} rowData * @returns {Object} */ - getRouteRequestDataFromRowData(rowData){ + getRouteRequestDataFromRowData(rowData, mapId){ + + // Here we need to retrieve the stored settings stored as "routeSettings" in the map module. + // This can be done with the function : + // Util.getLocalStorage('map').getItem(mapId); + // however this returns a promise, and I do not know how to make the return below wait for the promise to + // call back without using something like: + // async getRouteRequestDataFromRowData(rowData, mapId){ + // let routeSettings = await Util.getLocalStorage('map').getItem(mapId).routeSettings; + // return { + // ... + // }; + // } + // In theory if the storedLocal data can be retrieved here into a var we can just modify the returned object below + // to incorporate these settings like: + // wormholesThera: (rowData.hasOwnProperty('wormholesThera')) ? rowData.wormholesThera | 0 : routeSettings.wormholesThera | 1, + return { mapIds: (rowData.hasOwnProperty('mapIds')) ? rowData.mapIds : [], systemFromData: (rowData.hasOwnProperty('systemFromData')) ? rowData.systemFromData : {}, @@ -532,7 +550,7 @@ define([ let routeData = []; this._tableApi.rows().every(function(){ - routeData.push(module.getRouteRequestDataFromRowData(this.data())); + routeData.push(module.getRouteRequestDataFromRowData(this.data(), module._systemData.mapId)); }); this.getRouteData({routeData: routeData}, 'callbackAddRouteRows'); @@ -889,7 +907,17 @@ define([ id: this._config.routeSettingsDialogId, selectClass: this._config.systemDialogSelectClass, systemSelectOptions: systemSelectOptions, - maxSelectionLength: maxSelectionLength + maxSelectionLength: maxSelectionLength, //remove comma + // new options + select2Class: Util.config.select2Class, + routeDialogSizeSelectId: this._config.routeDialogSizeSelectId, + select2Class: Util.config.select2Class, + sizeOptions: MapUtil.allConnectionJumpMassTypes().map(type => ({ + id: type, + name: type, + selected: false + })) + }; requirejs(['text!templates/dialog/route_settings.html', 'mustache'], (template, Mustache) => { @@ -910,15 +938,38 @@ define([ callback: e => { let form = $(e.delegateTarget).find('form'); // get all system data from select2 + let systemSelectData = form.find('.' + this._config.systemDialogSelectClass).select2('data'); let systemsToData = []; + + // route settings additions + let routeSettingsData = $(form).getFormValues(); + + if( + routeSettingsData + ){ + let routeSettings = { + stargates: routeSettingsData.hasOwnProperty('stargates') ? parseInt(routeSettingsData.stargates) : 0, + jumpbridges: routeSettingsData.hasOwnProperty('jumpbridges') ? parseInt(routeSettingsData.jumpbridges) : 0, + wormholes: routeSettingsData.hasOwnProperty('wormholes') ? parseInt(routeSettingsData.wormholes) : 0, + wormholesReduced: routeSettingsData.hasOwnProperty('wormholesReduced') ? parseInt(routeSettingsData.wormholesReduced) : 0, + wormholesCritical: routeSettingsData.hasOwnProperty('wormholesCritical') ? parseInt(routeSettingsData.wormholesCritical) : 0, + wormholesEOL: routeSettingsData.hasOwnProperty('wormholesEOL') ? parseInt(routeSettingsData.wormholesEOL) : 0, + wormholesThera: routeSettingsData.hasOwnProperty('wormholesThera') ? parseInt(routeSettingsData.wormholesThera) : 0, + wormholesSizeMin: routeSettingsData.wormholesSizeMin || '', + excludeTypes: SystemRouteModule.getLowerSizeConnectionTypes(routeSettingsData.wormholesSizeMin), + endpointsBubble: routeSettingsData.hasOwnProperty('endpointsBubble') ? parseInt(routeSettingsData.endpointsBubble) : 0, + }; + Util.getLocalStore('map').setItem(`${dialogData.mapId}.routeSettings`, routeSettings); + } + // end route settings additions if(systemSelectData.length > 0){ systemsToData = SystemRouteModule.formSystemSelectData(systemSelectData); Util.getLocalStore('map').setItem(`${dialogData.mapId}.routes`, systemsToData); }else{ Util.getLocalStore('map').removeItem(`${dialogData.mapId}.routes`); - } + } this.showNotify({title: 'Route settings stored', type: 'success'}); @@ -935,6 +986,9 @@ define([ // -> add some delay until modal transition has finished let systemTargetSelect = $(e.target).find('.' + this._config.systemDialogSelectClass); systemTargetSelect.delay(240).initSystemSelect({key: 'id', maxSelectionLength: maxSelectionLength}); + + // init connection jump size select ------------------------------------------------------------------- + $(e.target).find('#' + this._config.routeDialogSizeSelectId).initConnectionSizeSelect(); }); // show dialog diff --git a/public/js/v2.0.1/app/ui/module/system_route.js b/public/js/v2.0.1/app/ui/module/system_route.js index 90604c8a..28916515 100644 --- a/public/js/v2.0.1/app/ui/module/system_route.js +++ b/public/js/v2.0.1/app/ui/module/system_route.js @@ -211,7 +211,7 @@ define([ // get current row data (important!) // -> "rowData" param is not current state, values are "on createCell()" state rowData = tableApi.row( $(cell).parents('tr')).data(); - let routeData = module.getRouteRequestDataFromRowData(rowData); + let routeData = module.getRouteRequestDataFromRowData(rowData, module._systemData.mapId); // overwrite some params routeData.skipSearch = 0; @@ -242,7 +242,7 @@ define([ // get current row data (important!) // -> "rowData" param is not current state, values are "on createCell()" state rowData = tableApi.row( $(cell).parents('tr')).data(); - let routeData = module.getRouteRequestDataFromRowData(rowData); + let routeData = module.getRouteRequestDataFromRowData(rowData, module._systemData.mapId); // overwrite some params routeData.skipSearch = 0; @@ -318,6 +318,8 @@ define([ // add "Rally Point" systems to table let systemsToData = module.getRallySystemsData(module._systemData.mapId); systemsToData.push(...systemsTo); + + // set global routeSettings module.drawRouteTable(module._systemData.mapId, module._systemFromData, systemsToData); }); @@ -441,7 +443,7 @@ define([ skipSearch: requestRouteData.length >= defaultRoutesCount }; - requestRouteData.push(this.getRouteRequestDataFromRowData(searchData)); + requestRouteData.push(this.getRouteRequestDataFromRowData(searchData, mapId)); } } } @@ -481,7 +483,23 @@ define([ * @param {Object} rowData * @returns {Object} */ - getRouteRequestDataFromRowData(rowData){ + getRouteRequestDataFromRowData(rowData, mapId){ + + // Here we need to retrieve the stored settings stored as "routeSettings" in the map module. + // This can be done with the function : + // Util.getLocalStorage('map').getItem(mapId); + // however this returns a promise, and I do not know how to make the return below wait for the promise to + // call back without using something like: + // async getRouteRequestDataFromRowData(rowData, mapId){ + // let routeSettings = await Util.getLocalStorage('map').getItem(mapId).routeSettings; + // return { + // ... + // }; + // } + // In theory if the storedLocal data can be retrieved here into a var we can just modify the returned object below + // to incorporate these settings like: + // wormholesThera: (rowData.hasOwnProperty('wormholesThera')) ? rowData.wormholesThera | 0 : routeSettings.wormholesThera | 1, + return { mapIds: (rowData.hasOwnProperty('mapIds')) ? rowData.mapIds : [], systemFromData: (rowData.hasOwnProperty('systemFromData')) ? rowData.systemFromData : {}, @@ -532,7 +550,7 @@ define([ let routeData = []; this._tableApi.rows().every(function(){ - routeData.push(module.getRouteRequestDataFromRowData(this.data())); + routeData.push(module.getRouteRequestDataFromRowData(this.data(), module._systemData.mapId)); }); this.getRouteData({routeData: routeData}, 'callbackAddRouteRows'); @@ -889,7 +907,17 @@ define([ id: this._config.routeSettingsDialogId, selectClass: this._config.systemDialogSelectClass, systemSelectOptions: systemSelectOptions, - maxSelectionLength: maxSelectionLength + maxSelectionLength: maxSelectionLength, //remove comma + // new options + select2Class: Util.config.select2Class, + routeDialogSizeSelectId: this._config.routeDialogSizeSelectId, + select2Class: Util.config.select2Class, + sizeOptions: MapUtil.allConnectionJumpMassTypes().map(type => ({ + id: type, + name: type, + selected: false + })) + }; requirejs(['text!templates/dialog/route_settings.html', 'mustache'], (template, Mustache) => { @@ -910,15 +938,38 @@ define([ callback: e => { let form = $(e.delegateTarget).find('form'); // get all system data from select2 + let systemSelectData = form.find('.' + this._config.systemDialogSelectClass).select2('data'); let systemsToData = []; + + // route settings additions + let routeSettingsData = $(form).getFormValues(); + + if( + routeSettingsData + ){ + let routeSettings = { + stargates: routeSettingsData.hasOwnProperty('stargates') ? parseInt(routeSettingsData.stargates) : 0, + jumpbridges: routeSettingsData.hasOwnProperty('jumpbridges') ? parseInt(routeSettingsData.jumpbridges) : 0, + wormholes: routeSettingsData.hasOwnProperty('wormholes') ? parseInt(routeSettingsData.wormholes) : 0, + wormholesReduced: routeSettingsData.hasOwnProperty('wormholesReduced') ? parseInt(routeSettingsData.wormholesReduced) : 0, + wormholesCritical: routeSettingsData.hasOwnProperty('wormholesCritical') ? parseInt(routeSettingsData.wormholesCritical) : 0, + wormholesEOL: routeSettingsData.hasOwnProperty('wormholesEOL') ? parseInt(routeSettingsData.wormholesEOL) : 0, + wormholesThera: routeSettingsData.hasOwnProperty('wormholesThera') ? parseInt(routeSettingsData.wormholesThera) : 0, + wormholesSizeMin: routeSettingsData.wormholesSizeMin || '', + excludeTypes: SystemRouteModule.getLowerSizeConnectionTypes(routeSettingsData.wormholesSizeMin), + endpointsBubble: routeSettingsData.hasOwnProperty('endpointsBubble') ? parseInt(routeSettingsData.endpointsBubble) : 0, + }; + Util.getLocalStore('map').setItem(`${dialogData.mapId}.routeSettings`, routeSettings); + } + // end route settings additions if(systemSelectData.length > 0){ systemsToData = SystemRouteModule.formSystemSelectData(systemSelectData); Util.getLocalStore('map').setItem(`${dialogData.mapId}.routes`, systemsToData); }else{ Util.getLocalStore('map').removeItem(`${dialogData.mapId}.routes`); - } + } this.showNotify({title: 'Route settings stored', type: 'success'}); @@ -935,6 +986,9 @@ define([ // -> add some delay until modal transition has finished let systemTargetSelect = $(e.target).find('.' + this._config.systemDialogSelectClass); systemTargetSelect.delay(240).initSystemSelect({key: 'id', maxSelectionLength: maxSelectionLength}); + + // init connection jump size select ------------------------------------------------------------------- + $(e.target).find('#' + this._config.routeDialogSizeSelectId).initConnectionSizeSelect(); }); // show dialog diff --git a/public/templates/dialog/route_settings.html b/public/templates/dialog/route_settings.html index 891fe9ef..a6034e0f 100644 --- a/public/templates/dialog/route_settings.html +++ b/public/templates/dialog/route_settings.html @@ -26,5 +26,103 @@ +

  Filter

+ + {{! Filter ------------------------------------------------------------------- }} + +
+ +
+
+ + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+ + +
+ +
+ + +
+
+
+
+ +
+ \ No newline at end of file