Skip to content

Commit 9c03533

Browse files
authored
Specie info display (#501)
* regroup species * client side grouping, hover icon for truncated text
1 parent 6fdd14d commit 9c03533

2 files changed

Lines changed: 55 additions & 15 deletions

File tree

bats_ai/core/fixtures/species.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -781,20 +781,20 @@
781781
},
782782
{
783783
"fields": {
784-
"category": "noid",
785-
"common_name": "Not a bat/Noise",
784+
"category": "Other",
785+
"common_name": "Noise",
786786
"family": "",
787787
"genus": "",
788-
"species": "Not a bat",
788+
"species": "Noise",
789789
"species_code": "NOISE",
790-
"species_code_6": "NOTBAT"
790+
"species_code_6": "NOISE"
791791
},
792792
"model": "core.Species",
793793
"pk": "65"
794794
},
795795
{
796796
"fields": {
797-
"category": "noid",
797+
"category": "Other",
798798
"common_name": "No Id can be determined",
799799
"family": "",
800800
"genus": "",
@@ -1067,8 +1067,8 @@
10671067
},
10681068
{
10691069
"fields": {
1070-
"category": "noid",
1071-
"common_name": "Code used for surveys that recorded 0 bats",
1070+
"category": "Other",
1071+
"common_name": "Not a bat",
10721072
"family": "",
10731073
"genus": "",
10741074
"species": "",

client/src/components/SingleSpecieEditor.vue

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ export default defineComponent({
5757
multiple: "secondary",
5858
frequency: "warning",
5959
[suggestedSpeciesKey]: "success",
60-
noid: "",
60+
Other: "",
6161
};
6262
6363
const categoryPriority: Record<string, number> = {
6464
[suggestedSpeciesKey]: 0,
6565
single: 1,
6666
multiple: 2,
6767
frequency: 3,
68-
noid: 4,
68+
Other: 4,
6969
};
7070
7171
const inRangeTooltip =
@@ -102,7 +102,7 @@ export default defineComponent({
102102
"Single",
103103
"Multiple",
104104
"Frequency",
105-
"Noid",
105+
"Other",
106106
];
107107
groupsOrder.forEach((key) => {
108108
result.push({ type: "subheader", title: key });
@@ -129,6 +129,10 @@ export default defineComponent({
129129
}
130130
};
131131
132+
const commonNameInfoThreshold = 36;
133+
const showCommonNameInfo = (commonName: string) =>
134+
commonName.length > commonNameInfoThreshold;
135+
132136
return {
133137
search,
134138
selectedCode,
@@ -138,6 +142,7 @@ export default defineComponent({
138142
speciesAutocomplete,
139143
onClearOrDeleteClick,
140144
inRangeTooltip,
145+
showCommonNameInfo,
141146
};
142147
},
143148
});
@@ -163,7 +168,10 @@ export default defineComponent({
163168
:custom-filter="customFilter"
164169
clear-on-select
165170
label="Select species"
166-
:menu-props="{ maxHeight: '300px', maxWidth: '400px' }"
171+
:menu-props="{
172+
maxHeight: '300px',
173+
maxWidth: '400px',
174+
}"
167175
:disabled="disabled"
168176
class="species-autocomplete-fill"
169177
density="compact"
@@ -192,10 +200,23 @@ export default defineComponent({
192200
</v-list-subheader>
193201
</template>
194202
<template #item="{ props: itemProps, item }">
195-
<v-list-item
196-
v-bind="itemProps"
197-
:title="(item.raw as Species).common_name"
198-
>
203+
<v-list-item v-bind="itemProps" class="species-option-item">
204+
<template #title>
205+
<div class="species-option-title-row">
206+
<span class="species-option-title">
207+
{{ (item.raw as Species).common_name }}
208+
</span>
209+
<v-icon
210+
v-if="showCommonNameInfo((item.raw as Species).common_name)"
211+
v-tooltip="(item.raw as Species).common_name"
212+
size="x-small"
213+
color="info"
214+
class="species-option-info-icon"
215+
>
216+
mdi-information-outline
217+
</v-icon>
218+
</div>
219+
</template>
199220
<template #subtitle="{}">
200221
<span>{{ (item.raw as Species).species_code }}</span>
201222
<v-chip
@@ -240,4 +261,23 @@ export default defineComponent({
240261
flex: 1 1 0;
241262
min-width: 0;
242263
}
264+
265+
.species-option-title-row {
266+
display: flex;
267+
align-items: center;
268+
gap: 6px;
269+
min-width: 0;
270+
}
271+
272+
.species-option-title {
273+
flex: 1 1 auto;
274+
min-width: 0;
275+
overflow: hidden;
276+
text-overflow: ellipsis;
277+
white-space: nowrap;
278+
}
279+
280+
.species-option-info-icon {
281+
flex: 0 0 auto;
282+
}
243283
</style>

0 commit comments

Comments
 (0)