Skip to content

[NAE-2463] Builder change localStorage sets#341

Open
Kovy95 wants to merge 3 commits into
release/6.5.0from
NAE-2463
Open

[NAE-2463] Builder change localStorage sets#341
Kovy95 wants to merge 3 commits into
release/6.5.0from
NAE-2463

Conversation

@Kovy95

@Kovy95 Kovy95 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

  • change the setting and getting properties from localStorage
  • fix the change detection bug
  • fix the problem with sending two requests to backend

Fixes NAE-2463

Dependencies

no new dependencies

Third party dependencies

  • No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

manually

Test Configuration

Name Tested on
OS linux mint 21
Runtime node 20.18.0
Dependency Manager npm 10.8.2
Framework version angular 17
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • New Features
    • Builder screens now persist sort and draft-related state more consistently across sessions.
    • Builder data saving/loading now exposes clearer loading status and prevents overlapping updates.
  • Bug Fixes
    • Improved editor robustness by avoiding errors when canvas elements aren’t available yet.
    • Role/user and master-detail sort settings now restore reliably in builder dialogs.
  • Style
    • Updated change detection behavior for improved performance in the edit mode view, with some examples reverting to default detection.

- change the setting and getting properties from localStorage
- fix the change detection bug
- fix the problem with sending two requests on backend
@Kovy95 Kovy95 self-assigned this Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

Walkthrough

This PR relocates builder service imports to a new services/ path, adds a LocalStorageService, wires it into builder sort persistence, updates BuilderIntegrationService loading behavior, and makes a few component and canvas behavior adjustments.

Changes

Builder services refactor and LocalStorage integration

