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
Jérome Perrin
rjs_json_form
Commits
e51a0e05
Commit
e51a0e05
authored
Apr 26, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkValidity(): fix error and improve invalid state information
parent
acc0d2b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
24 deletions
+59
-24
gadget_json_generated_form.js
gadget_json_generated_form.js
+59
-24
No files found.
gadget_json_generated_form.js
View file @
e51a0e05
/*jslint nomen: true, maxlen: 200, indent: 2, maxerr: 100*/
/*jslint nomen: true, maxlen: 200, indent: 2, maxerr: 100*/
/*global window, document, URL, rJS, RSVP, jIO, tv4 */
/*global window, document, URL, rJS, RSVP, jIO, tv4
, location
*/
(
function
(
window
,
document
,
rJS
,
RSVP
,
jIO
,
tv4
)
{
(
function
(
window
,
document
,
location
,
rJS
,
RSVP
,
jIO
,
tv4
)
{
"
use strict
"
;
"
use strict
"
;
var
render_object
,
var
render_object
,
expandSchema
;
expandSchema
;
...
@@ -1416,11 +1416,19 @@
...
@@ -1416,11 +1416,19 @@
return
tv4
.
validateMultiple
(
json_d
,
g
.
props
.
schema
[
""
]);
return
tv4
.
validateMultiple
(
json_d
,
g
.
props
.
schema
[
""
]);
})
})
.
push
(
function
(
validation
)
{
.
push
(
function
(
validation
)
{
var
index
,
var
i
,
tasks
=
[];
error_id
,
error
,
span
,
tasks
=
[],
errors_block
=
g
.
element
.
querySelector
(
"
div.error-block
"
);
if
(
errors_block
)
{
errors_block
.
parentNode
.
removeChild
(
errors_block
);
}
g
.
element
.
querySelectorAll
(
"
.error
"
).
forEach
(
function
(
error_message
)
{
g
.
element
.
querySelectorAll
(
"
.error
"
).
forEach
(
function
(
error_message
)
{
error_message
.
textContent
=
""
;
error_message
.
textContent
=
""
;
error_message
.
removeAttribute
(
"
id
"
);
error_message
.
hidden
=
true
;
error_message
.
hidden
=
true
;
});
});
...
@@ -1433,37 +1441,58 @@
...
@@ -1433,37 +1441,58 @@
return
false
;
return
false
;
});
});
}
}
function
print_error
(
message
)
{
span
=
document
.
createElement
(
"
span
"
);
span
.
setAttribute
(
"
class
"
,
"
error
"
);
span
.
textContent
=
"
errors:
"
;
errors_block
=
document
.
createElement
(
"
div
"
);
errors_block
.
setAttribute
(
"
class
"
,
"
subfield error-block
"
);
errors_block
.
appendChild
(
span
);
function
print_error
(
error
,
errorUid
,
errorId
)
{
return
function
(
element
)
{
return
function
(
element
)
{
var
id
=
element
.
id
,
var
id
=
element
.
id
,
error_message
;
error_message
,
a
=
document
.
createElement
(
"
a
"
);
a
.
setAttribute
(
"
href
"
,
"
#
"
+
errorUid
);
a
.
text
=
errorId
;
element
.
setAttribute
(
"
class
"
,
"
error-input
"
);
element
.
setAttribute
(
"
class
"
,
"
error-input
"
);
error_message
=
element
.
querySelector
(
"
#
"
+
id
.
replace
(
"
/
"
,
"
\\
/
"
)
+
"
> .error
"
);
error_message
=
element
.
querySelector
(
"
#
"
+
id
.
replace
(
"
/
"
,
"
\\
/
"
)
+
"
> .error
"
);
error_message
.
textContent
=
message
;
error_message
.
appendChild
(
a
);
error_message
.
setAttribute
(
"
id
"
,
errorUid
);
error_message
.
appendChild
(
document
.
createTextNode
(
error
.
message
));
error_message
.
hidden
=
false
;
error_message
.
hidden
=
false
;
a
=
document
.
createElement
(
"
a
"
);
a
.
text
=
errorId
;
a
.
setAttribute
(
"
data-error-link
"
,
"
#
"
+
errorUid
);
a
.
setAttribute
(
"
class
"
,
"
error-link
"
);
errors_block
.
appendChild
(
a
);
};
};
}
}
for
(
index
in
validation
.
errors
)
{
for
(
i
=
0
;
i
<
validation
.
errors
.
length
;
i
+=
1
)
{
if
(
validation
.
errors
.
hasOwnProperty
(
index
))
{
error
=
validation
.
errors
[
i
];
error_id
=
(
i
+
1
).
toString
();
tasks
.
push
(
tasks
.
push
(
g
.
getElementByPath
(
validation
.
errors
[
index
].
dataPath
)
g
.
getElementByPath
(
error
.
dataPath
||
"
/
"
)
.
push
(
print_error
(
validation
.
errors
[
index
].
message
))
.
push
(
print_error
(
error
,
"
error
"
+
error_id
,
error_id
))
);
);
}
}
}
for
(
index
in
validation
.
missing
)
{
for
(
i
=
0
;
i
<
validation
.
missing
.
length
;
i
+=
1
)
{
if
(
validation
.
missing
.
hasOwnProperty
(
index
))
{
error
=
validation
.
missing
[
i
];
error_id
=
(
i
+
1
).
toString
();
tasks
.
push
(
tasks
.
push
(
g
.
getElementByPath
(
validation
.
missing
[
index
].
dataPath
)
g
.
getElementByPath
(
error
.
dataPath
||
"
/
"
)
.
push
(
print_error
(
validation
.
missing
[
index
].
message
))
.
push
(
print_error
(
error
,
"
missing
"
+
error_id
,
error_id
))
);
);
}
}
}
return
RSVP
.
Queue
()
return
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
RSVP
.
all
(
tasks
);
return
RSVP
.
all
(
tasks
);
})
})
.
push
(
function
()
{
g
.
element
.
insertBefore
(
errors_block
,
g
.
element
.
firstChild
);
})
.
push
(
g
.
notifyInvalid
.
bind
(
g
))
.
push
(
g
.
notifyInvalid
.
bind
(
g
))
.
push
(
function
()
{
.
push
(
function
()
{
return
false
;
return
false
;
...
@@ -1631,8 +1660,14 @@
...
@@ -1631,8 +1660,14 @@
return
this
.
selfRemove
(
evt
);
return
this
.
selfRemove
(
evt
);
}
}
var
button_list
=
this
.
props
.
add_buttons
,
var
link
=
evt
.
target
.
getAttribute
(
"
data-error-link
"
),
button_list
=
this
.
props
.
add_buttons
,
i
;
i
;
if
(
link
)
{
location
.
href
=
link
;
return
;
}
for
(
i
=
0
;
i
<
button_list
.
length
;
i
=
i
+
1
)
{
for
(
i
=
0
;
i
<
button_list
.
length
;
i
=
i
+
1
)
{
if
(
evt
.
target
===
button_list
[
i
].
element
)
{
if
(
evt
.
target
===
button_list
[
i
].
element
)
{
return
button_list
[
i
].
event
(
evt
);
return
button_list
[
i
].
event
(
evt
);
...
@@ -1663,4 +1698,4 @@
...
@@ -1663,4 +1698,4 @@
return
getFormValuesAsJSONDict
(
g
);
return
getFormValuesAsJSONDict
(
g
);
});
});
}(
window
,
document
,
rJS
,
RSVP
,
jIO
,
tv4
));
}(
window
,
document
,
location
,
rJS
,
RSVP
,
jIO
,
tv4
));
\ No newline at end of file
\ 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