Skip to content

Commit

Permalink
include suggestion score in fields entities
Browse files Browse the repository at this point in the history
  • Loading branch information
leire committed Mar 12, 2024
1 parent 0b8d029 commit 8903802
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
:class="!singleOption ? 'span-entity--clickable' : 'span-entity'"
v-if="!visibleDropdown"
>
<span class="span-entity__text">{{ selectedOption.text }}</span>
<span class="span-entity__text">
<svgicon
class="span-entity__suggestion"
name="suggestion"
width="12"
height="12"
v-if="suggestion.score"
/>{{ selectedOption.text }}
<template v-if="suggestion.score">{{ suggestionScore }}</template></span
>
<BaseButton
class="span-entity__close-button"
@click="removeSelectedOption"
Expand Down Expand Up @@ -39,6 +48,7 @@

<script>
import "assets/icons/close";
import "assets/icons/suggestion";
export default {
name: "EntityComponent",
Expand Down Expand Up @@ -78,6 +88,9 @@ export default {
singleOption() {
return this.options.length === 1;
},
suggestionScore() {
return this.suggestion.score.toFixed(2);
},
},
methods: {
selectOption(option) {
Expand Down Expand Up @@ -150,21 +163,30 @@ export default {
line-height: 1.2;
@include font-size(11px);
}
&__suggestion {
margin-top: 1px;
min-width: 8px;
}
&__text {
display: flex;
gap: 4px;
min-width: 10px;
max-width: v-bind("entityPosition.width");
@include truncate;
@include truncate(auto);
}
&:hover {
position: relative;
max-width: none;
z-index: 1;
background: v-bind("selectedOption.color");
transition: background 0.3s;
> button {
opacity: 1;
}
.span-entity__text {
max-width: none;
}
}
&__close-button {
opacity: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useSpanAnnotationTextFieldViewModel = ({
) => {
const EntityComponentReference = Vue.extend(EntityComponent);
const entity = answer.options.find((e) => e.id === span.entity.id);
const suggestion = spanQuestion.suggestion.getSuggestion({
const suggestion = spanQuestion.suggestion?.getSuggestion({
start: span.from,
end: span.to,
label: entity?.value,
Expand Down

0 comments on commit 8903802

Please sign in to comment.