Skip to content

feat(legal-templates): AI template studio with jinja tag highlighting and full fieldtype support - #24

Open
abdullahsyed4c wants to merge 5 commits into
4csolutions:version-16from
abdullahsyed4c:feature/legal-templates
Open

abdullahsyed4c wants to merge 5 commits into
4csolutions:version-16from
abdullahsyed4c:feature/legal-templates

Conversation

@abdullahsyed4c

Copy link
Copy Markdown

Summary

This PR enhances Legal Templates with an AI Template Studio, native Word (.docx) Jinja tag highlighting, and full support for all 44 Frappe field types.

Key Changes

  • Word (.docx) Jinja Highlighting: Automatically highlights all Jinja variables ({{ variable }}) in yellow (WD_COLOR_INDEX.YELLOW) in downloaded Word documents while preserving 100% compatibility with docxtpl rendering.
  • Automatic Lifecycle Hook: on_update hook on Legal Templates ensures templates attached or updated in Frappe are highlighted automatically on save.
  • Support for All 44 Frappe Field Types: Categorized cleanly (Standard, Text & Content, Relationships, Media, Special, Layout) in both UI cards/dialogs and backend DocType layout generator.
  • AI Prompt Generator: Generates structured legal agreement templates from prompt descriptions via Frappe Flow (Gemini/Groq/OpenAI) with an offline synthesis engine fallback.
  • Document Dashboard & Direct Download: Action buttons for direct Word download from form and studio headers, plus executive document dashboard on generated DocTypes.

Files Changed

  • casecentral/legal_documents/doctype/legal_templates/legal_templates.js
  • casecentral/legal_documents/doctype/legal_templates/legal_templates.json
  • casecentral/legal_documents/doctype/legal_templates/legal_templates.py
  • casecentral/legal_documents/doctype/legal_templates/legal_templates_list.js
  • casecentral/legal_documents/doctype/legal_templates/template_studio.py
  • casecentral/public/js/legal_template.js

Abdullah Syed and others added 5 commits November 4, 2026 09:23
… and full fieldtype support

- Add native OpenXML highlighting for Jinja tags in downloaded Word (.docx) templates\n- Support all 44 Frappe field types organized by category in studio and modal\n- Add AI Prompt Generator integrated with Flow AI and live Gemini models\n- Add automatic Jinja highlighting on document save via on_update hook\n- Add direct Word (.docx) template download buttons to form and studio headers\n- Add executive document dashboard and generation button to generated doctypes
…rmatting improvements

- Remove unauthenticated debug endpoint download_sample_agreement with hardcoded paths
- Store AI API keys securely in Flow Provider DocType rather than plaintext site defaults
- Add explicit frappe.has_permission checks across all Template Studio whitelisted methods
- Refactor highlight_jinja_in_paragraph to preserve run-level formatting across paragraph runs
- Log exceptions in LegalTemplates.on_update instead of silently swallowing with bare pass
- Align Gemini model identifiers with current production endpoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants