Commit 14768f82 authored by Romain Courteaud's avatar Romain Courteaud Committed by Sebastien Robin

Calculate full document breadcrumb

parent 549864c6
...@@ -116,18 +116,28 @@ ...@@ -116,18 +116,28 @@
<script src="RSVP.js" type="text/javascript"></script>\n <script src="RSVP.js" type="text/javascript"></script>\n
<script src="renderjs.js" type="text/javascript"></script>\n <script src="renderjs.js" type="text/javascript"></script>\n
<script src="URI.js" type="text/javascript"></script>\n <script src="URI.js" type="text/javascript"></script>\n
\n <script src="handlebars.js" type="text/javascript"></script>\n
\n \n
<!-- custom script -->\n <!-- custom script -->\n
<script src="gadget_erp5_breadcrumb.js" type="text/javascript"></script>\n <script src="gadget_erp5_breadcrumb.js" type="text/javascript"></script>\n
\n
<script id="breadcrumb-template" type="text/x-handlebars-template">\n
<p>\n
{{#each parentlist}}\n
<a href="{{link}}">{{title}}</a> >\n
{{/each}}\n
<a class="responsive ui-btn ui-icon-carat-d ui-btn-icon-right" data-role="button" role="button">{{title}}</a>\n
</p>\n
</script>\n
\n
\n \n
</head>\n </head>\n
<body>\n <body>\n
<nav class="ui-title">\n <nav class="ui-title">\n
<div class="breadcrumb_container"></div>\n <p>\n
<h1>ERP5</h1>\n <a class="responsive ui-btn ui-icon-carat-d ui-btn-icon-right" data-role="button" role="button">ERP5</a>\n
</p>\n
</nav>\n </nav>\n
\n
</body>\n </body>\n
</html> </html>
...@@ -252,7 +262,7 @@ ...@@ -252,7 +262,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>sven</string> </value> <value> <string>romain</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -266,7 +276,7 @@ ...@@ -266,7 +276,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>936.46085.31000.7680</string> </value> <value> <string>937.44124.45260.39765</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -284,7 +294,7 @@ ...@@ -284,7 +294,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1407318368.87</float> <float>1411132836.24</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -99,16 +99,20 @@ ...@@ -99,16 +99,20 @@
</item> </item>
<item> <item>
<key> <string>text_content</string> </key> <key> <string>text_content</string> </key>
<value> <string>/*jslint indent: 2, maxerr: 3 */\n <value> <string>/*jslint nomen: true, indent: 2, maxerr: 3 */\n
/*global URI, document, window, rJS */\n /*global URI, window, rJS, Handlebars, RSVP */\n
(function (URI, document, window, rJS) {\n (function (URI, window, rJS, Handlebars, RSVP) {\n
"use strict";\n "use strict";\n
\n \n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
// Handlebars\n // Handlebars\n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
// Precompile the templates while loading the first gadget instance\n // Precompile the templates while loading the first gadget instance\n
var gadget_klass = rJS(window);\n var gadget_klass = rJS(window),\n
source = gadget_klass.__template_element\n
.getElementById("breadcrumb-template")\n
.innerHTML,\n
breadcrumb_template = Handlebars.compile(source);\n
\n \n
gadget_klass\n gadget_klass\n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
...@@ -124,48 +128,68 @@ ...@@ -124,48 +128,68 @@
return g.getElement()\n return g.getElement()\n
.push(function (element) {\n .push(function (element) {\n
g.props.element = element;\n g.props.element = element;\n
g.props.nav_element = element.querySelector("nav");\n
});\n });\n
})\n })\n
\n \n
.declareAcquiredMethod("whoWantToDisplayThis", "whoWantToDisplayThis")\n .declareAcquiredMethod("whoWantToDisplayThis", "whoWantToDisplayThis")\n
.declareAcquiredMethod("jio_get", "jio_get")\n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
// declared methods\n // declared methods\n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
.declareMethod(\'render\', function (options) {\n .declareMethod(\'render\', function (options) {\n
var gadget = this,\n
parent_queue = new RSVP.Queue(),\n
parent_list = [];\n
\n \n
var h1_element = this.props.element.querySelector("h1"),\n function handleParent(parent_link) {\n
parent_element = this.props.element.querySelector(".breadcrumb_container"),\n parent_queue.push(function () {\n
title = options.title || "ERP5",\n var uri,\n
parent_link = options.parent_link,\n jio_key;\n
gadget = this,\n
uri,\n
link_element;\n
\n
h1_element.textContent = title;\n
// Clear the previous rendering\n
while (parent_element.firstChild) {\n
parent_element.removeChild(parent_element.firstChild);\n
}\n
if (parent_link !== undefined) {\n if (parent_link !== undefined) {\n
uri = new URI(parent_link.href);\n uri = new URI(parent_link.href);\n
return gadget.whoWantToDisplayThis(uri.segment(2))\n jio_key = uri.segment(2);\n
if (jio_key === undefined) {\n
// Parent is the ERP5 site\n
parent_list.splice(0, 0, {\n
title: "ERP5",\n
link: "#"\n
});\n
} else {\n
// Parent is an ERP5 document\n
return gadget.whoWantToDisplayThis(jio_key)\n
.push(function (parent_href) {\n .push(function (parent_href) {\n
link_element = document.createElement("a");\n parent_list.splice(0, 0, {\n
// XXX Romain: please allow to "go home" via breadcrumb\n title: parent_link.name,\n
if (parent_href === "#erp5_gadget.jio_key=undefined") {\n link: parent_href\n
parent_href = "#";\n });\n
return gadget.jio_get({"_id": jio_key});\n
})\n
.push(function (result) {\n
// XXX Copy/pasted from gadget_erp5.js\n
handleParent(result.data._links.parent || "#");\n
});\n
}\n
\n
}\n }\n
link_element.textContent = parent_link.name || "Home";\n
link_element.href = parent_href;\n
link_element.setAttribute("class", "responsive ui-btn ui-icon-carat-u ui-btn-icon-left");\n
link_element.setAttribute("data-role", "button");\n
link_element.setAttribute("role", "button");\n
parent_element.appendChild(link_element);\n
});\n });\n
}\n }\n
\n
handleParent(options.parent_link);\n
\n
return new RSVP.Queue()\n
.push(function () {\n
return parent_queue;\n
})\n
.push(function () {\n
gadget.props.nav_element.innerHTML = breadcrumb_template({\n
title: options.title || "ERP5",\n
parentlist: parent_list\n
});\n
});\n
});\n });\n
\n \n
}(URI, document, window, rJS));</string> </value> }(URI, window, rJS, Handlebars, RSVP));</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -300,7 +324,7 @@ ...@@ -300,7 +324,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>937.42799.61797.63761</string> </value> <value> <string>937.44174.27024.38451</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -318,7 +342,7 @@ ...@@ -318,7 +342,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1411053138.25</float> <float>1411135730.1</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -140,15 +140,7 @@ ...@@ -140,15 +140,7 @@
<div data-gadget-url="gadget_erp5_breadcrumb.html"\n <div data-gadget-url="gadget_erp5_breadcrumb.html"\n
data-gadget-scope="breadcrumb"\n data-gadget-scope="breadcrumb"\n
data-gadget-sandbox="public"></div>\n data-gadget-sandbox="public"></div>\n
</div>\n
\n
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n
<div class="ui-controlgroup-controls">\n
<a class="responsive ui-btn ui-icon-plus ui-btn-icon-left ui-disabled" role="button" data-role="button">New</a>\n <a class="responsive ui-btn ui-icon-plus ui-btn-icon-left ui-disabled" role="button" data-role="button">New</a>\n
<a role="button" data-role="button" href="#" class="responsive ui-btn ui-icon-home ui-btn-icon-left">Home</a>\n
</div>\n
</div>\n
\n
</header>\n </header>\n
\n \n
<article></article>\n <article></article>\n
...@@ -156,7 +148,6 @@ ...@@ -156,7 +148,6 @@
<section data-gadget-url="gadget_jio.html"\n <section data-gadget-url="gadget_jio.html"\n
data-gadget-scope="jio_gadget"\n data-gadget-scope="jio_gadget"\n
data-gadget-sandbox="public"></section>\n data-gadget-sandbox="public"></section>\n
<!-- <aside></aside> -->\n
</body>\n </body>\n
</html> </html>
...@@ -281,7 +272,7 @@ ...@@ -281,7 +272,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>sven</string> </value> <value> <string>romain</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -295,7 +286,7 @@ ...@@ -295,7 +286,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>936.49302.26306.5341</string> </value> <value> <string>937.43906.3473.2406</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -313,7 +304,7 @@ ...@@ -313,7 +304,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1407832402.03</float> <float>1411130950.24</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -558,7 +558,7 @@ ...@@ -558,7 +558,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>937.42777.53771.30873</string> </value> <value> <string>937.44173.5242.20019</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -576,7 +576,7 @@ ...@@ -576,7 +576,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1411051824.11</float> <float>1411135519.91</float>
<string>GMT</string> <string>GMT</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