2021-01-29 09:18:22 +01:00
|
|
|
<template lang="pug">
|
2021-04-23 17:23:02 +02:00
|
|
|
tr(v-show="value")
|
|
|
|
th {{ label }}
|
2021-01-29 09:18:22 +01:00
|
|
|
td(:class="valueClasses")
|
2021-04-23 17:23:02 +02:00
|
|
|
| {{ formattedValue }}
|
2021-01-29 09:18:22 +01:00
|
|
|
cite
|
2021-04-23 17:23:02 +02:00
|
|
|
a(href="javascript:void(null);" @click="showMore" v-if="shouldCollapseText") show more...
|
2021-01-29 09:18:22 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'VTr',
|
|
|
|
props: {
|
|
|
|
label: {
|
|
|
|
type: String,
|
2021-04-23 17:23:02 +02:00
|
|
|
required: true,
|
|
|
|
default: ''
|
2021-01-29 09:18:22 +01:00
|
|
|
},
|
|
|
|
valueClasses: {
|
|
|
|
type: String,
|
2021-04-23 17:23:02 +02:00
|
|
|
required: false,
|
|
|
|
default: ''
|
2021-01-29 09:18:22 +01:00
|
|
|
},
|
|
|
|
value: {
|
2021-04-23 17:23:02 +02:00
|
|
|
type: [String, Number]
|
2021-01-29 09:18:22 +01:00
|
|
|
},
|
|
|
|
maxLength: {
|
|
|
|
type: Number,
|
|
|
|
default: 300
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
showAll: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-04-23 17:23:02 +02:00
|
|
|
shouldCollapseText () {
|
|
|
|
return this.value && this.value.length > this.maxLength && !this.showAll
|
2021-01-29 09:18:22 +01:00
|
|
|
},
|
|
|
|
formattedValue () {
|
2021-04-23 17:23:02 +02:00
|
|
|
if (this.shouldCollapseText) {
|
|
|
|
return this.value.substr(0, this.maxLength)
|
|
|
|
} else {
|
|
|
|
return this.value
|
2021-01-29 09:18:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
showMore () {
|
|
|
|
this.showAll = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|