1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

fix(app): datatable global checkbox doesn't reflect the selected state (#470)

This commit is contained in:
James Player 2025-03-10 09:21:20 +13:00 committed by GitHub
parent 438b1f9815
commit b57855f20d
10 changed files with 110 additions and 18 deletions

View file

@ -0,0 +1,27 @@
export function capitalize(s: string) {
return s.slice(0, 1).toUpperCase() + s.slice(1);
}
export function pluralize(val: number, word: string, plural = `${word}s`) {
return [1, -1].includes(Number(val)) ? word : plural;
}
export function addPlural(value: number, word: string, plural = `${word}s`) {
return `${value} ${pluralize(value, word, plural)}`;
}
/**
* Joins an array of strings into a grammatically correct sentence.
*/
export function grammaticallyJoin(
values: string[],
separator = ', ',
lastSeparator = ' and '
) {
if (values.length === 0) return '';
if (values.length === 1) return values[0];
const allButLast = values.slice(0, -1);
const last = values[values.length - 1];
return `${allButLast.join(separator)}${lastSeparator}${last}`;
}