Skip to content

Z flow edit cards fix & docs update - #233

Merged
Sobyt483 merged 4 commits into
mainfrom
z-flow-edit-cards-fix
Aug 6, 2026
Merged

Z flow edit cards fix & docs update#233
Sobyt483 merged 4 commits into
mainfrom
z-flow-edit-cards-fix

Conversation

@Sobyt483

@Sobyt483 Sobyt483 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes documentation errors in docs/dashboard.md reported in #232 (verified
against source), and extends the web-component bundle so its public methods are
callable on the DOM node.

Bug fix

Fixes a z-flow ordering bug: adding or removing loose cards via the Edit
Cards
dialog left the z-flow engine's internal order out of sync with the
grid, so cards jumped to wrong positions after save. onCardsEdited() now
re-syncs the z-flow order on loose-card changes, onGridChange() commits the
layout, and a new normalizeNodeOrder() re-indexes zFlowOrder into a dense
0..n sequence (replacing seedNodeOrder in commitZFlowLayout).

Docs (#232)

  • Angular example import @openmfp/webcomponents@openmfp/ngx (WC bundle
    ships no type declarations).
  • Removed the "Standalone dialog reuse" section and per-dialog language input
    rows — the three dialogs aren't exported and have no language input.
  • hasUnsavedChanges documented as protected (not consumer-readable);
    documented the unsavedChangesChange output as the replacement.
  • Clarified x/y persistence (loose cards only), corrected the "warning icon"
    dialog claims (state="Critical", no icon), and noted dialog test IDs live in
    shadow DOM.
  • Fixed stale "Add Card" JSDoc in dashboard.model.ts, and documented the full
    set of public methods (saveEdit, cancelEdit, confirmDiscard,
    onUnsavedNav*).

Web-component methods

@angular/elements only proxies inputs/outputs, so instance methods weren't
reachable on <mfp-wc-dashboard>. Extracted the method-forwarding into a tested
defineDashboardElementMethods() helper and extended it beyond
requestNavigation to cover all public edit-mode / unsaved-changes handlers.

Tests

Added dashboard-element-methods.spec.ts (delegation + not-yet-created
fallback). All 557 ngx tests pass; typecheck and lint clean.

Change Log

  • <mfp-wc-dashboard> now exposes saveEdit(), cancelEdit(),
    confirmDiscard(), onUnsavedNavSave(), onUnsavedNavDiscard(), and
    onUnsavedNavCancel() as callable methods on the DOM node (previously only
    requestNavigation() was forwarded).
  • @openmfp/ngx exports a new defineDashboardElementMethods() helper for
    wiring these methods onto a custom-element constructor.

Summary by CodeRabbit

  • New Features
    • Added dashboard controls for saving, canceling, and confirming edits.
    • Added unsaved-changes notifications and navigation handling.
    • Exposed dashboard actions through the custom element interface.
  • Bug Fixes
    • Improved card layout ordering when cards are added, removed, or repositioned.
    • Preserved consistent visual stacking order during edits.
  • Documentation
    • Updated dashboard API guidance, editing terminology, navigation workflows, dialog usage, styling, and persistence behavior.

Signed-off-by: Sobyt483 <andrianingomel@gmail.com>
Signed-off-by: Sobyt483 <andrianingomel@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The dashboard now normalizes z-flow ordering after card additions or removals and commits layout changes during grid updates. The custom element forwards dashboard navigation and edit methods. Documentation and tests cover the revised APIs, dialogs, persistence rules, and Shadow DOM queries.

Dashboard layout and API updates

Layer / File(s) Summary
Normalize z-flow layout ordering
projects/ngx/declarative-ui/dashboard/dashboard/engines/zflow/*
Normalizes z-flow order values and tests node additions and removals.
Synchronize dashboard card edits
projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.*
Synchronizes loose-card order, commits grid layout changes, updates tests, and reformats the template.
Forward dashboard methods through the custom element
projects/ngx/declarative-ui/dashboard/dashboard/dashboard-element-methods.*, projects/ngx/declarative-ui/dashboard/dashboard/index.ts, projects/webcomponents-dashboard/main.ts
Adds method forwarding for navigation, editing, and unsaved-navigation handlers, with initialization fallback behavior and delegation tests.
Update dashboard API documentation
docs/dashboard.md, projects/ngx/declarative-ui/dashboard/models/dashboard.model.ts
Documents the revised dashboard API, internal dialogs, persistence behavior, Shadow DOM testing, imports, and terminology.

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

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant DashboardElement
  participant AngularDashboard
  Caller->>DashboardElement: invoke dashboard method
  DashboardElement->>AngularDashboard: delegate when initialized
  AngularDashboard-->>DashboardElement: return navigation result or handle action
  DashboardElement-->>Caller: return result
Loading

Possibly related issues

  • openmfp/webcomponents#232 — Covers the documentation and dashboard API corrections included in this pull request.

Possibly related PRs

Suggested reviewers: gkrajniak

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary z-flow fix and documentation updates in the pull request.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch z-flow-edit-cards-fix

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

projects/webcomponents-dashboard/main.ts

Parsing error: /projects/webcomponents-dashboard/main.ts was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject.


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 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: 1

🤖 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 `@docs/dashboard.md`:
- Around line 413-414: Update the “### Public methods” table in
docs/dashboard.md to list the documented custom-dialog handlers and their
signatures: saveEdit(), cancelEdit(), confirmDiscard(), and each onUnsavedNav*()
handler. Keep the existing requestNavigation() and
Dashboard.registerAngularComponents() entries, or explicitly mark the
custom-dialog handler path as internal if those methods are not public.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: da907317-7890-4846-bfdd-afae9f5a2c9e

📥 Commits

Reviewing files that changed from the base of the PR and between 33d3a3f and 3c402a5.

📒 Files selected for processing (8)
  • docs/dashboard.md
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.html
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.spec.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/engines/zflow/z-flow-engine.spec.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/engines/zflow/z-flow-engine.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/engines/zflow/z-flow.helpers.ts
  • projects/ngx/declarative-ui/dashboard/models/dashboard.model.ts

Comment thread docs/dashboard.md
Sobyt483 and others added 2 commits August 6, 2026 16:18
@Sobyt483
Sobyt483 merged commit 1b614ef into main Aug 6, 2026
8 of 9 checks passed
@Sobyt483
Sobyt483 deleted the z-flow-edit-cards-fix branch August 6, 2026 14:20
@github-project-automation github-project-automation Bot moved this from Waiting For Review to Done in OpenMFP Development Aug 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: 1

🤖 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 `@docs/dashboard.md`:
- Around line 220-222: Update the Web-component consumers note to state that the
WC bundle forwards only the instance methods above onto the custom element, not
the static Dashboard.registerAngularComponents(types[]) method. Keep the
existing behavior and examples for requestNavigation and the void instance
handlers unchanged.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 380f439a-94a9-4659-9dc7-8f4cff7540c8

📥 Commits

Reviewing files that changed from the base of the PR and between 3c402a5 and ed15406.

📒 Files selected for processing (5)
  • docs/dashboard.md
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard-element-methods.spec.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard-element-methods.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/index.ts
  • projects/webcomponents-dashboard/main.ts

Comment thread docs/dashboard.md
Comment on lines 220 to +222
| `Dashboard.registerAngularComponents(types[])` | `void` | Static — registers standalone Angular card components by their element selector name. |

> **Web-component consumers:** `@angular/elements` only proxies inputs and outputs onto the custom element — instance methods are **not** reachable on the DOM node by default. The dashboard's WC bundle (`mfp-wc-dashboard.js`) explicitly forwards all of the methods above onto `<mfp-wc-dashboard>`, so they are callable directly on the DOM element (e.g. `document.querySelector('mfp-wc-dashboard').saveEdit()`). If the Angular component has not been created yet, `requestNavigation()` runs its callback synchronously and returns `true`, and the void handlers are no-ops.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not state that the static registration method is forwarded to the DOM node.

Dashboard.registerAngularComponents(types[]) is static. defineDashboardElementMethods() only defines requestNavigation and the void instance handlers on elementCtor.prototype. The current text promises that element.registerAngularComponents(...) is available, but it is not.

Change “all of the methods above” to “the instance methods above”, or add an explicit static proxy.

🧰 Tools
🪛 LanguageTool

[style] ~222-~222: Consider removing “of” to be more concise
Context: ...p-wc-dashboard.js) explicitly forwards all of the methods above onto `...

(ALL_OF_THE)

🤖 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 `@docs/dashboard.md` around lines 220 - 222, Update the Web-component consumers
note to state that the WC bundle forwards only the instance methods above onto
the custom element, not the static Dashboard.registerAngularComponents(types[])
method. Keep the existing behavior and examples for requestNavigation and the
void instance handlers unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

Status: Done

2 participants