- improved map export, removed unnecessary JSON data

- fixed bug where "updated" table column is not set on insert
This commit is contained in:
Exodus4D
2016-08-06 00:06:20 +02:00
parent 1c9c9f4563
commit 444d50698e
6 changed files with 53 additions and 37 deletions

View File

@@ -411,6 +411,9 @@ abstract class BasicModel extends \DB\Cortex {
* return false will stop any further action
*/
public function beforeInsertEvent(){
if($this->exists('updated')){
$this->touch('updated');
}
return true;
}

View File

@@ -120,7 +120,7 @@ class ConnectionModel extends BasicModel{
$this->eolUpdated = null;
}elseif(
in_array('wh_eol', $newTypes) &&
!in_array('wh_eol', $this->type)
!in_array('wh_eol', (array)$this->type) // $this->type == null for new connection! (e.g. map import)
){
// connection EOL status change
$this->touch('eolUpdated');
@@ -196,14 +196,17 @@ class ConnectionModel extends BasicModel{
*/
public function beforeInsertEvent(){
// check for "default" connection type and add them if missing
// -> get() with "true" returns RAW data! important for JSON table column check!
$types = (array)json_decode( $this->get('type', true) );
if(
!$this->scope ||
!$this->type
empty($types)
){
$this->setDefaultTypeData();
}
return true;
return parent::beforeInsertEvent();
}
/**

View File

@@ -3029,6 +3029,7 @@ define([
// check if system data should be added
var addSystemData = true;
if(
options.getAll !== true &&
options.checkForChange === true &&
!tempSystem.hasChanged()
){
@@ -3056,6 +3057,7 @@ define([
// check if connection data should be added
var addConnectionData = true;
if(
options.getAll !== true &&
options.checkForChange === true &&
!$(tempConnection).hasChanged()
){

View File

@@ -340,8 +340,25 @@ define([
var validExportForm = exportForm.isValidForm();
if(validExportForm){
// set map data right before download
$(this).setExportMapData(e.data.mapData);
var mapElement = Util.getMapModule().getActiveMap();
if(mapElement){
// IMPORTANT: Get map data from client (NOT from global mapData which is available in here)
// -> This excludes some data (e.g. wh statics)
// -> Bring export inline with main map toggle requests
var exportMapData = mapElement.getMapDataFromClient({
forceData: true,
getAll: true
});
// set map data right before download
$(this).setExportMapData(exportMapData);
// disable button
$(this).attr('disabled', true);
}else{
console.error('Map not found');
}
}else{
e.preventDefault();
}
@@ -514,21 +531,7 @@ define([
filename = fieldExport.val();
if(filename.length > 0){
// remove object properties that should not be included in export
// -> e.g. jsPlumb object,...
var allowedKeys = ['config', 'data'];
var replace = function(obj, keys) {
var dup = {};
for (var key in obj) {
if (keys.indexOf(key) !== -1) {
dup[key] = obj[key];
}
}
return dup;
};
mapDataEncoded = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify( replace(mapData, allowedKeys) ));
mapDataEncoded = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify( mapData ));
}
}

View File

@@ -3029,6 +3029,7 @@ define([
// check if system data should be added
var addSystemData = true;
if(
options.getAll !== true &&
options.checkForChange === true &&
!tempSystem.hasChanged()
){
@@ -3056,6 +3057,7 @@ define([
// check if connection data should be added
var addConnectionData = true;
if(
options.getAll !== true &&
options.checkForChange === true &&
!$(tempConnection).hasChanged()
){

View File

@@ -340,8 +340,25 @@ define([
var validExportForm = exportForm.isValidForm();
if(validExportForm){
// set map data right before download
$(this).setExportMapData(e.data.mapData);
var mapElement = Util.getMapModule().getActiveMap();
if(mapElement){
// IMPORTANT: Get map data from client (NOT from global mapData which is available in here)
// -> This excludes some data (e.g. wh statics)
// -> Bring export inline with main map toggle requests
var exportMapData = mapElement.getMapDataFromClient({
forceData: true,
getAll: true
});
// set map data right before download
$(this).setExportMapData(exportMapData);
// disable button
$(this).attr('disabled', true);
}else{
console.error('Map not found');
}
}else{
e.preventDefault();
}
@@ -514,21 +531,7 @@ define([
filename = fieldExport.val();
if(filename.length > 0){
// remove object properties that should not be included in export
// -> e.g. jsPlumb object,...
var allowedKeys = ['config', 'data'];
var replace = function(obj, keys) {
var dup = {};
for (var key in obj) {
if (keys.indexOf(key) !== -1) {
dup[key] = obj[key];
}
}
return dup;
};
mapDataEncoded = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify( replace(mapData, allowedKeys) ));
mapDataEncoded = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify( mapData ));
}
}