Commit 41e9c371 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] add fast input support

parent 075f68fc
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n CACHE MANIFEST\n
# generated on Wed, 01 Mar 2017 15:00:00 GMT\n # generated on Thu, 01 Jun 2017 15:00:00 GMT\n
# XXX + fonts\n # XXX + fonts\n
# images/ajax-loader.gif\n # images/ajax-loader.gif\n
CACHE:\n CACHE:\n
...@@ -175,6 +175,8 @@ gadget_erp5_notification.html\n ...@@ -175,6 +175,8 @@ gadget_erp5_notification.html\n
gadget_erp5_notification.js\n gadget_erp5_notification.js\n
gadget_erp5_page_action.html\n gadget_erp5_page_action.html\n
gadget_erp5_page_action.js\n gadget_erp5_page_action.js\n
gadget_erp5_page_add.html\n
gadget_erp5_page_add.js\n
gadget_erp5_page_form.html\n gadget_erp5_page_form.html\n
gadget_erp5_page_form.js\n gadget_erp5_page_form.js\n
gadget_erp5_page_front.html\n gadget_erp5_page_front.html\n
...@@ -371,7 +373,7 @@ NETWORK:\n ...@@ -371,7 +373,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.2829.24684.28142</string> </value> <value> <string>959.49530.43446.36010</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -389,7 +391,7 @@ NETWORK:\n ...@@ -389,7 +391,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1490088390.79</float> <float>1496322885.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Add
data-i18n=Fast Input
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Page Add</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_add.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c" data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-custom ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul data-role="listview" data-theme="c" data-inset="true" class="document-listview">
{{#each documentlist}}
<li><a data-i18n="{{title}}" class="ui-body-inherit" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, Handlebars, calculatePageTitle */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, calculatePageTitle) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
table_template = Handlebars.compile(gadget_klass.__template_element
.getElementById("table-template")
.innerHTML);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var new_content_list = [],
fast_input_list = [],
new_content_action_list = [],
fast_input_action_list = [],
gadget = this,
erp5_document;
return gadget.jio_getAttachment(options.jio_key, "links")
.push(function (result) {
var i,
promise_list = [];
erp5_document = result;
new_content_list = erp5_document._links.action_object_new_content_action || [];
fast_input_list = erp5_document._links.action_object_fast_input_jio || [];
if (new_content_list.constructor !== Array) {
new_content_list = [new_content_list];
}
if (fast_input_list.constructor !== Array) {
fast_input_list = [fast_input_list];
}
for (i = 0; i < new_content_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'change', options: {
view: new_content_list[i].href,
editable: true,
page: undefined
}}));
}
for (i = 0; i < fast_input_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'change', options: {
view: fast_input_list[i].href,
editable: true,
page: undefined
}}));
}
return RSVP.all(promise_list);
})
.push(function (all_result) {
// Only one action, directly show it
if (all_result.length === 1) {
return gadget.redirect({
command: 'raw',
options: {
url: all_result[0]
}
});
}
var i, j = 0;
for (i = 0; i < new_content_list.length; i += 1) {
new_content_action_list.push({
title: new_content_list[i].title,
i18n: new_content_list[i].title,
link: all_result[j]
});
j += 1;
}
for (i = 0; i < fast_input_list.length; i += 1) {
fast_input_action_list.push({
title: fast_input_list[i].title,
link: all_result[j],
i18n: fast_input_list[i].title
});
j += 1;
}
return gadget.translateHtml(table_template({
definition_title: "Add",
definition_i18n: "Add",
definition_icon: "plus",
documentlist: new_content_action_list
}) + table_template({
definition_title: "Fast Input",
documentlist: fast_input_action_list,
definition_icon: "exchange",
definition_i18n: "Fast Input"
}))
.push(function (my_translated_html) {
gadget.element.innerHTML = my_translated_html;
return RSVP.all([
gadget.getUrlFor({command: 'change', options: {
page: undefined
}}),
calculatePageTitle(gadget, erp5_document)
]);
})
.push(function (url_list) {
var dict = {
back_url: url_list[0],
page_title: url_list[1]
};
return gadget.updateHeader(dict);
});
});
});
}(window, rJS, RSVP, Handlebars, calculatePageTitle));
\ No newline at end of file
...@@ -71,12 +71,10 @@ ...@@ -71,12 +71,10 @@
// render the header // render the header
.push(function () { .push(function () {
var new_content_action = form_gadget.state.erp5_document._links.action_object_new_content_action; var new_content_action = "";
if ((form_gadget.state.erp5_document._links.hasOwnProperty('action_object_new_content_action')) ||
if (new_content_action !== undefined) { (form_gadget.state.erp5_document._links.hasOwnProperty('action_object_fast_input_jio_action'))) {
new_content_action = form_gadget.getUrlFor({command: 'change', options: {view: new_content_action.href, editable: true}}); new_content_action = form_gadget.getUrlFor({command: 'change', options: {page: "add"}});
} else {
new_content_action = "";
} }
return RSVP.all([ return RSVP.all([
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.34605.28227.45721</string> </value> <value> <string>959.49322.65017.42069</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476198578.1</float> <float>1496310453.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -61,13 +61,12 @@ ...@@ -61,13 +61,12 @@
// render the header // render the header
.push(function () { .push(function () {
var new_content_action = form_gadget.state.erp5_document._links.action_object_new_content_action, var new_content_action = "",
delete_action = form_gadget.state.erp5_document._links.action_object_delete_action; delete_action = form_gadget.state.erp5_document._links.action_object_delete_action;
if (new_content_action !== undefined) { if ((form_gadget.state.erp5_document._links.hasOwnProperty('action_object_new_content_action')) ||
new_content_action = form_gadget.getUrlFor({command: 'change', options: {view: new_content_action.href, editable: true}}); (form_gadget.state.erp5_document._links.hasOwnProperty('action_object_fast_input_jio_action'))) {
} else { new_content_action = form_gadget.getUrlFor({command: 'change', options: {page: "add"}});
new_content_action = "";
} }
if (delete_action !== undefined) { if (delete_action !== undefined) {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.31331.40640.10291</string> </value> <value> <string>958.33121.48203.5614</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1491385195.38</float> <float>1496310722.92</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