Fix for too long texture name

This commit is contained in:
Pig Fang 2019-12-08 10:29:49 +08:00
parent e3a34a4013
commit ce5b343617
8 changed files with 36 additions and 3 deletions

View File

@ -6,7 +6,7 @@
<div class="card-footer pb-2 pt-2 pl-1 pr-1"> <div class="card-footer pb-2 pt-2 pl-1 pr-1">
<div class="container d-flex justify-content-between"> <div class="container d-flex justify-content-between">
<span data-test="name" :title="name"> <span data-test="name" :title="name">
{{ textureName }} <small>({{ type }})</small> {{ textureName|truncate }} <small>({{ type }})</small>
</span> </span>
<a class="float-right dropdown"> <a class="float-right dropdown">
@ -43,6 +43,7 @@
<script> <script>
import setAsAvatar from './mixins/setAsAvatar' import setAsAvatar from './mixins/setAsAvatar'
import removeClosetItem from './mixins/removeClosetItem' import removeClosetItem from './mixins/removeClosetItem'
import truncateText from './mixins/truncateText'
import { showModal, toast } from '../scripts/notify' import { showModal, toast } from '../scripts/notify'
import { truthy } from '../scripts/validators' import { truthy } from '../scripts/validators'
@ -51,6 +52,7 @@ export default {
mixins: [ mixins: [
removeClosetItem, removeClosetItem,
setAsAvatar, setAsAvatar,
truncateText,
], ],
props: { props: {
tid: { tid: {

View File

@ -10,7 +10,7 @@
<div class="card-footer pb-0 pt-2 pl-1 pr-1"> <div class="card-footer pb-0 pt-2 pl-1 pr-1">
<div class="container d-flex justify-content-between"> <div class="container d-flex justify-content-between">
<p> <p>
<span :title="name">{{ name }} <span :title="name">{{ name|truncate }}
<small>{{ $t('skinlib.filter.' + type) }}</small> <small>{{ $t('skinlib.filter.' + type) }}</small>
</span> </span>
</p> </p>
@ -35,12 +35,14 @@
<script> <script>
import addClosetItem from './mixins/addClosetItem' import addClosetItem from './mixins/addClosetItem'
import removeClosetItem from './mixins/removeClosetItem' import removeClosetItem from './mixins/removeClosetItem'
import truncateText from './mixins/truncateText'
export default { export default {
name: 'SkinLibItem', name: 'SkinLibItem',
mixins: [ mixins: [
addClosetItem, addClosetItem,
removeClosetItem, removeClosetItem,
truncateText,
], ],
props: { props: {
tid: Number, tid: Number,

View File

@ -0,0 +1,9 @@
import Vue from 'vue'
export default Vue.extend({
filters: {
truncate(text: string = ''): string {
return text.length > 15 ? `${text.slice(0, 15)}...` : text
},
},
})

View File

@ -91,7 +91,7 @@
<tr> <tr>
<td v-t="'skinlib.show.name'" /> <td v-t="'skinlib.show.name'" />
<td> <td>
{{ name.length > 15 ? `${name.slice(0, 15)}...` : name }} {{ name|truncate }}
<small v-if="hasEditPermission"> <small v-if="hasEditPermission">
<a v-t="'skinlib.show.edit'" href="#" @click="changeTextureName" /> <a v-t="'skinlib.show.edit'" href="#" @click="changeTextureName" />
</small> </small>
@ -213,6 +213,7 @@ import setAsAvatar from '../../components/mixins/setAsAvatar'
import addClosetItem from '../../components/mixins/addClosetItem' import addClosetItem from '../../components/mixins/addClosetItem'
import removeClosetItem from '../../components/mixins/removeClosetItem' import removeClosetItem from '../../components/mixins/removeClosetItem'
import emitMounted from '../../components/mixins/emitMounted' import emitMounted from '../../components/mixins/emitMounted'
import truncateText from '../../components/mixins/truncateText'
import ApplyToPlayerDialog from '../../components/ApplyToPlayerDialog.vue' import ApplyToPlayerDialog from '../../components/ApplyToPlayerDialog.vue'
import { showModal, toast } from '../../scripts/notify' import { showModal, toast } from '../../scripts/notify'
import { truthy } from '../../scripts/validators' import { truthy } from '../../scripts/validators'
@ -229,6 +230,7 @@ export default {
addClosetItem, addClosetItem,
removeClosetItem, removeClosetItem,
setAsAvatar, setAsAvatar,
truncateText,
], ],
props: { props: {
baseUrl: { baseUrl: {

View File

@ -122,3 +122,10 @@ test('no avatar option if texture is cape', () => {
const wrapper = mount(ClosetItem, { propsData: factory({ type: 'cape' }) }) const wrapper = mount(ClosetItem, { propsData: factory({ type: 'cape' }) })
expect(wrapper.findAll('.dropdown-item')).toHaveLength(3) expect(wrapper.findAll('.dropdown-item')).toHaveLength(3)
}) })
test('truncate too long texture name', () => {
const wrapper = mount(ClosetItem, {
propsData: factory({ name: 'very-very-long-texture-name' }),
})
expect(wrapper.text()).toContain('very-very-long-...')
})

View File

@ -102,3 +102,12 @@ test('add to closet', async () => {
await flushPromises() await flushPromises()
expect(wrapper.emitted('like-toggled')[0]).toEqual([true]) expect(wrapper.emitted('like-toggled')[0]).toEqual([true])
}) })
test('truncate too long texture name', () => {
const wrapper = mount(SkinLibItem, {
propsData: {
name: 'very-very-long-texture-name',
},
})
expect(wrapper.text()).toContain('very-very-long-...')
})

View File

@ -30,6 +30,7 @@
- Fixed that error page doesn't display when using an unsupported hash algorithm. - Fixed that error page doesn't display when using an unsupported hash algorithm.
- Fixed fallback when unknown locale is detected. - Fixed fallback when unknown locale is detected.
- Fixed compatibility with PHP 7.4. - Fixed compatibility with PHP 7.4.
- Fixed the display problem for too long texture name.
## Removed ## Removed

View File

@ -30,6 +30,7 @@
- 当使用了不支持的密码加密算法时,错误页面没有正确显示的问题 - 当使用了不支持的密码加密算法时,错误页面没有正确显示的问题
- 修复不能针对未知语言进行降级的问题 - 修复不能针对未知语言进行降级的问题
- 与 PHP 7.4 的兼容问题 - 与 PHP 7.4 的兼容问题
- 材质名过长时的显示问题
## 移除 ## 移除