Skip to content

Commit 36a3ec5

Browse files
egeozcanclaude
andcommitted
feat(noteType): surface the notes that use a note type
The note type detail page was nearly empty — it showed only the name and description, even though the type's whole purpose is classifying notes. Add a "Notes" count meta-strip and a seeAll panel listing the notes of this type, mirroring displayCategory.tpl. The notes are fetched with a bounded query (GetNotes limited to MaxResultsPerPage) plus a real GetNoteCount total, rather than rendering the unbounded preloaded association — safe on types that classify very large numbers of notes. The panel's "See All" links to /notes?NoteTypeId=<id>. Verified: filtering is correct (no cross-type leak) and the count reflects the true total. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7d56c00 commit 36a3ec5

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

server/template_handlers/template_context_providers/note_template_context.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,25 @@ func NoteTypeContextProvider(context *application_context.MahresourcesContext) f
398398
return addErrContext(err, baseContext)
399399
}
400400

401+
// Fetch a bounded page of notes that use this type (plus a true total)
402+
// rather than rendering the unbounded preloaded association.
403+
noteQuery := &query_models.NoteQuery{NoteTypeId: noteType.ID}
404+
notes, err := context.GetNotes(0, constants.MaxResultsPerPage, noteQuery)
405+
if err != nil {
406+
return addErrContext(err, baseContext)
407+
}
408+
409+
notesTotal, err := context.GetNoteCount(noteQuery)
410+
if err != nil {
411+
return addErrContext(err, baseContext)
412+
}
413+
401414
return pongo2.Context{
402-
"pageTitle": "Note Type: " + noteType.Name,
403-
"prefix": "Note Type",
404-
"noteType": noteType,
415+
"pageTitle": "Note Type: " + noteType.Name,
416+
"prefix": "Note Type",
417+
"noteType": noteType,
418+
"notes": notes,
419+
"notesTotal": notesTotal,
405420
"action": template_entities.Entry{
406421
Name: "Edit",
407422
Url: "/noteType/edit?id=" + strconv.Itoa(int(query.ID)),

templates/displayNoteType.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
{# Name is shown once via the title-bar h1 (mainEntity/mainEntityType set by the provider), matching displayCategory.tpl #}
66
{% include "/partials/description.tpl" with description=noteType.Description descriptionEntity=noteType descriptionEditUrl="/v1/noteType/editDescription" descriptionEditId=noteType.ID %}
77

8+
{% if notes %}
9+
<div class="meta-strip">
10+
<div class="meta-strip-item">
11+
<span class="meta-strip-label">Notes</span>
12+
<span class="meta-strip-value">{{ notesTotal }}</span>
13+
</div>
14+
</div>
15+
{% endif %}
16+
17+
{% include "/partials/seeAll.tpl" with entities=notes subtitle="Notes" formAction="/notes" formID=noteType.ID formParamName="NoteTypeId" templateName="note" %}
18+
819
{% endblock %}
920

1021
{% block sidebar %}

0 commit comments

Comments
 (0)