Remove relatioship on focus.

This commit is contained in:
Paulo Gustavo Veiga 2022-03-07 19:43:04 -08:00
parent 27f580b4fa
commit e83cd3e9fa
2 changed files with 30 additions and 16 deletions

View File

@ -97,7 +97,7 @@ class ConnectionLine {
this._line2d.setVisibility(value, fade); this._line2d.setVisibility(value, fade);
} }
isVisible() { isVisible(): boolean {
return this._line2d.isVisible(); return this._line2d.isVisible();
} }

View File

@ -20,8 +20,10 @@ import { Arrow, Point, ElementClass } from '@wisemapping/web2d';
import ConnectionLine from './ConnectionLine'; import ConnectionLine from './ConnectionLine';
import ControlPoint from './ControlPoint'; import ControlPoint from './ControlPoint';
import RelationshipModel from './model/RelationshipModel'; import RelationshipModel from './model/RelationshipModel';
import PositionType from './PositionType';
import Topic from './Topic'; import Topic from './Topic';
import Shape from './util/Shape'; import Shape from './util/Shape';
import Workspace from './Workspace';
class Relationship extends ConnectionLine { class Relationship extends ConnectionLine {
private _focusShape: ElementClass; private _focusShape: ElementClass;
@ -187,7 +189,7 @@ class Relationship extends ConnectionLine {
this._startArrow.setVisibility(this.isVisible() && this._showStartArrow); this._startArrow.setVisibility(this.isVisible() && this._showStartArrow);
} }
addToWorkspace(workspace) { addToWorkspace(workspace: Workspace): void {
workspace.append(this._focusShape); workspace.append(this._focusShape);
workspace.append(this._controlPointsController); workspace.append(this._controlPointsController);
@ -207,11 +209,11 @@ class Relationship extends ConnectionLine {
this.redraw(); this.redraw();
} }
_initializeControlPointController(): void { private _initializeControlPointController(): void {
this.setOnFocus(true); this.setOnFocus(true);
} }
removeFromWorkspace(workspace) { removeFromWorkspace(workspace: Workspace): void {
workspace.removeChild(this._focusShape); workspace.removeChild(this._focusShape);
workspace.removeChild(this._controlPointsController); workspace.removeChild(this._controlPointsController);
if (!workspace.isReadOnly) { if (!workspace.isReadOnly) {
@ -243,7 +245,7 @@ class Relationship extends ConnectionLine {
} }
} }
private _refreshShape() { private _refreshShape(): void {
const sPos = this._line2d.getFrom(); const sPos = this._line2d.getFrom();
const tPos = this._line2d.getTo(); const tPos = this._line2d.getTo();
const ctrlPoints = this._line2d.getControlPoints(); const ctrlPoints = this._line2d.getControlPoints();
@ -279,19 +281,31 @@ class Relationship extends ConnectionLine {
setVisibility(value: boolean, fade = 0) { setVisibility(value: boolean, fade = 0) {
super.setVisibility(value, fade); super.setVisibility(value, fade);
if (this._showEndArrow) this._endArrow.setVisibility(this._showEndArrow);
// If visibility change, remove the on focus.
this.setOnFocus(false);
if (this._showEndArrow) {
this._endArrow.setVisibility(this._showEndArrow);
}
this._startArrow.setVisibility(this._showStartArrow && value, fade); this._startArrow.setVisibility(this._showStartArrow && value, fade);
} }
setOpacity(opacity: number) { setOpacity(opacity: number): void {
super.setOpacity(opacity); super.setOpacity(opacity);
if (this._showEndArrow) this._endArrow.setOpacity(opacity); if (this._showEndArrow) {
if (this._showStartArrow) this._startArrow.setOpacity(opacity); this._endArrow.setOpacity(opacity);
}
if (this._showStartArrow) {
this._startArrow.setOpacity(opacity);
}
} }
setShowEndArrow(visible: boolean) { setShowEndArrow(visible: boolean) {
this._showEndArrow = visible; this._showEndArrow = visible;
if (this._isInWorkspace) this.redraw(); if (this._isInWorkspace) {
this.redraw();
}
} }
setShowStartArrow(visible: boolean) { setShowStartArrow(visible: boolean) {
@ -315,25 +329,25 @@ class Relationship extends ConnectionLine {
if (this._endArrow) this._endArrow.setFrom(x, y); if (this._endArrow) this._endArrow.setFrom(x, y);
} }
setSrcControlPoint(control) { setSrcControlPoint(control: PositionType): void {
this._line2d.setSrcControlPoint(control); this._line2d.setSrcControlPoint(control);
this._startArrow.setControlPoint(control); this._startArrow.setControlPoint(control);
} }
setDestControlPoint(control) { setDestControlPoint(control: PositionType) {
this._line2d.setDestControlPoint(control); this._line2d.setDestControlPoint(control);
if (this._showEndArrow) this._endArrow.setControlPoint(control); if (this._showEndArrow) this._endArrow.setControlPoint(control);
} }
getControlPoints() { getControlPoints(): PositionType {
return this._line2d.getControlPoints(); return this._line2d.getControlPoints();
} }
isSrcControlPointCustom() { isSrcControlPointCustom(): boolean {
return this._line2d.isSrcControlPointCustom(); return this._line2d.isSrcControlPointCustom();
} }
isDestControlPointCustom() { isDestControlPointCustom(): boolean {
return this._line2d.isDestControlPointCustom(); return this._line2d.isDestControlPointCustom();
} }
@ -345,7 +359,7 @@ class Relationship extends ConnectionLine {
this._line2d.setIsDestControlPointCustom(isCustom); this._line2d.setIsDestControlPointCustom(isCustom);
} }
getId() { getId(): number {
return this._model.getId(); return this._model.getId();
} }