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
Rafael Monnerat
rjs_json_form
Commits
6d65e3c3
Commit
6d65e3c3
authored
Apr 15, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint fix
parent
7df80c9d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
94 deletions
+95
-94
gadget_json_generated_form.js
gadget_json_generated_form.js
+95
-94
No files found.
gadget_json_generated_form.js
View file @
6d65e3c3
...
...
@@ -3,7 +3,8 @@
(
function
(
window
,
document
,
rJS
,
RSVP
,
jIO
)
{
"
use strict
"
;
var
render_object
;
var
render_object
,
expandSchema
;
function
decodeJsonPointer
(
_str
)
{
// https://tools.ietf.org/html/rfc6901#section-5
...
...
@@ -170,6 +171,74 @@
});
}
function
allOf
(
g
,
schema_array
,
schema_path
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
var
i
,
arr
=
[];
for
(
i
=
0
;
i
<
schema_array
.
length
;
i
+=
1
)
{
arr
.
push
(
expandSchema
(
g
,
schema_array
[
i
],
schema_path
));
}
return
RSVP
.
all
(
arr
);
})
.
push
(
function
(
arr
)
{
var
i
,
x
,
y
,
key
,
next_schema
,
schema
,
schema_item
,
summ_arr
;
for
(
i
=
0
;
i
<
arr
.
length
-
1
;
i
+=
1
)
{
summ_arr
=
[];
for
(
x
=
0
;
x
<
arr
[
i
].
length
;
x
+=
1
)
{
for
(
y
=
0
;
y
<
arr
[
i
+
1
].
length
;
y
+=
1
)
{
schema
=
arr
[
i
][
x
].
schema
;
next_schema
=
arr
[
i
+
1
][
y
].
schema
;
if
(
schema
===
true
&&
next_schema
===
true
)
{
schema_item
=
{
schema
:
true
,
schema_path
:
arr
[
i
][
x
].
schema_path
};
}
else
if
(
schema
===
false
||
next_schema
===
false
)
{
schema_item
=
{
schema
:
false
,
schema_path
:
arr
[
i
][
x
].
schema_path
};
}
else
{
if
(
schema
===
true
)
{
schema
=
{};
}
if
(
next_schema
===
true
)
{
next_schema
=
{};
}
// copy before change
schema
=
JSON
.
parse
(
JSON
.
stringify
(
schema
));
for
(
key
in
next_schema
)
{
if
(
next_schema
.
hasOwnProperty
(
key
))
{
if
(
schema
.
hasOwnProperty
(
key
))
{
// XXX need use many many rules for merging
schema
[
key
]
=
next_schema
[
key
];
}
else
{
schema
[
key
]
=
next_schema
[
key
];
}
}
}
schema_item
=
{
schema
:
schema
,
schema_path
:
arr
[
i
][
x
].
schema_path
};
}
summ_arr
.
push
(
schema_item
);
}
}
arr
[
i
+
1
]
=
summ_arr
;
}
return
arr
[
arr
.
length
-
1
];
});
}
function
anyOf
(
g
,
schema_array
,
schema_path
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
...
...
@@ -197,6 +266,31 @@
});
}
expandSchema
=
function
(
g
,
schema
,
schema_path
)
{
if
(
schema
===
undefined
)
{
schema
=
true
;
}
if
(
schema
.
anyOf
!==
undefined
)
{
return
anyOf
(
g
,
schema
.
anyOf
,
schema_path
);
}
if
(
schema
.
allOf
!==
undefined
)
{
return
allOf
(
g
,
schema
.
allOf
,
schema_path
);
}
if
(
schema
.
$ref
)
{
return
g
.
loadJSONSchema
(
schema
.
$ref
,
schema_path
)
.
push
(
function
(
schema_part
)
{
return
expandSchema
(
g
,
schema_part
,
schema_path
);
});
}
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
[{
schema
:
schema
,
schema_path
:
schema_path
}];
});
};
function
render_select_type
(
gadget
,
title
,
schema_arr
,
event
)
{
var
scope
=
Math
.
random
().
toString
(
36
).
substr
(
2
,
9
),
type_arr
=
[],
...
...
@@ -380,99 +474,6 @@
return
queue
;
}
function
expandSchema
(
g
,
schema
,
schema_path
)
{
if
(
schema
===
undefined
)
{
schema
=
true
;
}
if
(
schema
.
anyOf
!==
undefined
)
{
return
anyOf
(
g
,
schema
.
anyOf
,
schema_path
);
}
if
(
schema
.
allOf
!==
undefined
)
{
return
allOf
(
g
,
schema
.
allOf
,
schema_path
);
}
if
(
schema
.
$ref
)
{
return
g
.
loadJSONSchema
(
schema
.
$ref
,
schema_path
)
.
push
(
function
(
schema_part
)
{
return
expandSchema
(
g
,
schema_part
,
schema_path
);
});
}
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
[{
schema
:
schema
,
schema_path
:
schema_path
}];
});
}
function
allOf
(
g
,
schema_array
,
schema_path
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
var
i
,
arr
=
[];
for
(
i
=
0
;
i
<
schema_array
.
length
;
i
+=
1
)
{
arr
.
push
(
expandSchema
(
g
,
schema_array
[
i
],
schema_path
));
}
return
RSVP
.
all
(
arr
);
})
.
push
(
function
(
arr
)
{
var
i
,
x
,
y
,
key
,
next_schema
,
schema
,
schema_item
,
summ_arr
;
for
(
i
=
0
;
i
<
arr
.
length
-
1
;
i
+=
1
)
{
summ_arr
=
[];
for
(
x
=
0
;
x
<
arr
[
i
].
length
;
x
+=
1
)
{
for
(
y
=
0
;
y
<
arr
[
i
+
1
].
length
;
y
+=
1
)
{
schema
=
arr
[
i
][
x
].
schema
;
next_schema
=
arr
[
i
+
1
][
y
].
schema
;
if
(
schema
===
true
&&
next_schema
===
true
)
{
schema_item
=
{
schema
:
true
,
schema_path
:
arr
[
i
][
x
].
schema_path
};
}
else
if
(
schema
===
false
||
next_schema
===
false
)
{
schema_item
=
{
schema
:
false
,
schema_path
:
arr
[
i
][
x
].
schema_path
};
}
else
{
if
(
schema
===
true
)
{
schema
=
{};
}
if
(
next_schema
===
true
)
{
next_schema
=
{};
}
// copy before change
schema
=
JSON
.
parse
(
JSON
.
stringify
(
schema
));
for
(
key
in
next_schema
)
{
if
(
next_schema
.
hasOwnProperty
(
key
))
{
if
(
schema
.
hasOwnProperty
(
key
))
{
// XXX need use many many rules for merging
schema
[
key
]
=
next_schema
[
key
];
}
else
{
schema
[
key
]
=
next_schema
[
key
];
}
}
}
schema_item
=
{
schema
:
schema
,
schema_path
:
arr
[
i
][
x
].
schema_path
};
}
summ_arr
.
push
(
schema_item
);
}
}
arr
[
i
+
1
]
=
summ_arr
;
}
return
arr
[
arr
.
length
-
1
];
});
}
function
render_field
(
gadget
,
key
,
path
,
json_field
,
default_value
,
root
,
schema_path
,
type
)
{
var
div
,
label
,
...
...
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