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
899c03a6
Commit
899c03a6
authored
May 10, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix gadget.getElementByPath()
parent
8aa5557a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
gadget_json_generated_form_child.js
gadget_json_generated_form_child.js
+21
-19
No files found.
gadget_json_generated_form_child.js
View file @
899c03a6
...
...
@@ -1191,6 +1191,7 @@
path
,
scope
,
key
,
next_data_path
,
slash_count
=
0
,
slash_count_next
,
bingo
,
...
...
@@ -1199,21 +1200,26 @@
if
(
data_path
!==
"
/
"
)
{
for
(
path
in
options
.
arrays
)
{
if
(
options
.
arrays
.
hasOwnProperty
(
path
)
&&
data_path
.
startsWith
(
path
))
{
array
=
options
.
arrays
[
path
]
.
querySelectorAll
(
"
div[data-gadget-parent-scope='
"
+
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
"
']
"
);
data_path
=
data_path
.
slice
(
path
.
length
).
split
(
"
/
"
);
idx
=
data_path
[
0
];
data_path
=
"
/
"
+
data_path
.
slice
(
1
).
join
(
"
/
"
);
bingo
=
array
[
idx
].
getAttribute
(
'
data-gadget-scope
'
);
slash_count_next
=
path
.
split
(
"
/
"
).
length
-
1
;
if
(
slash_count_next
>
slash_count
)
{
bingo
=
path
;
slash_count
=
slash_count_next
;
}
}
}
if
(
bingo
)
{
return
g
.
getDeclaredGadget
(
bingo
)
array
=
options
.
arrays
[
bingo
]
.
querySelectorAll
(
"
div[data-gadget-parent-scope='
"
+
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
"
']
"
);
next_data_path
=
data_path
.
slice
(
bingo
.
length
).
split
(
"
/
"
);
idx
=
next_data_path
[
0
];
next_data_path
=
"
/
"
+
next_data_path
.
slice
(
1
).
join
(
"
/
"
);
return
g
.
getDeclaredGadget
(
array
[
idx
].
getAttribute
(
'
data-gadget-scope
'
))
.
push
(
function
(
gadget
)
{
return
gadget
.
getElementByPath
(
data_path
);
return
gadget
.
getElementByPath
(
next_
data_path
);
});
}
slash_count
=
0
;
for
(
path
in
options
.
objects
)
{
if
(
options
.
objects
.
hasOwnProperty
(
path
)
&&
data_path
.
startsWith
(
path
))
{
slash_count_next
=
path
.
split
(
"
/
"
).
length
-
1
;
...
...
@@ -1225,17 +1231,13 @@
}
if
(
bingo
)
{
path
=
options
.
objects
[
bingo
];
for
(
key
in
path
)
{
if
(
path
.
hasOwnProperty
(
key
))
{
if
(
data_path
.
startsWith
(
bingo
+
encodeJsonPointer
(
key
)))
{
data_path
=
data_path
.
slice
(
bingo
.
length
+
encodeJsonPointer
(
key
).
length
);
if
(
!
data_path
)
{
data_path
=
"
/
"
;
}
scope
=
path
[
key
];
break
;
}
key
=
decodeJsonPointer
(
data_path
.
slice
(
bingo
.
length
).
split
(
'
/
'
)[
0
]);
if
(
path
.
hasOwnProperty
(
key
))
{
next_data_path
=
data_path
.
slice
(
bingo
.
length
+
encodeJsonPointer
(
key
).
length
);
if
(
!
next_data_path
)
{
next_data_path
=
"
/
"
;
}
scope
=
path
[
key
];
}
}
if
(
scope
===
false
)
{
...
...
@@ -1246,7 +1248,7 @@
if
(
scope
)
{
return
g
.
getDeclaredGadget
(
scope
)
.
push
(
function
(
gadget
)
{
return
gadget
.
getElementByPath
(
data_path
);
return
gadget
.
getElementByPath
(
next_
data_path
);
});
}
}
...
...
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