Commit 6270565a authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: Allow public acquisition of submitDialog and support custom dialog method

With this; other gadgets can call submitDialog and pass a custom dialog method
parent cb815b52
......@@ -19,10 +19,11 @@
});
}
function submitDialog(is_updating) {
function submitDialog(is_updating, param_list) {
var gadget = this,
button_container =
gadget.element.querySelector('.dialog_button_container'),
custom_dialog_method = param_list ? param_list[1] : null,
update_button = button_container.querySelector('button'),
submit_input = button_container.querySelector('input');
submit_input.disabled = true;
......@@ -55,7 +56,7 @@
}
}
// ERP5 expects target Script name in dialog_method field
data.dialog_method = gadget.state.form_definition.action;
data.dialog_method = custom_dialog_method || gadget.state.form_definition.action;
// For Update Action - override the default value from "action"
if (is_updating) {
data.dialog_method = gadget.state.form_definition.update_action;
......@@ -82,7 +83,6 @@
if (gadget.state.redirect_to_parent) {
return gadget.redirect({command: 'history_previous'});
}
console.log('COSUCOUS', result);
if ((gadget.state.jio_key === result.jio_key) &&
(!result.view)) {
// don't update navigation history when not really redirecting
......@@ -107,7 +107,6 @@
}
}
console.log('lets redirect', command, result.jio_key, result.view);
// forced document change thus we update history
return gadget.redirect({
command: command,
......@@ -131,6 +130,10 @@
}
function submitDialogWithCustomDialogMethod(custom_dialog_method) {
return submitDialog.apply(this, [false, custom_dialog_method]);
}
var gadget_klass = rJS(window),
dialog_button_source = gadget_klass.__template_element
.getElementById("dialog-button-template")
......@@ -153,6 +156,8 @@
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("submitContent", "submitContent")
.allowPublicAcquisition("submitDialogWithCustomDialogMethod",
submitDialogWithCustomDialogMethod)
/////////////////////////////////////////////////////////////////
// Proxy methods to the child gadget
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.51952.22484.24285</string> </value>
<value> <string>979.52235.13599.34184</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1573729014.21</float>
<float>1573746083.31</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