mirror of
https://github.com/directus/directus.git
synced 2026-02-11 04:45:34 -05:00
* Fix lint issues Merge in main * Add support for resizing columns. Disable sorting on json columns * Replaced static text with translations * remove unused variables * add no collection/fields states to system-fields * turn columns to notice when creating list-m2m * tweak system-fields no fields background color * add danger styling for deselect in table layout * add tooltips * prevent linking to items without ID yet * fix launch icon for list layout * tweak padding for per page * Update missing types * resolve ::v-deep to :deep warning * minor style tweaks * fix search * fix destructuring crashing when no permissions * remove unused variables Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
31 lines
624 B
TypeScript
31 lines
624 B
TypeScript
import { useI18n } from 'vue-i18n';
|
|
|
|
export function formatCollectionItemsCount(
|
|
totalItems: number,
|
|
currentPage: number,
|
|
perPage: number,
|
|
isFiltered = false
|
|
) {
|
|
const { t, n } = useI18n();
|
|
|
|
const opts = {
|
|
start: n((+currentPage - 1) * perPage + 1),
|
|
end: n(Math.min(currentPage * perPage, totalItems || 0)),
|
|
count: n(totalItems || 0),
|
|
};
|
|
|
|
if (isFiltered) {
|
|
if (totalItems === 1) {
|
|
return t('one_filtered_item');
|
|
}
|
|
|
|
return t('start_end_of_count_filtered_items', opts);
|
|
}
|
|
|
|
if (totalItems > perPage) {
|
|
return t('start_end_of_count_items', opts);
|
|
}
|
|
|
|
return t('item_count', { count: totalItems });
|
|
}
|