4444 <div class =" flex grow" >
4545 <BestPhotoTag v-if =" isStarted" />
4646 <div v-if =" !isStarted" class =" flex gap-2" >
47- <Button label =" Not an insect" severity =" danger" icon =" pi pi-times" outlined
48- class =" not-hover:text-white!" @click =" confirmNotInsect($event)"
49- :loading =" isSubmittingNotInsect || loading" />
47+ <AnnotationNotAnInsectButton :observation =" assignment.observation" :loading =" loading"
48+ @on-submit-success =" onSubmitAnnotation(true)" />
5049 <Button v-if =" !isStarted" label =" Annotate this picture" icon =" pi pi-arrow-right" iconPos =" right"
5150 @click =" startAnnotation" :loading =" loading" />
5251 </div >
9897
9998<script setup lang='ts'>
10099import { computed , ref , watch } from ' vue' ;
101- import { useConfirm } from " primevue/useconfirm" ;
102- import { useToast } from " primevue/usetoast" ;
103100import VueMagnifier from ' @websitebeaver/vue-magnifier' ;
104101import ' @websitebeaver/vue-magnifier/styles.css'
105102
106103import { AnnotationType } from ' mosquito-alert' ;
107- import type { Assignment , AnnotationRequest } from ' mosquito-alert' ;
104+ import type { Assignment } from ' mosquito-alert' ;
108105
109106import AnnotationForm from ' ./AnnotationForm.vue' ;
110107import AnnotationTypeTag from ' ./AnnotationTypeTag.vue' ;
111108import AnnotationGalleriaFullScreen from ' ./AnnotationGalleriaFullScreen.vue' ;
109+ import AnnotationNotAnInsectButton from ' ./AnnotationNotAnInsectButton.vue' ;
112110import ObservationInfoData from ' ../observations/ObservationInfoData.vue' ;
113111import BestPhotoTag from ' ../photos/BestPhotoTag.vue' ;
114- import { identificationTasksApi } from ' @/services/apiService' ;
115-
116- const confirm = useConfirm ();
117- const toast = useToast ();
118112
119113const numVisible = ref (7 );
120114
@@ -125,7 +119,6 @@ const isFavourite = ref(false);
125119const activePhotoIndex = ref (0 );
126120const showGalleriaFullscreen = ref (false );
127121const observationDialogVisible = ref (false );
128- const isSubmittingNotInsect = ref (false );
129122
130123const activePhoto = computed (() => {
131124 return props .assignment .observation .photos [activePhotoIndex .value ];
@@ -176,38 +169,4 @@ const onSubmitAnnotation = (shouldContinue: boolean) => {
176169 }
177170}
178171
179- const confirmNotInsect = (event : MouseEvent ) => {
180- isSubmittingNotInsect .value = true ;
181- confirm .require ({
182- target: event .currentTarget as HTMLElement ,
183- message: ' Are you sure you want to mark this image as not an insect?' ,
184- icon: ' pi pi-info-circle' ,
185- rejectProps: {
186- label: ' Cancel' ,
187- severity: ' secondary' ,
188- outlined: true
189- },
190- acceptProps: {
191- label: ' Accept' ,
192- severity: ' danger'
193- },
194- accept : () => {
195- const annotationRequest = <AnnotationRequest >{
196- classification: null ,
197- }
198- identificationTasksApi .annotationsCreate ({
199- observationUuid: props .assignment .observation .uuid ,
200- annotationRequest: annotationRequest ,
201- }).then (() => {
202- toast .add ({ severity: ' info' , summary: ' Annotation rejected' , detail: ' Marked as not an insect' , life: 3000 });
203- onSubmitAnnotation (true );
204- }).catch (() => {
205- toast .add ({ severity: ' danger' , summary: ' Failed' , detail: ' Annotation failed' , life: 3000 });
206- })
207- },
208- reject : () => { }
209- });
210- isSubmittingNotInsect .value = false ;
211- }
212-
213172 </script >
0 commit comments