Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<div>
<div class="task-name">{{task.name}}</div>
<div class="task-description">{{task.description}}</div>
<div class="meta-annotation-task">
<div class="task-header">
<div class="task-name">{{task.name}}</div>
<div class="task-description">{{task.description}}</div>
</div>
<div class="task-values-container">
<button class="btn btn-outline-primary task-value"
:class="optionStyle(option)"
Expand Down Expand Up @@ -41,24 +43,65 @@ export default {
</script>

<style scoped lang="scss">
.meta-annotation-task {
min-width: 0;
container-type: inline-size;
}

.task-header {
display: flex;
align-items: baseline;
min-width: 0;
}

.task-name {
font-size: 16px;
padding: 10px 15px 5px 15px;
display: inline-block;
width: 125px;
flex: 0 1 125px;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.task-description {
font-size: 12px;
padding: 10px 15px 5px 15px;
vertical-align: middle;
display: inline-block;
width: calc(100% - 125px);
flex: 1 1 auto;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

@container (max-width: 380px) {
.task-name {
font-size: 13px;
padding: 6px 8px 2px 8px;
flex-basis: 88px;
}

.task-description {
font-size: 11px;
padding: 6px 8px 2px 8px;
}

.task-values-container {
padding: 0 8px 8px 8px;
gap: 3px;

.task-value {
font-size: 12px;
padding: 0.15rem 0.4rem;
line-height: 1.2;
}
}

.predicted-conf {
font-size: 8pt;
}
}

.selected {
color: #fff;
background-color: $primary-alt !important;
Expand All @@ -79,10 +122,15 @@ export default {
padding: 0 15px 10px 15px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 4px;
min-width: 0;
box-shadow: 0 5px 5px -5px rgba(0,0,0,0.2);

.task-value {
flex: 1 1 auto;
min-width: 0;
white-space: normal;
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,26 @@ export default {
</script>

<style scoped lang="scss">
.meta-task-container {
display: flex;
flex-direction: column;
flex: 0 0 auto;
max-height: 50%;
min-height: 0;
min-width: 0;
width: 100%;
margin-top: auto;
overflow: hidden;

.title {
flex-shrink: 0;
}
}

.meta-task-list {
flex: 1 1 auto;
min-height: 0;
overflow-x: hidden;
overflow-y: auto;
min-height: 250px;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import MetaAnnotationTask from '@/components/usecases/MetaAnnotationTask.vue'

const task = {
id: 1,
name: 'Temporality',
description: 'When the concept occurred',
options: [
{ id: 10, name: 'Current' },
{ id: 11, name: 'Historical' }
],
value: 10,
validated: true,
predicted_value: null,
acc: 0.9
}

describe('MetaAnnotationTask.vue', () => {
it('renders the task name, description and option buttons', () => {
const wrapper = mount(MetaAnnotationTask, { props: { task } })

expect(wrapper.text()).toContain('Temporality')
expect(wrapper.text()).toContain('When the concept occurred')
const buttons = wrapper.findAll('button.task-value')
expect(buttons).toHaveLength(2)
expect(buttons[0].text()).toContain('Current')
expect(buttons[1].text()).toContain('Historical')
})

it('emits select:metaAnno when an option is clicked', async () => {
const wrapper = mount(MetaAnnotationTask, { props: { task } })

await wrapper.findAll('button.task-value')[1].trigger('click')

expect(wrapper.emitted('select:metaAnno')[0]).toEqual([task, task.options[1]])
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { describe, it, expect, vi } from 'vitest'
import { mount, flushPromises } from '@vue/test-utils'
import MetaAnnotationTaskContainer from '@/components/usecases/MetaAnnotationTaskContainer.vue'

const mountContainer = () => {
const mockGet = vi.fn((url: string) => {
if (url === '/api/meta-tasks/') {
return Promise.resolve({
data: {
results: [
{ id: 1, name: 'Temporality', description: 'When', values: [10, 11] },
{ id: 2, name: 'Negation', description: 'Affirmed or negated', values: [12, 13] }
]
}
})
}
if (url === '/api/meta-task-values/') {
return Promise.resolve({
data: {
results: [
{ id: 10, name: 'Current' },
{ id: 11, name: 'Historical' },
{ id: 12, name: 'Affirmed' },
{ id: 13, name: 'Negated' }
]
}
})
}
if (url.startsWith('/api/meta-annotations/')) {
return Promise.resolve({ data: { results: [] } })
}
return Promise.reject(new Error(`Unexpected request: ${url}`))
})

const wrapper = mount(MetaAnnotationTaskContainer, {
props: {
modelPackSet: true,
taskIDs: [1, 2],
selectedEnt: { id: 99 }
},
global: {
mocks: {
$http: { get: mockGet, put: vi.fn(), post: vi.fn(), delete: vi.fn() }
}
}
})

return { wrapper, mockGet }
}

describe('MetaAnnotationTaskContainer.vue', () => {
it('renders fetched meta tasks in a scrollable list', async () => {
const { wrapper } = mountContainer()
await flushPromises()

expect(wrapper.find('.meta-task-container').exists()).toBe(true)
expect(wrapper.find('.meta-task-list').exists()).toBe(true)
expect(wrapper.findAllComponents({ name: 'MetaAnnotationTask' })).toHaveLength(2)
expect(wrapper.text()).toContain('Temporality')
expect(wrapper.text()).toContain('Negation')
})
})
11 changes: 10 additions & 1 deletion medcat-trainer/webapp/frontend/src/views/TrainAnnotations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<div class="sidebar-container">
<plugin-slot name="train-annotations:sidebar" :project="project" />
<transition name="slide-left">
<div>
<div class="sidebar-top">
<concept-summary v-if="!conceptSynonymSelection && !hasRelations" :selectedEnt="currentEnt"
:altSearch="altSearch"
:project="project" :searchFilterDBIndex="searchFilterDBIndex"
Expand Down Expand Up @@ -1025,11 +1025,20 @@ $app-header-height: 60px;
display: flex;
justify-content: space-between;
flex-direction: column;
min-height: 0;
overflow: hidden;
padding: 5px;

.sidebar-top {
flex: 1 1 auto;
min-height: 0;
overflow: auto;
}

.add-annotation {
width: 100%;
flex: 1 1 auto;
min-height: 0;
}
}

Expand Down
Loading