Commit 1bf5b483 authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs: schema_editor: use id as reference in new created document

parent 1f0c33c1
...@@ -25,15 +25,14 @@ ...@@ -25,15 +25,14 @@
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment") .declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_put", "jio_put")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this; var gadget = this,
return RSVP.Queue() portal_type = options.portal_type,
.push(function () {
var portal_type = options.portal_type,
ext = file_ext[portal_type], ext = file_ext[portal_type],
ret = { ret = {
title: "Untitled Schema", title: "Untitled Schema",
...@@ -41,14 +40,20 @@ ...@@ -41,14 +40,20 @@
parent_relative_url: "schema_module", parent_relative_url: "schema_module",
content_type: content_type[portal_type] || undefined content_type: content_type[portal_type] || undefined
}; };
return RSVP.Queue()
.push(function () {
if (ext) { if (ext) {
ret.filename = "default." + ext; ret.filename = "default." + ext;
} }
return gadget.jio_post(ret); return gadget.jio_post(ret);
}) })
.push(function (id) { .push(function (id) {
ret.reference = id;
return gadget.jio_put(id, ret)
.push(function () {
return gadget.jio_putAttachment(id, 'data', return gadget.jio_putAttachment(id, 'data',
new Blob(['{"$schema": "http://json-schema.org/draft-04/schema#" }'])) new Blob(['{"$schema": "http://json-schema.org/draft-07/schema#" }']));
})
.push(function () { .push(function () {
return gadget.updatePanel({editable: true}); return gadget.updatePanel({editable: true});
}) })
......
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