Skip to content

Feat/user text templates#3094

Open
alizaib1217 wants to merge 14 commits intomainfrom
feat/user-text-templates
Open

Feat/user text templates#3094
alizaib1217 wants to merge 14 commits intomainfrom
feat/user-text-templates

Conversation

@alizaib1217
Copy link
Copy Markdown
Contributor

@alizaib1217 alizaib1217 commented Apr 8, 2026

Personal templates are integrated directly into the Quill editor toolbar. Through the Custom toolbar popover, users can configure an MT dropdown with any combination of personal and global templates for quick one-click insertion while writing. Changes made on the My Templates page are reflected in the toolbar immediately without a page reload.

What's changed

  • New "My Templates" page — accessible from the navigation menu, users can create, edit, and delete their own personal templates with a clean side-by-side layout
  • Global templates are also visible — all users can browse global templates from the same page. If an admin has granted you edit access, you can modify them, too
  • Admin permission control — admins can enable global template editing for specific users directly from the User Management page
  • MT dropdown in the toolbar — when editing a reaction or analysis, open the Custom toolbar popover and you'll find a pre-added MT row. Pick which templates (personal or global) you want quick access to, save, and they appear in your editor toolbar

Test instance: https://az-texttemp.deploy.chemdev.scc.kit.edu/


  • rather 1-story 1-commit than sub-atomic commits

  • commit title is meaningful => git history search

  • commit description is helpful => helps the reviewer to understand the changes

  • code is up-to-date with the latest developments of the target branch (rebased to it or whatever) => ⏩-merge for linear history is favoured

  • added code is linted

  • tests are passing (at least locally): we still have some random test failure on CI. thinking of asking spec/examples.txt to be commited

  • in case the changes are visible to the end-user,  video or screenshots should be added to the PR => helps with user testing

  • testing coverage improvement is improved.

  • CHANGELOG :  add a bullet point on top (optional: reference to github issue/PR )

  • parallele PR for documentation  on docusaurus  if the feature/fix is tagged for a release

@alizaib1217 alizaib1217 linked an issue Apr 8, 2026 that may be closed by this pull request
1 task
@alizaib1217 alizaib1217 self-assigned this Apr 9, 2026
@alizaib1217 alizaib1217 requested a review from phuang26 April 9, 2026 12:02
  - Add /my_templates route and HAML mount point
  - Register MyTemplates React app in application.js
  - Add My Templates link in user dropdown (UserAuth.js)
  - Add My Templates button in custom toolbar popover
  Added a new "Global Text Template Editor" permission that admins can
  toggle per user from the User Management page. When enabled, the user
  can edit predefined (global) text templates from their My Templates page.

  - Add global_text_template_editor flag to profile defaults
  - Expose the flag via user entity and admin profile API
  - Add toggle button and handler in UserManagement UI
  - Add global_text_template_editor method on User model
@alizaib1217 alizaib1217 force-pushed the feat/user-text-templates branch from 18a87d7 to 28228ca Compare April 9, 2026 12:08
@alizaib1217 alizaib1217 marked this pull request as ready for review April 9, 2026 12:11
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

LCOV of commit 28228ca during CI - Ruby Lint, RSpec, and code coverage #1196

Summary coverage rate:
  lines......: 65.7% (18365 of 27972 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

LCOV of commit c087707 during CI - Ruby Lint, RSpec, and code coverage #1198

Summary coverage rate:
  lines......: 65.7% (18366 of 27971 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@alizaib1217 alizaib1217 marked this pull request as draft April 10, 2026 09:27
@github-actions
Copy link
Copy Markdown

LCOV of commit b8b491e during CI - Ruby Lint, RSpec, and code coverage #1204

Summary coverage rate:
  lines......: 65.7% (18365 of 27972 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

  - Add uniqueness validation to PredefinedTextTemplate model
  - Use save/update instead of save!/update! in personal and predefined
    template endpoints to return JSON 422 on validation failure
  - Handle res.error in frontend to show error banner without updating list
# frozen_string_literal: true

class PersonalTextTemplate < TextTemplate
validates :name, presence: true, uniqueness: { scope: :user_id, message: 'already exists in your personal templates' }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails/I18nLocaleTexts: Move locale texts to the locale files in the config/locales directory.

class PredefinedTextTemplate < TextTemplate
# STI: this file is only here because of rails model autoloading.
# place all code in app/models/text_template.rb.
validates :name, presence: true, uniqueness: { message: 'already exists in global templates' }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails/I18nLocaleTexts: Move locale texts to the locale files in the config/locales directory.

@alizaib1217 alizaib1217 removed the request for review from phuang26 April 10, 2026 13:18
@github-actions
Copy link
Copy Markdown

LCOV of commit ad2227d during CI - Ruby Lint, RSpec, and code coverage #1206

Summary coverage rate:
  lines......: 65.7% (18370 of 27978 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@github-actions
Copy link
Copy Markdown

LCOV of commit b28bcf0 during CI - Ruby Lint, RSpec, and code coverage #1207

Summary coverage rate:
  lines......: 65.7% (18369 of 27979 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@alizaib1217 alizaib1217 requested a review from phuang26 April 10, 2026 19:04
@alizaib1217 alizaib1217 marked this pull request as ready for review April 10, 2026 19:06
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.

Allow users to save own text templates for reaction descriptions

1 participant