1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

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

This commit is contained in:
James Player 2025-03-17 15:35:51 +13:00 committed by GitHub
parent b0de6d41b7
commit d5981a4be9
10 changed files with 114 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}`;
}