Fix truncate via adding 'truncateStr'

- Because the 'truncate' function uses 'trunc-html' which seem not to function anymore like expected what has to be investigated further.
This commit is contained in:
Wolfgang Huß 2021-03-29 11:27:27 +02:00
parent ff50273f94
commit 6f79bba69d
2 changed files with 13 additions and 1 deletions

View File

@ -5,7 +5,7 @@
<template #index="scope">{{ scope.index + 1 }}.</template>
<template #id="scope">
<nuxt-link :to="{ path: '/', query: { hashtag: encodeURI(scope.row.id) } }">
<b>#{{ scope.row.id | truncate(20) }}</b>
<b>#{{ scope.row.id | truncateStr(20) }}</b>
</nuxt-link>
</template>
</ds-table>

View File

@ -33,6 +33,18 @@ export default ({ app = {} }) => {
}
return trunc(value, length).html
},
truncateStr: (value = '', length = -1) => {
if (!value || typeof value !== 'string' || value.length <= 0) {
return ''
}
if (length <= 0) {
return value
}
if (length < value.length) {
return value.substring(0, length) + '…'
}
return value
},
list: (value, glue = ', ', truncate = 0) => {
if (!Array.isArray(value) || !value.length) {
return ''