Commit ee2cfb59 authored by Roque's avatar Roque

erp5_officejs: remove post list gadget

- rendering of Post Module (and every portal type) is done by controller gadget
parent 9f30e982
......@@ -81,7 +81,7 @@
return has_more_dict;
})
.declareMethod("getFormDefinition", function (portal_type, action_reference, extra_params) {
.declareMethod("getFormDefinition", function (portal_type, action_reference, source_reference) {
var gadget = this,
parent = "portal_types/" + portal_type,
query = 'portal_type: "Action Information" AND reference: "' + action_reference + '" AND parent_relative_url: "' + parent + '"',
......@@ -109,7 +109,7 @@
form_definition.has_more_views = false;
form_definition.has_more_actions = has_more_dict.has_more_actions;
//for backward compatibility (header add button - '+' icon)
if (extra_params && extra_params.source_reference) {
if (form_definition.action_type === "object_list") {
form_definition._links.action_object_new_content_action = {
page: "handle_action",
title: "New Post",
......@@ -118,7 +118,7 @@
action_type: "object_jio_js_script",
parent_portal_type: "Post Module",
portal_type: "HTML Post",
source_reference: extra_params.source_reference
source_reference: source_reference
};
//form_definition.has_more_actions = false;
}
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.38080.43465.46097</string> </value>
<value> <string>975.39168.2243.39099</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1557406082.03</float>
<float>1557426063.79</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,6 +3,31 @@
(function (window, rJS, document) {
"use strict";
// TODO: move this to common utils
function getFormInfo(form_definition) {
var child_gadget_url,
form_type,
action_category = form_definition.action_type;
switch (action_category) {
case 'object_list':
form_type = 'list';
child_gadget_url = 'gadget_erp5_pt_form_list.html';
break;
case 'object_dialog':
form_type = 'dialog';
child_gadget_url = 'gadget_erp5_pt_form_dialog.html';
break;
case 'object_jio_js_script':
form_type = 'dialog';
child_gadget_url = 'gadget_erp5_pt_form_dialog.html';
break;
default:
form_type = 'page';
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';
}
return [form_type, child_gadget_url];
}
rJS(window)
/////////////////////////////////////////////////////////////////
......@@ -25,28 +50,14 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("getPortalType", function (jio_document, options) {
var gadget = this;
if (jio_document) {
if (jio_document.portal_type === undefined) {
throw new Error('Can not display document: ' + options.jio_key);
}
return jio_document.portal_type;
}
if (options.portal_type) {
return options.portal_type;
}
return gadget.getSetting('parent_portal_type');
})
.declareMethod("render", function (options) {
var gadget = this,
default_view = "jio_view",
common_utils_gadget_url = "gadget_officejs_common_utils.html",
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html',
gadget_utils,
jio_document,
portal_type;
portal_type,
front_page;
return gadget.declareGadget(common_utils_gadget_url)
.push(function (result) {
gadget_utils = result;
......@@ -54,35 +65,38 @@
})
.push(function (result) {
jio_document = result;
if (jio_document.portal_type === undefined) {
throw new Error('Can not display document: ' + options.jio_key);
}
}, function (error) {})
.push(function () {
return gadget.getPortalType(jio_document, options);
return gadget.getSetting('parent_portal_type');
})
.push(function (result) {
portal_type = result;
.push(function (parent_portal_type) {
if (jio_document) {
portal_type = jio_document.portal_type;
} else if (options.portal_type) {
portal_type = options.portal_type;
} else {
portal_type = parent_portal_type;
}
front_page = portal_type === parent_portal_type;
return gadget_utils.getFormDefinition(portal_type, default_view);
})
.push(function (form_definition) {
var form_type = 'page', front_page = false;
if (form_definition.action_type === "object_list") {
form_type = 'list';
child_gadget_url = 'gadget_erp5_pt_form_list.html';
//TODO: when refactoring is done in ojs_post_list (front-page), this will come from options
front_page = true;
}
var form_info = getFormInfo(form_definition),
form_type = form_info[0],
child_gadget_url = form_info[1];
return gadget.changeState({
jio_key: options.jio_key,
doc: jio_document,
portal_type: portal_type,
//TODO child_gadget_url should be decided in utils.getFormDefinition based on form type
child_gadget_url: child_gadget_url,
form_definition: form_definition,
form_type: form_type,
editable: false,
view: options.view,
front_page: front_page, //options.front_page
has_more_views: form_definition.has_more_views,
has_more_actions: form_definition.has_more_actions
view: options.view || default_view,
front_page: front_page
});
});
})
......@@ -96,10 +110,21 @@
}
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'fg'})
scope: 'form_view'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
})
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_view')
.push(function (view_gadget) {
return view_gadget.getDeclaredGadget('fg');
})
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
});
}(window, rJS, document));
\ No newline at end of file
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.39226.38744.26965</string> </value>
<value> <string>975.39482.5501.59630</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>1557409603.33</float>
<float>1557425018.64</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -225,8 +225,6 @@ gadget_erp5_page_action_officejs.html\n
gadget_erp5_page_action_officejs.js\n
gadget_erp5_page_ojs_controller.html\n
gadget_erp5_page_ojs_controller.js\n
gadget_erp5_page_ojs_post_list.html\n
gadget_erp5_page_ojs_post_list.js\n
gadget_officejs_form_view.html\n
gadget_officejs_form_view.js\n
gadget_erp5_page_handle_action.html\n
......@@ -748,7 +746,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.36365.10903.26368</string> </value>
<value> <string>975.39501.47391.29610</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -766,7 +764,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1557238532.71</float>
<float>1557426235.16</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.39213.26027.31914</string> </value>
<value> <string>975.39467.50073.9608</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1557408888.25</float>
<float>1557424135.7</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -4,6 +4,31 @@
(function (window, document, rJS, RSVP) {
"use strict";
// TODO: move this to common utils
function getFormInfo(form_definition) {
var child_gadget_url,
form_type,
action_category = form_definition.action_type;
switch (action_category) {
case 'object_list':
form_type = 'list';
child_gadget_url = 'gadget_erp5_pt_form_list.html';
break;
case 'object_dialog':
form_type = 'dialog';
child_gadget_url = 'gadget_erp5_pt_form_dialog.html';
break;
case 'object_jio_js_script':
form_type = 'dialog';
child_gadget_url = 'gadget_erp5_pt_form_dialog.html';
break;
default:
form_type = 'page';
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';
}
return [form_type, child_gadget_url];
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -56,7 +81,10 @@
valid_action = form_definition.action_type === "object_jio_js_script" &&
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;
action_gadget_url = form_definition.fields_raw_properties.gadget_field_action_js_script.values.gadget_url,
form_info = getFormInfo(form_definition),
form_type = form_info[0],
child_gadget_url = form_info[1];
if (valid_action) {
gadget.element.appendChild(fragment);
return gadget.declareGadget(action_gadget_url, {
......@@ -70,19 +98,20 @@
return gadget.changeState({
doc: doc,
parent_options: options,
child_gadget_url: 'gadget_erp5_pt_form_dialog.html',
form_type: 'dialog',
child_gadget_url: child_gadget_url,
form_type: form_type,
form_definition: form_definition,
view: action_reference,
valid_action: valid_action
});
});
} else {
//TODO refactor this to avoid 2 calls almost identical
return gadget.changeState({
doc: {},
parent_options: options,
child_gadget_url: 'gadget_erp5_pt_form_dialog.html',
form_type: 'dialog',
child_gadget_url: child_gadget_url,
form_type: form_type,
form_definition: form_definition,
view: action_reference,
valid_action: valid_action
......
......@@ -224,7 +224,7 @@
</tuple>
<state>
<tuple>
<float>1554736326.96</float>
<float>1557423724.15</float>
<string>UTC</string>
</tuple>
</state>
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.29197.38946.55620</string> </value>
<value> <string>975.39483.32712.34679</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1557237549.7</float>
<float>1557425011.91</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -373,7 +373,7 @@
</item>
<item>
<key> <string>configuration_frontpage_gadget_url</string> </key>
<value> <string>ojs_post_list</string> </value>
<value> <string>ojs_controller</string> </value>
</item>
<item>
<key> <string>configuration_hateoas_url</string> </key>
......@@ -680,7 +680,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.45016.35830.60074</string> </value>
<value> <string>973.45044.62122.33672</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -698,7 +698,7 @@
</tuple>
<state>
<tuple>
<float>1550239976.87</float>
<float>1557417902.24</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