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
801f592b
Commit
801f592b
authored
Mar 22, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lint gadget_erp5_page_slap_load_schema.js
parent
dc2fdc3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
53 deletions
+62
-53
gadget_erp5_page_slap_load_schema.js
gadget_erp5_page_slap_load_schema.js
+62
-53
No files found.
gadget_erp5_page_slap_load_schema.js
View file @
801f592b
/*jslint nomen: true, maxlen:
20
0, indent: 2*/
/*global window, rJS,
console, RSVP, jIO, tv4, URI, JSON
*/
/*jslint nomen: true, maxlen:
8
0, indent: 2*/
/*global window, rJS,
RSVP, jIO, tv4, URI
*/
(
function
(
window
,
rJS
,
RSVP
,
URI
,
jIO
,
tv4
)
{
"
use strict
"
;
function
extend
(
obj
,
obj1
)
{
for
(
var
i
in
obj1
)
{
if
(
obj1
.
hasOwnProperty
(
i
))
{
obj
[
i
]
=
obj1
[
i
];
}
}
var
key
;
for
(
key
in
obj1
)
{
if
(
obj1
.
hasOwnProperty
(
key
))
{
obj
[
key
]
=
obj1
[
key
];
}
}
}
function
getBaseUrl
(
schema_url
)
{
...
...
@@ -89,7 +90,9 @@
return
JSON
.
parse
(
JSON
.
stringify
(
obj
));
}
// Inspired from https://github.com/nexedi/dream/blob/master/dream/platform/src/jsplumb/jsplumb.js#L398
// Inspired from
// https://github.com/nexedi/dream/blob/master/dream/platform/
// src/jsplumb/jsplumb.js#L398
function
expandSchema
(
json_schema
,
full_schema
,
base_url
)
{
var
i
,
expanded_json_schema
=
clone
(
json_schema
)
||
{};
...
...
@@ -98,44 +101,47 @@
expanded_json_schema
.
properties
=
{};
}
return
RSVP
.
Queue
().
push
(
function
()
{
if
(
json_schema
.
$ref
)
{
return
resolveReference
(
json_schema
,
full_schema
,
base_url
)
.
push
(
function
(
remote_schema
)
{
return
expandSchema
(
remote_schema
,
full_schema
,
base_url
);
})
.
push
(
function
(
referencedx
)
{
extend
(
expanded_json_schema
,
referencedx
);
delete
expanded_json_schema
.
$ref
;
return
true
;
});
}
return
true
;
})
return
RSVP
.
Queue
()
.
push
(
function
()
{
if
(
json_schema
.
$ref
)
{
return
resolveReference
(
json_schema
,
full_schema
,
base_url
)
.
push
(
function
(
remote_schema
)
{
return
expandSchema
(
remote_schema
,
full_schema
,
base_url
);
})
.
push
(
function
(
referencedx
)
{
extend
(
expanded_json_schema
,
referencedx
);
delete
expanded_json_schema
.
$ref
;
return
true
;
});
}
return
true
;
})
.
push
(
function
()
{
var
property
,
queue
=
RSVP
.
Queue
();
var
property
,
queue
=
RSVP
.
Queue
();
function
wrapperResolveReference
(
p
)
{
return
resolveReference
(
json_schema
.
properties
[
p
],
full_schema
,
base_url
).
push
(
function
(
external_schema
)
{
// console.log(p);
return
expandSchema
(
external_schema
,
function
wrapperResolveReference
(
p
)
{
return
resolveReference
(
json_schema
.
properties
[
p
],
full_schema
,
base_url
)
.
push
(
function
(
external_schema
)
{
// console.log(p);
return
expandSchema
(
external_schema
,
full_schema
,
base_url
);
})
.
push
(
function
(
referencedx
)
{
extend
(
expanded_json_schema
.
properties
[
p
],
referencedx
);
if
(
json_schema
.
properties
[
p
].
$ref
)
{
...
...
@@ -143,19 +149,18 @@
}
return
referencedx
;
});
});
}
}
// expand ref in properties
for
(
property
in
json_schema
.
properties
)
{
if
(
json_schema
.
properties
.
hasOwnProperty
(
property
))
{
queue
.
push
(
wrapperResolveReference
.
bind
(
this
,
property
)
);
// expand ref in properties
for
(
property
in
json_schema
.
properties
)
{
if
(
json_schema
.
properties
.
hasOwnProperty
(
property
))
{
queue
.
push
(
wrapperResolveReference
.
bind
(
this
,
property
)
);
}
}
}
return
queue
;
})
return
queue
;
})
.
push
(
function
()
{
var
zqueue
=
RSVP
.
Queue
();
...
...
@@ -196,6 +201,7 @@
});
}
/*
function getMetaJSONSchema() {
return getJSON("slapos_load_meta_schema.json");
}
...
...
@@ -209,6 +215,7 @@
return expandSchema(schema, schema, base_url);
});
}
*/
rJS
(
window
)
.
declareMethod
(
"
loadJSONSchema
"
,
function
(
url
)
{
...
...
@@ -224,7 +231,9 @@
return
getJSON
(
url
);
})
.
declareMethod
(
"
validateJSONForSoftwareType
"
,
function
(
schema_url
,
software_type
,
generated_json
)
{
.
declareMethod
(
"
validateJSONForSoftwareType
"
,
function
(
schema_url
,
software_type
,
generated_json
)
{
var
base_url
=
getBaseUrl
(
schema_url
);
return
getJSON
(
schema_url
)
.
push
(
function
(
json_object
)
{
...
...
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