Skip to content

Commit

Permalink
feat: adds info about cht.v1.analytics.getTargetDocs(); (#1523)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianabarsan authored Sep 26, 2024
1 parent bc1ad52 commit 8efc44c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions content/en/building/reference/_partial_cht_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ _Introduced in v3.12.0_

Provides CHT-Core Framework's functions to contact summary, targets and tasks. The API is available in the `cht` reserved variable under the `v1` version.

| Function | Arguments | Description |
| -------- | --------- | ----------- |
| hasPermissions(permissions, userRoles, chtPermissionsSettings) | `permissions`: String or array of permission name(s).<br>`userRoles`: (Optional) Array of user roles. Default to the current logged in user.<br>`chtPermissionsSettings`: (Optional) Object of configured permissions in CHT-Core's settings. Default to the current instance's configured permissions. | Returns true if the user has the permission(s), otherwise returns false. |
| hasAnyPermission(permissionsGroups, userRoles, chtPermissionsSettings) | `permissionsGroups`: Array of groups of permission name(s).<br>`userRoles`: (Optional) Array of user roles. Default to the current logged in user.<br>`chtPermissionsSettings`: (Optional) Object of configured permissions in CHT-Core's settings. Default to the current instance's configured permissions. | Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. |
| getExtensionLib(name) | `name`: String of script name | Returns an executable function identified by the given name configured as [extension-libs]({{< ref "extension-libs" >}}).
| Function | Arguments | Description |
| -------- | --------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| hasPermissions(permissions, userRoles, chtPermissionsSettings) | `permissions`: String or array of permission name(s).<br>`userRoles`: (Optional) Array of user roles. Default to the current logged in user.<br>`chtPermissionsSettings`: (Optional) Object of configured permissions in CHT-Core's settings. Default to the current instance's configured permissions. | Returns true if the user has the permission(s), otherwise returns false. |
| hasAnyPermission(permissionsGroups, userRoles, chtPermissionsSettings) | `permissionsGroups`: Array of groups of permission name(s).<br>`userRoles`: (Optional) Array of user roles. Default to the current logged in user.<br>`chtPermissionsSettings`: (Optional) Object of configured permissions in CHT-Core's settings. Default to the current instance's configured permissions. | Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. |
| getExtensionLib(name) | `name`: String of script name | Returns an executable function identified by the given name configured as [extension-libs]({{< ref "extension-libs" >}}).
| analytics.getTargetDocs() | | Returns three [target]({{< ref "core/overview/db-schema#targets" >}} ) documents of the contact, calculated for the last three reporting intervals, including the current one. When viewing one of the current logged in user's associated facilities, returns the target documents for the contact associated with the current logged in user. Returns an empty array if no target documents are found (for example when viewing a contact that does not upload targets). _Introduced in v4.11.0_ |

### CHT API's code samples

Expand All @@ -25,4 +26,5 @@ const hasAnyGroup = cht.v1.hasAnyPermission([
['can_view_reports', 'can_verify_reports']
]);
const averageFn = cht.v1.getExtensionLib('average.js');
const targetDocs = cht.v1.analytics.getTargetDocs();
```

0 comments on commit 8efc44c

Please sign in to comment.