Skip to content

Feature/per project export templates#141

Merged
therealbrad merged 20 commits intomainfrom
feature/per-project-export-templates
Mar 19, 2026
Merged

Feature/per project export templates#141
therealbrad merged 20 commits intomainfrom
feature/per-project-export-templates

Conversation

@therealbrad
Copy link
Contributor

Description

Adds per-project export template assignment and default selection. Admins can now configure which Case Export Templates are available for each project and set a project-specific default. The QuickScript export dialog filters templates to only show those assigned to the current project, with the project default pre-selected. If no templates are assigned, all enabled templates are shown (backward compatible).

Related Issue

Closes #85

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement

How Has This Been Tested?

Describe the tests you ran to verify your changes:

  • Unit tests
  • Integration tests
  • E2E tests
  • Manual testing

Test Configuration:

  • OS: macOS
  • Browser (if applicable): Chrome
  • Node version: 22.x

Manual Test Scenarios

  1. Assign templates to project — Navigate to Project Settings > QuickScript, assign templates via the combobox, save, reload — selections persist
  2. Set project default — Select a default template from the dropdown, save, reload — default persists
  3. Unassign default template — Remove the template set as default, save — default is automatically cleared
  4. Export dialog filtering — Open QuickScript export dialog — only assigned templates appear in the dropdown
  5. Default pre-selection — Open export dialog — project default template is pre-selected
  6. Backward compatibility — Remove all template assignments from a project — export dialog shows all enabled templates
  7. Edge case: all assigned templates disabled — Assign templates, then disable them all in admin — export dialog shows empty state message

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have signed the CLA

Screenshots (if applicable)

Additional Notes

Changes Summary

Schema (schema.zmodel):

  • Added defaultCaseExportTemplateId nullable FK and defaultCaseExportTemplate relation to Projects model (with onDelete: SetNull)
  • Added defaultForProjects back-relation on CaseExportTemplate
  • Updated CaseExportTemplateProjectAssignment access rules to allow project admins (not just system admins) to manage assignments

Admin UI:

  • New ExportTemplateAssignmentSection component on the Project Settings > QuickScript page
  • Uses MultiAsyncCombobox for template selection with category/language badges
  • Separate dropdown for setting the project default (filtered to assigned templates only)
  • Explicit Save button with delete-all/recreate pattern for assignments

Export Dialog (QuickScriptModal.tsx):

  • Filters template list to project-assigned templates when assignments exist
  • Pre-selects with priority: project default > global isDefault > first available
  • Falls back to all enabled templates when no assignments configured
  • Shows empty state message when assignments exist but all are disabled/deleted

Translations:

  • Added new keys under projects.settings.quickScript.exportTemplates (en-US only per project conventions)
  • Added noAvailableTemplates key under repository.quickScript

Shared component improvement:

  • Updated MultiAsyncCombobox X button styling to use opacity-70 hover:opacity-100 pattern (matching dialog close button) for better visibility across themes

therealbrad and others added 20 commits March 18, 2026 22:07
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Added nullable defaultCaseExportTemplateId Int? FK to Projects model
- Added defaultCaseExportTemplate CaseExportTemplate? optional relation with onDelete: SetNull
- Added defaultForProjects Projects[] back-relation on CaseExportTemplate model
- Named relation 'ProjectDefaultExportTemplate' disambiguates from join-table relation
…ltCaseExportTemplate relation

- prisma/schema.prisma updated with defaultCaseExportTemplateId FK and relation
- lib/hooks updated with new relation metadata
- Database schema pushed (nullable column added to Projects table)
- OpenAPI spec updated to include new fields
- 25-01-SUMMARY.md created
- STATE.md updated with decisions and session info
- ROADMAP.md phase 25 marked complete (1/1 plans done)
- REQUIREMENTS.md SCHEMA-02 marked complete
…ectAssignment

- Add @@Allow('create,delete') for users with explicit SPECIFIC_ROLE Project Admin on project
- Add @@Allow('create,delete') for users with PROJECTADMIN access assigned to project
- Mirrors access pattern from Projects model for consistency
- Run pnpm generate to regenerate ZenStack/Prisma artifacts
- Add 26-01-SUMMARY.md with plan execution results
- Update STATE.md with progress, decisions, and session info
- Update ROADMAP.md progress for phase 26
- Mark ADMIN-01 requirement as complete

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add ExportTemplateAssignmentSection with checkbox list for template assignment
- Delete-all/recreate save pattern for assignments
- Default template selector (filtered to assigned templates only)
- Clears default when unchecked template was the default
- Add exportTemplates translation keys to en-US.json quickScript namespace
- data-testid="export-template-assignment-section" for testing
…pt page

- Import ExportTemplateAssignmentSection component
- Add defaultCaseExportTemplateId to project query select
- Render ExportTemplateAssignmentSection between toggle card and code repo section
- Add 26-02-SUMMARY.md with component details and decisions
- Update STATE.md: session, decisions, metrics
- Update ROADMAP.md: phase 26 plans complete
- Mark ADMIN-02 requirement complete in REQUIREMENTS.md
- Replace checkbox list with MultiAsyncCombobox for template selection
- Add alphabetical sorting by name in template options
- Push metadata badges (category, language) to the right in option rows
- Add assignedLabel and selectPlaceholder translation keys
- Fix MultiAsyncCombobox X button alignment and check icon consistency
- Updated SUMMARY.md with checkpoint approval, UI refinements, and final commit hashes
- STATE.md: progress updated to 100%, decisions and session recorded
- ROADMAP.md: phase 26 marked complete (2/2 plans)
- Added 'noAvailableTemplates' key under repository.quickScript namespace
- Value: 'No available templates. Contact your admin.'
- Used when project has assignments configured but all are disabled/deleted
…re-select project default

- Fetch project assignments via useFindManyCaseExportTemplateProjectAssignment
- Fetch project defaultCaseExportTemplateId via useFindUniqueProjects
- filteredTemplates: shows only assigned templates when assignments exist (EXPORT-01)
- Fallback: no assignments = all enabled templates shown (EXPORT-03)
- defaultTemplate priority: user selection > project default > global isDefault > first (EXPORT-02)
- assignmentsExistButEmpty: renders empty state message and disables export button
- groupedTemplates updated to use filteredTemplates preserving category grouping
- SUMMARY.md created with task commits, decisions, and deviations
- STATE.md updated: progress 100%, decisions, session info
- ROADMAP.md updated: Phase 27 complete (1/1 plans)
- REQUIREMENTS.md: EXPORT-01, EXPORT-02, EXPORT-03 marked complete
Update three docs to cover the new per-project template assignment feature:
- quickscript-templates.md: new "Per-Project Template Assignment" section
- projects/quickscript.md: updated template selection behavior and priority
- llm-quickscript.md: mention Export Templates in Settings > QuickScript

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@therealbrad therealbrad merged commit 84e50a9 into main Mar 19, 2026
6 checks passed
@therealbrad therealbrad deleted the feature/per-project-export-templates branch March 19, 2026 13:39
@therealbrad
Copy link
Contributor Author

🎉 This PR is included in version 0.16.28 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Per-Project Export Template Assignment and Default Selection

1 participant