Commit d4132ed7 authored by Roque's avatar Roque

erp5_officejs: create document dialog form is skipped if there is only one sub portal type

parent f97a7d4b
...@@ -22,6 +22,25 @@ ...@@ -22,6 +22,25 @@
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("createDocument", function (portal_type, parent_portal_type) {
var gadget = this,
doc = {
title: "Untitled Document",
portal_type: portal_type,
parent_relative_url: parent_portal_type
};
return gadget.jio_post(doc)
.push(function (id) {
return gadget.redirect({
command: 'display',
options: {
jio_key: id,
editable: true
}
});
});
})
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
allowed_sub_types_list = options.allowed_sub_types_list.split(","), allowed_sub_types_list = options.allowed_sub_types_list.split(","),
...@@ -50,7 +69,8 @@ ...@@ -50,7 +69,8 @@
child_gadget_url: 'gadget_erp5_pt_form_dialog.html', child_gadget_url: 'gadget_erp5_pt_form_dialog.html',
form_type: 'dialog', form_type: 'dialog',
form_definition: form_result.form_definition, form_definition: form_result.form_definition,
view: "view" view: "view",
show_dialog: allowed_sub_types_list.length > 1
}); });
}); });
}) })
...@@ -58,35 +78,28 @@ ...@@ -58,35 +78,28 @@
.onStateChange(function () { .onStateChange(function () {
var fragment = document.createElement('div'), var fragment = document.createElement('div'),
gadget = this; gadget = this;
while (this.element.firstChild) { if (gadget.state.show_dialog) {
this.element.removeChild(this.element.firstChild); while (this.element.firstChild) {
this.element.removeChild(this.element.firstChild);
}
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'fg'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
} else {
// if there is only one sub portal type, skip create document dialog rendering
return gadget.createDocument(gadget.state.doc.portal_type[0],
gadget.state.parent_portal_type.replace(/ /g, '_').toLowerCase());
} }
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'fg'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
}) })
.allowPublicAcquisition('submitContent', function (options) { .allowPublicAcquisition('submitContent', function (options) {
var gadget = this, var gadget = this,
content_dict = options[2], content_dict = options[2];
doc = { return gadget.createDocument(content_dict.portal_type,
title: "Untitled Document", gadget.state.parent_portal_type.replace(/ /g, '_').toLowerCase());
portal_type: content_dict.portal_type,
parent_relative_url: gadget.state.parent_portal_type.replace(/ /g, '_').toLowerCase()
};
return gadget.jio_post(doc)
.push(function (id) {
return gadget.redirect({
command: 'display',
options: {
jio_key: id,
editable: true
}
});
});
}); });
}(window, document, rJS)); }(window, document, rJS));
\ No newline at end of file
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.19418.14997.64017</string> </value> <value> <string>976.33879.24839.5393</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1560247823.23</float> <float>1561020945.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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