File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
packages/web-forms/src/components Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -121,10 +121,19 @@ initializeForm(props.formXml, {
121121 initializeFormError .value = new FormInitializationError (cause );
122122 });
123123
124+ type BeforeSubmitCallback = () => void ;
125+ const beforeSubmitCallbacks: BeforeSubmitCallback [] = [];
126+ provide <(callback : BeforeSubmitCallback ) => void >(
127+ ' registerBeforeSubmit' ,
128+ (callback : BeforeSubmitCallback ) => beforeSubmitCallbacks .push (callback )
129+ );
130+
124131const handleSubmit = () => {
125132 const root = odkForm .value ;
126133
127134 if (root ?.validationState .violations ?.length === 0 ) {
135+ // Run all registered beforeSubmit functions
136+ beforeSubmitCallbacks .forEach ((callback ) => callback ());
128137 // eslint-disable-next-line @typescript-eslint/no-floating-promises
129138 emitSubmit (root );
130139 // eslint-disable-next-line @typescript-eslint/no-floating-promises
Original file line number Diff line number Diff line change 22import type { GeopointInputNode } from ' @getodk/xforms-engine' ;
33import Button from ' primevue/button' ;
44import PrimeProgressSpinner from ' primevue/progressspinner' ;
5- import { computed , ref } from ' vue' ;
5+ import { inject , computed , ref } from ' vue' ;
66
77interface Coordinates {
88 latitude: string ;
@@ -101,6 +101,10 @@ const observer = new IntersectionObserver(
101101 { threshold: 0.6 }
102102);
103103
104+ const registerBeforeSubmit = inject <(callback : () => void ) => void >(' registerBeforeSubmit' );
105+ // Autosave geopoint value before submitting the form.
106+ registerBeforeSubmit ?.(() => save ());
107+
104108const start = () => {
105109 geoLocationError .value = false ;
106110 if (watchID .value ) {
You can’t perform that action at this time.
0 commit comments