Commit ca411361 authored by Roque's avatar Roque

erp5_post: refactoring on action gadgets

parent 194ce8e4
......@@ -3,7 +3,7 @@
(function (window, rJS, RSVP) {
"use strict";
var gadget_utils;
var parent_gadget, form_view_gadget;
rJS(window)
......@@ -22,29 +22,32 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("handleRender", function (gadget, gadget_utils, options, action_reference, parent_portal_type, form_definition) {
var child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';
.declareMethod("render", function (gadget) {
return form_view_gadget.renderGadget(gadget);
})
.declareMethod("handleRender", function (gadget, options, action_reference, form_definition) {
var child_gadget_url = 'gadget_erp5_pt_form_view_editable.html', this_gadget = this;
parent_gadget = gadget;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getUrlParameter('portal_type'),
gadget.getUrlParameter('parent_relative_url'),
gadget.getSetting('portal_type'),
gadget.getSetting('parent_relative_url')
parent_gadget.getUrlParameter('portal_type'),
parent_gadget.getUrlParameter('parent_relative_url'),
parent_gadget.getSetting('portal_type'),
parent_gadget.getSetting('parent_relative_url'),
parent_gadget.declareGadget("gadget_officejs_form_view.html")
]);
})
.push(function (result) {
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_utils.getFormDefinition(parent_portal_type, action_reference)
.push(function (result) {
form_definition = result;
return gadget_utils.createDocument(options);
})
form_view_gadget = result[4];
return form_view_gadget.createDocument(options)
.push(function (jio_key) {
return gadget.jio_get(jio_key)
return parent_gadget.jio_get(jio_key)
.push(function (new_document) {
return gadget.changeState({
return parent_gadget.changeState({
jio_key: jio_key,
doc: new_document,
child_gadget_url: child_gadget_url,
......@@ -60,7 +63,7 @@
});
})
.declareMethod("handleSubmit", function (gadget, gadget_utils, jio_key, content_dict) {
.declareMethod("handleSubmit", function (gadget, jio_key, content_dict) {
return gadget.notifySubmitting()
.push(function () {
return gadget.jio_get(jio_key);
......
......@@ -22,27 +22,35 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("handleRender", function (gadget, gadget_utils, options, action_reference, parent_portal_type, form_definition) {
var child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';
return gadget.jio_get(options.jio_key)
.push(function (parent_document) {
var title = parent_document.title;
if (!title.startsWith('Re: ')) { title = 'Re: ' + parent_document.title; }
return gadget.changeState({
doc: {title: title},
parent_document: parent_document,
child_gadget_url: child_gadget_url,
form_definition: form_definition,
view: action_reference,
editable: true,
has_more_views: false,
has_more_actions: false,
is_form_list: false
.declareMethod("render", function (gadget) {
return gadget_utils.renderGadget(gadget);
})
.declareMethod("handleRender", function (gadget, options, action_reference, form_definition) {
return gadget.declareGadget("gadget_officejs_form_view.html")
.push(function (declared_gadget) {
gadget_utils = declared_gadget;
var child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';
return gadget.jio_get(options.jio_key)
.push(function (parent_document) {
var title = parent_document.title;
if (!title.startsWith('Re: ')) { title = 'Re: ' + parent_document.title; }
return gadget.changeState({
doc: {title: title},
parent_document: parent_document,
child_gadget_url: child_gadget_url,
form_definition: form_definition,
view: action_reference,
editable: true,
has_more_views: false,
has_more_actions: false,
is_form_list: false
});
});
});
})
.declareMethod("handleSubmit", function (gadget, gadget_utils, jio_key, content_dict) {
.declareMethod("handleSubmit", function (gadget, jio_key, content_dict) {
var document = {
my_title: gadget.state.doc.title,
portal_type: gadget.state.parent_document.portal_type,
......
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