Skip to content

Commit

Permalink
Merge pull request #35480 from dimagi/mjr/enterprise-percent-changes
Browse files Browse the repository at this point in the history
Allow enterprise console to handle percent summary data
  • Loading branch information
mjriley authored Dec 9, 2024
2 parents 647dc46 + 3ec0393 commit b878399
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion corehq/apps/enterprise/static/enterprise/js/project_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,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) {
$display.html(Number(data.total).toLocaleString());
$display.html(localizeNumberlikeString(data.total));
},
error: function (request) {
if (request.responseJSON) {
Expand Down

0 comments on commit b878399

Please sign in to comment.