Commit a381fef8 authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs: schema_editor: add gadget_erp5_page_ojs_add_json_schema.*

parent 9c70680e
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add JSON Schema</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_add_json_schema.js"></script>
</head>
<body>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Blob) {
"use strict";
var content_type = {
Spreadsheet: 'application/x-asc-spreadsheet',
Presentation: 'application/x-asc-presentation',
Text: 'application/x-asc-text'
};
var file_ext = {
Spreadsheet: 'xlsy',
Presentation: 'ppty',
Text: 'docy'
};
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this;
return RSVP.Queue()
.push(function () {
var portal_type = options.portal_type,
ext = file_ext[portal_type],
ret = {
title: "Untitled Document",
portal_type: "JSON Schema",
parent_relative_url: "schema_module",
content_type: content_type[portal_type] || undefined
};
if (ext) {
ret.filename = "default." + ext;
}
return gadget.jio_post(ret);
})
.push(function (id) {
return gadget.jio_putAttachment(id, 'data',
new Blob(['{"$schema": "http://json-schema.org/draft-04/schema#" }']))
.push(function () {
return gadget.redirect({
command: 'display',
options: {
jio_key: id,
editable: true
}
});
});
});
});
}(window, rJS, RSVP, Blob));
......@@ -137,7 +137,9 @@
];
} else {
tasks = [
gadget.getUrlFor({command: "index", options: {"page": "ojs_multi_upload"}}),
gadget.getUrlFor({command: "index", options: {
page: "ojs_add_json_schema"
}}),
gadget.getSetting('document_title_plural')
];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment