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