Browse Source

Update useTeacherList.ts

pull/1395/head
Hironsan 3 years ago
parent
commit
c02223d6b4
1 changed files with 19 additions and 2 deletions
  1. 21
      frontend/composables/useTeacherList.ts

21
frontend/composables/useTeacherList.ts

@ -21,7 +21,7 @@ export const useTeacherList = (service: any) => {
await getTeacherList(projectId, exampleId) await getTeacherList(projectId, exampleId)
} }
const annotateExample = async(
const annotateLabel = async(
projectId: string, projectId: string,
exampleId: number, exampleId: number,
labelId: number labelId: number
@ -46,10 +46,27 @@ export const useTeacherList = (service: any) => {
await getTeacherList(projectId, exampleId) await getTeacherList(projectId, exampleId)
} }
const annotateOrRemoveLabel = async(
projectId: string,
exampleId: number,
srcKey: string
) => {
const labelId = parseInt(srcKey, 10)
// @ts-ignore
const annotation = state.teacherList.find(item => item.label === labelId)
if (annotation) {
// @ts-ignore
await removeTeacher(projectId, exampleId, annotation.id)
} else {
await annotateLabel(projectId, exampleId, labelId)
}
}
return { return {
state, state,
getTeacherList, getTeacherList,
annotateExample,
annotateLabel,
annotateOrRemoveLabel,
removeTeacher, removeTeacher,
clearTeacherList, clearTeacherList,
autoLabel, autoLabel,

Loading…
Cancel
Save