Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ELEMENTS-1771:Allow option to configure Integer display Formatting nuxeo-checkbox-aggregation.js 3.1.x #1010

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 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,16 @@ 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) || false;
if (isNumberFormattingEnabled) {
return new Intl.NumberFormat().format(docCount); // Apply formatting if enabled
}
return docCount; // Return if formatting is disabled
}

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