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
4e62f742
Commit
4e62f742
authored
Sep 12, 2023
by
Leonard Ambros II
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-WG-387' into 'development'
Changed implementation for generating "others" field in options. See merge request
!58
parents
2df749bb
72b8e641
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
96 deletions
+110
-96
generateFields.js
...bContent/WebGde-Widgets/DataInputWidget/generateFields.js
+108
-94
NKTI_Schema.json
.../WebContent/WebGde-Widgets/sample_schema/NKTI_Schema.json
+2
-2
No files found.
WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
View file @
4e62f742
...
...
@@ -466,60 +466,67 @@ const inputChecklist = (key, validation) => {
var
dropdownContent
=
document
.
createElement
(
'div'
);
dropdownContent
.
classList
.
add
(
'dropdown-content'
);
dropdown1
.
appendChild
(
dropdownContent
);
var
isOther
=
false
;
// Create the checkboxes for each item
items
.
forEach
(
function
(
item
,
index
)
{
var
div
=
document
.
createElement
(
'div'
);
div
.
classList
.
add
(
'checkbox'
);
var
checkbox
=
document
.
createElement
(
'input'
);
checkbox
.
type
=
'checkbox'
;
checkbox
.
name
=
'checkboxChoices'
;
checkbox
.
value
=
item
;
if
(
index
==
0
)
checkbox
.
setAttribute
(
'id'
,
`
${
key
}
`
);
div
.
appendChild
(
checkbox
);
var
label
=
document
.
createTextNode
(
item
);
div
.
appendChild
(
label
);
dropdownContent
.
appendChild
(
div
)
if
(
item
.
toLowerCase
()
===
"other"
||
item
.
toLowerCase
()
===
"others"
){
isOther
=
true
;
}
else
{
var
div
=
document
.
createElement
(
'div'
);
div
.
classList
.
add
(
'checkbox'
);
var
checkbox
=
document
.
createElement
(
'input'
);
checkbox
.
type
=
'checkbox'
;
checkbox
.
name
=
'checkboxChoices'
;
checkbox
.
value
=
item
;
if
(
index
==
0
)
checkbox
.
setAttribute
(
'id'
,
`
${
key
}
`
);
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
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
;
});
if
(
isOther
){
// 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
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
=>
{
dependentCheckbox
.
value
=
event
.
target
.
value
;
});
inputTextBox
.
addEventListener
(
"input"
,
event
=>
{
dependentCheckbox
.
value
=
event
.
target
.
value
;
});
}
return
dropdown1
;
}
catch
(
err
)
{
...
...
@@ -546,58 +553,64 @@ const inputRadiolist = (key, validation) => {
var
dropdownContent
=
document
.
createElement
(
'div'
);
dropdownContent
.
classList
.
add
(
'dropdown-content'
);
dropdown1
.
appendChild
(
dropdownContent
);
var
isOther
=
false
;
// Create radio buttons for each item
items
.
forEach
((
item
,
index
)
=>
{
var
radioDiv
=
document
.
createElement
(
'div'
);
radioDiv
.
classList
.
add
(
'radio-like-checkbox'
);
var
radio
=
document
.
createElement
(
'input'
);
radio
.
type
=
'radio'
;
radio
.
name
=
'radioChoices'
;
radio
.
value
=
item
;
if
(
index
==
0
)
radio
.
setAttribute
(
'id'
,
`
${
key
}
`
);
var
label
=
document
.
createTextNode
(
item
);
radioDiv
.
appendChild
(
radio
);
radioDiv
.
appendChild
(
label
);
dropdownContent
.
appendChild
(
radioDiv
);
});
// 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
if
(
item
.
toLowerCase
()
===
"other"
||
item
.
toLowerCase
()
===
"others"
){
isOther
=
true
;
}
else
{
var
radioDiv
=
document
.
createElement
(
'div'
);
radioDiv
.
classList
.
add
(
'radio-like-checkbox'
);
var
radio
=
document
.
createElement
(
'input'
);
radio
.
type
=
'radio'
;
radio
.
name
=
'radioChoices'
;
radio
.
value
=
item
;
if
(
index
==
0
)
radio
.
setAttribute
(
'id'
,
`
${
key
}
`
);
var
label
=
document
.
createTextNode
(
item
);
radioDiv
.
appendChild
(
radio
);
radioDiv
.
appendChild
(
label
);
dropdownContent
.
appendChild
(
radioDiv
);
}
});
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
=>
{
if
(
dependentRadio
.
checked
)
{
dependentRadio
.
value
=
event
.
target
.
value
;
}
});
inputTextBox
.
addEventListener
(
"input"
,
event
=>
{
if
(
dependentRadio
.
checked
)
{
dependentRadio
.
value
=
event
.
target
.
value
;
}
});
}
return
dropdown1
;
}
catch
(
err
)
{
...
...
@@ -815,6 +828,7 @@ const deconstruct = async (section, container, classAttribute) => {
case
'textarea'
:
case
'alphanumeric'
:
case
'alphabet'
:
case
'email'
:
input
=
inputString
(
key
,
validation
)
break
case
'specific'
:
...
...
WebGde/WebContent/WebGde-Widgets/sample_schema/NKTI_Schema.json
View file @
4e62f742
...
...
@@ -72,8 +72,8 @@
"aka"
:
"field9"
,
"validation"
:
{
"fieldLength"
:
20.0
,
"collection"
:
"
dropdown
"
,
"
options"
:
[
"Emergency Room"
,
"Inpatient"
,
"Outpatient
"
],
"collection"
:
"
radiolist
"
,
"
items"
:
[
"Emergency Room"
,
"Inpatient"
,
"Outpatient"
,
"others
"
],
"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