-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2490 - added SkillNameRouterLink.vue for long skill names in skills …
…table
- Loading branch information
Showing
5 changed files
with
82 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
dashboard-prime/src/components/skills/SkillNameRouterLink.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<script setup> | ||
import { computed, onMounted, ref } from 'vue'; | ||
import StringHighlighter from '@/common-components/utilities/StringHighlighter.js'; | ||
const props = defineProps({ | ||
skill: Object, | ||
subjectId: String, | ||
filterValue: String, | ||
limit: { | ||
type: Number, | ||
required: false, | ||
default: 45, | ||
}, | ||
}); | ||
const slop = ref(15); | ||
const displayFullText = ref(false); | ||
onMounted(() => { | ||
displayFullText.value = props.skill.name.length < props.limit + slop.value; | ||
}); | ||
const truncate = computed(() => { | ||
return props.skill.name.length >= props.limit + slop.value; | ||
}); | ||
const toDisplay = computed(() => { | ||
if (displayFullText.value) { | ||
return `${props.skill.name}`; | ||
} | ||
return `${props.skill.name.substring(0, props.limit)}`; | ||
}); | ||
const highlightedValue = computed(() => { | ||
const value = toDisplay.value; | ||
const filterValue = props.filterValue ? props.filterValue.trim() : ''; | ||
if (filterValue && filterValue.length > 0) { | ||
const highlighted = StringHighlighter.highlight(value, filterValue); | ||
return highlighted || value; | ||
} else { | ||
return value; | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="inline-block"> | ||
<router-link :data-cy="`manageSkillLink_${skill.skillId}`" | ||
tag="span" | ||
:to="{ name:'SkillOverview', params: { projectId: skill.projectId, subjectId: subjectId, skillId: skill.skillId }}" | ||
:aria-label="`Manage skill ${skill.name} via link`"> | ||
<span class="text-lg inline-block" v-html="highlightedValue" /> | ||
</router-link> | ||
<a v-if="truncate" | ||
@click="displayFullText = !displayFullText" | ||
aria-label="Show/Hide truncated text" | ||
data-cy="showMoreOrLessBtn"> | ||
<small v-if="displayFullText" data-cy="showLess"> << less</small> | ||
<small v-else data-cy="showMore"><em>... >> more</em></small> | ||
</a> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
a, | ||
a small { | ||
cursor: pointer; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters