mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-10 17:33:24 +01:00
Fix chage to type
This commit is contained in:
parent
5695c2ab6a
commit
90f1906788
@ -59,7 +59,7 @@ class CommandContext {
|
||||
/** */
|
||||
createModel() {
|
||||
const mindmap = this._designer.getMindmap();
|
||||
return mindmap.createNode(NodeModel.MAIN_TOPIC_TYPE);
|
||||
return mindmap.createNode('MainTopic');
|
||||
}
|
||||
|
||||
/** */
|
||||
|
@ -34,7 +34,7 @@ class ConnectionLine {
|
||||
|
||||
let line;
|
||||
const ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
|
||||
if (targetNode.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (targetNode.getType() === 'CentralTopic') {
|
||||
line = this._createLine(lineType, ConnectionLine.CURVED);
|
||||
line.setSrcControlPoint(ctrlPoints[0]);
|
||||
line.setDestControlPoint(ctrlPoints[1]);
|
||||
|
@ -243,7 +243,7 @@ class Designer extends Events {
|
||||
});
|
||||
|
||||
// Register node listeners ...
|
||||
if (topic.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (topic.getType() !== 'CentralTopic') {
|
||||
// Central Topic doesn't support to be dragged
|
||||
this._dragManager.add(topic);
|
||||
}
|
||||
@ -443,7 +443,7 @@ class Designer extends Events {
|
||||
}
|
||||
// Execute event ...
|
||||
const topic = nodes[0];
|
||||
if (topic.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (topic.getType() !== 'CentralTopic') {
|
||||
this._actionDispatcher.shrinkBranch([topic.getId()], !topic.areChildrenShrunken());
|
||||
}
|
||||
}
|
||||
@ -476,7 +476,7 @@ class Designer extends Events {
|
||||
*/
|
||||
_copyNodeProps(sourceModel, targetModel) {
|
||||
// I don't copy the font size if the target is the source is the central topic.
|
||||
if (sourceModel.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (sourceModel.getType() !== 'CentralTopic') {
|
||||
const fontSize = sourceModel.getFontSize();
|
||||
if (fontSize) {
|
||||
targetModel.setFontSize(fontSize);
|
||||
@ -586,7 +586,7 @@ class Designer extends Events {
|
||||
|
||||
// Hack: if parent is central topic, add node below not on opposite side.
|
||||
// This should be done in the layout
|
||||
if (parentTopic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (parentTopic.getType() === 'CentralTopic') {
|
||||
siblingModel.setOrder(topic.getOrder() + 2);
|
||||
}
|
||||
|
||||
@ -954,7 +954,7 @@ class Designer extends Events {
|
||||
/** */
|
||||
changeTopicShape(shape) {
|
||||
const validateFunc = (topic) => !(
|
||||
topic.getType() === INodeModel.CENTRAL_TOPIC_TYPE && shape === TopicShape.LINE
|
||||
topic.getType() === 'CentralTopic' && shape === TopicShape.LINE
|
||||
);
|
||||
|
||||
const validateError = 'Central Topic shape can not be changed to line figure.';
|
||||
|
@ -145,7 +145,7 @@ class DragPivot {
|
||||
let result = null;
|
||||
const parentTopic = this._targetTopic;
|
||||
if (parentTopic) {
|
||||
if (parentTopic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (parentTopic.getType() === 'CentralTopic') {
|
||||
result = this._straightLine;
|
||||
} else {
|
||||
result = this._curvedLine;
|
||||
|
@ -25,15 +25,12 @@ import {
|
||||
} from '@wisemapping/web2d';
|
||||
import IconGroupRemoveTip from './IconGroupRemoveTip';
|
||||
|
||||
import NoteModel from './model/NoteModel';
|
||||
import LinkModel from './model/LinkModel';
|
||||
import IconModel from './model/IconModel';
|
||||
import Icon from './Icon';
|
||||
|
||||
const ORDER_BY_TYPE = new Map();
|
||||
ORDER_BY_TYPE.set(IconModel.FEATURE_TYPE, 0);
|
||||
ORDER_BY_TYPE.set(NoteModel.FEATURE_TYPE, 1);
|
||||
ORDER_BY_TYPE.set(LinkModel.FEATURE_TYPE, 2);
|
||||
ORDER_BY_TYPE.set('icon', 0);
|
||||
ORDER_BY_TYPE.set('note', 1);
|
||||
ORDER_BY_TYPE.set('link', 2);
|
||||
|
||||
class IconGroup {
|
||||
constructor(topicId, iconSize) {
|
||||
|
@ -22,9 +22,9 @@ export const create = (nodeModel, options) => {
|
||||
$assert(type, 'Node model type can not be null');
|
||||
|
||||
let result;
|
||||
if (type === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (type === 'CentralTopic') {
|
||||
result = new CentralTopic(nodeModel, options);
|
||||
} else if (type === INodeModel.MAIN_TOPIC_TYPE) {
|
||||
} else if (type === 'MainTopic') {
|
||||
result = new MainTopic(nodeModel, options);
|
||||
} else {
|
||||
$assert(false, `unsupported node type:${type}`);
|
||||
|
@ -86,7 +86,7 @@ class Relationship extends ConnectionLine {
|
||||
|
||||
const targetTopic = this._targetTopic;
|
||||
let targetPosition = targetTopic.getPosition();
|
||||
if (targetTopic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (targetTopic.getType() === 'CentralTopic') {
|
||||
targetPosition = Shape.workoutIncomingConnectionPoint(targetTopic, sourcePosition);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ class RelationshipPivot {
|
||||
_calculateFromPosition(toPosition) {
|
||||
// Calculate origin position ...
|
||||
let sourcePosition = this._sourceTopic.getPosition();
|
||||
if (this._sourceTopic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (this._sourceTopic.getType() === 'CentralTopic') {
|
||||
sourcePosition = Shape.workoutIncomingConnectionPoint(this._sourceTopic, toPosition);
|
||||
}
|
||||
const controlPoint = Shape.calculateDefaultControlPoints(sourcePosition, toPosition);
|
||||
|
@ -1337,7 +1337,7 @@ class Topic extends NodeGraph {
|
||||
|
||||
/** @return {Boolean} true if the topic is the central topic of the map */
|
||||
isCentralTopic() {
|
||||
return this.getModel().getType() === INodeModel.CENTRAL_TOPIC_TYPE;
|
||||
return this.getModel().getType() === 'CentralTopic';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,29 +17,26 @@
|
||||
*/
|
||||
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import IconModel from './model/IconModel';
|
||||
import ImageIcon from './ImageIcon';
|
||||
import LinkModel from './model/LinkModel';
|
||||
import LinkIcon from './LinkIcon';
|
||||
import NoteModel from './model/NoteModel';
|
||||
import NoteIcon from './NoteIcon';
|
||||
|
||||
const TopicFeatureFactory = {
|
||||
/** the icon object */
|
||||
Icon: {
|
||||
id: IconModel.FEATURE_TYPE,
|
||||
id: 'icon',
|
||||
icon: ImageIcon,
|
||||
},
|
||||
|
||||
/** the link object */
|
||||
Link: {
|
||||
id: LinkModel.FEATURE_TYPE,
|
||||
id: 'link',
|
||||
icon: LinkIcon,
|
||||
},
|
||||
|
||||
/** the note object */
|
||||
Note: {
|
||||
id: NoteModel.FEATURE_TYPE,
|
||||
id: 'note',
|
||||
icon: NoteIcon,
|
||||
},
|
||||
|
||||
|
@ -51,11 +51,11 @@ class XMLSerializerBeta {
|
||||
const parentTopic = document.createElement('topic');
|
||||
|
||||
// Set topic attributes...
|
||||
if (topic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (topic.getType() === 'CentralTopic') {
|
||||
parentTopic.setAttribute('central', true);
|
||||
} else {
|
||||
const parent = topic.getParent();
|
||||
if (parent == null || parent.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (parent == null || parent.getType() === 'CentralTopic') {
|
||||
const pos = topic.getPosition();
|
||||
parentTopic.setAttribute('position', `${pos.x},${pos.y}`);
|
||||
} else {
|
||||
@ -206,8 +206,8 @@ class XMLSerializerBeta {
|
||||
|
||||
_deserializeNode(domElem, mindmap) {
|
||||
const type = domElem.getAttribute('central') != null
|
||||
? INodeModel.CENTRAL_TOPIC_TYPE
|
||||
: INodeModel.MAIN_TOPIC_TYPE;
|
||||
? 'CentralTopic'
|
||||
: 'MainTopic';
|
||||
const topic = mindmap.createNode(type);
|
||||
|
||||
// Load attributes...
|
||||
|
@ -68,7 +68,7 @@ class XMLSerializerPela {
|
||||
const parentTopic = document.createElement('topic');
|
||||
|
||||
// Set topic attributes...
|
||||
if (topic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (topic.getType() === 'CentralTopic') {
|
||||
parentTopic.setAttribute('central', 'true');
|
||||
} else {
|
||||
const pos = topic.getPosition();
|
||||
@ -96,7 +96,7 @@ class XMLSerializerPela {
|
||||
}
|
||||
}
|
||||
|
||||
if (topic.areChildrenShrunken() && topic.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if (topic.areChildrenShrunken() && topic.getType() !== 'CentralTopic') {
|
||||
parentTopic.setAttribute('shrink', 'true');
|
||||
}
|
||||
|
||||
@ -268,8 +268,8 @@ class XMLSerializerPela {
|
||||
|
||||
_deserializeNode(domElem, mindmap) {
|
||||
const type = domElem.getAttribute('central') != null
|
||||
? INodeModel.CENTRAL_TOPIC_TYPE
|
||||
: INodeModel.MAIN_TOPIC_TYPE;
|
||||
? 'CentralTopic'
|
||||
: 'MainTopic';
|
||||
|
||||
// Load attributes...
|
||||
let id = domElem.getAttribute('id');
|
||||
@ -349,7 +349,7 @@ class XMLSerializerPela {
|
||||
|
||||
const isShrink = domElem.getAttribute('shrink');
|
||||
// Hack: Some production maps has been stored with the central topic collapsed. This is a bug.
|
||||
if ($defined(isShrink) && type !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if ($defined(isShrink) && type !== 'CentralTopic') {
|
||||
topic.setChildrenShrunken(isShrink);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user