Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-workflow
Commits
34f2e61f
Commit
34f2e61f
authored
2 years ago
by
Amit Sharma
Browse files
Options
Download
Patches
Plain Diff
Added env based odk from files
parent
c8a4107a
main
dev
feat/centro
feature/formlistapi
fix/remove-forms
revert-67-contributeByGitpod
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
apps/wrapper/src/components/GenericForm/index.js
+12
-7
apps/wrapper/src/components/GenericForm/index.js
apps/wrapper/src/components/GenericForm/index.module.css
+29
-1
apps/wrapper/src/components/GenericForm/index.module.css
apps/wrapper/src/workflow_first.json
+3
-3
apps/wrapper/src/workflow_first.json
packages/form-manager/src/app.controller.ts
+4
-4
packages/form-manager/src/app.controller.ts
with
48 additions
and
15 deletions
+48
-15
apps/wrapper/src/components/GenericForm/index.js
+
12
−
7
View file @
34f2e61f
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
styles
from
'
./index.module.css
'
;
import
styles
from
'
./index.module.css
'
;
const
GITPOD_URL
=
process
.
env
.
GITPOD_WORKSPACE_URL
const
GenericForm
=
(
props
)
=>
{
const
GenericForm
=
(
props
)
=>
{
const
{
selectedFlow
}
=
props
;
const
{
selectedFlow
}
=
props
;
const
formSpec
=
require
(
`../../
${
selectedFlow
.
config
}
`
);
const
formSpec
=
require
(
`../../
${
selectedFlow
.
config
}
`
);
...
@@ -12,21 +14,21 @@ const GenericForm = (props) => {
...
@@ -12,21 +14,21 @@ const GenericForm = (props) => {
const
getFormURI
=
(
form
,
ofsd
,
prefillSpec
)
=>
{
const
getFormURI
=
(
form
,
ofsd
,
prefillSpec
)
=>
{
console
.
log
(
form
,
ofsd
,
prefillSpec
);
console
.
log
(
form
,
ofsd
,
prefillSpec
);
return
encodeURIComponent
(
`
https://enketo-manager-ratings-tech.samagra.io/
?form=
${
form
}
&onFormSuccessData=
${
encodeFunction
(
ofsd
)}
&prefillSpec=
${
encodeFunction
(
prefillSpec
)}
`
);
return
encodeURIComponent
(
`
${
GITPOD_URL
.
slice
(
0
,
GITPOD_URL
.
indexOf
(
'
/
'
)
+
2
)
+
"
3006-
"
+
GITPOD_URL
.
slice
(
GITPOD_URL
.
indexOf
(
'
/
'
)
+
2
)}
/prefill
?form=
${
form
}
&onFormSuccessData=
${
encodeFunction
(
ofsd
)}
&prefillSpec=
${
encodeFunction
(
prefillSpec
)}
`
);
}
}
const
startingForm
=
formSpec
.
start
;
const
startingForm
=
formSpec
.
start
ingForm
;
const
[
formId
,
setFormId
]
=
useState
(
startingForm
);
const
[
formId
,
setFormId
]
=
useState
(
startingForm
);
const
[
encodedFormSpec
,
setEncodedFormSpec
]
=
useState
(
encodeURI
(
JSON
.
stringify
(
formSpec
.
forms
[
formId
])));
const
[
encodedFormSpec
,
setEncodedFormSpec
]
=
useState
(
encodeURI
(
JSON
.
stringify
(
formSpec
.
forms
[
formId
])));
const
[
onFormSuccessData
,
setOnFormSuccessData
]
=
useState
(
undefined
);
const
[
onFormSuccessData
,
setOnFormSuccessData
]
=
useState
(
undefined
);
const
[
onFormFailureData
,
setOnFormFailureData
]
=
useState
(
undefined
);
const
[
onFormFailureData
,
setOnFormFailureData
]
=
useState
(
undefined
);
const
[
encodedFormURI
,
setEncodedFormURI
]
=
useState
(
getFormURI
(
formId
,
formSpec
.
forms
[
formId
].
onSuccess
,
formSpec
.
forms
[
formId
].
prefill
));
const
[
encodedFormURI
,
setEncodedFormURI
]
=
useState
(
getFormURI
(
formId
,
formSpec
.
forms
[
formId
].
on
Form
Success
,
formSpec
.
forms
[
formId
].
prefill
));
useEffect
(()
=>
{
useEffect
(()
=>
{
// Manage onNext
// Manage onNext
window
.
addEventListener
(
'
message
'
,
function
(
e
)
{
window
.
addEventListener
(
'
message
'
,
function
(
e
)
{
const
data
=
e
.
data
;
const
data
=
e
.
data
;
try
{
try
{
/* message = {
/* message = {
nextForm: "formID",
nextForm: "formID",
...
@@ -54,11 +56,14 @@ const GenericForm = (props) => {
...
@@ -54,11 +56,14 @@ const GenericForm = (props) => {
return
(
return
(
<
div
className
=
{
styles
.
container
}
>
<
div
className
=
{
styles
.
container
}
>
<
div
>
ODK
FORM
<
/div
>
<
div
className
=
{
styles
.
header
}
>
<
div
>
Go
back
<
/div
>
<
div
>
{
selectedFlow
.
name
}
<
/div
>
<
/div
>
<
iframe
title
=
'
current-form
'
<
iframe
title
=
'
current-form
'
style
=
{{
height
:
"
100vh
"
,
width
:
"
100vw
"
}
}
className
=
{
styles
.
odkForm
}
src
=
{
src
=
{
`
http://localhost:8005
/preview?formSpec=
${
encodedFormSpec
}
&xform=
${
encodedFormURI
}
`
`
${
GITPOD_URL
.
slice
(
0
,
GITPOD_URL
.
indexOf
(
'
/
'
)
+
2
)
+
"
8065-
"
+
GITPOD_URL
.
slice
(
GITPOD_URL
.
indexOf
(
'
/
'
)
+
2
)}
/preview?formSpec=
${
encodedFormSpec
}
&xform=
${
encodedFormURI
}
`
}
}
/
>
/
>
<
/div
>
<
/div
>
...
...
This diff is collapsed.
Click to expand it.
apps/wrapper/src/components/GenericForm/index.module.css
+
29
−
1
View file @
34f2e61f
.container
{
.container
{
height
:
100vh
;
display
:
flex
;
flex-direction
:
column
;
gap
:
1rem
;
align-items
:
center
;
width
:
40vw
;
padding-bottom
:
2rem
;
}
.header
{
display
:
flex
;
flex-direction
:
row
;
width
:
100%
;
justify-content
:
space-between
;
}
.header
:nth-child
(
1
)
{
font-size
:
1rem
;
color
:
#ffc119
;
}
.header
:nth-child
(
2
)
{
font-size
:
3rem
;
color
:
#ffc119
;
}
.odkForm
{
height
:
90%
;
width
:
100%
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
apps/wrapper/src/workflow_first.json
+
3
−
3
View file @
34f2e61f
{
{
"forms"
:
{
"forms"
:
{
"
test
"
:
{
"
nursing
"
:
{
"skipOnSuccessMessage"
:
true
,
"skipOnSuccessMessage"
:
true
,
"submissionURL"
:
"http://esamwad.samagra.io/api/v4/form/submit"
,
"submissionURL"
:
"http://esamwad.samagra.io/api/v4/form/submit"
,
"name"
:
"Test Form"
,
"name"
:
"
Nursing
Test Form"
,
"isSuccess"
:
"async (formData) => { console.log('From isSuccess', formData.getElementsByTagName('reg_no')[0].textContent); return formData.getElementsByTagName('reg_no')[0].textContent === 'registration123'; }"
,
"isSuccess"
:
"async (formData) => { console.log('From isSuccess', formData.getElementsByTagName('reg_no')[0].textContent); return formData.getElementsByTagName('reg_no')[0].textContent === 'registration123'; }"
,
"messageOnFailure"
:
"Form submission failed"
,
"messageOnFailure"
:
"Form submission failed"
,
"messageOnSuccess"
:
"Form submitted successfully or Maybe you are already registered"
,
"messageOnSuccess"
:
"Form submitted successfully or Maybe you are already registered"
,
...
@@ -44,6 +44,6 @@
...
@@ -44,6 +44,6 @@
}
}
}
}
},
},
"startingForm"
:
"
test
"
,
"startingForm"
:
"
nursing
"
,
"metaData"
:
{}
"metaData"
:
{}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
packages/form-manager/src/app.controller.ts
+
4
−
4
View file @
34f2e61f
...
@@ -129,10 +129,10 @@ export class AppController {
...
@@ -129,10 +129,10 @@ export class AppController {
}
}
};
};
@
Get
()
//
@Get()
getHello
():
string
{
//
getHello(): string {
return
this
.
appService
.
getHello
();
//
return this.appService.getHello();
}
//
}
@
Post
(
'
prefill
'
)
@
Post
(
'
prefill
'
)
getPrefill
(@
Body
()
prefillDto
:
PrefillDto
):
string
{
getPrefill
(@
Body
()
prefillDto
:
PrefillDto
):
string
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets