Fix map loading

This commit is contained in:
Paulo Gustavo Veiga 2021-12-03 16:43:50 -08:00
parent 025e4714e9
commit c9cac78d2d
14 changed files with 51 additions and 71 deletions

6
libraries/bootstrap.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,7 @@
*/
import { $assert } from "@wisemapping/core-js";
class CommandContext {
constructor(designer) {
$assert(designer, 'designer can not be null');

View File

@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import web2d from '@wisemapping/web2d';
import INodeModel, { TopicShape } from './model/INodeModel';
@ -24,14 +25,14 @@ const ConnectionLine = new Class({
initialize(sourceNode, targetNode, lineType) {
$assert(targetNode, 'parentNode node can not be null');
$assert(sourceNode, 'childNode node can not be null');
$assert(sourceNode != targetNode, 'Circular connection');
$assert(sourceNode !== targetNode, 'Circular connection');
this._targetTopic = targetNode;
this._sourceTopic = sourceNode;
let line;
const ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
if (targetNode.getType() == INodeModel.CENTRAL_TOPIC_TYPE) {
if (targetNode.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
line = this._createLine(lineType, ConnectionLine.CURVED);
line.setSrcControlPoint(ctrlPoints[0]);
line.setDestControlPoint(ctrlPoints[1]);
@ -59,7 +60,7 @@ const ConnectionLine = new Class({
if (!$defined(lineType)) {
lineType = defaultStyle;
}
lineType = parseInt(lineType);
lineType = parseInt(lineType, 10);
this._lineType = lineType;
let line = null;
switch (lineType) {
@ -124,7 +125,7 @@ const ConnectionLine = new Class({
const targetTopicSize = targetTopic.getSize();
let y;
let x;
if (targetTopic.getShapeType() == TopicShape.LINE) {
if (targetTopic.getShapeType() === TopicShape.LINE) {
y = targetTopicSize.height;
} else {
y = targetTopicSize.height / 2;
@ -197,9 +198,7 @@ const ConnectionLine = new Class({
},
});
ConnectionLine.getStrokeColor = function () {
return '#495879';
};
ConnectionLine.getStrokeColor = () => '#495879';
ConnectionLine.SIMPLE = 0;
ConnectionLine.POLYLINE = 1;

View File

@ -16,6 +16,7 @@
* limitations under the License.
*/
import web2d from '@wisemapping/web2d';
import { $defined } from '@wisemapping/core-js';
import Shape from './util/Shape';
import ActionDispatcher from './ActionDispatcher';

View File

@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from "@wisemapping/core-js";
import web2d from '@wisemapping/web2d';
const Icon = new Class({
@ -50,7 +51,7 @@ const Icon = new Class({
},
remove() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
},
});

View File

@ -16,6 +16,7 @@
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import $ from '@libraries/jquery-2.1.0';
import Icon from './Icon';
import FloatingTip from './widget/FloatingTip';

View File

@ -15,6 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert, $defined } from "@wisemapping/core-js";
import $ from '@libraries/jquery-2.1.0';
class FeatureModel {
/**
@ -41,7 +43,7 @@ class FeatureModel {
/** */
setAttributes(attributes) {
for (key in attributes) {
for (const key in attributes) {
this[`set${key.capitalize()}`](attributes[key]);
}
}

View File

@ -1,3 +1,4 @@
/* eslint-disable class-methods-use-this */
/*
* Copyright [2015] [wisemapping]
*
@ -15,6 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from "@wisemapping/core-js";
class IMindmap {
getCentralTopic() {
@ -23,52 +25,52 @@ class IMindmap {
/** @abstract */
getDescription() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
setDescription(value) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
getId() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
setId(id) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
getVersion() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
setVersion(version) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
addBranch(nodeModel) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
getBranches() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
removeBranch(node) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
getRelationships() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/**
@ -103,27 +105,27 @@ class IMindmap {
/** @abstract */
hasAlreadyAdded(node) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
createNode(type, id) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
createRelationship(fromNode, toNode) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
addRelationship(rel) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
deleteRelationship(relationship) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** */
@ -137,7 +139,7 @@ class IMindmap {
for (let i = 0; i < branches.length; i++) {
const node = branches[i];
if (i != 0) {
if (i !== 0) {
result = `${result},\n `;
}
result = `${result}(${i}) =>${node.inspect()}`;

View File

@ -224,7 +224,7 @@ class INodeModel {
/** */
areChildrenShrunken() {
const result = this.getProperty('shrunken');
$defined(result) ? result : false;
return $defined(result) ? result : false;
}
/**
@ -250,7 +250,7 @@ class INodeModel {
/** @abstract */
append(node) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/**
@ -311,32 +311,32 @@ class INodeModel {
/** @abstract */
getPropertiesKeys() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
putProperty(key, value) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
setParent(parent) {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
getChildren() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
getParent() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** @abstract */
clone() {
throw 'Unsupported operation';
throw new Error('Unsupported operation');
}
/** */

View File

@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from "@wisemapping/core-js";
import FeatureModel from './FeatureModel';
class NoteModel extends FeatureModel {

View File

@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $defined } from "@wisemapping/core-js";
import ModelCodeName from './ModelCodeName';
import Beta2PelaMigrator from './Beta2PelaMigrator';
import Pela2TangoMigrator from './Pela2TangoMigrator';

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createDocument, innerXML } from '@wisemapping/core-js';
import { $defined, $assert, createDocument, innerXML } from '@wisemapping/core-js';
import ModelCodeName from './ModelCodeName';
import Mindmap from '../model/Mindmap';
import INodeModel from '../model/INodeModel';

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert, createDocument } from '@wisemapping/core-js';
import { $assert, $defined, createDocument } from '@wisemapping/core-js';
import web2d from '@wisemapping/web2d';
import Mindmap from '../model/Mindmap';
import INodeModel, { TopicShape } from '../model/INodeModel';

View File

@ -166,38 +166,9 @@ function loadDesignerOptions(jsonConf) {
return result;
}
global.editor = {};
global.editor.WaitDialog = new Class({
initialize() {
this.panel = this._buildPanel();
},
_buildPanel() {
const result = $('#load');
const content = result.find('.modal-content');
const winH = $(window).height();
// Set the popup window to center
content.css('margin-top', winH / 2 - content.height() / 2);
return result;
},
show() {
this.panel.modal({
backdrop: 'static',
});
},
close() {
this.panel.modal('hide');
},
});
// Show loading dialog ...
$(() => {
import('../../../../../../libraries/bootstrap').then(() => {
global.waitDialog = new global.editor.WaitDialog();
global.waitDialog.show();
// from viewmode.html ---------
var mapId = 'welcome';
// Set readonly option ...
@ -207,13 +178,7 @@ $(() => {
// Load map from XML file persisted on disk...
var persistence = PersistenceManager.getInstance();
var mindmap;
try {
mindmap = persistence.load(mapId);
} catch (e) {
// If the map could not be loaded, create a new empty map...
mindmap = Mindmap.buildEmpty(mapId);
}
var mindmap = persistence.load(mapId);
designer.loadMap(mindmap);
// from viewmode.html ---------
});