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
5f555486
Commit
5f555486
authored
Feb 24, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove multiple JSON.parse
parent
6f31e5a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
30 deletions
+17
-30
gadget_erp5_page_slap_load_schema.js
gadget_erp5_page_slap_load_schema.js
+17
-30
No files found.
gadget_erp5_page_slap_load_schema.js
View file @
5f555486
...
@@ -22,11 +22,12 @@
...
@@ -22,11 +22,12 @@
return
RSVP
.
Queue
()
return
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
jIO
.
util
.
ajax
({
return
jIO
.
util
.
ajax
({
url
:
url
url
:
url
,
dataType
:
"
json
"
})
})
.
then
(
function
(
evt
)
{
})
return
evt
.
target
.
responseText
;
.
push
(
function
(
evt
)
{
})
;
return
evt
.
target
.
response
;
});
});
}
}
...
@@ -46,7 +47,6 @@
...
@@ -46,7 +47,6 @@
function
resolveReference
(
partial_schema
,
schema
,
base_url
)
{
function
resolveReference
(
partial_schema
,
schema
,
base_url
)
{
var
parts
,
var
parts
,
external_schema
,
ref
=
partial_schema
.
$ref
;
ref
=
partial_schema
.
$ref
;
if
(
ref
===
undefined
)
{
if
(
ref
===
undefined
)
{
...
@@ -69,8 +69,7 @@
...
@@ -69,8 +69,7 @@
}
}
return
getJSON
(
ref
);
return
getJSON
(
ref
);
})
})
.
push
(
function
(
json
)
{
.
push
(
function
(
external_schema
)
{
external_schema
=
JSON
.
parse
(
json
);
parts
=
ref
.
split
(
"
#
"
);
parts
=
ref
.
split
(
"
#
"
);
ref
=
"
#
"
+
parts
[
1
];
ref
=
"
#
"
+
parts
[
1
];
return
resolveLocalReference
(
ref
,
external_schema
);
return
resolveLocalReference
(
ref
,
external_schema
);
...
@@ -190,15 +189,12 @@
...
@@ -190,15 +189,12 @@
return
getJSON
(
"
slapos_load_meta_schema.json
"
);
return
getJSON
(
"
slapos_load_meta_schema.json
"
);
}
}
function
validateJSONSchema
(
json
,
base_url
)
{
function
validateJSONSchema
(
schema
,
base_url
)
{
return
getMetaJSONSchema
()
return
getMetaJSONSchema
()
.
push
(
function
(
meta_schema
)
{
.
push
(
function
(
meta_schema
)
{
if
(
!
tv4
.
validate
(
json
,
meta_schema
))
{
if
(
!
tv4
.
validate
(
schema
,
meta_schema
))
{
throw
new
Error
(
"
Non valid JSON schema
"
+
json
);
throw
new
Error
(
"
Non valid JSON schema
"
+
schema
);
}
}
return
JSON
.
parse
(
json
);
})
.
push
(
function
(
schema
)
{
return
expandSchema
(
schema
,
schema
,
base_url
);
return
expandSchema
(
schema
,
schema
,
base_url
);
});
});
}
}
...
@@ -219,17 +215,11 @@
...
@@ -219,17 +215,11 @@
})
})
.
declareMethod
(
"
loadSoftwareJSON
"
,
function
(
url
)
{
.
declareMethod
(
"
loadSoftwareJSON
"
,
function
(
url
)
{
return
getJSON
(
url
)
return
getJSON
(
url
);
.
push
(
function
(
json
)
{
return
JSON
.
parse
(
json
);
});
})
})
.
declareMethod
(
"
validateJSONForSoftwareType
"
,
function
(
schema_url
,
software_type
,
generated_json
)
{
.
declareMethod
(
"
validateJSONForSoftwareType
"
,
function
(
schema_url
,
software_type
,
generated_json
)
{
return
getJSON
(
schema_url
)
return
getJSON
(
schema_url
)
.
push
(
function
(
json
)
{
return
JSON
.
parse
(
json
);
})
.
push
(
function
(
json_object
)
{
.
push
(
function
(
json_object
)
{
var
parameter_schema_url
,
var
parameter_schema_url
,
st
,
st
,
...
@@ -254,9 +244,7 @@
...
@@ -254,9 +244,7 @@
}
}
return
getJSON
(
parameter_schema_url
)
return
getJSON
(
parameter_schema_url
)
.
push
(
function
(
json
)
{
.
push
(
function
(
schema
)
{
var
schema
=
JSON
.
parse
(
json
);
return
expandSchema
(
schema
,
schema
,
base_url
)
return
expandSchema
(
schema
,
schema
,
base_url
)
.
push
(
function
(
loaded_json
)
{
.
push
(
function
(
loaded_json
)
{
return
tv4
.
validateMultiple
(
generated_json
,
loaded_json
);
return
tv4
.
validateMultiple
(
generated_json
,
loaded_json
);
...
@@ -267,10 +255,9 @@
...
@@ -267,10 +255,9 @@
.
declareMethod
(
"
validateJSON
"
,
function
(
schema_url
,
generated_json
)
{
.
declareMethod
(
"
validateJSON
"
,
function
(
schema_url
,
generated_json
)
{
return
getJSON
(
schema_url
)
return
getJSON
(
schema_url
)
.
push
(
function
(
json
)
{
.
push
(
function
(
schema
)
{
var
base_url
,
var
base_url
,
url_uri
=
URI
(
schema_url
),
url_uri
=
URI
(
schema_url
);
schema
=
JSON
.
parse
(
json
);
base_url
=
url_uri
.
path
().
split
(
"
/
"
);
base_url
=
url_uri
.
path
().
split
(
"
/
"
);
base_url
.
pop
();
base_url
.
pop
();
...
...
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