From 5dc6fb37d78b2484aa3e1bf1d37ebd3b60acbe88 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 7 Mar 2022 19:49:27 -0800 Subject: [PATCH] Add missing types to commands. --- packages/mindplot/src/components/Topic.ts | 3 --- .../commands/AddRelationshipCommand.ts | 16 +++++----------- .../src/components/commands/AddTopicCommand.ts | 7 ------- .../commands/ChangeFeatureToTopicCommand.ts | 7 ------- .../src/components/commands/DragTopicCommand.ts | 3 --- .../commands/MoveControlPointCommand.ts | 16 +++++----------- 6 files changed, 10 insertions(+), 42 deletions(-) diff --git a/packages/mindplot/src/components/Topic.ts b/packages/mindplot/src/components/Topic.ts index f51a4fa0..7e56bd3e 100644 --- a/packages/mindplot/src/components/Topic.ts +++ b/packages/mindplot/src/components/Topic.ts @@ -375,17 +375,14 @@ abstract class Topic extends NodeGraph { this.adjustShapes(); } - /** */ addRelationship(relationship: Relationship) { this._relationships.push(relationship); } - /** */ deleteRelationship(relationship: Rect) { this._relationships = this._relationships.filter((r) => r !== relationship); } - /** */ getRelationships(): Relationship[] { return this._relationships; } diff --git a/packages/mindplot/src/components/commands/AddRelationshipCommand.ts b/packages/mindplot/src/components/commands/AddRelationshipCommand.ts index f16df219..b32273d7 100644 --- a/packages/mindplot/src/components/commands/AddRelationshipCommand.ts +++ b/packages/mindplot/src/components/commands/AddRelationshipCommand.ts @@ -17,6 +17,7 @@ */ import { $assert } from '@wisemapping/core-js'; import Command from '../Command'; +import CommandContext from '../CommandContext'; import RelationshipModel from '../model/RelationshipModel'; class AddRelationshipCommand extends Command { @@ -25,27 +26,20 @@ class AddRelationshipCommand extends Command { /** * @classdesc This command class handles do/undo of adding a relationship to a topic. */ - constructor(model:RelationshipModel) { + constructor(model: RelationshipModel) { $assert(model, 'Relationship model can not be null'); super(); this._model = model; } - /** - * Overrides abstract parent method - */ - execute(commandContext) { + execute(commandContext: CommandContext) { const relationship = commandContext.addRelationship(this._model); relationship.setOnFocus(true); } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ - undoExecute(commandContext) { - const rel = commandContext.findRelationships(this._model.getId()); + undoExecute(commandContext: CommandContext) { + const rel = commandContext.findRelationships([this._model.getId()]); commandContext.deleteRelationship(rel[0]); } } diff --git a/packages/mindplot/src/components/commands/AddTopicCommand.ts b/packages/mindplot/src/components/commands/AddTopicCommand.ts index ce273552..2208a495 100644 --- a/packages/mindplot/src/components/commands/AddTopicCommand.ts +++ b/packages/mindplot/src/components/commands/AddTopicCommand.ts @@ -38,9 +38,6 @@ class AddTopicCommand extends Command { this._parentsIds = parentTopicsId; } - /** - * Overrides abstract parent method - */ execute(commandContext: CommandContext) { const me = this; this._models.forEach((model, index) => { @@ -68,10 +65,6 @@ class AddTopicCommand extends Command { }); } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ undoExecute(commandContext: CommandContext) { // Delete disconnected the nodes. Create a copy of the topics ... const clonedModel = []; diff --git a/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts b/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts index 07253e15..573a2923 100644 --- a/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts +++ b/packages/mindplot/src/components/commands/ChangeFeatureToTopicCommand.ts @@ -37,9 +37,6 @@ class ChangeFeatureToTopicCommand extends Command { this._attributes = attributes; } - /** - * Overrides abstract parent method - */ execute(commandContext: CommandContext) { const topic = commandContext.findTopics([this._topicId])[0]; const feature = topic.findFeatureById(this._featureId); @@ -49,10 +46,6 @@ class ChangeFeatureToTopicCommand extends Command { this._attributes = oldAttributes; } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ undoExecute(commandContext: CommandContext) { this.execute(commandContext); } diff --git a/packages/mindplot/src/components/commands/DragTopicCommand.ts b/packages/mindplot/src/components/commands/DragTopicCommand.ts index d550a378..d8cf4d38 100644 --- a/packages/mindplot/src/components/commands/DragTopicCommand.ts +++ b/packages/mindplot/src/components/commands/DragTopicCommand.ts @@ -47,9 +47,6 @@ class DragTopicCommand extends Command { this._order = order; } - /** - * Overrides abstract parent method - */ execute(commandContext: CommandContext): void { const topic = commandContext.findTopics([this._topicsId])[0]; topic.setVisibility(false); diff --git a/packages/mindplot/src/components/commands/MoveControlPointCommand.ts b/packages/mindplot/src/components/commands/MoveControlPointCommand.ts index 85f9868a..2856c6e5 100644 --- a/packages/mindplot/src/components/commands/MoveControlPointCommand.ts +++ b/packages/mindplot/src/components/commands/MoveControlPointCommand.ts @@ -19,19 +19,20 @@ import { $assert, $defined } from '@wisemapping/core-js'; import { Line } from '@wisemapping/web2d'; import Command from '../Command'; import ControlPoint from '../ControlPoint'; +import PositionType from '../PositionType'; class MoveControlPointCommand extends Command { private _ctrlPointControler: ControlPoint; private _line: Line; - private _controlPoint: any; + private _controlPoint: Line; - private _oldControlPoint: any; + private _oldControlPoint: Line; - private _originalEndPoint: any; + private _originalEndPoint: PositionType; - private _wasCustom: any; + private _wasCustom: boolean; private _endPoint: any; @@ -68,9 +69,6 @@ class MoveControlPointCommand extends Command { this._point = point; } - /** - * Overrides abstract parent method - */ execute() { const model = this._line.getModel(); switch (this._point) { @@ -97,10 +95,6 @@ class MoveControlPointCommand extends Command { this._line.getLine().updateLine(this._point); } - /** - * Overrides abstract parent method - * @see {@link mindplot.Command.undoExecute} - */ undoExecute() { const line = this._line; const model = line.getModel();