From 496bc44d9ce769b9e8753e66153b26025102e0ce Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 5 Mar 2026 11:11:12 +0200 Subject: [PATCH] UI: Refactor rule chain note and fixed minor bugs --- ui-ngx/package.json | 2 +- .../app/core/services/item-buffer.service.ts | 18 +++++++-- .../rulechain/add-note-dialog.component.html | 2 +- .../rulechain/rule-note-editor.component.ts | 3 +- .../rulechain/rulechain-page.component.html | 37 +++++++++++------- .../rulechain/rulechain-page.component.scss | 9 +++++ .../rulechain/rulechain-page.component.ts | 38 +++++++++++-------- .../pages/rulechain/rulechain-page.models.ts | 2 +- .../pages/rulechain/rulenote.component.html | 6 +-- .../pages/rulechain/rulenote.component.scss | 6 --- .../pages/rulechain/rulenote.component.ts | 20 +++++++--- .../assets/locale/locale.constant-en_US.json | 1 - ui-ngx/yarn.lock | 5 ++- 13 files changed, 93 insertions(+), 56 deletions(-) diff --git a/ui-ngx/package.json b/ui-ngx/package.json index 5b4d985114..6e1ea4bf33 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -71,7 +71,7 @@ "ngx-clipboard": "^16.0.0", "ngx-daterangepicker-material": "^6.0.4", "ngx-drag-drop": "^20.0.1", - "ngx-flowchart": "file:../../ngx-flowchart/dist/ngx-flowchart", + "ngx-flowchart": "https://github.com/thingsboard/ngx-flowchart.git#release/4.1.0", "ngx-hm-carousel": "^19.0.0", "ngx-markdown": "^20.1.0", "ngx-sharebuttons": "^17.0.0", diff --git a/ui-ngx/src/app/core/services/item-buffer.service.ts b/ui-ngx/src/app/core/services/item-buffer.service.ts index ba4b29cbcb..1dc7146883 100644 --- a/ui-ngx/src/app/core/services/item-buffer.service.ts +++ b/ui-ngx/src/app/core/services/item-buffer.service.ts @@ -16,7 +16,13 @@ import { Injectable } from '@angular/core'; import { BreakpointId, Dashboard, DashboardLayoutId } from '@app/shared/models/dashboard.models'; -import { AliasesInfo, EntityAlias, EntityAliases, EntityAliasInfo, getEntityAliasId } from '@shared/models/alias.models'; +import { + AliasesInfo, + EntityAlias, + EntityAliases, + EntityAliasInfo, + getEntityAliasId +} from '@shared/models/alias.models'; import { Datasource, DatasourceType, @@ -75,6 +81,8 @@ export interface RuleNodesReference { notes?: FcRuleNote[]; originX?: number; originY?: number; + minX?: number; + minY?: number; } @Injectable({ @@ -375,6 +383,8 @@ export class ItemBufferService { height: origNote.height, content: origNote.content, backgroundColor: origNote.backgroundColor, + borderWidth: origNote.borderWidth, + borderColor: origNote.borderColor, applyDefaultMarkdownStyle: origNote.applyDefaultMarkdownStyle, markdownCss: origNote.markdownCss }); @@ -392,6 +402,8 @@ export class ItemBufferService { } ruleNodes.originX = left + (right - left) / 2; ruleNodes.originY = top + (bottom - top) / 2; + ruleNodes.minX = left; + ruleNodes.minY = top; connections.forEach(connection => { ruleNodes.connections.push(connection); }); @@ -405,8 +417,8 @@ export class ItemBufferService { public pasteRuleChainObjects(x: number, y: number): RuleNodesReference { const ruleNodes: RuleNodesReference = this.storeGet(RULE_NODES); if (ruleNodes) { - const deltaX = x - ruleNodes.originX; - const deltaY = y - ruleNodes.originY; + const deltaX = isDefinedAndNotNull(ruleNodes.minX) ? Math.max(x - ruleNodes.originX, -ruleNodes.minX) : x - ruleNodes.originX; + const deltaY = isDefinedAndNotNull(ruleNodes.minY) ? Math.max(y - ruleNodes.originY, -ruleNodes.minY) : y - ruleNodes.originY; for (const node of ruleNodes.nodes) { const component = this.ruleChainService.getRuleNodeComponentByClazz(node.ruleChainType, node.componentClazz); if (component) { diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/add-note-dialog.component.html b/ui-ngx/src/app/modules/home/pages/rulechain/add-note-dialog.component.html index 6359e32ff1..33aa61d0e1 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/add-note-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/rulechain/add-note-dialog.component.html @@ -27,7 +27,7 @@
- - + @if (!isImport) { + + + }