Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
rjs_json_form
Commits
0028a25c
Commit
0028a25c
authored
Mar 07, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rm jquery dependence, rm unused code, fix run validation event on change
parent
8f61be1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
113 deletions
+20
-113
README.md
README.md
+1
-1
gadget_json_generated_form.html
gadget_json_generated_form.html
+0
-1
gadget_json_generated_form.js
gadget_json_generated_form.js
+19
-111
No files found.
README.md
View file @
0028a25c
...
...
@@ -14,7 +14,7 @@
[
gadget_json_generated_form.html
](
gadget_json_generated_form.html
)
*
**done**
remove slapos specific code
*
**
partly
done**
remove jquery dependence
*
**done**
remove jquery dependence
*
**partly done**
full support of json schema
*
**done**
support in path
[
rfc6901
](
https://tools.ietf.org/html/rfc6901
)
*
using changeState and mutex
...
...
gadget_json_generated_form.html
View file @
0028a25c
...
...
@@ -8,7 +8,6 @@
<link
href=
"gadget_erp5_page_slap_parameter_form.css"
rel=
"stylesheet"
type=
"text/css"
/>
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"jquery.js"
type=
"text/javascript"
></script>
<script
src=
"gadget_global.js"
></script>
<script
src=
"gadget_json_generated_form.js"
type=
"text/javascript"
></script>
</head>
...
...
gadget_json_generated_form.js
View file @
0028a25c
/*jslint nomen: true, maxlen: 200, indent: 2*/
/*global
rJS, window, document, RSVP, $
, loopEventListener */
/*global
window, document, rJS, RSVP
, loopEventListener */
(
function
(
window
,
document
,
rJS
,
$
,
loopEventListener
)
{
(
function
(
window
,
document
,
rJS
,
RSVP
,
loopEventListener
)
{
"
use strict
"
;
function
decodeJsonPointer
(
_str
)
{
...
...
@@ -474,7 +474,7 @@
field_list
[
i
],
'
change
'
,
false
,
gadget
.
processValidation
.
bind
(
g
,
g
.
options
.
schema_url
)
gadget
.
processValidation
.
bind
(
g
,
g
.
options
.
schema_url
,
undefined
)
));
}
...
...
@@ -548,38 +548,35 @@
return
loadschema_gadget
.
validateJSON
(
schema_url
,
json_dict
);
})
.
push
(
function
(
validation
)
{
var
error_index
,
field_name
,
var
index
,
div
,
divm
,
missing_index
,
missing_field_name
;
field_name
;
$
(
g
.
element
.
querySelectorAll
(
"
span.error
"
)).
each
(
function
(
i
,
span
)
{
g
.
element
.
querySelectorAll
(
"
span.error
"
).
forEach
(
function
(
span
)
{
span
.
textContent
=
""
;
});
$
(
g
.
element
.
querySelectorAll
(
"
div.error-input
"
)).
each
(
function
(
i
,
div
)
{
g
.
element
.
querySelectorAll
(
"
div.error-input
"
).
forEach
(
function
(
div
)
{
div
.
setAttribute
(
"
class
"
,
""
);
});
if
(
validation
.
valid
)
{
return
"
VALID
"
;
}
for
(
error_
index
in
validation
.
errors
)
{
if
(
validation
.
errors
.
hasOwnProperty
(
error_
index
))
{
field_name
=
validation
.
errors
[
error_
index
].
dataPath
;
div
=
$
(
"
.slapos-parameter[name='
"
+
field_name
+
"
']
"
)[
0
]
.
parentNode
;
for
(
index
in
validation
.
errors
)
{
if
(
validation
.
errors
.
hasOwnProperty
(
index
))
{
field_name
=
validation
.
errors
[
index
].
dataPath
;
div
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='
"
+
field_name
+
"
']
"
)
.
parentNode
;
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter error-input
"
);
div
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
errors
[
error_
index
].
message
;
div
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
errors
[
index
].
message
;
}
}
for
(
missing_
index
in
validation
.
missing
)
{
if
(
validation
.
missing
.
hasOwnProperty
(
missing_
index
))
{
missing_field_name
=
validation
.
missing
[
missing_
index
].
dataPath
;
div
m
=
$
(
'
.slapos-parameter[name=
'
+
missing_field_name
+
"
']
"
)[
0
]
.
parentNode
;
div
m
.
setAttribute
(
"
class
"
,
"
error-input
"
);
div
m
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
missing
[
missing_
index
].
message
;
for
(
index
in
validation
.
missing
)
{
if
(
validation
.
missing
.
hasOwnProperty
(
index
))
{
field_name
=
validation
.
missing
[
index
].
dataPath
;
div
=
g
.
element
.
querySelector
(
'
.slapos-parameter[name=
'
+
field_name
+
"
']
"
)
.
parentNode
;
div
.
setAttribute
(
"
class
"
,
"
error-input
"
);
div
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
missing
[
index
].
message
;
}
}
return
"
ERROR
"
;
...
...
@@ -614,78 +611,6 @@
});
})
.
declareMethod
(
'
renderFailoverTextArea
'
,
function
(
content
,
error
)
{
var
g
=
this
,
div
=
document
.
createElement
(
"
div
"
),
div_error
=
document
.
createElement
(
"
div
"
),
span_error
=
document
.
createElement
(
"
span
"
),
textarea
=
document
.
createElement
(
"
textarea
"
),
fieldset
=
document
.
createElement
(
"
fieldset
"
),
fieldset_list
=
g
.
element
.
querySelectorAll
(
'
fieldset
'
),
button0
=
g
.
element
.
querySelector
(
"
button.slapos-show-raw-parameter
"
),
button1
=
g
.
element
.
querySelector
(
"
button.slapos-show-form
"
);
if
(
button0
!==
null
)
{
$
(
button0
).
addClass
(
"
hidden-button
"
);
}
if
(
button1
!==
null
)
{
$
(
button1
).
addClass
(
"
hidden-button
"
);
}
div
.
setAttribute
(
"
class
"
,
"
field
"
);
textarea
.
setAttribute
(
"
rows
"
,
"
10
"
);
textarea
.
setAttribute
(
"
cols
"
,
"
80
"
);
textarea
.
setAttribute
(
"
name
"
,
"
text_content
"
);
textarea
.
textContent
=
content
;
span_error
.
setAttribute
(
"
class
"
,
"
error
"
);
span_error
.
textContent
=
"
Parameter form is not available, use the textarea above for edit the instance parameters.
"
;
div_error
.
setAttribute
(
"
class
"
,
"
error
"
);
div
.
appendChild
(
textarea
);
div_error
.
appendChild
(
span_error
);
div
.
appendChild
(
textarea
);
fieldset
.
appendChild
(
div
);
fieldset
.
appendChild
(
div_error
);
fieldset_list
[
0
].
innerHTML
=
''
;
$
(
fieldset_list
[
1
]).
replaceWith
(
fieldset
);
fieldset_list
[
2
].
innerHTML
=
''
;
return
fieldset
;
})
.
declareMethod
(
'
renderRawParameterTextArea
'
,
function
(
content
)
{
var
g
=
this
,
div
=
document
.
createElement
(
"
div
"
),
div_error
=
document
.
createElement
(
"
div
"
),
textarea
=
document
.
createElement
(
"
textarea
"
),
fieldset
=
document
.
createElement
(
"
fieldset
"
),
fieldset_list
=
g
.
element
.
querySelectorAll
(
'
fieldset
'
);
div
.
setAttribute
(
"
class
"
,
"
field
"
);
textarea
.
setAttribute
(
"
rows
"
,
"
10
"
);
textarea
.
setAttribute
(
"
cols
"
,
"
80
"
);
textarea
.
setAttribute
(
"
name
"
,
"
text_content
"
);
textarea
.
textContent
=
content
;
div
.
appendChild
(
textarea
);
div
.
appendChild
(
textarea
);
fieldset
.
appendChild
(
div
);
fieldset
.
appendChild
(
div_error
);
$
(
fieldset_list
[
1
]).
replaceWith
(
fieldset
);
fieldset_list
[
2
].
innerHTML
=
''
;
return
fieldset
;
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
g
=
this
,
queue
;
...
...
@@ -731,21 +656,4 @@
// });
});
//.declareService(function () {
// var gadget = this;
//return gadget.processValidation(gadget.options.json_url)
// .fail(function (error) {
// var parameter_xml = '';
// console.log(error.stack);
// if (gadget.options.value.parameter.parameter_hash !== undefined) {
// parameter_xml = atob(gadget.options.value.parameter.parameter_hash);
// }
// return gadget.renderFailoverTextArea(parameter_xml, error.toString())
// .push(function () {
// error = undefined;
// return gadget;
// });
// });
//});
}(
window
,
document
,
rJS
,
$
,
loopEventListener
));
\ No newline at end of file
}(
window
,
document
,
rJS
,
RSVP
,
loopEventListener
));
\ No newline at end of file
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