Skip to content
Snippets Groups Projects
Commit 70e6e543 authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Merge branch 'truncate-null' into 'master'

Handle null or undefined values in truncate mixin

Closes #1037

See merge request teklia/arkindex/frontend!1329
parents 3c14eab4 7d0f57f9
No related branches found
No related tags found
1 merge request!1329Handle null or undefined values in truncate mixin
......@@ -2,18 +2,17 @@ import { TRUNCATE_LENGTHS } from './config'
import { ensureArray } from './helpers'
const truncateFilter = maxLength => text => {
return text.length > maxLength ? text.slice(0, maxLength) + '' : text
}
const truncateFilters = {
truncateSelect: truncateFilter(TRUNCATE_LENGTHS.select),
truncateLong: truncateFilter(TRUNCATE_LENGTHS.long),
truncateShort: truncateFilter(TRUNCATE_LENGTHS.short),
truncateNotification: truncateFilter(TRUNCATE_LENGTHS.notification)
if (text?.length > maxLength) return text.slice(0, maxLength) + ''
return text ?? ''
}
export const truncateMixin = {
methods: truncateFilters
methods: {
truncateSelect: truncateFilter(TRUNCATE_LENGTHS.select),
truncateLong: truncateFilter(TRUNCATE_LENGTHS.long),
truncateShort: truncateFilter(TRUNCATE_LENGTHS.short),
truncateNotification: truncateFilter(TRUNCATE_LENGTHS.notification)
}
}
const corporaFilters = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment