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
cd0da176
Commit
cd0da176
authored
Apr 23, 2019
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix creating new property
parent
ab0c6934
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
49 deletions
+61
-49
jsonform/gadget_json_generated_form_child.js
jsonform/gadget_json_generated_form_child.js
+61
-49
No files found.
jsonform/gadget_json_generated_form_child.js
View file @
cd0da176
...
@@ -305,30 +305,28 @@
...
@@ -305,30 +305,28 @@
property_name
,
property_name
,
parent_path
,
parent_path
,
scope
;
scope
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
scope
=
generateUid
(
g
);
parent_path
=
options
.
parent_path
;
if
(
options
.
parent_type
!==
"
array
"
)
{
property_name
=
options
.
property_name
;
if
(
!
property_name
)
{
property_name
=
input_element
.
value
;
}
if
(
!
property_name
)
{
throw
new
Error
(
"
can't create property without name
"
);
}
if
(
g
.
props
.
objects
[
parent_path
].
hasOwnProperty
(
property_name
)
&&
g
.
props
.
objects
[
parent_path
][
property_name
]
!==
""
)
{
throw
new
Error
(
"
you can't create property with existed name
"
);
}
if
(
input_element
)
{
input_element
.
value
=
""
;
}
}
scope
=
generateUid
(
g
);
return
g
.
declareGadget
(
'
gadget_json_generated_form_child.html
'
,
{
scope
:
scope
});
parent_path
=
options
.
parent_path
;
})
if
(
options
.
parent_type
!==
"
array
"
)
{
property_name
=
options
.
property_name
;
if
(
!
property_name
)
{
property_name
=
input_element
.
value
;
}
if
(
!
property_name
)
{
// XXX notify user
// you can't create property without property_name
return
RSVP
.
Queue
();
}
if
(
g
.
props
.
objects
[
parent_path
].
hasOwnProperty
(
property_name
)
&&
g
.
props
.
objects
[
parent_path
][
property_name
]
!==
""
)
{
// XXX notify user
// you can't create property with existed property_name
return
RSVP
.
Queue
();
}
if
(
input_element
)
{
input_element
.
value
=
""
;
}
}
return
g
.
declareGadget
(
'
gadget_json_generated_form_child.html
'
,
{
scope
:
scope
})
.
push
(
function
(
form_gadget
)
{
.
push
(
function
(
form_gadget
)
{
form_gadget
.
element
.
setAttribute
(
"
data-gadget-parent-scope
"
,
form_gadget
.
element
.
setAttribute
(
"
data-gadget-parent-scope
"
,
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
));
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
));
...
@@ -663,18 +661,23 @@
...
@@ -663,18 +661,23 @@
return
event
(
schema_alternatives
[
value
[
scope
]].
value
);
return
event
(
schema_alternatives
[
value
[
scope
]].
value
);
})
})
.
push
(
function
(
v
)
{
.
push
(
function
(
v
)
{
notify
.
scope
=
v
.
scope
;
if
(
v
)
{
notify
.
path
=
v
.
path
;
return
RSVP
.
Queue
()
if
(
rerender
)
{
.
push
(
function
()
{
return
rerender
(
g
,
schema_alternatives
);
notify
.
scope
=
v
.
scope
;
notify
.
path
=
v
.
path
;
if
(
rerender
)
{
return
rerender
(
g
,
schema_alternatives
);
}
return
render_options
;
})
.
push
(
function
(
render_options
)
{
return
g
.
render
(
render_options
);
})
.
push
(
function
()
{
return
gadget
.
rootNotifyChange
(
notify
);
});
}
}
return
render_options
;
})
.
push
(
function
(
render_options
)
{
return
g
.
render
(
render_options
);
})
.
push
(
function
()
{
return
gadget
.
rootNotifyChange
(
notify
);
});
});
},
},
rerender
:
function
()
{
rerender
:
function
()
{
...
@@ -722,20 +725,25 @@
...
@@ -722,20 +725,25 @@
};
};
return
event
(
schema_alternatives
[
0
].
value
)
return
event
(
schema_alternatives
[
0
].
value
)
.
push
(
function
(
v
)
{
.
push
(
function
(
v
)
{
notify
.
scope
=
v
.
scope
;
if
(
v
)
{
notify
.
path
=
v
.
path
;
return
RSVP
.
Queue
()
if
(
rerender
)
{
.
push
(
function
()
{
return
rerender
(
undefined
,
schema_alternatives
);
notify
.
scope
=
v
.
scope
;
notify
.
path
=
v
.
path
;
if
(
rerender
)
{
return
rerender
(
undefined
,
schema_alternatives
);
}
return
true
;
})
.
push
(
function
(
r
)
{
if
(
!
r
)
{
input
.
setAttribute
(
"
style
"
,
"
display: none;
"
);
}
else
{
input
.
removeAttribute
(
"
style
"
);
}
return
gadget
.
rootNotifyChange
(
notify
);
});
}
}
return
true
;
})
.
push
(
function
(
r
)
{
if
(
!
r
)
{
input
.
setAttribute
(
"
style
"
,
"
display: none;
"
);
}
else
{
input
.
removeAttribute
(
"
style
"
);
}
return
gadget
.
rootNotifyChange
(
notify
);
});
});
},
},
rerender
:
function
()
{
rerender
:
function
()
{
...
@@ -1269,7 +1277,11 @@
...
@@ -1269,7 +1277,11 @@
type
:
value
.
type
,
type
:
value
.
type
,
schema_arr
:
[
value
]
schema_arr
:
[
value
]
})
})
.
push
(
element_append
);
.
push
(
element_append
)
.
push
(
undefined
,
function
(
err
)
{
// XXX notify user
console
.
error
(
err
);
});
});
});
});
});
return
queue
;
return
queue
;
...
@@ -2372,4 +2384,4 @@
...
@@ -2372,4 +2384,4 @@
});
});
});
});
}(
window
,
document
,
location
,
rJS
,
RSVP
,
tv4
));
}(
window
,
document
,
location
,
rJS
,
RSVP
,
tv4
));
\ 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