Commit 41a3e3fa authored by Romain Courteaud's avatar Romain Courteaud Committed by Sebastien Robin

DIsplay the list of modules as frontpage

parent 8ae3c86e
......@@ -95,10 +95,19 @@
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string>.CodeMirror, .codemirror_gadget {\n
<value> <string>// .CodeMirror, .codemirror_gadget {\n
// FIXME: hardcoded value\n
height: 50em;\n
}</string> </value>
// height: 50em;\n
// }\n
\n
.CodeMirror {\n
// border: 1px solid #eee;\n
height: 60em;\n
}\n
// .CodeMirror-scroll {\n
// overflow-y: hidden;\n
// overflow-x: auto;\n
// }</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -109,6 +109,76 @@
$.mobile.linkBindingEnabled = false;\n
$.mobile.hashListeningEnabled = false;\n
$.mobile.pushStateEnabled = false;\n
\n
/////////////////////////////////////////////////////////////////\n
// Some functions\n
/////////////////////////////////////////////////////////////////\n
function renderFrontpage(gadget, options) {\n
document.querySelector("h1").textContent = "ERP5";\n
\n
return gadget.declareGadget("gadget_erp5_pt_frontpage.html", {\n
scope: "frontpage_gadget"\n
})\n
.push(function (sub_gadget) {\n
return RSVP.all([\n
sub_gadget.render(),\n
sub_gadget.getElement()\n
]);\n
});\n
}\n
\n
function renderJioDocument(gadget, options) {\n
var sub_options;\n
return gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
var jio_key = options.jio_key,\n
view = options.view;\n
\n
gadget.props.jio_key = jio_key;\n
///////////////////////////////////////////////\n
// Display erp5 document view\n
///////////////////////////////////////////////\n
return jio_gadget.get({"_id": jio_key}, {"_view": view});\n
})\n
.push(function (result) {\n
document.querySelector("h1").textContent = result.data.title || result.data.reference || options.jio_key;\n
var uri = new URI(\n
result.data._embedded._view._links.form_definition.href\n
);\n
// if ((uri.scheme() === "urn") &&\n
// (uri.segment(0) === "jio") &&\n
// (uri.segment(1) === "get")) {\n
// }\n
return RSVP.all([\n
result,\n
gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.get(\n
{"_id": uri.segment(2)},\n
{"_view": "view"}\n
);\n
})\n
]);\n
})\n
.push(function (result) {\n
sub_options = options.form_gadget || {};\n
sub_options.erp5_document = result[0].data;\n
sub_options.form_definition = result[1].data;\n
sub_options.view = options.view;\n
\n
return gadget.declareGadget("gadget_erp5_pt_" + sub_options.form_definition.pt + ".html", {\n
scope: "form_gadget"\n
});\n
})\n
\n
.push(function (form_gadget) {\n
return RSVP.all([\n
form_gadget.render(sub_options),\n
form_gadget.getElement()\n
]);\n
})\n
}\n
\n
\n
/////////////////////////////////////////////////////////////////\n
// Gadget behaviour\n
......@@ -204,68 +274,21 @@
// Render the page\n
.declareMethod(\'render\', function (options) {\n
var gadget = this,\n
sub_options;\n
queue;\n
\n
// $.mobile.loading(\'show\');\n
if (options.jio_key === undefined) {\n
// Redirect to the default view\n
return gadget.aq_pleasePublishMyState({jio_key: "web_page_module", view: "view"})\n
.push(gadget.pleaseRedirectMyHash.bind(gadget));\n
queue = renderFrontpage(gadget, options);\n
} else {\n
if (options.view === undefined) {\n
// Redirect to the default view\n
return gadget.aq_pleasePublishMyState({jio_key: options.jio_key, view: "view"})\n
.push(gadget.pleaseRedirectMyHash.bind(gadget));\n
}\n
queue = renderJioDocument(gadget, options);\n
}\n
if (options.view === undefined) {\n
// Redirect to the default view\n
return gadget.aq_pleasePublishMyState({jio_key: options.jio_key, view: "view"})\n
.push(gadget.pleaseRedirectMyHash.bind(gadget));\n
}\n
return gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
var jio_key = options.jio_key,\n
view = options.view;\n
\n
gadget.props.jio_key = jio_key;\n
///////////////////////////////////////////////\n
// Display erp5 document view\n
///////////////////////////////////////////////\n
return jio_gadget.get({"_id": jio_key}, {"_view": view});\n
})\n
.push(function (result) {\n
document.querySelector("h1").textContent = result.data.title || result.data.reference || options.jio_key;\n
var uri = new URI(\n
result.data._embedded._view._links.form_definition.href\n
);\n
// if ((uri.scheme() === "urn") &&\n
// (uri.segment(0) === "jio") &&\n
// (uri.segment(1) === "get")) {\n
// }\n
return RSVP.all([\n
result,\n
gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.get(\n
{"_id": uri.segment(2)},\n
{"_view": "view"}\n
);\n
})\n
]);\n
})\n
.push(function (result) {\n
sub_options = options.form_gadget || {};\n
sub_options.erp5_document = result[0].data;\n
sub_options.form_definition = result[1].data;\n
sub_options.view = options.view;\n
\n
return gadget.declareGadget("gadget_erp5_pt_" + sub_options.form_definition.pt + ".html", {\n
scope: "form_gadget"\n
});\n
})\n
\n
.push(function (form_gadget) {\n
return RSVP.all([\n
form_gadget.render(sub_options),\n
form_gadget.getElement()\n
]);\n
})\n
\n
return queue\n
.push(function (all_response) {\n
var page_element = all_response[1],\n
element = document.querySelector("article");\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_pt_frontpage.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_pt_frontpage_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
<!DOCTYPE html>\n
<html>\n
<head>\n
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<title>ERP5 PT Frontpage</title>\n
\n
<!-- renderjs -->\n
<script src="RSVP.js" type="text/javascript"></script>\n
<script src="renderjs.js" type="text/javascript"></script>\n
<script src="handlebars.js" type="text/javascript"></script>\n
\n
\n
<!-- custom script -->\n
<script src="gadget_global.js" type="text/javascript"></script>\n
<script src="gadget_erp5_pt_frontpage.js" type="text/javascript"></script>\n
\n
<script id="table-template" type="text/x-handlebars-template">\n
<ul data-role="listview" data-inset="true" class="document-listview">\n
{{#each documentlist}}\n
<li><a href="{{link}}">{{title}}</a></li>\n
{{/each}}\n
</ul>\n
</script>\n
\n
</head>\n
<body>\n
<section class="document_list"></section>\n
</body>\n
</html>
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 Frontpage</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_pt_frontpage.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_pt_frontpage_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*global rJS, RSVP, Handlebars, initGadgetMixin */\n
/*jslint nomen: true */\n
(function (window, rJS, RSVP, Handlebars) {\n
"use strict";\n
\n
/////////////////////////////////////////////////////////////////\n
// Handlebars\n
/////////////////////////////////////////////////////////////////\n
// Precompile the templates while loading the first gadget instance\n
var gadget_klass = rJS(window),\n
source = gadget_klass.__template_element\n
.getElementById("table-template")\n
.innerHTML,\n
table_template = Handlebars.compile(source);\n
\n
gadget_klass\n
/////////////////////////////////////////////////////////////////\n
// ready\n
/////////////////////////////////////////////////////////////////\n
// Init local properties\n
.ready(function (g) {\n
g.props = {};\n
})\n
\n
// Assign the element to a variable\n
.ready(function (g) {\n
return g.getElement()\n
.push(function (element) {\n
g.props.element = element;\n
});\n
})\n
\n
/////////////////////////////////////////////////////////////////\n
// Acquired methods\n
/////////////////////////////////////////////////////////////////\n
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")\n
.declareAcquiredMethod("whoWantToDisplayThis",\n
"whoWantToDisplayThis")\n
\n
/////////////////////////////////////////////////////////////////\n
// declared methods\n
/////////////////////////////////////////////////////////////////\n
.declareMethod("render", function (options) {\n
var gadget = this;\n
\n
return gadget.jio_allDocs({\n
"query": \'meta_type:"ERP5 Folder"\',\n
"select_list": ["title"]\n
})\n
.push(function (result) {\n
var result_list = [],\n
i;\n
for (i = 0; i < result.data.rows.length; i += 1) {\n
console.log(result.data.rows[i]);\n
result_list.push(RSVP.all([\n
gadget.whoWantToDisplayThis(result.data.rows[i].id),\n
result.data.rows[i].value.title || result.data.rows[i].id\n
]));\n
}\n
return RSVP.all(result_list);\n
})\n
.push(function (document_list) {\n
var i,\n
parameter_list = [],\n
doc;\n
for (i = 0; i < document_list.length; i += 1) {\n
doc = document_list[i];\n
parameter_list[i] = {\n
link: doc[0],\n
title: doc[1]\n
};\n
}\n
\n
parameter_list.sort(function (a, b) {\n
var result = 0;\n
if (a.title < b.title) {\n
result = -1;\n
} else if (a.title > b.title) {\n
result = 1;\n
}\n
return result;\n
});\n
\n
gadget.props.element.querySelector(\'.document_list\').innerHTML =\n
table_template({\n
documentlist: parameter_list\n
});\n
});\n
});\n
}(window, rJS, RSVP, Handlebars));
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 Frontpage JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
5
\ No newline at end of file
6
\ No newline at end of file
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