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
35492a16
Commit
35492a16
authored
Aug 22, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notify about changes after rendering if document changed during render
parent
26024012
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
jsonform.gadget.js
jsonform.gadget.js
+5
-0
jsonform/gadget_json_generated_form_child.js
jsonform/gadget_json_generated_form_child.js
+16
-6
No files found.
jsonform.gadget.js
View file @
35492a16
...
@@ -684,6 +684,11 @@
...
@@ -684,6 +684,11 @@
.
push
(
function
()
{
.
push
(
function
()
{
return
g
.
checkValidity
();
return
g
.
checkValidity
();
})
})
.
push
(
function
()
{
if
(
g
.
props
.
form_gadget
.
props
.
changed
)
{
g
.
notifyChange
();
}
})
.
push
(
function
()
{
.
push
(
function
()
{
return
g
;
return
g
;
});
});
...
...
jsonform/gadget_json_generated_form_child.js
View file @
35492a16
...
@@ -121,7 +121,7 @@
...
@@ -121,7 +121,7 @@
return
schema
;
return
schema
;
}
}
function
render_enum
(
schema
,
json_document
)
{
function
render_enum
(
g
,
schema
,
json_document
)
{
var
input
=
document
.
createElement
(
"
select
"
),
var
input
=
document
.
createElement
(
"
select
"
),
option
,
option
,
i
,
i
,
...
@@ -132,6 +132,7 @@
...
@@ -132,6 +132,7 @@
if
(
schema
.
default
)
{
if
(
schema
.
default
)
{
if
(
json_document
===
undefined
)
{
if
(
json_document
===
undefined
)
{
json_document
=
schema
.
default
;
json_document
=
schema
.
default
;
g
.
props
.
changed
=
true
;
}
}
}
else
{
}
else
{
option
=
document
.
createElement
(
"
option
"
);
option
=
document
.
createElement
(
"
option
"
);
...
@@ -177,7 +178,7 @@
...
@@ -177,7 +178,7 @@
return
input
;
return
input
;
}
}
function
render_boolean
(
schema
,
json_document
)
{
function
render_boolean
(
g
,
schema
,
json_document
)
{
var
input
,
var
input
,
schema_for_selection
=
{
schema_for_selection
=
{
type
:
"
boolean
"
,
type
:
"
boolean
"
,
...
@@ -193,7 +194,7 @@
...
@@ -193,7 +194,7 @@
if
(
getDocumentType
(
schema
.
default
)
===
"
boolean
"
)
{
if
(
getDocumentType
(
schema
.
default
)
===
"
boolean
"
)
{
schema_for_selection
.
default
=
schema
.
default
;
schema_for_selection
.
default
=
schema
.
default
;
}
}
input
=
render_enum
(
schema_for_selection
,
json_document
);
input
=
render_enum
(
g
,
schema_for_selection
,
json_document
);
input
.
setAttribute
(
'
data-json-type
'
,
"
boolean
"
);
input
.
setAttribute
(
'
data-json-type
'
,
"
boolean
"
);
return
input
;
return
input
;
}
}
...
@@ -274,7 +275,13 @@
...
@@ -274,7 +275,13 @@
document
:
options
.
default_dict
,
document
:
options
.
default_dict
,
display_label
:
options
.
parent_type
!==
"
array
"
,
display_label
:
options
.
parent_type
!==
"
array
"
,
scope
:
scope
scope
:
scope
});
})
.
push
(
function
()
{
if
(
form_gadget
.
props
.
changed
)
{
g
.
props
.
changed
=
true
;
}
return
form_gadget
.
element
;
});
});
});
}
}
...
@@ -777,7 +784,7 @@
...
@@ -777,7 +784,7 @@
if
(
json_field
.
const
!==
undefined
)
{
if
(
json_field
.
const
!==
undefined
)
{
input
=
render_const
(
json_field
,
default_value
);
input
=
render_const
(
json_field
,
default_value
);
}
else
if
(
json_field
.
enum
!==
undefined
)
{
}
else
if
(
json_field
.
enum
!==
undefined
)
{
input
=
render_enum
(
json_field
,
default_value
);
input
=
render_enum
(
gadget
,
json_field
,
default_value
);
// XXX take in account existing type with enum
// XXX take in account existing type with enum
type_changed
=
false
;
type_changed
=
false
;
}
}
...
@@ -787,7 +794,7 @@
...
@@ -787,7 +794,7 @@
}
}
if
(
!
input
&&
type
===
"
boolean
"
)
{
if
(
!
input
&&
type
===
"
boolean
"
)
{
input
=
render_boolean
(
json_field
,
default_value
);
input
=
render_boolean
(
gadget
,
json_field
,
default_value
);
}
}
if
(
!
input
&&
[
"
string
"
,
"
integer
"
,
"
number
"
,
"
null
"
].
indexOf
(
type
)
>=
0
)
{
if
(
!
input
&&
[
"
string
"
,
"
integer
"
,
"
number
"
,
"
null
"
].
indexOf
(
type
)
>=
0
)
{
...
@@ -806,6 +813,7 @@
...
@@ -806,6 +813,7 @@
if
(
type
===
"
integer
"
||
type
===
"
number
"
)
{
if
(
type
===
"
integer
"
||
type
===
"
number
"
)
{
if
(
default_value
===
undefined
&&
typeof
json_field
.
default
===
"
number
"
)
{
if
(
default_value
===
undefined
&&
typeof
json_field
.
default
===
"
number
"
)
{
input
.
value
=
json_field
.
default
;
input
.
value
=
json_field
.
default
;
gadget
.
props
.
changed
=
true
;
}
}
input
.
setAttribute
(
"
data-json-type
"
,
type
);
input
.
setAttribute
(
"
data-json-type
"
,
type
);
if
(
default_value
===
undefined
||
default_value
===
null
||
if
(
default_value
===
undefined
||
default_value
===
null
||
...
@@ -827,6 +835,7 @@
...
@@ -827,6 +835,7 @@
}
else
{
}
else
{
if
(
default_value
===
undefined
&&
typeof
json_field
.
default
===
"
string
"
)
{
if
(
default_value
===
undefined
&&
typeof
json_field
.
default
===
"
string
"
)
{
input
.
value
=
json_field
.
default
;
input
.
value
=
json_field
.
default
;
gadget
.
props
.
changed
=
true
;
}
}
input
.
type
=
"
text
"
;
input
.
type
=
"
text
"
;
if
(
json_field
.
pattern
)
{
if
(
json_field
.
pattern
)
{
...
@@ -1607,6 +1616,7 @@
...
@@ -1607,6 +1616,7 @@
property_name
=
g
.
element
.
getAttribute
(
'
data-json-property-name
'
),
property_name
=
g
.
element
.
getAttribute
(
'
data-json-property-name
'
),
schema
=
options
.
schema
,
schema
=
options
.
schema
,
root
;
root
;
g
.
props
.
change
=
false
;
g
.
props
.
inputs
=
[];
g
.
props
.
inputs
=
[];
g
.
props
.
add_buttons
=
[];
g
.
props
.
add_buttons
=
[];
g
.
props
.
add_custom_data
=
{};
g
.
props
.
add_custom_data
=
{};
...
...
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