Skip to content

Refactor Field Inspection into a Decoupled Vue Directive#226

Open
Sendipad wants to merge 3 commits into
developfrom
refactor-field-inspect-directive-10670225873261897384
Open

Refactor Field Inspection into a Decoupled Vue Directive#226
Sendipad wants to merge 3 commits into
developfrom
refactor-field-inspect-directive-10670225873261897384

Conversation

@Sendipad

Copy link
Copy Markdown
Owner

This PR refactors the field inspection feature in the flexirule workspace to align with Frappe's native Form Builder while using a more modern and decoupled Vue 3 approach.

Key Changes:

  • Centralized Configuration: Added constants.js to manage the modifier key (defaulting to Shift).
  • Custom Directive: Created v-field-inspect to handle the heavy lifting of state tracking, visual swapping (label to fieldname), and the click-to-copy mechanism.
  • Improved Visuals: Implemented an elegant in-place swap for fields with labels and a non-intrusive micro-badge for grid/labelless fields.
  • Architectural Cleanup:
    • Applied the directive once in ControlFactory.vue, removing the need for manual attributes on every control.
    • Completely removed the legacy, monolithic tracking logic and state from App.vue.
    • Sanitized all control components by removing redundant data-fxr-fieldname attributes.

This refactoring significantly reduces code duplication, simplifies the core application state, and provides a more robust and maintainable pattern for developer tools within the Rule Builder.


PR created automatically by Jules for task 10670225873261897384 started by @Sendipad

- Replaced legacy, repetitive field inspection logic with a centralized `v-field-inspect` custom directive.
- Introduced `flexirule/public/js/flexirule/rule_builder/constants.js` with a configurable `INSPECT_MODIFIER` (Shift).
- Implemented in-place text swapping for labels and a micro-badge fallback for labelless controls.
- Centralized directive application in `ControlFactory.vue` to cover all fields automatically.
- Removed deprecated `fieldInspector` state and global mouse listeners from `App.vue`.
- Swept all individual controls to remove redundant `data-fxr-fieldname` attributes.

Co-authored-by: Sendipad <705960+Sendipad@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits June 20, 2026 13:38
- Fixed an issue where field inspection didn't work in modals by changing `ControlFactory` wrapper from `display: contents` to `display: block`.
- Hardened modifier key detection in `v-field-inspect` directive to reliably capture Shift key states.
- Re-synchronized all hovered instances when the modifier key is toggled.
- Cleaned up legacy `fieldInspector` code from `App.vue` and redundant attributes from controls.

Co-authored-by: Sendipad <705960+Sendipad@users.noreply.github.com>
- Migrated `v-field-inspect` from `ControlFactory.vue` to base controls (`ComboBox`, `Data`, `Check`, `Text`, `Code`, `FlexValue`, `MultiSelect`).
- This ensures fields used directly in configuration panels (bypassing the factory) are correctly inspectable.
- Improved directive label detection to support varied FlexiRule label classes (`.fxr-label`, `.label-area`, `.control-label`).
- Converted all remaining manual `data-fxr-fieldname` attributes to the new directive.
- Added comprehensive logging and safety resets to the directive.
- Verified asset build and linting.

Co-authored-by: Sendipad <705960+Sendipad@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant