Embed visual rule builder in subject/user rule forms#1676
Open
Embed visual rule builder in subject/user rule forms#1676
Conversation
Replace the plain text condition_string input with an interactive visual builder from caesar-rules-ui. No backend changes needed the controller's existing JSON.parse(condition_string) path handles submission unchanged.
Member
|
@kieftrav What's the purpose of the docker compose override? Is that for testing this feature specifically, or how is it meant to be used? |
- Remove docker-compose.override.yml from tracking and add to .gitignore - Fix CSS property ordering in crb-* styles (alphabetical per hound) - Merge .crb-value .label into parent rule - Add Caesar Rules documentation link to subject/user rule forms
0bf49a9 to
34a6720
Compare
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Embed visual rule builder in subject/user rule new and edit forms, replacing the raw text input with an interactive UI from caesar-rules-ui. No backend changes — the controller's existing
JSON.parse(condition_string)path handles form submission unchanged.Linked Issue
Describe your changes
New asset:
caesar_rule_builder.js— Adapted version of caesar-rules-ui for the Rails asset pipeline. Wrapped in an IIFE, exposesCaesarRuleBuilder.mount(container, { initialRules, onChange }). All CSS classes prefixedcrb-to avoid Bootstrap 3 conflicts. Picked up automatically via Sprocketsrequire_tree ..Subject rules form (
app/views/subject_rules/_form.html.erb): Replacedf.input :condition_string(plain text input) with a hidden field + builder mount point. On edit, the existing condition is passed from the JSONB column (@subject_rule[:condition]) directly into the builder. TheonChangecallback syncs the builder's output to the hidden field as JSON on every mutation.User rules form (
app/views/user_rules/_form.html.erb): Same pattern as subject rules.Scoped CSS (
app/assets/stylesheets/application.scss): ~68 lines ofcrb--prefixed styles using existing Zooniverse theme variables ($zooniverse-teal,$zooniverse-light-teal, etc.). Bootstrap.form-controlon inputs/selects for visual consistency.How to Review
Local setup:
App runs in development mode — no auth required (uses
FakeCredential).Pages to test:
/workflows/55/subject_rules/new/workflows/55/subject_rules/2/edit/workflows/55/user_rules/new/workflows/55/user_rules/1/editSteps:
> (gt)from the dropdown, add alookupvalue (data.consensus_score) and aconstvalue (3) — confirm the JSON output preview updates in real time["gte", ["lookup", "UC.classifications", 5], ["const", 3]](the seed data condition)>=to>— confirm the hidden field updates and existing values are preserved/user_rules/newand/user_rules/1/edit)/workflows/55— confirm the read-only condition display on the workflow page is unaffectedChecklist
Feature
_condition.html.erb) on workflow show page unaffectedGeneral
require_tree .Demo
caesar-rules-builder-ui.mov