Add missing types to commands.

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

View File

@ -375,17 +375,14 @@ abstract class Topic extends NodeGraph {
this.adjustShapes(); this.adjustShapes();
} }
/** */
addRelationship(relationship: Relationship) { addRelationship(relationship: Relationship) {
this._relationships.push(relationship); this._relationships.push(relationship);
} }
/** */
deleteRelationship(relationship: Rect) { deleteRelationship(relationship: Rect) {
this._relationships = this._relationships.filter((r) => r !== relationship); this._relationships = this._relationships.filter((r) => r !== relationship);
} }
/** */
getRelationships(): Relationship[] { getRelationships(): Relationship[] {
return this._relationships; return this._relationships;
} }

View File

@ -17,6 +17,7 @@
*/ */
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import Command from '../Command'; import Command from '../Command';
import CommandContext from '../CommandContext';
import RelationshipModel from '../model/RelationshipModel'; import RelationshipModel from '../model/RelationshipModel';
class AddRelationshipCommand extends Command { 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. * @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'); $assert(model, 'Relationship model can not be null');
super(); super();
this._model = model; this._model = model;
} }
/** execute(commandContext: CommandContext) {
* Overrides abstract parent method
*/
execute(commandContext) {
const relationship = commandContext.addRelationship(this._model); const relationship = commandContext.addRelationship(this._model);
relationship.setOnFocus(true); relationship.setOnFocus(true);
} }
/** undoExecute(commandContext: CommandContext) {
* Overrides abstract parent method const rel = commandContext.findRelationships([this._model.getId()]);
* @see {@link mindplot.Command.undoExecute}
*/
undoExecute(commandContext) {
const rel = commandContext.findRelationships(this._model.getId());
commandContext.deleteRelationship(rel[0]); commandContext.deleteRelationship(rel[0]);
} }
} }

View File

@ -38,9 +38,6 @@ class AddTopicCommand extends Command {
this._parentsIds = parentTopicsId; this._parentsIds = parentTopicsId;
} }
/**
* Overrides abstract parent method
*/
execute(commandContext: CommandContext) { execute(commandContext: CommandContext) {
const me = this; const me = this;
this._models.forEach((model, index) => { 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) { undoExecute(commandContext: CommandContext) {
// Delete disconnected the nodes. Create a copy of the topics ... // Delete disconnected the nodes. Create a copy of the topics ...
const clonedModel = []; const clonedModel = [];

View File

@ -37,9 +37,6 @@ class ChangeFeatureToTopicCommand extends Command {
this._attributes = attributes; this._attributes = attributes;
} }
/**
* Overrides abstract parent method
*/
execute(commandContext: CommandContext) { execute(commandContext: CommandContext) {
const topic = commandContext.findTopics([this._topicId])[0]; const topic = commandContext.findTopics([this._topicId])[0];
const feature = topic.findFeatureById(this._featureId); const feature = topic.findFeatureById(this._featureId);
@ -49,10 +46,6 @@ class ChangeFeatureToTopicCommand extends Command {
this._attributes = oldAttributes; this._attributes = oldAttributes;
} }
/**
* Overrides abstract parent method
* @see {@link mindplot.Command.undoExecute}
*/
undoExecute(commandContext: CommandContext) { undoExecute(commandContext: CommandContext) {
this.execute(commandContext); this.execute(commandContext);
} }

View File

@ -47,9 +47,6 @@ class DragTopicCommand extends Command {
this._order = order; this._order = order;
} }
/**
* Overrides abstract parent method
*/
execute(commandContext: CommandContext): void { execute(commandContext: CommandContext): void {
const topic = commandContext.findTopics([this._topicsId])[0]; const topic = commandContext.findTopics([this._topicsId])[0];
topic.setVisibility(false); topic.setVisibility(false);

View File

@ -19,19 +19,20 @@ import { $assert, $defined } from '@wisemapping/core-js';
import { Line } from '@wisemapping/web2d'; import { Line } from '@wisemapping/web2d';
import Command from '../Command'; import Command from '../Command';
import ControlPoint from '../ControlPoint'; import ControlPoint from '../ControlPoint';
import PositionType from '../PositionType';
class MoveControlPointCommand extends Command { class MoveControlPointCommand extends Command {
private _ctrlPointControler: ControlPoint; private _ctrlPointControler: ControlPoint;
private _line: Line; 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; private _endPoint: any;
@ -68,9 +69,6 @@ class MoveControlPointCommand extends Command {
this._point = point; this._point = point;
} }
/**
* Overrides abstract parent method
*/
execute() { execute() {
const model = this._line.getModel(); const model = this._line.getModel();
switch (this._point) { switch (this._point) {
@ -97,10 +95,6 @@ class MoveControlPointCommand extends Command {
this._line.getLine().updateLine(this._point); this._line.getLine().updateLine(this._point);
} }
/**
* Overrides abstract parent method
* @see {@link mindplot.Command.undoExecute}
*/
undoExecute() { undoExecute() {
const line = this._line; const line = this._line;
const model = line.getModel(); const model = line.getModel();