Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos.core
Commits
9b56a686
Commit
9b56a686
authored
Oct 17, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio: Fixup required support on parameter editor
parent
a9ed4da5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
29 deletions
+55
-29
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.js
...age_module/rjs_gadget_erp5_page_slap_parameter_form_js.js
+53
-27
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.xml
...ge_module/rjs_gadget_erp5_page_slap_parameter_form_js.xml
+2
-2
No files found.
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.js
View file @
9b56a686
...
@@ -40,8 +40,9 @@
...
@@ -40,8 +40,9 @@
);
);
}
}
function
render_selection
(
json_field
,
default_value
)
{
function
render_selection
(
json_field
,
default_value
,
is_required
)
{
var
option_list
=
[
domsugar
(
'
option
'
,
{
var
property_dict
=
{
size
:
1
},
option_list
=
[
domsugar
(
'
option
'
,
{
value
:
""
,
value
:
""
,
selected
:
(
default_value
===
undefined
)
selected
:
(
default_value
===
undefined
)
})],
})],
...
@@ -77,16 +78,18 @@
...
@@ -77,16 +78,18 @@
value
:
default_value
,
value
:
default_value
,
text
:
default_value
,
text
:
default_value
,
"
data-format
"
:
data_format
,
"
data-format
"
:
data_format
,
selected
:
selected
selected
:
true
}));
}));
}
}
return
domsugar
(
'
select
'
,
{
size
:
1
,
property_dict
[
"
data-format
"
]
=
data_format
;
"
data-format
"
:
data_format
if
(
is_required
)
{
},
option_list
);
property_dict
.
required
=
true
;
}
return
domsugar
(
'
select
'
,
property_dict
,
option_list
);
}
}
function
render_selection_oneof
(
json_field
,
default_value
)
{
function
render_selection_oneof
(
json_field
,
default_value
,
is_required
)
{
var
option_list
=
[
domsugar
(
'
option
'
,
{
var
option_list
=
[
domsugar
(
'
option
'
,
{
value
:
""
,
value
:
""
,
selected
:
(
default_value
===
undefined
)
selected
:
(
default_value
===
undefined
)
...
@@ -114,7 +117,7 @@
...
@@ -114,7 +117,7 @@
},
option_list
);
},
option_list
);
}
}
function
render_textarea
(
json_field
,
default_value
,
data_format
)
{
function
render_textarea
(
json_field
,
default_value
,
data_format
,
is_required
)
{
var
value
=
''
;
var
value
=
''
;
if
(
default_value
!==
undefined
)
{
if
(
default_value
!==
undefined
)
{
if
(
default_value
instanceof
Array
)
{
if
(
default_value
instanceof
Array
)
{
...
@@ -129,14 +132,14 @@
...
@@ -129,14 +132,14 @@
});
});
}
}
function
render_field
(
json_field
,
default_value
)
{
function
render_field
(
json_field
,
default_value
,
is_required
)
{
var
data_format
,
domsugar_input_dict
=
{};
var
data_format
,
domsugar_input_dict
=
{};
if
(
json_field
[
'
enum
'
]
!==
undefined
)
{
if
(
json_field
[
'
enum
'
]
!==
undefined
)
{
return
render_selection
(
json_field
,
default_value
);
return
render_selection
(
json_field
,
default_value
,
is_required
);
}
}
if
(
json_field
.
oneOf
!==
undefined
)
{
if
(
json_field
.
oneOf
!==
undefined
)
{
return
render_selection_oneof
(
json_field
,
default_value
);
return
render_selection_oneof
(
json_field
,
default_value
,
is_required
);
}
}
if
(
json_field
.
type
===
"
boolean
"
)
{
if
(
json_field
.
type
===
"
boolean
"
)
{
...
@@ -147,7 +150,7 @@
...
@@ -147,7 +150,7 @@
if
(
default_value
===
"
false
"
)
{
if
(
default_value
===
"
false
"
)
{
default_value
=
false
;
default_value
=
false
;
}
}
return
render_selection
(
json_field
,
default_value
);
return
render_selection
(
json_field
,
default_value
,
is_required
);
}
}
if
(
json_field
.
type
===
"
array
"
)
{
if
(
json_field
.
type
===
"
array
"
)
{
...
@@ -157,11 +160,11 @@
...
@@ -157,11 +160,11 @@
data_format
=
"
array-number
"
;
data_format
=
"
array-number
"
;
}
}
}
}
return
render_textarea
(
json_field
,
default_value
,
data_format
);
return
render_textarea
(
json_field
,
default_value
,
data_format
,
is_required
);
}
}
if
(
json_field
.
type
===
"
string
"
&&
json_field
.
textarea
===
true
)
{
if
(
json_field
.
type
===
"
string
"
&&
json_field
.
textarea
===
true
)
{
return
render_textarea
(
json_field
,
default_value
,
"
string
"
);
return
render_textarea
(
json_field
,
default_value
,
"
string
"
,
is_required
);
}
}
if
(
default_value
!==
undefined
)
{
if
(
default_value
!==
undefined
)
{
...
@@ -179,6 +182,10 @@
...
@@ -179,6 +182,10 @@
domsugar_input_dict
.
type
=
"
text
"
;
domsugar_input_dict
.
type
=
"
text
"
;
}
}
if
(
is_required
)
{
domsugar_input_dict
.
required
=
true
;
}
return
domsugar
(
'
input
'
,
domsugar_input_dict
);
return
domsugar
(
'
input
'
,
domsugar_input_dict
);
}
}
...
@@ -192,7 +199,8 @@
...
@@ -192,7 +199,8 @@
default_used_list
=
[],
default_used_list
=
[],
default_div
,
default_div
,
span_error
,
span_error
,
span_info
;
span_info
,
is_required
;
if
(
default_dict
===
undefined
)
{
if
(
default_dict
===
undefined
)
{
default_dict
=
{};
default_dict
=
{};
...
@@ -271,6 +279,10 @@
...
@@ -271,6 +279,10 @@
div
.
appendChild
(
label
);
div
.
appendChild
(
label
);
div_input
=
document
.
createElement
(
"
div
"
);
div_input
=
document
.
createElement
(
"
div
"
);
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
is_required
=
false
;
if
((
Array
.
isArray
(
json_field
.
required
))
&&
(
json_field
.
required
.
includes
(
key
)))
{
is_required
=
true
;
}
if
(
json_field
.
properties
[
key
].
type
===
'
object
'
)
{
if
(
json_field
.
properties
[
key
].
type
===
'
object
'
)
{
label
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
label
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
div_input
=
render_subform
(
json_field
.
properties
[
key
],
div_input
=
render_subform
(
json_field
.
properties
[
key
],
...
@@ -278,7 +290,8 @@
...
@@ -278,7 +290,8 @@
div_input
,
div_input
,
path
+
"
/
"
+
key
);
path
+
"
/
"
+
key
);
}
else
{
}
else
{
input
=
render_field
(
json_field
.
properties
[
key
],
default_dict
[
key
]);
input
=
render_field
(
json_field
.
properties
[
key
],
default_dict
[
key
],
is_required
);
input
.
name
=
path
+
"
/
"
+
key
;
input
.
name
=
path
+
"
/
"
+
key
;
input
.
setAttribute
(
"
class
"
,
"
slapos-parameter
"
);
input
.
setAttribute
(
"
class
"
,
"
slapos-parameter
"
);
input
.
setAttribute
(
"
placeholder
"
,
"
"
);
input
.
setAttribute
(
"
placeholder
"
,
"
"
);
...
@@ -317,7 +330,7 @@
...
@@ -317,7 +330,7 @@
div
.
appendChild
(
label
);
div
.
appendChild
(
label
);
div_input
=
document
.
createElement
(
"
div
"
);
div_input
=
document
.
createElement
(
"
div
"
);
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
input
=
render_field
({
"
type
"
:
"
string
"
,
"
textarea
"
:
true
},
default_dict
[
key
]);
input
=
render_field
({
"
type
"
:
"
string
"
,
"
textarea
"
:
true
},
default_dict
[
key
]
,
false
);
input
.
name
=
path
+
"
/
"
+
key
;
input
.
name
=
path
+
"
/
"
+
key
;
input
.
setAttribute
(
"
class
"
,
"
slapos-parameter
"
);
input
.
setAttribute
(
"
class
"
,
"
slapos-parameter
"
);
input
.
setAttribute
(
"
placeholder
"
,
"
"
);
input
.
setAttribute
(
"
placeholder
"
,
"
"
);
...
@@ -592,6 +605,7 @@
...
@@ -592,6 +605,7 @@
for
(
error_index
in
validation
.
errors
)
{
for
(
error_index
in
validation
.
errors
)
{
if
(
validation
.
errors
.
hasOwnProperty
(
error_index
))
{
if
(
validation
.
errors
.
hasOwnProperty
(
error_index
))
{
field_name
=
validation
.
errors
[
error_index
].
dataPath
;
field_name
=
validation
.
errors
[
error_index
].
dataPath
;
if
(
field_name
!==
""
)
{
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
);
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
);
if
(
input_field
===
null
)
{
if
(
input_field
===
null
)
{
field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
);
field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
);
...
@@ -600,6 +614,18 @@
...
@@ -600,6 +614,18 @@
div
=
input_field
.
parentNode
;
div
=
input_field
.
parentNode
;
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter error-input
"
);
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter error-input
"
);
div
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
errors
[
error_index
].
message
;
div
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
errors
[
error_index
].
message
;
}
else
if
(
validation
.
errors
[
error_index
].
code
==
"
302
"
)
{
// OBJECT_REQUIRED use case
field_name
=
"
/
"
+
validation
.
errors
[
error_index
].
params
.
key
;
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
);
if
(
input_field
===
null
)
{
field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
);
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
);
}
div
=
input_field
.
parentNode
;
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter error-input
"
);
div
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
errors
[
error_index
].
message
;
}
}
}
}
}
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.xml
View file @
9b56a686
...
@@ -280,7 +280,7 @@
...
@@ -280,7 +280,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
100
0.42210.9826.36164
</string>
</value>
<value>
<string>
100
3.46178.61021.55398
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -298,7 +298,7 @@
...
@@ -298,7 +298,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
16
56947623.15
</float>
<float>
16
66027007.74
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
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