From 549864c6076127bbf2137c3c9c84b3900a60f945 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Fri, 19 Sep 2014 09:19:27 +0000 Subject: [PATCH] Group modules by business_application --- .../rjs_gadget_erp5_pt_frontpage_html.xml | 11 ++-- .../rjs_gadget_erp5_pt_frontpage_js.xml | 58 +++++++++++++++---- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_html.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_html.xml index 4e7bf11d61..c814020c2c 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_html.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_html.xml @@ -123,11 +123,12 @@ <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 + <dl data-role="listview" data-inset="true" class="document-listview">\n + <dt>{{definition_title}}</dt>\n {{#each documentlist}}\n - <li><a href="{{link}}">{{title}}</a></li>\n + <dd><a href="{{link}}">{{title}}</a></dd>\n {{/each}}\n - </ul>\n + </dl>\n </script>\n \n </head>\n @@ -271,7 +272,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>936.25886.55930.55876</string> </value> + <value> <string>937.42724.27724.55893</string> </value> </item> <item> <key> <string>state</string> </key> @@ -289,7 +290,7 @@ </tuple> <state> <tuple> - <float>1406120865.84</float> + <float>1411117135.09</float> <string>GMT</string> </tuple> </state> diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_js.xml index c06a21c201..783a533d7e 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_frontpage_js.xml @@ -148,7 +148,7 @@ \n return gadget.jio_allDocs({\n "query": \'meta_type:"ERP5 Folder" AND id:"%_module"\',\n - "select_list": ["title"]\n + "select_list": ["title", "business_application_title"]\n })\n .push(function (result) {\n var result_list = [],\n @@ -156,24 +156,53 @@ for (i = 0; i < result.data.rows.length; i += 1) {\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 + result.data.rows[i].value.title || result.data.rows[i].id,\n + result.data.rows[i].value.business_application_title\n ]));\n }\n return RSVP.all(result_list);\n })\n .push(function (document_list) {\n var i,\n - parameter_list = [],\n + business_application_dict = {},\n + business_application_list = [],\n + business_application,\n + module_info,\n + result_html = "",\n doc;\n for (i = 0; i < document_list.length; i += 1) {\n doc = document_list[i];\n - parameter_list[i] = {\n + if (doc[2] === undefined) {\n + doc[2] = "Other";\n + }\n + module_info = {\n link: doc[0],\n title: doc[1]\n };\n + if (business_application_dict[doc[2]] === undefined) {\n + business_application_dict[doc[2]] = [module_info];\n + business_application_list.push(doc[2]);\n + } else {\n + business_application_dict[doc[2]].push(module_info);\n + }\n }\n \n - parameter_list.sort(function (a, b) {\n + business_application_list.sort(function (a, b) {\n + // Push the "Other" value at the end\n + var result = 0;\n + if (a === "Other") {\n + result = 1;\n + } else if (b === "Other") {\n + result = -1;\n + } else if (a < b) {\n + result = -1;\n + } else if (a > b) {\n + result = 1;\n + }\n + return result;\n + });\n +\n + function sort_module(a, b) {\n var result = 0;\n if (a.title < b.title) {\n result = -1;\n @@ -181,12 +210,19 @@ result = 1;\n }\n return result;\n - });\n + }\n \n - gadget.props.element.querySelector(\'.document_list\').innerHTML =\n - table_template({\n - documentlist: parameter_list\n + for (i = 0; i < business_application_list.length; i += 1) {\n + business_application = business_application_list[i];\n + business_application_dict[business_application].sort(sort_module);\n + result_html += table_template({\n + definition_title: business_application,\n + documentlist: business_application_dict[business_application]\n });\n + }\n +\n +\n + gadget.props.element.querySelector(\'.document_list\').innerHTML = result_html;\n });\n });\n }(window, rJS, RSVP, Handlebars)); @@ -326,7 +362,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>937.42839.47775.36010</string> </value> + <value> <string>937.43884.286.40960</string> </value> </item> <item> <key> <string>state</string> </key> @@ -344,7 +380,7 @@ </tuple> <state> <tuple> - <float>1411055530.72</float> + <float>1411118240.63</float> <string>GMT</string> </tuple> </state> -- 2.30.9