Boards Comments Functions
Each of these functions require the <commentsbutton /> tag to be present on the view. The button does not have to be visible to the user but it must be present in the view HTML. See <commentsbutton> for details.
OpenDrawer
| OpenDrawer | |
|---|---|
| No parameters |
Opens the comments drawer slide out panel for the current view. This feature is available in WebEOC Nexus 10.18 and later. |
Example
<script>
BoardScript.Comments.OpenDrawer();
</script>
CloseDrawer
| CloseDrawer | |
|---|---|
| No parameters |
Closes the comments drawer slide out UI for the current view. This feature is available in WebEOC Nexus 10.18 and later. |
Example
<script>
BoardScript.Comments.CloseDrawer();
</script>
GetUnreadCount
| GetUnreadCount | ||
|---|---|---|
| callback | #optional |
Get the unread comment count for the current view/user. Result can be received via callback or async/await Promise return. This feature is available in WebEOC Nexus 10.18 and later. |
Example
<script>
// callback
BoardScript.Comments.GetUnreadCount(function (count) {
console.log('Unread count is:', count);
});
// async/await
const count = await BoardScript.Comments.GetUnreadCount();
console.log('Unread count is:', count);
</script>
GetCounts (ByName)
Get the comment counts for a user by specifying a board, view, dataid.
Overload for GetCounts() that specifies board, view, dataid via args parameter.
| GetCounts (By Name) | ||
|---|---|---|
| args | object |
Single parameter arguments object for specifying board/view/dataid. Language: JavaScript title: args Copy Code
This feature is available in WebEOC Nexus 10.19 and later. |
| callback | #optional | Result can be received via callback or async/await Promise return. |
JavaScript Example
<script>
const args = {
"boardName": "My board"
"viewName": "My View"
};
// callback
BoardScript.Comments.GetCounts(args, function (countsObject) {
console.log('Unread count is:', countsObject.unreadCount);
console.log('Total count is:', countsObject.totalCount);
});
// async/await
const countsObject = await BoardScript.Comments.GetCounts(args);
console.log('Unread count is:', countsObject.unreadCount);
console.log('Total count is:', countsObject.totalCount);
</script>
GetCounts
| GetCounts | ||
|---|---|---|
| callback | #optional |
Get the comment count for the current view/user. Result can be received via callback or async/await Promise return. This feature is available in WebEOC Nexus 10.18 and later. |
Example
<script>
// callback
BoardScript.Comments.GetCounts(function (countsObject) {
console.log('Unread count is:', countsObject.unreadCount);
console.log('Total count is:', countsObject.totalCount);
});
// async/await
const countsObject = await BoardScript.Comments.GetCounts();
console.log('Unread count is:', countsObject.unreadCount);
console.log('Total count is:', countsObject.totalCount);
</script>
Unread Counts on a List View
BoardScript.Comments.GetCounts(params, callback)
Pass an array of items to trigger the batch endpoint. The key is not required in boardscript usage — the JS wrapper (boardmanager.js) assigns positional keys ("0", "1", …) automatically before POSTing, then re-sorts the response back into the original array order before calling your callback. The callback always receives a same-length array positionally aligned to your input.
Sample Boardscript
(function loadCommentCounts() {
document.addEventListener('DOMContentLoaded', function () {
var rows = Array.prototype.slice.call(document.querySelectorAll('tr[data-dataid]'));
if (!rows.length) { return; }
// Build params — no 'key' needed, the wrapper assigns keys internally
var params = rows.map(function (r) {
return {
boardName: 'My Board',
viewName: 'List View',
dataId: Number(r.getAttribute('data-dataid'))
};
});
// Optionally append a view-level item (no dataId) to get a board-wide unread count
params.push({ boardName: 'My Board', viewName: 'List View', dataId: null });
BoardScript.Comments.GetCounts(params, function (results) {
// Last item is the optional board-wide count
var listCount = (results[results.length - 1] && results[results.length - 1].unreadCount) || 0;
// Per-row badges
results.slice(0, -1).forEach(function (result, i) {
if (result && result.unreadCount > 0) {
var badge = document.getElementById('comment-count-' + rows[i].getAttribute('data-dataid'));
if (badge) {
badge.textContent = result.unreadCount;
badge.style.display = '';
}
}
});
// Board-level button badge
if (listCount > 0) {
var btn = document.getElementById('comments-board-btn');
if (btn) {
var tb = document.createElement('span');
tb.className = 'badge badge-pill badge-danger ml-1';
tb.textContent = listCount;
btn.appendChild(tb);
}
}
});
});
}());
How the Boardscript works
-
tr[data-dataid] rows are collected after DOM ready — one item per visible record.
-
An extra item with dataId: null is appended to get a view-level unread count (e.g. for a nav button badge).
-
BoardScript.Comments.GetCounts(array, callback) auto-assigns key: String(i) to each item before POSTing to /api/comments/v1/counts/batch, then rebuilds the result array in the original order — the callback receives a positionally aligned array with no key handling needed from the caller.
-
result.error / result.unreadCount drive the badge render; items with zero unread or a per-item error are skipped silently.
-
The key is only relevant when calling the HTTP endpoint directly (for example, from Postman or a custom fetch). Boardscripts never need to set it.
-
Only pass records currently visible to the user.
-
The batch handler performs three bulk DB queries regardless of array length (view ID lookup, comment threads, read statuses), so a 50-row list costs the same number of round trips as a 1-row list.
-
The single-record GET /api/comments/v1/counts?boardName=...&viewName=...&dataId=... endpoint is unchanged for backwards compatibility.