rails-schema 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75eb165fa4db98c3ef82f825eccb9288fa94c2d74426ae8116546fa95305dc17
4
- data.tar.gz: aaf4af95cbc0b22f345d17fd897b8890b82702d601268f2a227055f44c84c764
3
+ metadata.gz: 06e278b737001f1ceeae2ef9d2014893a265125c7c011191a222a3d3fc48745e
4
+ data.tar.gz: '039a8aef58083c1ff5e023fee87e113c394a0dc1f008e37421460187f6fb3d44'
5
5
  SHA512:
6
- metadata.gz: 0dbd41660049021c934ffa405ddff95e0b5a6f1e587dc67bd1b1da7e69c0a7aebdfb0684fe8d1a1ccfa78fa06adb2f8f7d0dd02ed21fca9c34131296621acc83
7
- data.tar.gz: fb06c1f8dbcd7aa07e67a92f759abe9f48299da55e7d9d726cf05cfa8fd185db61677e1f82eb813b0c1214f57ae58091f6629f82df8e6361932c623f09a7b2d5
6
+ metadata.gz: 17d59e29828e31ee3298a2f5b0f86b24d31240912b77668874f2be071c610f3af50641ebadaaf1c449d6cd532c0b5bdc4ac36c6137cdc15f5ca075a102c1a9e1
7
+ data.tar.gz: 979e7da7b4e3fb215b2f25095ae0eae96d6901efa5cb0915a5a76273571ec222ccc5fa41f2495e15126f3c01312a4096f5e44966a0b94c8e0fc59228dcb0b957
data/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.1.7] - 2026-04-25
8
+
9
+ ### Added
10
+
11
+ - Manual Positioning toggle — toolbar checkbox that removes all simulation forces when enabled; nodes stay wherever they are dropped and drag-and-drop continues to work normally; unchecking re-enables automatic force-directed layout (#33)
12
+ - Layout persistence — node positions, visibility, zoom, and toggle states are auto-saved to `localStorage` and restored on page reload; layouts are scoped per schema via a fingerprint hash so different projects don't collide (#33)
13
+ - Save/Load Layout — export the current layout as a portable `.json` file to share with teammates or check into git; import a saved layout file to restore it (#33)
14
+ - File menu dropdown — toolbar "File" menu groups Export Mermaid, Save Layout, and Load Layout actions (#33)
15
+
7
16
  ## [0.1.6] - 2026-03-28
8
17
 
9
18
  ### Added
data/CLAUDE.md CHANGED
@@ -102,8 +102,11 @@ Single self-contained HTML file — no CDN, no network requests. D3 is vendored/
102
102
 
103
103
  - **Vanilla JS + d3-force** for graph rendering
104
104
  - **CSS custom properties** for dark/light theming
105
- - Features: searchable sidebar, click-to-focus, double-click to isolate neighborhood, detail panel (clicking a relation link auto-selects the related model, adding it to the diagram if hidden), zoom/pan, keyboard shortcuts (`/` search, `Esc` deselect, `+/-` zoom, `F` fit), Mermaid ER diagram export (`.mmd`) filtered by sidebar visibility
105
+ - Features: searchable sidebar, click-to-focus, double-click to isolate neighborhood, detail panel (clicking a relation link auto-selects the related model, adding it to the diagram if hidden), zoom/pan, keyboard shortcuts (`/` search, `Esc` deselect, `+/-` zoom, `F` fit)
106
106
  - **Through edges toggle** — legend checkbox to show/hide `:through` edges on the diagram at runtime; `config.show_through_edges` (default `true`) sets the initial checkbox state; through associations always remain visible in the detail panel regardless of toggle state; filtering happens in `setupSimulation()` on the frontend (edges stay in `data.edges` for the detail panel)
107
+ - **Manual Positioning toggle** — toolbar checkbox that removes all simulation forces when enabled; nodes stay wherever they are dropped since nothing pushes or pulls them; drag-and-drop continues to work normally via the standard `fx/fy` mechanism; unchecking calls `render()` to restore all forces and resume automatic layout; in manual mode, `ticked()` skips `layoutOrphans()`/`layoutSelfRefNodes()` to preserve manually-placed positions; `dragEnded` keeps `fx/fy` set so nodes stay pinned where dropped
108
+ - **Layout persistence** — node positions, visibility, zoom, collapsed groups, and toggle states are auto-saved to `localStorage` on every state change; on page load, saved layout is restored via `applyLayout()`, which honors the saved `manualPositioning` flag: when true, nodes are pinned via `fx/fy` and forces are removed so the restored layout is frozen; when false, positions seed `x/y` only and forces keep running so automatic layout resumes; `localStorage` key is `"rails-schema-layout:" + fingerprint` where fingerprint is a djb2 hash of sorted node IDs, so different schemas get separate saved layouts
109
+ - **File menu dropdown** — toolbar dropdown ("File ▼") groups export/import actions: "Export Mermaid" (`.mmd` filtered by sidebar visibility), "Save Layout" (downloads a `.json` file with positions, visibility, zoom, and toggle state), "Load Layout" (reads a `.json` file via file picker and applies it); the JSON format uses a `version: 1` field and `schemaFingerprint` for forward compatibility; layout files are portable and can be shared with teammates or checked into git
107
110
  - **Select All smart toggle** — when all models are already selected and a search filter is active, "Select All" narrows to only filtered models (acts as "select only these"); otherwise it adds filtered models to the current selection
108
111
  - **Model grouping** — when `config.model_schema_group` is set, models are organized under collapsible group headers in the sidebar with color-coded dots; each group's models get a distinct node header color in the SVG; a custom d3 force (`strength 0.15`) pulls same-group nodes toward their centroid, and a separation force pushes overlapping group bounding boxes apart; double-click a group header to select/deselect (uses delayed click timer to avoid triggering collapse); search also matches group names
109
112
 
@@ -115,4 +118,5 @@ Single self-contained HTML file — no CDN, no network requests. D3 is vendored/
115
118
  - **Force-directed layout** — handles unknown schemas gracefully without pre-defined positions
116
119
  - **Node layout categories** — three-way partition in `app.js`: connected nodes use force simulation, self-ref-only models (all edges point to themselves) are placed in a vertical left column via `layoutSelfRefNodes()`, true orphans (zero edges) are placed in rows above the diagram via `layoutOrphans()`
117
120
  - **Edge deduplication** — `GraphBuilder.deduplicate_edges` chains two passes: (1) HABTM dedup merges symmetric `has_and_belongs_to_many` pairs into one edge with `reverse_label`, (2) has_many/belongs_to dedup merges matching pairs (same foreign_key, reversed endpoints) into one edge where the has_many/has_one side is kept and the belongs_to label becomes `reverse_label` with its own `reverse_association_type`. The frontend uses `reverse_association_type` to color each label by its own association type.
121
+ - **Layout persistence** — dual storage: `localStorage` for automatic save/restore (zero friction), plus JSON file export/import for portability and sharing. Restoring a layout honors the saved `manualPositioning` flag: manual-mode layouts are pinned and frozen (forces removed) so they survive exactly; auto-mode layouts seed initial positions but let forces keep running so the user can return to automatic layout by unchecking the toggle and reloading. The `schemaFingerprint` (djb2 hash of sorted node IDs) scopes `localStorage` keys so different schemas don't collide and schema changes get a clean slate.
118
122
  - **Model grouping config** — `config.model_schema_group` accepts `nil` (default, no grouping), `:namespaces` (splits `model.name` on `::`, drops the model name, keeps namespace parts), or a custom `Proc` that receives a model and returns an array (e.g., `["Admin", "Reports"]`). `Configuration#resolved_group_proc` normalizes all forms into a callable proc. `GraphBuilder` calls it per model and attaches the result as `Node#group`. The `group` field is omitted from JSON when empty to keep output compact when grouping is off.
data/README.md CHANGED
@@ -169,11 +169,15 @@ If the targeted loading doesn't find any models, the gem falls back to a full ea
169
169
  - **Click-to-focus** — click a model to highlight its neighborhood, fading unrelated models
170
170
  - **Double-click to isolate** — double-click a model to filter the view to only that model and its direct neighbors
171
171
  - **Through edges toggle** — checkbox in the legend to show/hide `:through` association edges on the diagram; through associations always remain visible in the detail panel regardless of toggle state
172
+ - **Manual Positioning** — toolbar checkbox that removes all simulation forces; nodes stay exactly where you drop them and drag-and-drop continues to work normally; uncheck to re-enable automatic force-directed layout
173
+ - **Layout persistence** — node positions, visibility, zoom, and toggle states are automatically saved to `localStorage` and restored on page reload; scoped per schema so different projects don't collide
172
174
  - **Detail panel** — full column list and associations for the selected model; clicking a relation link auto-selects the related model (adding it to the diagram if hidden)
173
175
  - **Dark/light theme** — toggle or auto-detect from system preference
174
176
  - **Zoom & pan** — scroll wheel, pinch, or buttons
175
177
  - **Keyboard shortcuts** — `/` search, `Esc` deselect, `+/-` zoom, `F` fit to screen
176
- - **Export to Mermaid** — download the diagram as a `.mmd` file for use in Markdown, GitHub, or other tools that render Mermaid ER diagrams; respects sidebar visibility filters so you can export a subset of models
178
+ - **File menu** — toolbar dropdown grouping export/import actions: Export Mermaid (`.mmd`), Save Layout (`.json`), and Load Layout
179
+ - **Save/Load Layout** — export the current layout as a portable `.json` file to share with teammates or check into version control; import a saved layout to restore it on any machine or browser
180
+ - **Export to Mermaid** — download the diagram as a `.mmd` file for use in Markdown, GitHub, or other tools that render Mermaid ER diagrams; respects sidebar visibility filters so you can export a subset of models
177
181
  - **Deduplicated edges** — reciprocal associations (e.g. `has_many :posts` / `belongs_to :user`, or symmetric HABTM) are merged into a single edge with dual labels, each colored by its own association type
178
182
  - **Self-contained** — single HTML file with all CSS, JS, and data inlined
179
183