Browse Source

fix post merge with master

pull/1384/head
mauro 3 years ago
parent
commit
241e9022cf
2 changed files with 75 additions and 8 deletions
  1. 6
      frontend/components/tasks/sequenceLabeling/EntityItemBox.vue
  2. 77
      frontend/pages/projects/_id/sequence-labeling/index.vue

6
frontend/components/tasks/sequenceLabeling/EntityItemBox.vue

@ -19,7 +19,6 @@
@selectTarget="selectTarget(chunk)" @selectTarget="selectTarget(chunk)"
@deleteLink="deleteLink($event.id, $event.ndx)" @deleteLink="deleteLink($event.id, $event.ndx)"
@selectNewLinkType="selectNewLinkType($event)" @selectNewLinkType="selectNewLinkType($event)"
@changeLinkType="changeLinkType($event)"
@hideAllLinkMenus="hideAllLinkMenus()" @hideAllLinkMenus="hideAllLinkMenus()"
/> />
<v-menu <v-menu
@ -134,11 +133,6 @@ export default {
default: () => ([]), default: () => ([]),
required: true required: true
}, },
changeLinkType: {
type: Function,
default: () => ([]),
required: true
},
hideAllLinkMenus: { hideAllLinkMenus: {
type: Function, type: Function,
default: () => ([]), default: () => ([]),

77
frontend/pages/projects/_id/sequence-labeling/index.vue

@ -22,11 +22,19 @@
<v-card-text class="title"> <v-card-text class="title">
<entity-item-box <entity-item-box
:labels="labels" :labels="labels"
:link-types="linkTypes"
:text="doc.text" :text="doc.text"
:entities="annotations" :entities="annotations"
:delete-annotation="remove" :delete-annotation="remove"
:update-entity="update" :update-entity="update"
:add-entity="add" :add-entity="add"
:source-chunk="sourceChunk"
:source-link-type="sourceLinkType"
:select-source="selectSource"
:select-target="selectTarget"
:delete-link="deleteLink"
:select-new-link-type="selectNewLinkType"
:hide-all-link-menus="hideAllLinkMenus"
/> />
</v-card-text> </v-card-text>
</v-card> </v-card>
@ -39,12 +47,18 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import {mapGetters} from 'vuex'
import LayoutText from '@/components/tasks/layout/LayoutText' import LayoutText from '@/components/tasks/layout/LayoutText'
import ListMetadata from '@/components/tasks/metadata/ListMetadata' import ListMetadata from '@/components/tasks/metadata/ListMetadata'
import ToolbarLaptop from '@/components/tasks/toolbar/ToolbarLaptop' import ToolbarLaptop from '@/components/tasks/toolbar/ToolbarLaptop'
import ToolbarMobile from '@/components/tasks/toolbar/ToolbarMobile' import ToolbarMobile from '@/components/tasks/toolbar/ToolbarMobile'
import EntityItemBox from '~/components/tasks/sequenceLabeling/EntityItemBox' import EntityItemBox from '~/components/tasks/sequenceLabeling/EntityItemBox'
const NONE = {
id: -1,
none: true
};
export default { export default {
layout: 'workspace', layout: 'workspace',
@ -76,12 +90,19 @@ export default {
annotations: [], annotations: [],
docs: [], docs: [],
labels: [], labels: [],
links: [],
linkTypes: [],
project: {}, project: {},
enableAutoLabeling: false
enableAutoLabeling: false,
sourceChunk: NONE,
sourceLink: NONE,
sourceLinkType: NONE
} }
}, },
computed: { computed: {
...mapGetters('auth', ['isAuthenticated', 'getUsername', 'getUserId']),
shortKeys() { shortKeys() {
return Object.fromEntries(this.labels.map(item => [item.id, [item.suffixKey]])) return Object.fromEntries(this.labels.map(item => [item.id, [item.suffixKey]]))
}, },
@ -108,25 +129,48 @@ export default {
async created() { async created() {
this.labels = await this.$services.label.list(this.projectId) this.labels = await this.$services.label.list(this.projectId)
this.linkTypes = await this.$services.linkTypes.list(this.projectId)
this.project = await this.$services.project.findById(this.projectId) this.project = await this.$services.project.findById(this.projectId)
}, },
methods: { methods: {
async list(docId) { async list(docId) {
this.annotations = await this.$services.sequenceLabeling.list(this.projectId, docId)
this.hideAllLinkMenus();
const annotations = await this.$services.sequenceLabeling.list(this.projectId, docId);
const links = await this.$services.sequenceLabeling.listLinks(this.projectId);
annotations.forEach(function(annotation) {
annotation.links = links.filter(link => link.annotation_id_1 === annotation.id);
});
this.annotations = annotations;
this.links = links;
},
populateLinks() {
const links = this.links;
this.annotations.forEach(function(annotation) {
annotation.links = links.filter(link => link.annotation_id_1 === annotation.id);
});
}, },
async remove(id) { async remove(id) {
this.hideAllLinkMenus();
await this.$services.sequenceLabeling.delete(this.projectId, this.doc.id, id) await this.$services.sequenceLabeling.delete(this.projectId, this.doc.id, id)
await this.list(this.doc.id) await this.list(this.doc.id)
}, },
async add(startOffset, endOffset, labelId) { async add(startOffset, endOffset, labelId) {
this.hideAllLinkMenus();
await this.$services.sequenceLabeling.create(this.projectId, this.doc.id, labelId, startOffset, endOffset) await this.$services.sequenceLabeling.create(this.projectId, this.doc.id, labelId, startOffset, endOffset)
await this.list(this.doc.id) await this.list(this.doc.id)
}, },
async update(labelId, annotationId) { async update(labelId, annotationId) {
this.hideAllLinkMenus();
await this.$services.sequenceLabeling.changeLabel(this.projectId, this.doc.id, annotationId, labelId) await this.$services.sequenceLabeling.changeLabel(this.projectId, this.doc.id, annotationId, labelId)
await this.list(this.doc.id) await this.list(this.doc.id)
}, },
@ -148,6 +192,35 @@ export default {
const approved = !this.doc.isApproved const approved = !this.doc.isApproved
await this.$services.example.approve(this.projectId, this.doc.id, approved) await this.$services.example.approve(this.projectId, this.doc.id, approved)
await this.$fetch() await this.$fetch()
},
selectSource(chunk) {
this.sourceChunk = chunk;
},
async selectTarget(chunk) {
// to avoid duplicated links:
if (!chunk.links.find(ch => ch.id === this.sourceChunk.id)) {
await this.$services.sequenceLabeling.createLink(this.projectId, this.sourceChunk.id, chunk.id, this.sourceLinkType.id, this.getUserId);
await this.list(this.doc.id);
}
this.hideAllLinkMenus();
},
async deleteLink(id, ndx) {
await this.$services.sequenceLabeling.deleteLink(this.projectId, this.sourceChunk.links[ndx].id)
await this.list(this.doc.id)
this.hideAllLinkMenus();
},
selectNewLinkType(type) {
this.sourceLinkType = type;
},
hideAllLinkMenus() {
this.sourceChunk = NONE;
this.sourceLinkType = NONE;
} }
}, },

Loading…
Cancel
Save