Skip to content

[draft] feat(#10662): display contact profile photo#11087

Open
benkags wants to merge 18 commits into
medic:masterfrom
benkags:10662-display-profile-photo
Open

[draft] feat(#10662): display contact profile photo#11087
benkags wants to merge 18 commits into
medic:masterfrom
benkags:10662-display-profile-photo

Conversation

@benkags
Copy link
Copy Markdown
Contributor

@benkags benkags commented May 18, 2026

Description

Add the ability to display the profile photo of the user when provided in the contact profile. The profile photo field is configurable in contact type definition.

Code review checklist

  • UI/UX backwards compatible: Test it works for the new design (enabled by default). And test it works in the old design, enable can_view_old_navigation permission to see the old design. Test it has appropriate design for RTL languages.
  • Readable: Concise, well named, follows the style guide
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.
  • AI disclosure: Please disclose use of AI per the guidelines.

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

YASHSHARMAOFFICIALLY and others added 18 commits May 18, 2026 18:49
…rt forms

When a report form contains [db-doc="true"] sub-documents with binary/file
fields, attachments are now routed to the owning sub-document instead of
always attaching to the main report doc.

- Add resolveOwnerDoc() to walk up XML tree to nearest db-doc ancestor
- Route FileManager file uploads to correct owner doc
- Route inline binary blobs to correct owner doc
- Fall back to main report doc when element is not inside a sub-doc
processAllAttachments now walks the parsed XML to determine which
prepared doc owns each [type=binary] element (main / sibling / repeat
child) and attaches files accordingly, instead of dumping every upload
on preparedDocs[0]. Field-value sanitization and orphan cleanup also
run per-doc.

Adds two private helpers:
- resolveContactOwnerDoc: DOM-walk from any element to its section root,
  then to the owning prepared doc (with mainDoc fallback).
- findContactOwnerForFilename: locates the [type=binary] node whose text
  matches a FileManager filename and resolves its owner.

No public API changes; no new service dependencies.
saveContact now uses validateAttachments(preparedDocs.preparedDocs)
New 'attachment routing to sub-contacts' describe block exercising:
- file uploaded inside a sibling section -> sibling doc
- file uploaded inside a repeat child -> i-th repeat doc
- mixed uploads across main / sibling / repeat -> each owner
- FileManager file with no matching binary node -> main doc fallback
- inline binary (draw widget) inside sibling -> sibling doc
- per-doc field-value sanitization (sibling field rewritten, main untouched)
- main-doc orphan cleanup on edit path with per-doc loop
- main-doc & sub-doc oversize attachment fails saveContact
- normal-sized attachment passes validation
Enketo's setVal rewrites uploaded binary nodes to type="file" the
moment a value is set.
…oc attachments

- findFileNodeByFilename now selects [type=file], matching Enketo's
  runtime XML state
- use doc.form for the xpath-rooted filename
- additional tests: orphan file fallback, db-doc nested in repeats, and filename shape for sub-doc binaries.
Standalone Angular component that resolves a contact's photo
attachment via DbService and renders an <img>, falling back to
the type icon on 404 or missing field.
Replaces the resource-icon span in contacts-content with
mm-contact-photo so a contact's uploaded photo renders in the
heading, falling back to the type icon otherwise.
Adds an optional photo_field to the ContactType schema and sets
the default person type to use it, letting form authors configure
which doc field holds the profile photo per contact type.
Adds two scenarios asserting the photo renders in the heading
when uploaded and falls back to the type icon otherwise.
Rename the default photo field from `photo` to `profile_photo` across
the component default, the `person` contact-type config, unit tests,
and the e2e custom type / XML forms / spec. Add `border-radius: 50%`
and `object-fit: cover` to the contact photo so rectangular or opaque
uploads display as a clean circle in the profile header.
try {
const blob = await this.dbService.get().getAttachment(doc._id, attachmentName);
this.rawUrl = (window.URL || window.webkitURL).createObjectURL(blob);
this.objectUrl = this.domSanitizer.bypassSecurityTrustUrl(this.rawUrl);
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.

3 participants