@@ -35,7 +35,23 @@ const props = defineProps({
3535const title = computed <string >(
3636 () => props .customTitle ?? (props .isReference ? " Reference" : " Hypothesis" ),
3737)
38- const selectedJob = ref <string >()
38+ const selectedJob = computed ({
39+ // getter
40+ get() {
41+ return props .isReference ? jobSelectionStore .referenceJobId : jobSelectionStore .hypothesisJobId
42+ },
43+ // setter
44+ set(newValue ) {
45+ // Note: we are using destructuring assignment syntax here.
46+ if (props .isReference ) {
47+ jobSelectionStore .referenceJobId = newValue
48+ } else {
49+ jobSelectionStore .hypothesisJobId = newValue
50+ }
51+ }
52+ })
53+
54+
3955// Whether there are documents that have not been tagged yet.
4056// Not relevant for source layer.
4157const untaggedDocsExist = computed (() => {
@@ -55,27 +71,4 @@ const sourceLayerHasMissingAnnotations = computed(() => {
5571 if (job .tagger .id !== SOURCE_LAYER ) return false
5672 return job .progress .finished !== documentsStore .numSourceAnnotations
5773})
58-
59- // Watches & mounts
60- // watch both referenceJobId and hypothesisJobId
61- watch (
62- () => [jobSelectionStore .referenceJobId , jobSelectionStore .hypothesisJobId ],
63- () => {
64- if (props .isReference )
65- selectedJob .value = jobSelectionStore .referenceJobId
66- else selectedJob .value = jobSelectionStore .hypothesisJobId
67- },
68- { immediate: true },
69- )
70- // reverse
71- watch (
72- selectedJob ,
73- () => {
74- if (! selectedJob .value ) return
75- if (props .isReference )
76- jobSelectionStore .referenceJobId = selectedJob .value
77- else jobSelectionStore .hypothesisJobId = selectedJob .value
78- },
79- { immediate: true },
80- )
8174 </script >
0 commit comments