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 @@
// 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) {
var gadget = this,
allowed_sub_types_list = options.allowed_sub_types_list.split(","),
......@@ -50,7 +69,8 @@
child_gadget_url: 'gadget_erp5_pt_form_dialog.html',
form_type: 'dialog',
form_definition: form_result.form_definition,
view: "view"
view: "view",
show_dialog: allowed_sub_types_list.length > 1
});
});
})
......@@ -58,6 +78,7 @@
.onStateChange(function () {
var fragment = document.createElement('div'),
gadget = this;
if (gadget.state.show_dialog) {
while (this.element.firstChild) {
this.element.removeChild(this.element.firstChild);
}
......@@ -67,26 +88,18 @@
.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());
}
})
.allowPublicAcquisition('submitContent', function (options) {
var gadget = this,
content_dict = options[2],
doc = {
title: "Untitled Document",
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
}
});
});
content_dict = options[2];
return gadget.createDocument(content_dict.portal_type,
gadget.state.parent_portal_type.replace(/ /g, '_').toLowerCase());
});
}(window, document, rJS));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.19418.14997.64017</string> </value>
<value> <string>976.33879.24839.5393</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1560247823.23</float>
<float>1561020945.58</float>
<string>UTC</string>
</tuple>
</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