Skip refresh of chlidren node.

This commit is contained in:
Paulo Gustavo Veiga 2023-03-03 09:11:19 -03:00
parent 39dd2486a5
commit 90bf53d762
3 changed files with 61 additions and 66 deletions

View File

@ -1064,9 +1064,10 @@ abstract class Topic extends NodeGraph {
workspace.append(this._outgoingLine); workspace.append(this._outgoingLine);
const incomingLines = this.getIncomingLines(); if (!this.areChildrenShrunken()) {
incomingLines.forEach((line) => line.redraw()); const incomingLines = this.getIncomingLines();
incomingLines.forEach((line) => line.redraw());
}
result = true; result = true;
} }
@ -1152,7 +1153,7 @@ abstract class Topic extends NodeGraph {
const bgColor = this.getBackgroundColor(); const bgColor = this.getBackgroundColor();
innerShape.setFill(bgColor); innerShape.setFill(bgColor);
if (redrawChildren || shapeChanged || connectionChanged) { if ((redrawChildren || shapeChanged || connectionChanged) && !this.areChildrenShrunken()) {
this.getChildren().forEach((t) => t.redraw(true)); this.getChildren().forEach((t) => t.redraw(true));
} }
} }

View File

@ -1,24 +1,24 @@
const DE = { const EN = {
LOADING: 'Laden ...', LOADING: 'Loading ..',
SAVING: 'Speichern ...', SAVING: 'Saving ...',
SAVE_COMPLETE: 'Speichern abgeschlossen', SAVE_COMPLETE: 'Save completed',
ZOOM_IN_ERROR: 'Vergrößerung zu hoch.', ZOOM_IN_ERROR: 'Zoom too high.',
ZOOM_ERROR: 'Es kann nicht weiter vergrößert bzw. verkleinert werden.', ZOOM_ERROR: 'No more zoom can be applied.',
ONLY_ONE_TOPIC_MUST_BE_SELECTED: 'Thema konnte nicht angelegt werden. Bitte wähle nur ein Thema aus.', ONLY_ONE_TOPIC_MUST_BE_SELECTED: 'Could not create a topic. Only one topic must be selected.',
ONE_TOPIC_MUST_BE_SELECTED: 'Thema konnte nicht angelegt werden. Es muss ein Thema ausgewählt werden.', ONE_TOPIC_MUST_BE_SELECTED: 'Could not create a topic. One topic must be selected.',
ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE: 'Kinderknoten können nicht eingefaltet werden. Es muss ein Thema ausgewäht werden.', ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE: 'Children can not be collapsed. One topic must be selected.',
SAVE_COULD_NOT_BE_COMPLETED: 'Sichern wurde nicht abgeschlossen. Versuche es später nocheinmal.', SAVE_COULD_NOT_BE_COMPLETED: 'Save could not be completed, please try again latter.',
UNEXPECTED_ERROR_LOADING: 'Es tut uns leid, ein unerwarteter Fehler ist aufgetreten.\nVersuche, den Editor neu zu laden. Falls das Problem erneut auftritt, kontaktiere uns bitte unter support@wisemapping.com.', MAIN_TOPIC: 'Main Topic',
MAIN_TOPIC: 'Hauptthema', SUB_TOPIC: 'Sub Topic',
SUB_TOPIC: 'Unterthema', ISOLATED_TOPIC: 'Isolated Topic',
ISOLATED_TOPIC: 'Isoliertes Thema', CENTRAL_TOPIC: 'Central Topic',
CENTRAL_TOPIC: 'Zentrales Thema', ENTITIES_COULD_NOT_BE_DELETED: 'Could not delete topic or relation. At least one map entity must be selected.',
CLIPBOARD_IS_EMPTY: 'Es gibt nichts zu kopieren. Die Zwischenablage ist leer.', CLIPBOARD_IS_EMPTY: 'Nothing to copy. Clipboard is empty.',
CENTRAL_TOPIC_CAN_NOT_BE_DELETED: 'Das zentrale Thema kann nicht gelöscht werden.', CENTRAL_TOPIC_CAN_NOT_BE_DELETED: 'Central topic can not be deleted.',
RELATIONSHIP_COULD_NOT_BE_CREATED: 'Die Beziehung konnte nicht angelegt werden. Es muss erst ein Vater-Thema ausgewählt werden, um die Beziehung herzustellen.', RELATIONSHIP_COULD_NOT_BE_CREATED: 'Relationship could not be created. A parent relationship topic must be selected first.',
SESSION_EXPIRED: 'Deine Sitzung ist abgelaufen, bitte melde dich erneut an.', SESSION_EXPIRED: 'Your session has expired, please log-in again.',
CENTRAL_TOPIC_CONNECTION_STYLE_CAN_NOT_BE_CHANGED: 'Der Verbindungsstil kann für das zentrale Thema nicht geändert werden.', CENTRAL_TOPIC_CONNECTION_STYLE_CAN_NOT_BE_CHANGED: 'Connection style can not be changed for central topic.',
CENTRAL_TOPIC_STYLE_CAN_NOT_BE_CHANGED: 'Das zentrale Thema kann nicht in den Linienstil geändert werden.', CENTRAL_TOPIC_STYLE_CAN_NOT_BE_CHANGED: 'Central topic can not be changed to line style.',
}; };
export default DE; export default EN;

View File

