Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 21x 21x 20x 20x 4x 4x 2x 4x 15x | /**
* A short, human label for an item, so a notification's reader knows which
* item it is about (a comment under review, an email not sent): the first text-like field with a value, in the entity's field order.
* The value may be a plain string or a multilingual object; it is returned as
* stored and translated by the UI.
*/
function pickItemLabel(entity, item) {
for (const field of entity.fields || []) {
if (field.type !== 'text' && field.type !== 'textarea') continue
const value = item[field.fieldId]
if (typeof value === 'string' && value.trim()) return value.trim().slice(0, 120)
if (value && typeof value === 'object') {
const first = Object.values(value).find((v) => typeof v === 'string' && v.trim())
if (first) return first.trim().slice(0, 120)
}
}
return null
}
module.exports = { pickItemLabel }
|