11import stores from "@/stores"
2- import { type Job , SOURCE_LAYER } from "@/types/jobs"
2+ import { type Job } from "@/types/jobs"
33import type { SelectOption } from "@/types/ui/select"
44import { useRouteQuery } from "@vueuse/router"
55
66/** Stores the current job selection from the <select>. Used in Evaluation & Export. */
77const useJobSelection = defineStore ( "jobSelection" , ( ) => {
88 // Stores
99 const { jobs } = storeToRefs ( stores . useJobs ( ) )
10- const { reload } = stores . useJobs ( )
11- const corpora = stores . useCorpora ( )
12- const documentsStore = stores . useDocuments ( )
10+ const { corpusId } = storeToRefs ( stores . useCorpora ( ) )
1311
1412 // Fields
1513 const hypothesisId = useRouteQuery < string > ( "hypothesis" )
@@ -20,29 +18,15 @@ const useJobSelection = defineStore("jobSelection", () => {
2018 const options = computed < SelectOption [ ] > ( ( ) : SelectOption [ ] =>
2119 jobs . value
2220 . filter ( ( j : Job ) => j . progress . finished > 0 )
23- . map ( ( j : Job ) => ( { value : j . tagger . id , text : formatJobString ( j ) } ) ) ,
24- )
25-
26- watch (
27- ( ) => corpora . corpusId ,
28- ( ) => {
29- hypothesisId . value = undefined
30- referenceId . value = undefined
31- } ,
21+ . map ( ( j : Job ) => ( { value : j . tagger . id , text : format ( j ) } ) ) ,
3222 )
3323
3424 /** Format as displayed in the <select> */
35- function formatJobString ( job : Job ) : string {
36- const total = job . progress . total
37- let finished = job . progress . finished
38- if ( job . tagger . id === SOURCE_LAYER ) {
39- finished = documentsStore . numSourceAnnotations
40- return `source annotations [${ finished } /${ total } docs]`
41- }
42- return `${ job . tagger . id } (${ job . tagger . description } ) [${ finished } /${ total } docs]`
25+ function format ( job : Job ) : string {
26+ return `${ job . tagger . id } (${ job . tagger . description } ) [${ job . progress . finished } /${ job . progress . total } docs]`
4327 }
4428
45- reload ( )
29+ watch ( corpusId , ( ) => { hypothesisId . value = undefined ; referenceId . value = undefined } )
4630
4731 return { hypothesisId, referenceId, options }
4832} )
0 commit comments