- new "persistent system aliases" for systems, closed #496
- improved bulk delete for systems
This commit is contained in:
@@ -414,7 +414,10 @@ class System extends Controller\AccessController {
|
||||
*/
|
||||
public function delete(\Base $f3){
|
||||
$mapId = (int)$f3->get('POST.mapId');
|
||||
$systemIds = (array)$f3->get('POST.systemIds');
|
||||
$systemIds = array_map('intval', (array)$f3->get('POST.systemIds'));
|
||||
|
||||
$return = (object) [];
|
||||
$return->deletedSystemIds = [];
|
||||
|
||||
if($mapId){
|
||||
$activeCharacter = $this->getCharacter();
|
||||
@@ -429,25 +432,52 @@ class System extends Controller\AccessController {
|
||||
foreach($systemIds as $systemId){
|
||||
if( $system = $map->getSystemById($systemId) ){
|
||||
// check whether system should be deleted OR set "inactive"
|
||||
if( !empty($system->description) ){
|
||||
if( $this->checkDeleteMode($map, $system) ){
|
||||
$system->erase();
|
||||
}else{
|
||||
// keep data -> set "inactive"
|
||||
$system->setActive(false);
|
||||
$system->save();
|
||||
}else{
|
||||
$system->erase();
|
||||
}
|
||||
|
||||
$system->reset();
|
||||
|
||||
$return->deletedSystemIds[] = $systemId;
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast map changes
|
||||
$this->broadcastMapData($map);
|
||||
if(count($return->deletedSystemIds)){
|
||||
$this->broadcastMapData($map);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo json_encode([]);
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether a system should be "deleted" or set "inactive" (keep some data)
|
||||
* @param Model\MapModel $map
|
||||
* @param Model\SystemModel $system
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkDeleteMode(Model\MapModel $map, Model\SystemModel $system){
|
||||
$delete = true;
|
||||
|
||||
if( !empty($system->description) ){
|
||||
// never delete systems with custom description set!
|
||||
$delete = false;
|
||||
}elseif(
|
||||
$map->persistentAliases &&
|
||||
!empty($system->alias) &&
|
||||
($system->alias != $system->name)
|
||||
){
|
||||
// map setting "persistentAliases" is active (default) AND
|
||||
// alias is set and != name
|
||||
$delete = false;
|
||||
}
|
||||
|
||||
return $delete;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,11 @@ class MapModel extends BasicModel {
|
||||
'nullable' => false,
|
||||
'default' => 1
|
||||
],
|
||||
'persistentAliases' => [
|
||||
'type' => Schema::DT_BOOL,
|
||||
'nullable' => false,
|
||||
'default' => 1
|
||||
],
|
||||
'systems' => [
|
||||
'has-many' => ['Model\SystemModel', 'mapId']
|
||||
],
|
||||
@@ -156,6 +161,7 @@ class MapModel extends BasicModel {
|
||||
$mapData->icon = $this->icon;
|
||||
$mapData->deleteExpiredConnections = $this->deleteExpiredConnections;
|
||||
$mapData->deleteEolConnections = $this->deleteEolConnections;
|
||||
$mapData->persistentAliases = $this->persistentAliases;
|
||||
$mapData->created = strtotime($this->created);
|
||||
$mapData->updated = strtotime($this->updated);
|
||||
|
||||
|
||||
@@ -109,12 +109,21 @@ define([
|
||||
|
||||
let systemDeleteDialog = bootbox.confirm(msg, result => {
|
||||
if(result){
|
||||
deleteSystems(map, validDeleteSystems, (systems) => {
|
||||
deleteSystems(map, validDeleteSystems, (deletedSystems) => {
|
||||
// callback function after deleted -> close dialog
|
||||
systemDeleteDialog.modal('hide');
|
||||
|
||||
if(systems.length === 1){
|
||||
Util.showNotify({title: 'System deleted', text: $(systems[0]).data('name'), type: 'success'});
|
||||
// check whether all systems were deleted properly
|
||||
if(deletedSystems.length !== validDeleteSystems.length){
|
||||
let notDeletedCount = validDeleteSystems.length - deletedSystems.length;
|
||||
|
||||
Util.showNotify({
|
||||
title: 'Failed to delete systems',
|
||||
text: '(' + notDeletedCount + '/' + validDeleteSystems.length + ') systems could not be deleted',
|
||||
type: 'warning'}
|
||||
);
|
||||
}else if(deletedSystems.length === 1){
|
||||
Util.showNotify({title: 'System deleted', text: $(deletedSystems[0]).data('name'), type: 'success'});
|
||||
}else{
|
||||
Util.showNotify({title: systems.length + ' systems deleted', type: 'success'});
|
||||
}
|
||||
@@ -150,11 +159,18 @@ define([
|
||||
map: map,
|
||||
systems: systems
|
||||
}
|
||||
}).done(function(){
|
||||
// remove systems from map
|
||||
removeSystems(this.map, this.systems);
|
||||
}).done(function(data){
|
||||
// check if all systems were deleted that should get deleted
|
||||
let deletedSystems = this.systems.filter(
|
||||
function(system){
|
||||
return this.indexOf( $(system).data('id') ) !== -1;
|
||||
}, data.deletedSystemIds
|
||||
);
|
||||
|
||||
callback(this.systems);
|
||||
// remove systems from map
|
||||
removeSystems(this.map, deletedSystems);
|
||||
|
||||
callback(deletedSystems);
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
let reason = status + ' ' + error;
|
||||
Util.showNotify({title: jqXHR.status + ': deleteSystem', text: reason, type: 'warning'});
|
||||
|
||||
@@ -435,18 +435,24 @@ define([
|
||||
// trigger system delete event
|
||||
activeMap.trigger('pf:deleteSystems', [{
|
||||
systems: [systemElement[0]],
|
||||
callback: function(){
|
||||
callback: function(deletedSystems){
|
||||
// callback function after ajax "delete" success
|
||||
// remove table row
|
||||
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
|
||||
// check if system was deleted
|
||||
if(deletedSystems.length === 1){
|
||||
// remove table row
|
||||
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
|
||||
|
||||
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
|
||||
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
|
||||
|
||||
// refresh connection table (connections might have changed) ==================
|
||||
let connectionsElement = $('#' + config.mapInfoConnectionsId);
|
||||
let mapDataNew = activeMap.getMapDataFromClient({forceData: true});
|
||||
// refresh connection table (connections might have changed) ==================
|
||||
let connectionsElement = $('#' + config.mapInfoConnectionsId);
|
||||
let mapDataNew = activeMap.getMapDataFromClient({forceData: true});
|
||||
|
||||
connectionsElement.loadConnectionInfoTable(mapDataNew);
|
||||
connectionsElement.loadConnectionInfoTable(mapDataNew);
|
||||
}else{
|
||||
// error
|
||||
Util.showNotify({title: 'Failed to delete system', text: rowData.name, type: 'error'});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ define([
|
||||
|
||||
deleteExpiredConnectionsId: 'pf-map-dialog-delete-connections-expired', // id for "deleteExpiredConnections" checkbox
|
||||
deleteEolConnectionsId: 'pf-map-dialog-delete-connections-eol', // id for "deleteEOLConnections" checkbox
|
||||
persistentAliasesId: 'pf-map-dialog-persistent-aliases', // id for "persistentAliases" checkbox
|
||||
|
||||
characterSelectId: 'pf-map-dialog-character-select', // id for "character" select
|
||||
corporationSelectId: 'pf-map-dialog-corporation-select', // id for "corporation" select
|
||||
@@ -108,6 +109,7 @@ define([
|
||||
let accessAlliance = [];
|
||||
let deleteExpiredConnections = true;
|
||||
let deleteEolConnections = true;
|
||||
let persistentAliases = true;
|
||||
|
||||
if(mapData !== false){
|
||||
// set current map information
|
||||
@@ -123,6 +125,7 @@ define([
|
||||
|
||||
deleteExpiredConnections = mapData.config.deleteExpiredConnections;
|
||||
deleteEolConnections = mapData.config.deleteEolConnections;
|
||||
persistentAliases = mapData.config.persistentAliases;
|
||||
}
|
||||
|
||||
// render main dialog -----------------------------------------------------
|
||||
@@ -154,8 +157,10 @@ define([
|
||||
// settings tab --------------
|
||||
deleteExpiredConnectionsId : config.deleteExpiredConnectionsId,
|
||||
deleteEolConnectionsId : config.deleteEolConnectionsId,
|
||||
persistentAliasesId : config.persistentAliasesId,
|
||||
deleteExpiredConnections: deleteExpiredConnections,
|
||||
deleteEolConnections: deleteEolConnections,
|
||||
persistentAliases: persistentAliases,
|
||||
|
||||
characterSelectId: config.characterSelectId,
|
||||
corporationSelectId: config.corporationSelectId,
|
||||
@@ -246,6 +251,9 @@ define([
|
||||
if( form.find('#' + config.deleteEolConnectionsId).length ){
|
||||
formData.deleteEolConnections = formData.hasOwnProperty('deleteEolConnections') ? parseInt( formData.deleteEolConnections ) : 0;
|
||||
}
|
||||
if( form.find('#' + config.persistentAliasesId).length ){
|
||||
formData.persistentAliases = formData.hasOwnProperty('persistentAliases') ? parseInt( formData.persistentAliases ) : 0;
|
||||
}
|
||||
|
||||
let requestData = {formData: formData};
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -121,6 +121,10 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* move panel out of "cookie" accept hint
|
||||
* @param direction
|
||||
*/
|
||||
let moveAdminPanel = (direction) => {
|
||||
let adminPanel = $('#' + config.stickyPanelAdminId);
|
||||
adminPanel.css({bottom: ((direction === 'up') ? '+' : '-') + '=35px'});
|
||||
|
||||
@@ -109,12 +109,21 @@ define([
|
||||
|
||||
let systemDeleteDialog = bootbox.confirm(msg, result => {
|
||||
if(result){
|
||||
deleteSystems(map, validDeleteSystems, (systems) => {
|
||||
deleteSystems(map, validDeleteSystems, (deletedSystems) => {
|
||||
// callback function after deleted -> close dialog
|
||||
systemDeleteDialog.modal('hide');
|
||||
|
||||
if(systems.length === 1){
|
||||
Util.showNotify({title: 'System deleted', text: $(systems[0]).data('name'), type: 'success'});
|
||||
// check whether all systems were deleted properly
|
||||
if(deletedSystems.length !== validDeleteSystems.length){
|
||||
let notDeletedCount = validDeleteSystems.length - deletedSystems.length;
|
||||
|
||||
Util.showNotify({
|
||||
title: 'Failed to delete systems',
|
||||
text: '(' + notDeletedCount + '/' + validDeleteSystems.length + ') systems could not be deleted',
|
||||
type: 'warning'}
|
||||
);
|
||||
}else if(deletedSystems.length === 1){
|
||||
Util.showNotify({title: 'System deleted', text: $(deletedSystems[0]).data('name'), type: 'success'});
|
||||
}else{
|
||||
Util.showNotify({title: systems.length + ' systems deleted', type: 'success'});
|
||||
}
|
||||
@@ -150,11 +159,18 @@ define([
|
||||
map: map,
|
||||
systems: systems
|
||||
}
|
||||
}).done(function(){
|
||||
// remove systems from map
|
||||
removeSystems(this.map, this.systems);
|
||||
}).done(function(data){
|
||||
// check if all systems were deleted that should get deleted
|
||||
let deletedSystems = this.systems.filter(
|
||||
function(system){
|
||||
return this.indexOf( $(system).data('id') ) !== -1;
|
||||
}, data.deletedSystemIds
|
||||
);
|
||||
|
||||
callback(this.systems);
|
||||
// remove systems from map
|
||||
removeSystems(this.map, deletedSystems);
|
||||
|
||||
callback(deletedSystems);
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
let reason = status + ' ' + error;
|
||||
Util.showNotify({title: jqXHR.status + ': deleteSystem', text: reason, type: 'warning'});
|
||||
|
||||
@@ -435,18 +435,24 @@ define([
|
||||
// trigger system delete event
|
||||
activeMap.trigger('pf:deleteSystems', [{
|
||||
systems: [systemElement[0]],
|
||||
callback: function(){
|
||||
callback: function(deletedSystems){
|
||||
// callback function after ajax "delete" success
|
||||
// remove table row
|
||||
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
|
||||
// check if system was deleted
|
||||
if(deletedSystems.length === 1){
|
||||
// remove table row
|
||||
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
|
||||
|
||||
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
|
||||
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
|
||||
|
||||
// refresh connection table (connections might have changed) ==================
|
||||
let connectionsElement = $('#' + config.mapInfoConnectionsId);
|
||||
let mapDataNew = activeMap.getMapDataFromClient({forceData: true});
|
||||
// refresh connection table (connections might have changed) ==================
|
||||
let connectionsElement = $('#' + config.mapInfoConnectionsId);
|
||||
let mapDataNew = activeMap.getMapDataFromClient({forceData: true});
|
||||
|
||||
connectionsElement.loadConnectionInfoTable(mapDataNew);
|
||||
connectionsElement.loadConnectionInfoTable(mapDataNew);
|
||||
}else{
|
||||
// error
|
||||
Util.showNotify({title: 'Failed to delete system', text: rowData.name, type: 'error'});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ define([
|
||||
|
||||
deleteExpiredConnectionsId: 'pf-map-dialog-delete-connections-expired', // id for "deleteExpiredConnections" checkbox
|
||||
deleteEolConnectionsId: 'pf-map-dialog-delete-connections-eol', // id for "deleteEOLConnections" checkbox
|
||||
persistentAliasesId: 'pf-map-dialog-persistent-aliases', // id for "persistentAliases" checkbox
|
||||
|
||||
characterSelectId: 'pf-map-dialog-character-select', // id for "character" select
|
||||
corporationSelectId: 'pf-map-dialog-corporation-select', // id for "corporation" select
|
||||
@@ -108,6 +109,7 @@ define([
|
||||
let accessAlliance = [];
|
||||
let deleteExpiredConnections = true;
|
||||
let deleteEolConnections = true;
|
||||
let persistentAliases = true;
|
||||
|
||||
if(mapData !== false){
|
||||
// set current map information
|
||||
@@ -123,6 +125,7 @@ define([
|
||||
|
||||
deleteExpiredConnections = mapData.config.deleteExpiredConnections;
|
||||
deleteEolConnections = mapData.config.deleteEolConnections;
|
||||
persistentAliases = mapData.config.persistentAliases;
|
||||
}
|
||||
|
||||
// render main dialog -----------------------------------------------------
|
||||
@@ -154,8 +157,10 @@ define([
|
||||
// settings tab --------------
|
||||
deleteExpiredConnectionsId : config.deleteExpiredConnectionsId,
|
||||
deleteEolConnectionsId : config.deleteEolConnectionsId,
|
||||
persistentAliasesId : config.persistentAliasesId,
|
||||
deleteExpiredConnections: deleteExpiredConnections,
|
||||
deleteEolConnections: deleteEolConnections,
|
||||
persistentAliases: persistentAliases,
|
||||
|
||||
characterSelectId: config.characterSelectId,
|
||||
corporationSelectId: config.corporationSelectId,
|
||||
@@ -246,6 +251,9 @@ define([
|
||||
if( form.find('#' + config.deleteEolConnectionsId).length ){
|
||||
formData.deleteEolConnections = formData.hasOwnProperty('deleteEolConnections') ? parseInt( formData.deleteEolConnections ) : 0;
|
||||
}
|
||||
if( form.find('#' + config.persistentAliasesId).length ){
|
||||
formData.persistentAliases = formData.hasOwnProperty('persistentAliases') ? parseInt( formData.persistentAliases ) : 0;
|
||||
}
|
||||
|
||||
let requestData = {formData: formData};
|
||||
|
||||
|
||||
@@ -1141,6 +1141,11 @@ td.pf-popover-trigger{
|
||||
// footer (navigation) ============================================================================
|
||||
.navbar-fixed-bottom{
|
||||
padding: 2px 0;
|
||||
|
||||
.container-fluid{
|
||||
padding-left: 0; // overwrite default
|
||||
padding-right: 0; // verwrite default
|
||||
}
|
||||
}
|
||||
// global info panel ==============================================================================
|
||||
#pf-global-info{
|
||||
|
||||
Reference in New Issue
Block a user