Add missing types to commands.

This commit is contained in:
Paulo Gustavo Veiga 2022-03-07 19:49:27 -08:00
parent e83cd3e9fa
commit 5dc6fb37d7
6 changed files with 10 additions and 42 deletions

View File

@ -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;
}

View File

@ -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]);
}
}

View File

@ -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 = [];

View File

@ -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);
}

View File

@ -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);

View File

@ -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();