Commit 0e88bea9 authored by Roque's avatar Roque

erp5_officejs: action gadgets handle submit

parent b800a43e
...@@ -9,12 +9,7 @@ ...@@ -9,12 +9,7 @@
// Acquired methods // Acquired methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -38,9 +33,20 @@ ...@@ -38,9 +33,20 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, action_reference; var gadget = this, action_reference;
return gadget.getUrlParameter("action") return RSVP.Queue()
.push(function (action_parameter) { .push(function () {
action_reference = action_parameter; return RSVP.all([
gadget.getUrlParameter('portal_type'),
gadget.getUrlParameter('parent_relative_url'),
gadget.getSetting('portal_type'),
gadget.getSetting('parent_relative_url'),
gadget.getUrlParameter("action")
]);
})
.push(function (result) {
action_reference = result[4];
if (result[0] !== undefined) {options.portal_type = result[0]; } else {options.portal_type = result[2]; }
if (result[1] !== undefined) {options.parent_relative_url = result[1]; } else {options.parent_relative_url = result[3]; }
return gadget.getActionFormDefinition(action_reference); return gadget.getActionFormDefinition(action_reference);
}) })
.push(function (form_definition) { .push(function (form_definition) {
...@@ -54,7 +60,7 @@ ...@@ -54,7 +60,7 @@
element: fragment element: fragment
}) })
.push(function (action_gadget) { .push(function (action_gadget) {
return action_gadget.handleRender(gadget, options, action_reference, form_definition); return action_gadget.render(options, action_reference, form_definition);
}); });
} }
} }
...@@ -63,60 +69,12 @@ ...@@ -63,60 +69,12 @@
}); });
}) })
.onStateChange(function () { .declareMethod('triggerSubmit', function () {
var gadget = this; var gadget = this;
return gadget.getUrlParameter("action") return gadget.getDeclaredGadget('action_field')
.push(function (action_reference) {
return gadget.getActionFormDefinition(action_reference);
})
.push(function (form_definition) {
if (form_definition.fields_raw_properties.hasOwnProperty("gadget_field_action_js_script")) {
var fragment = document.createElement('div'),
action_gadget_url = form_definition.fields_raw_properties.gadget_field_action_js_script.values.gadget_url;
gadget.element.appendChild(fragment);
return gadget.declareGadget(action_gadget_url, {
scope: "action_field",
element: fragment
})
.push(function (action_gadget) { .push(function (action_gadget) {
return action_gadget.render(gadget); return action_gadget.triggerSubmit();
}); });
}
}); });
})
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.declareMethod('triggerSubmit', function () {
return this.getDeclaredGadget('fg')
.push(function (gadget) {
return gadget.triggerSubmit();
});
})
.allowPublicAcquisition('submitContent', function (options) {
var gadget = this,
jio_key = options[0],
//target_url = options[1],
content_dict = options[2];
return gadget.getUrlParameter("action")
.push(function (action_reference) {
return gadget.getActionFormDefinition(action_reference);
})
.push(function (form_definition) {
if (form_definition.fields_raw_properties.hasOwnProperty("gadget_field_action_js_script")) {
var fragment = document.createElement('div'),
action_gadget_url = form_definition.fields_raw_properties.gadget_field_action_js_script.values.gadget_url;
gadget.element.appendChild(fragment);
return gadget.declareGadget(action_gadget_url, {
scope: "action_field",
element: fragment
})
.push(function (action_gadget) {
return action_gadget.handleSubmit(gadget, jio_key, content_dict);
});
}
});
});
}(window, document, rJS, RSVP)); }(window, document, rJS, RSVP));
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.17966.28995.38997</string> </value> <value> <string>975.23581.9849.38673</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1556220394.2</float> <float>1556559118.24</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