Layer / File(s) Summary
New LocalStorageService
projects/netgrif-components/src/lib/builder/services/local-storage.service.ts
Adds an injectable service deriving a prefix from injected process case data and exposing prefix-namespaced getItem/setItem.
LocalStorageService wiring into builder component and dialogs
projects/netgrif-components/src/lib/builder/builder.component.ts, projects/netgrif-components/src/lib/builder/dialogs/dialog-manage-roles/dialog-manage-roles.component.ts, projects/netgrif-components/src/lib/builder/modeler/*master-detail.service.ts, projects/netgrif-components/src/lib/builder/modeler/services/history/history.service.ts
Injects LocalStorageService via providers/constructors and replaces direct localStorage reads/writes with the service for role, data, history, actions, and role sort persistence.
BuilderIntegrationService loading and error handling
projects/netgrif-components/src/lib/builder/services/builder-integration.service.ts
Moves field initialization into the constructor, adds loading$/isLoading(), guards setData() re-entrancy, and updates setModelData() to send xml_text while toggling loading state and logging errors.
Import path relocation to services/
projects/netgrif-components/src/lib/builder/**/*.ts, projects/netgrif-components/src/lib/builder/**/*.spec.ts, projects/netgrif-components/src/lib/builder/public-api.ts
Updates BuilderModeService/BuilderMode/BuilderIntegrationService import paths to the new services/ location throughout the module and its tests.
Change detection and canvas guard fixes
projects/nae-example-app/src/app/doc/builder-example/*, projects/netgrif-components/src/lib/builder/modeler/edit-mode/*, projects/netgrif-components/src/lib/builder/modeler/services/canvas/canvas-mode-service.ts
Adds OnPush to EditModeComponent, removes it from the example component, defaults nullish arc coordinates to 0, guards canvas element registration with optional chaining, and consolidates a Case import.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DialogManageRolesComponent
  participant MasterDetailService
  participant LocalStorageService
  participant Storage as localStorage

  DialogManageRolesComponent->>LocalStorageService: getItem(key)
  MasterDetailService->>LocalStorageService: setItem(key, value)
  LocalStorageService->>Storage: read/write prefix + key
  Storage-->>LocalStorageService: value
Loading
sequenceDiagram
  participant Caller
  participant BuilderIntegrationService
  participant API

  Caller->>BuilderIntegrationService: setData(history)
  BuilderIntegrationService->>BuilderIntegrationService: check _loading.value
  BuilderIntegrationService->>API: setModelData(xml_text)
  BuilderIntegrationService->>BuilderIntegrationService: _loading = true
  API-->>BuilderIntegrationService: response / error
  BuilderIntegrationService->>BuilderIntegrationService: _loading = false
Loading

Suggested labels: bugfix, improvement, Medium

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and refers to the main localStorage-related builder change, though it doesn’t mention the other fixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added bugfix improvement New feature or request Medium labels Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts (1)

337-346: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Guard the zero-length case before computing the arc ratio. ?? never applies here because finalX/finalY are always numbers, so arcLength === 0 can still propagate NaN into the SVG points attribute. Handle arcLength <= 0 explicitly and fall back to the intersection point.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts`
around lines 337 - 346, Guard the zero-length case in moveTemporaryArc before
calculating arcRatio, since finalX/finalY are always numbers and the current
fallback does not prevent NaN. In edit-mode.service.ts, update the
moveTemporaryArc logic to check arcLength <= 0 after computing the intersection
and, in that case, set the SVG points to the intersection point directly instead
of deriving the arrow position.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@projects/netgrif-components/src/lib/builder/services/builder-integration.service.ts`:
- Around line 99-101: The loading$ getter in BuilderIntegrationService is
exposing the internal LoadingEmitter directly instead of a read-only Observable,
unlike reloadCase$ and reloadModes$. Update loading$ to return the observable
view via asObservable() so callers can subscribe but cannot invoke next() on the
private emitter.

In
`@projects/netgrif-components/src/lib/builder/services/local-storage.service.ts`:
- Around line 18-20: The LocalStorageService.getItem method currently promises a
string but delegates to localStorage.getItem, which can return null. Update the
getItem signature to return string | null and make sure any callers of
LocalStorageService.getItem handle the nullable result correctly; use the
getItem method and _prefix field as the main reference points when adjusting the
API.

---

Outside diff comments:
In
`@projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts`:
- Around line 337-346: Guard the zero-length case in moveTemporaryArc before
calculating arcRatio, since finalX/finalY are always numbers and the current
fallback does not prevent NaN. In edit-mode.service.ts, update the
moveTemporaryArc logic to check arcLength <= 0 after computing the intersection
and, in that case, set the SVG points to the intersection point directly instead
of deriving the arrow position.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d163ce73-6957-4cf4-998e-4e4fc379bc21

📥 Commits

Reviewing files that changed from the base of the PR and between 6a78c83 and 20e9445.

📒 Files selected for processing (41)
  • projects/nae-example-app/src/app/doc/builder-example/builder-tabbed-case-view/builder-tabbed-case-view.component.ts
  • projects/nae-example-app/src/app/doc/builder-example/builder-tabs-example.component.ts
  • projects/netgrif-components/src/lib/builder/builder.component.spec.ts
  • projects/netgrif-components/src/lib/builder/builder.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-manage-roles/dialog-manage-roles.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-model-edit/dialog-model-edit.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-transition-edit/dialog-transition-edit.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/edit-panel/edit-panel.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/edit-panel/edit-panel.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/field-list/field-list.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/field-list/field-list.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/form-builder.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/form-builder.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/gridster/gridster.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/gridster/gridster.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/info-label/info-label.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/info-label/info-label.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/actions-mode/actions-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/control-panel/control-panel.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/data-mode/data-detail/data-detail.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/data-mode/data-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/context-menu/menu-items/transition/edit-form-menu-item.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/context-menu/menu-items/transition/edit-transition-actions-menu-item.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/services/modes/canvas-tool-context.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/services/modes/canvas-tool.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/services/modes/select-tool.ts
  • projects/netgrif-components/src/lib/builder/modeler/history-mode/history-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/model-import-service.ts
  • projects/netgrif-components/src/lib/builder/modeler/modeler.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/role-mode/role-detail/role-detail.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/role-mode/role-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/services/canvas/canvas-mode-service.ts
  • projects/netgrif-components/src/lib/builder/modeler/services/history/history.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/task-mode/task-mode.component.ts
  • projects/netgrif-components/src/lib/builder/public-api.ts
  • projects/netgrif-components/src/lib/builder/services/builder-integration.service.ts
  • projects/netgrif-components/src/lib/builder/services/builder-mode.service.spec.ts
  • projects/netgrif-components/src/lib/builder/services/builder-mode.service.ts
  • projects/netgrif-components/src/lib/builder/services/local-storage.service.ts

Comment thread projects/netgrif-components/src/lib/builder/services/local-storage.service.ts Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 7, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
27.8% Coverage on New Code (required ≥ 50%)

See analysis details on SonarQube Cloud

@Kovy95 Kovy95 requested a review from Retoocs July 8, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix improvement New feature or request Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants