Skip to content

Conversation

@konard
Copy link

@konard konard commented Jan 5, 2026

Summary

This PR adds pagination and search functionality to the templates list page, addressing issue #2847.

Features implemented:

  • Paginated template list (default 20 per page with page navigation)
  • Search/filter by template name
  • Sort by name, type, created date, or updated date

Changes

Backend

  • queries/templates.sql: Added new query-templates SQL query with:

    • COUNT(*) OVER() for total count
    • OFFSET and LIMIT for pagination
    • ILIKE search on name field
    • Dynamic ORDER BY substitution
  • models/templates.go: Added Templates slice type and Total field to Template struct for pagination support

  • models/queries.go: Added QueryTemplates query reference as string type

  • internal/core/core.go: Added templateQuerySortFields for allowed sort columns

  • internal/core/templates.go: Added QueryTemplates() function for paginated template retrieval

  • cmd/templates.go: Updated GetTemplates handler to support pagination parameters (page, query, order_by, order)

Frontend

  • frontend/src/api/index.js: Updated getTemplates to accept params

  • frontend/src/views/Templates.vue:

    • Added search input with submit
    • Added backend pagination with b-table pagination props
    • Added backend sorting support
    • Updated template count to use templates.total
  • i18n/en.json: Added templates.queryPlaceholder translation

Testing

  • Go code builds successfully
  • Frontend builds successfully
  • ESLint passes with no errors

Screenshots

The UI follows the same pattern as the existing Campaigns and Lists pages for consistency.

Fixes #2847


🤖 Generated with Claude Code

konard and others added 2 commits January 5, 2026 23:08
Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: knadh#2847
Implements pagination, search, and sorting functionality for the
templates list page, addressing issue knadh#2847.

Changes:
- Add query-templates SQL query with pagination, search and sorting
- Add QueryTemplates function to core/templates.go
- Update GetTemplates API handler to support pagination parameters
- Add Templates type and Total field to template model
- Update frontend Templates.vue with pagination and search UI
- Update API call to support pagination parameters
- Add i18n translation for search placeholder

The implementation follows the existing patterns used in campaigns
and lists pages for consistency.

Fixes knadh#2847

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Feature: Add pagination and search to templates page Feature: Add pagination and search to templates page Jan 5, 2026
@konard konard marked this pull request as ready for review January 5, 2026 22:20
@konard
Copy link
Author

konard commented Jan 5, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $6.936327 USD
  • Calculated by Anthropic: $4.812010 USD
  • Difference: $-2.124317 (-30.63%)
    📎 Log file uploaded as GitHub Gist (1258KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Author

konard commented Jan 5, 2026

🔄 Auto-restart 1/3

Detected uncommitted changes from previous run. Starting new session to review and commit them.

Uncommitted files:

M frontend/yarn.lock
?? frontend/package-lock.json

Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback.

@konard
Copy link
Author

konard commented Jan 5, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.601133 USD
  • Calculated by Anthropic: $0.890814 USD
  • Difference: $-0.710319 (-44.36%)
    📎 Log file uploaded as GitHub Gist (1488KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

return c.JSON(http.StatusOK, okResp{models.PageResults{Results: []models.Template{}}})
}

out := models.PageResults{
Copy link
Owner

Choose a reason for hiding this comment

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

This breaks backwards-compatibility by changing the current API response structure.

@graysoncooper
Copy link

Hi! Hope you don't mind me adding to the repo again, trying to build something for automated QA testing on individual PRs. Here's a summary of my testing for this PR. What I did here: create dev container, build a test plan, run test agent against the actual app, and the results below look good from the PR description.

Listmonk Templates Test Report

Summary

Category Total Passed Failed Skipped
ROUTE (UI/UX) 16 14 0 2
LOGIC (API) 4 4 0 0
EDGE (Edge Cases) 5 5 0 0
Total 25 23 0 2

Overall Result: PASSED

ROUTE-14-final
Detailed Results

ROUTE Tests (UI/UX)

Test ID Description Result Notes
ROUTE-1 Templates list displays with pagination controls PASSED Pagination controls visible, 5 templates displayed
ROUTE-2 Search templates by name PASSED Search for "visual" returned 2 correct results
ROUTE-3 Search with special characters is sanitized PASSED Special characters handled gracefully
ROUTE-4 Sort templates by name column PASSED Ascending/descending sort works
ROUTE-5 Sort templates by type column PASSED Type sorting functional
ROUTE-6 Sort templates by created_at column PASSED Created date sorting works
ROUTE-7 Sort templates by updated_at column PASSED Updated date sorting works
ROUTE-8 Navigate between pages using pagination SKIPPED Only 5 templates, all fit on one page
ROUTE-9 Total count updates after search SKIPPED Verified in ROUTE-2
ROUTE-10 Empty search results display correctly PASSED "No data" message shown for no matches
ROUTE-11 Create new template and verify it appears in list PASSED Created "ITO Bot Test Template", count updated to 5
ROUTE-12 Delete template and verify it is removed PASSED Deleted template, count returned to 4
ROUTE-13 Clone template and verify duplicate appears PASSED Cloned "Sample visual template", copy appeared
ROUTE-14 Set template as default and verify list updates PASSED "Default archive template" set as default
ROUTE-15 Combined search and pagination PASSED Search filtered results, pagination updated
ROUTE-16 Combined search and sorting PASSED Search + sort by name worked correctly

LOGIC Tests (API)

Test ID Description Result Notes
LOGIC-1 API returns templates with pagination metadata PASSED Response includes total, per_page, page fields
LOGIC-2 API supports search query parameter PASSED ?query=visual returned filtered results
LOGIC-3 API supports sorting parameters PASSED ?order_by=name&order=asc sorted correctly
LOGIC-4 Response includes all required fields PASSED id, name, type, body, created_at, updated_at, is_default present

EDGE Tests (Edge Cases)

Test ID Description Result Notes
EDGE-1 Whitespace-only search handled correctly PASSED Returns all templates (whitespace trimmed)
EDGE-2 Type badge colors for different types PASSED Campaign/Visual (orange), Transactional (red), Campaign/HTML (blue)
EDGE-3 Rapid clicking on pagination/sorting PASSED No errors, sorting toggled correctly
EDGE-4 Template type in human-readable format PASSED "Campaign / Visual" instead of "campaign_visual"
EDGE-5 Default template indicator visible PASSED "Default" badge shown next to default template

Test Artifacts

Screenshots

Located in screenshots/ folder:

  • ROUTE-1 through ROUTE-16: Start and final screenshots for each test
  • LOGIC-1 through LOGIC-3: API response screenshots
  • EDGE-1 through EDGE-3: Edge case test screenshots

Videos

Located in videos/ folder:

  • ROUTE-1.webm through ROUTE-16.webm: Individual test recordings
  • LOGIC-tests.webm: API test session recording
  • EDGE-tests.webm: Edge case test session recording

Assets here: https://drive.google.com/drive/u/0/folders/1I6LgNCU-WzZ2wkIAO85VxSSMQiZWkt-S

Notes
  1. ROUTE-8 and ROUTE-9 were skipped because the test data only had 5 templates, which all fit on a single page. The pagination functionality was verified through other tests.

  2. All CRUD operations (Create, Read, Update via Set Default, Delete) worked correctly.

  3. The API properly handles search, sorting, and pagination parameters.

  4. Edge cases like whitespace search and rapid clicking are handled gracefully.

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.

Feature: Add pagination and search to templates page

3 participants