Skip to content

Commit

Permalink
ELEMENTS-1771:Allow option to configure Integer display Formatting nu…
Browse files Browse the repository at this point in the history
…xeo-checkbox-aggregation.js
  • Loading branch information
yashgupta-hyland committed Dec 2, 2024
1 parent 715b2a7 commit 30d24f8
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions ui/nuxeo-aggregation/nuxeo-checkbox-aggregation.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ import { AggregationBehavior } from './nuxeo-aggregation-behavior.js';
noink
checked="{{item.checked}}"
on-change="_computeValues"
aria-label$="[[item.label]] ([[item.docCount]])"
aria-label$="[[item.label]] ([[_formatDocCount(item.docCount)]])"
>
[[item.label]] ([[item.docCount]])
[[item.label]] ([[_formatDocCount(item.docCount)]])
</paper-checkbox>
</div>
</template>
Expand Down Expand Up @@ -179,17 +179,15 @@ import { AggregationBehavior } from './nuxeo-aggregation-behavior.js';
noink
checked="{{item.checked}}"
on-change="_computeValues"
aria-label$="[[item.label]] ([[item.docCount]])"
aria-label$="[[item.label]] ([[_formatDocCount(item.docCount)]])"
>
[[item.label]] ([[item.docCount]])
[[item.label]] ([[_formatDocCount(item.docCount)]])
</paper-checkbox>
</div>
</template>
</dom-repeat>
<span hidden$="[[_hideShowMoreButton(buckets, visibleItems)]]" class="show-more-button">
<a href="javascript:void(0);" on-tap="_toggleShow">
[[_computeShowMoreLabel(_showAll, i18n)]]
</a>
<a href="javascript:void(0);" on-tap="_toggleShow"> [[_computeShowMoreLabel(_showAll, i18n)]] </a>
</span>
</template>
</dom-if>
Expand Down Expand Up @@ -257,6 +255,19 @@ import { AggregationBehavior } from './nuxeo-aggregation-behavior.js';
this.setAttribute('tabindex', 0);
}

_formatDocCount(docCount) {
// Fetch the property value from web-ui-properties.xml
const isNumberFormattingEnabled =
Nuxeo && Nuxeo.UI && Nuxeo.UI.config && Nuxeo.UI.config.numberFormattingEnabled !== undefined
? Nuxeo.UI.config.numberFormattingEnabled
: false; // Default to false if the property is not set

if (isNumberFormattingEnabled) {
return new Intl.NumberFormat().format(docCount); // Apply formatting if enabled
}
return docCount.toString(); // Return if formatting is disabled
}

_computeVisibleBuckets(buckets, visibleItems, _showAll) {
if (!buckets || buckets.length === 0) {
return [];
Expand Down

0 comments on commit 30d24f8

Please sign in to comment.