Commit 087b0523 authored by Romain Courteaud's avatar Romain Courteaud

webrjs break break

parent 5225bf78
...@@ -3,14 +3,13 @@ ...@@ -3,14 +3,13 @@
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>ERP5 Page Jump</title> <title>ERP5 PT Form Python Action</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html"> <link rel="http://www.renderjs.org/rel/interface" href="interface_erp5_page_template.html">
<link rel="http://www.renderjs.org/rel/interface" href="interface_erp5_form_content_provider.html">
<!-- renderjs --> <!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script> <script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script> <script src="jiodev.js" type="text/javascript"></script>
<!-- custom script --> <!-- custom script -->
...@@ -18,23 +17,13 @@ ...@@ -18,23 +17,13 @@
<script src="gadget_erp5_global.js" type="text/javascript"></script> <script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_jump.js" type="text/javascript"></script> <script src="gadget_erp5_page_jump.js" type="text/javascript"></script>
<!-- XXX need theme here currently -->
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-plane">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul class="document-listview">
{{#each documentlist}}
<li><a data-i18n="{{i18n}}" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head> </head>
<body> <body>
<form>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="erp5_form"
data-gadget-sandbox="public">
</div>
</form>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -152,11 +152,13 @@ ...@@ -152,11 +152,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -200,16 +202,20 @@ ...@@ -200,16 +202,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -232,7 +238,7 @@ ...@@ -232,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>970.15568.12710.24302</string> </value> <value> <string>980.38546.46958.29201</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +256,7 @@ ...@@ -250,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1537191534.73</float> <float>1576770423.33</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -259,16 +265,20 @@ ...@@ -259,16 +265,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -316,7 +326,9 @@ ...@@ -316,7 +326,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
/*global window, rJS, RSVP, Handlebars, URI, calculatePageTitle */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, URI, calculatePageTitle) { /*global window, rJS, RSVP, calculatePageTitle */
(function (window, rJS, RSVP, calculatePageTitle) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////////// function checkValidity() {
// Handlebars return this.getDeclaredGadget("erp5_form")
///////////////////////////////////////////////////////////////// .push(function (declared_gadget) {
// Precompile the templates while loading the first gadget instance return declared_gadget.checkValidity();
var gadget_klass = rJS(window), });
source = gadget_klass.__template_element }
.getElementById("table-template")
.innerHTML,
table_template = Handlebars.compile(source);
gadget_klass function getContent() {
///////////////////////////////////////////////////////////////// return this.getDeclaredGadget("erp5_form")
// ready .push(function (sub_gadget) {
///////////////////////////////////////////////////////////////// return sub_gadget.getContent();
// Init local properties });
.ready(function (g) { }
g.props = {};
function submitDialog() {
var gadget = this;
return gadget.getDeclaredGadget("erp5_form")
.push(function (sub_gadget) {
return sub_gadget.getContent();
})
.push(function (data) {
return gadget.submitContent(
gadget.state.jio_key,
gadget.state.erp5_document._embedded._view._actions.put.href, // most likely points to Base_callDialogMethod
data
);
}) })
.push(function (result) { // success redirect handler
console.log(result);
throw new Error("couscous");
var splitted_jio_key_list,
splitted_current_jio_key_list,
command,
i;
// Assign the element to a variable if (!result.jio_key) {
.ready(function (g) { return;
return g.getElement() }
.push(function (element) { if (gadget.state.jio_key === result.jio_key) {
g.props.element = element; // don't update navigation history when not really redirecting
return gadget.redirect({command: 'cancel_dialog_with_history'});
}
// Check if the redirection goes to a same parent's subdocument.
// In this case, do not add current document to the history
// example: when cloning, do not keep the original document in history
splitted_jio_key_list = result.jio_key.split('/');
splitted_current_jio_key_list = gadget.state.jio_key.split('/');
command = 'display_with_history';
if (splitted_jio_key_list.length === splitted_current_jio_key_list.length) {
for (i = 0; i < splitted_jio_key_list.length - 1; i += 1) {
if (splitted_jio_key_list[i] !== splitted_current_jio_key_list[i]) {
command = 'push_history';
}
}
} else {
command = 'push_history';
}
// forced document change thus we update history
return gadget.redirect({
command: command,
options: {
"jio_key": result.jio_key,
"view": result.view
// do not mingle with editable because it isn't necessary
}
}); });
}) });
}
var gadget_klass = rJS(window);
gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // acquisition
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("submitContent", "submitContent")
///////////////////////////////////////////////////////////////// .declareMethod('triggerSubmit', function () {
// declared methods return;
///////////////////////////////////////////////////////////////// })
.declareMethod("render", function (options) { .declareMethod('checkValidity', checkValidity, {mutex: 'changestate'})
var gadget = this, .declareMethod('getContent', getContent, {mutex: 'changestate'})
erp5_document,
result_list,
view_list;
return gadget.jio_getAttachment(options.jio_key, "links")
.push(function (result) {
var i,
promise_list = [
gadget.getUrlFor({command: 'cancel_dialog_with_history'})
];
erp5_document = result;
view_list = erp5_document._links.action_object_jump || [];
if (view_list.constructor !== Array) {
view_list = [view_list];
}
for (i = 0; i < view_list.length; i += 1) { .declareMethod('render', function render(options) {
promise_list.push(gadget.getUrlFor({command: 'push_history', options: { return this.changeState({
extended_search: new URI(view_list[i].href).query(true).query, jio_key: options.jio_key,
page: 'search' view: options.view,
}})); erp5_document: options.erp5_document,
} form_definition: options.form_definition,
return RSVP.all(promise_list); erp5_form: options.erp5_form || {}
});
}) })
.push(function (all_result) {
var i,
tab_list = [];
result_list = all_result; .declareJob('submit', function () {
return submitDialog.apply(this);
})
for (i = 1; i < all_result.length; i += 1) { .onStateChange(function onStateChange() {
tab_list.push({ var form_gadget = this;
title: view_list[i - 1].title, return new RSVP.Queue()
link: all_result[i], .push(function () {
i18n: view_list[i - 1].title // Render the erp5_from
}); return form_gadget.getDeclaredGadget("erp5_form");
} })
.push(function (erp5_form) {
var form_options = form_gadget.state.erp5_form;
// pass own form options to the embedded form
form_options.erp5_document = form_gadget.state.erp5_document;
form_options.form_definition = form_gadget.state.form_definition;
form_options.view = form_gadget.state.view;
form_options.jio_key = form_gadget.state.jio_key;
form_options.editable = true; // dialog is always editable
return erp5_form.render(form_options);
})
.push(function () {
// Render the headers
return RSVP.all([ return RSVP.all([
gadget.translateHtml(table_template({ form_gadget.getUrlFor({command: 'cancel_dialog_with_history'}),
definition_title: "Jumps", calculatePageTitle(form_gadget, form_gadget.state.erp5_document)
documentlist: tab_list,
definition_i18n: "Jumps"
})),
calculatePageTitle(gadget, erp5_document)
]); ]);
}) })
.push(function (last_result_list) { .push(function (all_result) {
gadget.props.element.innerHTML = last_result_list[0]; return form_gadget.updateHeader({
cancel_url: all_result[0],
return gadget.updateHeader({ page_title: all_result[1]
back_url: result_list[0],
page_title: last_result_list[1]
});
}); });
}) })
.declareMethod("triggerSubmit", function () { .push(function () {
return; return form_gadget.submit();
});
}); });
}(window, rJS, RSVP, Handlebars, URI, calculatePageTitle)); }(window, rJS, RSVP, calculatePageTitle));
\ No newline at end of file
...@@ -148,11 +148,13 @@ ...@@ -148,11 +148,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -196,16 +198,20 @@ ...@@ -196,16 +198,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -228,7 +234,7 @@ ...@@ -228,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>972.57046.22658.49288</string> </value> <value> <string>980.38546.25211.16042</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +252,7 @@ ...@@ -246,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1547028207.68</float> <float>1576770513.98</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -255,16 +261,20 @@ ...@@ -255,16 +261,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -312,7 +322,9 @@ ...@@ -312,7 +322,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -104,9 +104,12 @@ ...@@ -104,9 +104,12 @@
}})); }}));
} }
for (i = 0; i < jump_list.length; i += 1) { for (i = 0; i < jump_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'push_history', options: { promise_list.push(gadget.getUrlFor({command: 'display_dialog_with_history', options: {
extended_search: new URI(jump_list[i].href).query(true).query, jio_key: gadget.state.jio_key,
page: 'search' view: jump_list[i].href,
page: 'jump' // Views in ERP5 must be forms but because of
// extended_search: new URI(jump_list[i].href).query(true).query,
// page: 'search'
}})); }}));
} }
promise_list.push( promise_list.push(
......
...@@ -148,11 +148,13 @@ ...@@ -148,11 +148,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -196,16 +198,20 @@ ...@@ -196,16 +198,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -228,7 +234,7 @@ ...@@ -228,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.28771.29128.25958</string> </value> <value> <string>980.37038.2353.40806</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +252,7 @@ ...@@ -246,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1556782424.57</float> <float>1576769613.3</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -255,16 +261,20 @@ ...@@ -255,16 +261,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -312,7 +322,9 @@ ...@@ -312,7 +322,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
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