Skip to content

Commit

Permalink
Allow enterprise console to handle percent summary data
Browse files Browse the repository at this point in the history
  • Loading branch information
mjriley authored and jingcheng16 committed Dec 8, 2024
1 parent edcb49c commit 1b67a86
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions corehq/apps/enterprise/static/enterprise/js/project_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,25 @@ hqDefine("enterprise/js/project_dashboard", [
return self;
};

function localizeNumberlikeString(input) {
if ((typeof input === "string") && (input.endsWith('%'))) {
const number = input.slice(0, -1);
return Number(number).toLocaleString(
undefined,
{minimumFractionDigits: 1, maximumFractionDigits: 1}
) + '%';
} else {
return Number(input).toLocaleString();
}
}

function updateDisplayTotal($element, kwargs) {
const $display = $element.find(".total");
const slug = $element.data("slug");
const requestParams = {
url: initialPageData.reverse("enterprise_dashboard_total", slug),
success: function (data) {
if (typeof data.total === 'number') {
$display.html(Number(data.total).toLocaleString());
} else {
$display.html(data.total);
}
$display.html(localizeNumberlikeString(data.total));
},
error: function (request) {
if (request.responseJSON) {
Expand Down

0 comments on commit 1b67a86

Please sign in to comment.