@ -15,11 +15,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import PositionType from '../PositionType'; import PositionType from '../PositionType';
import SizeType from '../SizeType'; import SizeType from '../SizeType';
import ChildrenSorterStrategy from './ChildrenSorterStrategy'; import ChildrenSorterStrategy from './ChildrenSorterStrategy';
type NodeValue = number | SizeType | PositionType | boolean;
type MapValue = {
hasChanged: boolean;
value: NodeValue | undefined;
oldValue: NodeValue | undefined;
};
type NodeKey = 'order' | 'position' | 'size' | 'freeDisplacement' | 'shrink';
class Node { class Node {
private _id: number; private _id: number;
@ -28,7 +36,7 @@ class Node {
private _sorter: ChildrenSorterStrategy; private _sorter: ChildrenSorterStrategy;
private _properties; private _properties: Map<NodeKey, MapValue>;
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
_children!: Node[]; _children!: Node[];
@ -41,7 +49,7 @@ class Node {
$assert(typeof id === 'number' && Number.isFinite(id), 'id can not be null'); $assert(typeof id === 'number' && Number.isFinite(id), 'id can not be null');
this._id = id; this._id = id;
this._sorter = sorter; this._sorter = sorter;
this._properties = {}; this._properties = new Map();
this.setSize(size); this.setSize(size);
this.setPosition(position); this.setPosition(position);
@ -50,27 +58,23 @@ class Node {
this._heightChanged = false; this._heightChanged = false;
} }
/** */
getId(): number { getId(): number {
return this._id; return this._id;
} }
/** */ hasFreeDisplacementChanged(): boolean {
hasFreeDisplacementChanged() {
return this.isPropertyChanged('freeDisplacement'); return this.isPropertyChanged('freeDisplacement');
} }
/** */ setShrunken(value: boolean): void {
setShrunken(value: boolean) {
this.setProperty('shrink', value); this.setProperty('shrink', value);
} }
/** */ areChildrenShrunken(): boolean {
areChildrenShrunken() { return Boolean(this.getProperty('shrink'));
return this.getProperty('shrink');
} }
setOrder(order: number) { setOrder(order: number): void {
$assert( $assert(
typeof order === 'number' && Number.isFinite(order), typeof order === 'number' && Number.isFinite(order),
`Order can not be null. Value:${order}`, `Order can not be null. Value:${order}`,
@ -81,25 +85,22 @@ class Node {
} }
} }
/** */ resetPositionState(): void {
resetPositionState() { const prop = this._properties.get('position');
const prop = this._properties.position;
if (prop) { if (prop) {
prop.hasChanged = false; prop.hasChanged = false;
} }
} }
/** */ resetOrderState(): void {
resetOrderState() { const prop = this._properties.get('order');
const prop = this._properties.order;
if (prop) { if (prop) {
prop.hasChanged = false; prop.hasChanged = false;
} }
} }
/** */ resetFreeState(): void {
resetFreeState() { const prop = this._properties.get('freeDisplacement');
const prop = this._properties.freeDisplacement;
if (prop) { if (prop) {
prop.hasChanged = false; prop.hasChanged = false;
} }
@ -109,12 +110,10 @@ class Node {
return this.getProperty('order') as number; return this.getProperty('order') as number;
} }
/** */ hasOrderChanged(): boolean {
hasOrderChanged() { return Boolean(this.isPropertyChanged('order'));
return this.isPropertyChanged('order');
} }
/** */
hasPositionChanged() { hasPositionChanged() {
return this.isPropertyChanged('position'); return this.isPropertyChanged('position');
} }
@ -127,7 +126,6 @@ class Node {
return this.getProperty('position') as PositionType; return this.getProperty('position') as PositionType;
} }
/** */
setSize(size: SizeType): void { setSize(size: SizeType): void {
const currentSize = this.getSize(); const currentSize = this.getSize();
if ( if (
@ -140,7 +138,6 @@ class Node {
} }
} }
/** */
getSize(): SizeType { getSize(): SizeType {
return this.getProperty('size') as SizeType; return this.getProperty('size') as SizeType;
} }
@ -155,7 +152,6 @@ class Node {
this.setProperty('freeDisplacement', { ...newDisplacement }); this.setProperty('freeDisplacement', { ...newDisplacement });
} }
/** */
getFreeDisplacement(): PositionType { getFreeDisplacement(): PositionType {
const freeDisplacement = this.getProperty('freeDisplacement') as PositionType; const freeDisplacement = this.getProperty('freeDisplacement') as PositionType;
return freeDisplacement || { x: 0, y: 0 }; return freeDisplacement || { x: 0, y: 0 };
@ -173,13 +169,13 @@ class Node {
} }
} }
setProperty(key: string, value) { private setProperty(key: NodeKey, value: NodeValue): void {
let prop = this._properties[key]; let prop = this._properties.get(key);
if (!prop) { if (!prop) {
prop = { prop = {
hasChanged: false, hasChanged: false,
value: null, value: undefined,
oldValue: null, oldValue: undefined,
}; };
} }
@ -189,21 +185,19 @@ class Node {
prop.value = value; prop.value = value;
prop.hasChanged = true; prop.hasChanged = true;
} }
this._properties[key] = prop; this._properties.set(key, prop);
} }
private getProperty(key: string): null | number | PositionType | SizeType { private getProperty(key: NodeKey): NodeValue | undefined {
const prop = this._properties[key]; return this._properties.get(key)?.value;
return $defined(prop) ? prop.value : null;
} }
isPropertyChanged(key: string) { isPropertyChanged(key: NodeKey): boolean {
const prop = this._properties[key]; const prop = this._properties.get(key);
return prop ? prop.hasChanged : false; return prop ? prop.hasChanged : false;
} }
/** */ getSorter(): ChildrenSorterStrategy {
getSorter() {
return this._sorter; return this._sorter;
} }