Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-ui
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WEBGDE-Components
web-ui
Commits
9bc578fc
Commit
9bc578fc
authored
Sep 11, 2023
by
Owen Ryan Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed implementation for generating "others" field in options.
parent
dd374a8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
95 deletions
+109
-95
generateFields.js
...bContent/WebGde-Widgets/DataInputWidget/generateFields.js
+108
-94
NKTI_Schema.json
.../WebContent/WebGde-Widgets/sample_schema/NKTI_Schema.json
+1
-1
No files found.
WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
View file @
9bc578fc
...
@@ -466,60 +466,67 @@ const inputChecklist = (key, validation) => {
...
@@ -466,60 +466,67 @@ const inputChecklist = (key, validation) => {
var
dropdownContent
=
document
.
createElement
(
'div'
);
var
dropdownContent
=
document
.
createElement
(
'div'
);
dropdownContent
.
classList
.
add
(
'dropdown-content'
);
dropdownContent
.
classList
.
add
(
'dropdown-content'
);
dropdown1
.
appendChild
(
dropdownContent
);
dropdown1
.
appendChild
(
dropdownContent
);
var
isOther
=
false
;
// Create the checkboxes for each item
// Create the checkboxes for each item
items
.
forEach
(
function
(
item
,
index
)
{
items
.
forEach
(
function
(
item
,
index
)
{
var
div
=
document
.
createElement
(
'div'
);
if
(
item
.
toLowerCase
()
===
"other"
||
item
.
toLowerCase
()
===
"others"
){
div
.
classList
.
add
(
'checkbox'
);
isOther
=
true
;
}
else
{
var
checkbox
=
document
.
createElement
(
'input'
);
var
div
=
document
.
createElement
(
'div'
);
checkbox
.
type
=
'checkbox'
;
div
.
classList
.
add
(
'checkbox'
);
checkbox
.
name
=
'checkboxChoices'
;
checkbox
.
value
=
item
;
var
checkbox
=
document
.
createElement
(
'input'
);
if
(
index
==
0
)
checkbox
.
setAttribute
(
'id'
,
`
${
key
}
`
);
checkbox
.
type
=
'checkbox'
;
checkbox
.
name
=
'checkboxChoices'
;
div
.
appendChild
(
checkbox
);
checkbox
.
value
=
item
;
var
label
=
document
.
createTextNode
(
item
);
if
(
index
==
0
)
checkbox
.
setAttribute
(
'id'
,
`
${
key
}
`
);
div
.
appendChild
(
label
);
dropdownContent
.
appendChild
(
div
)
div
.
appendChild
(
checkbox
);
var
label
=
document
.
createTextNode
(
item
);
div
.
appendChild
(
label
);
dropdownContent
.
appendChild
(
div
)
}
})
})
// Create the checkbox dependent on an input text value
var
dependentDiv
=
document
.
createElement
(
'div'
);
dependentDiv
.
classList
.
add
(
'checkbox'
);
var
dependentCheckbox
=
document
.
createElement
(
'input'
);
dependentCheckbox
.
type
=
'checkbox'
;
dependentCheckbox
.
name
=
'checkboxChoices'
;
dependentCheckbox
.
id
=
'checkDP'
;
dependentCheckbox
.
value
=
''
;
// Set the value here based on the input text
dependentDiv
.
appendChild
(
dependentCheckbox
);
var
dependentLabel
=
document
.
createTextNode
(
'other'
);
dependentDiv
.
appendChild
(
dependentLabel
);
dropdownContent
.
appendChild
(
dependentDiv
);
// Initially hide the input text box
if
(
isOther
){
var
inputTextBox
=
document
.
createElement
(
'input'
);
// Create the checkbox dependent on an input text value
inputTextBox
.
type
=
'text'
;
var
dependentDiv
=
document
.
createElement
(
'div'
);
inputTextBox
.
id
=
'dependentTB'
;
dependentDiv
.
classList
.
add
(
'checkbox'
);
inputTextBox
.
style
.
display
=
'none'
;
var
dependentCheckbox
=
document
.
createElement
(
'input'
);
inputTextBox
.
style
.
padding
=
'0px'
;
dependentCheckbox
.
type
=
'checkbox'
;
dropdownContent
.
appendChild
(
inputTextBox
);
dependentCheckbox
.
name
=
'checkboxChoices'
;
dependentCheckbox
.
id
=
'checkDP'
;
// Add event listener to the "other" checkbox
dependentCheckbox
.
value
=
''
;
// Set the value here based on the input text
dependentCheckbox
.
addEventListener
(
'change'
,
function
()
{
dependentDiv
.
appendChild
(
dependentCheckbox
);
if
(
dependentCheckbox
.
checked
)
{
inputTextBox
.
style
.
display
=
'inline-block'
;
var
dependentLabel
=
document
.
createTextNode
(
'other'
);
}
else
{
dependentDiv
.
appendChild
(
dependentLabel
);
inputTextBox
.
style
.
display
=
'none'
;
// Hide the input text box when "other" checkbox is unchecked
dropdownContent
.
appendChild
(
dependentDiv
);
}
// Update the value of the dependentCheckbox when the input value changes
// Initially hide the input text box
dependentCheckbox
.
value
=
inputTextBox
.
value
;
var
inputTextBox
=
document
.
createElement
(
'input'
);
});
inputTextBox
.
type
=
'text'
;
inputTextBox
.
id
=
'dependentTB'
;
inputTextBox
.
style
.
display
=
'none'
;
inputTextBox
.
style
.
padding
=
'0px'
;
dropdownContent
.
appendChild
(
inputTextBox
);
// Add event listener to the "other" checkbox
dependentCheckbox
.
addEventListener
(
'change'
,
function
()
{
if
(
dependentCheckbox
.
checked
)
{
inputTextBox
.
style
.
display
=
'inline-block'
;
}
else
{
inputTextBox
.
style
.
display
=
'none'
;
// Hide the input text box when "other" checkbox is unchecked
}
// Update the value of the dependentCheckbox when the input value changes
dependentCheckbox
.
value
=
inputTextBox
.
value
;
});
inputTextBox
.
addEventListener
(
"input"
,
event
=>
{
inputTextBox
.
addEventListener
(
"input"
,
event
=>
{
dependentCheckbox
.
value
=
event
.
target
.
value
;
dependentCheckbox
.
value
=
event
.
target
.
value
;
});
});
}
return
dropdown1
;
return
dropdown1
;
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -546,58 +553,64 @@ const inputRadiolist = (key, validation) => {
...
@@ -546,58 +553,64 @@ const inputRadiolist = (key, validation) => {
var
dropdownContent
=
document
.
createElement
(
'div'
);
var
dropdownContent
=
document
.
createElement
(
'div'
);
dropdownContent
.
classList
.
add
(
'dropdown-content'
);
dropdownContent
.
classList
.
add
(
'dropdown-content'
);
dropdown1
.
appendChild
(
dropdownContent
);
dropdown1
.
appendChild
(
dropdownContent
);
var
isOther
=
false
;
// Create radio buttons for each item
// Create radio buttons for each item
items
.
forEach
((
item
,
index
)
=>
{
items
.
forEach
((
item
,
index
)
=>
{
var
radioDiv
=
document
.
createElement
(
'div'
);
if
(
item
.
toLowerCase
()
===
"other"
||
item
.
toLowerCase
()
===
"others"
){
radioDiv
.
classList
.
add
(
'radio-like-checkbox'
);
isOther
=
true
;
}
else
{
var
radio
=
document
.
createElement
(
'input'
);
var
radioDiv
=
document
.
createElement
(
'div'
);
radio
.
type
=
'radio'
;
radioDiv
.
classList
.
add
(
'radio-like-checkbox'
);
radio
.
name
=
'radioChoices'
;
radio
.
value
=
item
;
var
radio
=
document
.
createElement
(
'input'
);
if
(
index
==
0
)
radio
.
setAttribute
(
'id'
,
`
${
key
}
`
);
radio
.
type
=
'radio'
;
radio
.
name
=
'radioChoices'
;
var
label
=
document
.
createTextNode
(
item
);
radio
.
value
=
item
;
radioDiv
.
appendChild
(
radio
);
if
(
index
==
0
)
radio
.
setAttribute
(
'id'
,
`
${
key
}
`
);
radioDiv
.
appendChild
(
label
);
dropdownContent
.
appendChild
(
radioDiv
);
var
label
=
document
.
createTextNode
(
item
);
});
radioDiv
.
appendChild
(
radio
);
radioDiv
.
appendChild
(
label
);
// Create the radio button dependent on an input text value
dropdownContent
.
appendChild
(
radioDiv
);
var
dependentDiv
=
document
.
createElement
(
'div'
);
dependentDiv
.
classList
.
add
(
'radio-like-checkbox'
);
var
dependentRadio
=
document
.
createElement
(
'input'
);
dependentRadio
.
type
=
'radio'
;
dependentRadio
.
name
=
'radioChoices'
;
dependentRadio
.
value
=
''
;
dependentDiv
.
appendChild
(
dependentRadio
);
var
dependentLabel
=
document
.
createTextNode
(
'other'
);
dependentDiv
.
appendChild
(
dependentLabel
);
dropdownContent
.
appendChild
(
dependentDiv
);
var
inputTextBox
=
document
.
createElement
(
'input'
);
inputTextBox
.
type
=
'text'
;
inputTextBox
.
id
=
'dependentTB'
;
inputTextBox
.
style
.
display
=
'none'
;
inputTextBox
.
style
.
padding
=
'0px'
;
dropdownContent
.
appendChild
(
inputTextBox
);
// Add event listener to the "other" radio button
dependentRadio
.
addEventListener
(
'change'
,
function
()
{
if
(
dependentRadio
.
checked
)
{
inputTextBox
.
style
.
display
=
'inline-block'
;
}
else
{
inputTextBox
.
style
.
display
=
'none'
;
// Hide the input text box when "other" radio button is unchecked
}
}
});
});
if
(
isOther
){
// Create the radio button dependent on an input text value
var
dependentDiv
=
document
.
createElement
(
'div'
);
dependentDiv
.
classList
.
add
(
'radio-like-checkbox'
);
var
dependentRadio
=
document
.
createElement
(
'input'
);
dependentRadio
.
type
=
'radio'
;
dependentRadio
.
name
=
'radioChoices'
;
dependentRadio
.
value
=
''
;
dependentDiv
.
appendChild
(
dependentRadio
);
var
dependentLabel
=
document
.
createTextNode
(
'other'
);
dependentDiv
.
appendChild
(
dependentLabel
);
dropdownContent
.
appendChild
(
dependentDiv
);
var
inputTextBox
=
document
.
createElement
(
'input'
);
inputTextBox
.
type
=
'text'
;
inputTextBox
.
id
=
'dependentTB'
;
inputTextBox
.
style
.
display
=
'none'
;
inputTextBox
.
style
.
padding
=
'0px'
;
dropdownContent
.
appendChild
(
inputTextBox
);
// Add event listener to the "other" radio button
dependentRadio
.
addEventListener
(
'change'
,
function
()
{
if
(
dependentRadio
.
checked
)
{
inputTextBox
.
style
.
display
=
'inline-block'
;
}
else
{
inputTextBox
.
style
.
display
=
'none'
;
// Hide the input text box when "other" radio button is unchecked
}
});
inputTextBox
.
addEventListener
(
"input"
,
event
=>
{
inputTextBox
.
addEventListener
(
"input"
,
event
=>
{
if
(
dependentRadio
.
checked
)
{
if
(
dependentRadio
.
checked
)
{
dependentRadio
.
value
=
event
.
target
.
value
;
dependentRadio
.
value
=
event
.
target
.
value
;
}
}
});
});
}
return
dropdown1
;
return
dropdown1
;
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -815,6 +828,7 @@ const deconstruct = async (section, container, classAttribute) => {
...
@@ -815,6 +828,7 @@ const deconstruct = async (section, container, classAttribute) => {
case
'textarea'
:
case
'textarea'
:
case
'alphanumeric'
:
case
'alphanumeric'
:
case
'alphabet'
:
case
'alphabet'
:
case
'email'
:
input
=
inputString
(
key
,
validation
)
input
=
inputString
(
key
,
validation
)
break
break
case
'specific'
:
case
'specific'
:
...
...
WebGde/WebContent/WebGde-Widgets/sample_schema/NKTI_Schema.json
View file @
9bc578fc
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
"validation"
:
{
"validation"
:
{
"fieldLength"
:
20.0
,
"fieldLength"
:
20.0
,
"collection"
:
"radiolist"
,
"collection"
:
"radiolist"
,
"items"
:
[
"Emergency Room"
,
"Inpatient"
,
"Outpatient"
],
"items"
:
[
"Emergency Room"
,
"Inpatient"
,
"Outpatient"
,
"others"
],
"mandatory"
:
true
"mandatory"
:
true
}
}
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment