From 31ca17e80cd752680018eb54772522c10cf7ed71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 7 Sep 2018 04:07:03 +0200 Subject: [PATCH] Revert "erp5_officejs_support_request_ui: Speedup the Support Request worklist searching." This reverts commit 9a84ef83f9aa46cf93cad43aec440dab65cebddc. Eventhough there's a delay due to cache, the default worklist implementation is efficient and worklist is translated. --- .../gadget_supportrequest_page_worklist_js.js | 61 +++++++++++------- ...gadget_supportrequest_page_worklist_js.xml | 4 +- .../SupportRequestModule_getWorklistAsJson.py | 31 ---------- ...SupportRequestModule_getWorklistAsJson.xml | 62 ------------------- 4 files changed, 40 insertions(+), 118 deletions(-) delete mode 100644 bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.py delete mode 100644 bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.xml diff --git a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.js b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.js index 873aa01d60..a2f122f1fb 100644 --- a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.js +++ b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.js @@ -1,6 +1,6 @@ -/*global window, rJS, RSVP, Handlebars */ +/*global window, rJS, RSVP, Handlebars, URI */ /*jslint nomen: true, indent: 2, maxerr: 3 */ -(function (window, rJS, RSVP, Handlebars) { +(function (window, rJS, RSVP, Handlebars, URI) { "use strict"; ///////////////////////////////////////////////////////////////// @@ -20,7 +20,6 @@ .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("translateHtml", "translateHtml") .declareAcquiredMethod("updateHeader", "updateHeader") - .declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getUrlFor", "getUrlFor") ///////////////////////////////////////////////////////////////// @@ -34,43 +33,58 @@ page_icon: 'clipboard' }) .push(function () { - return gadget.getSetting("hateoas_url"); - }) - .push(function (hateoas_url) { return gadget.jio_getAttachment( - 'support_request_module', - hateoas_url + 'support_request_module' - + "/SupportRequestModule_getWorklistAsJson" + 'portal_workflow', + 'links' ); }) .push(function (result) { + return gadget.jio_getAttachment( + // result.data.rows[0].id, + 'portal_workflow', + result._links.action_worklist.href + ); + }) + .push(function (links) { /*jslint continue:true*/ - var promise_list = [], + var action_list = links.worklist, + query_string, + promise_list = [], display_options, i; - - for (i = 0; i < result.length; i += 1) { - if (result[i].action_count === 0) { + for (i = 0; i < action_list.length; i += 1) { + query_string = new URI(action_list[i].href).query(true).query; + if (query_string.indexOf('portal_type:"Support Request"') === -1) { continue; } - display_options = { - jio_key: "support_request_module", - extended_search: result[i].query_string, - page: 'form', - view: 'view' - }; + display_options = {extended_search: query_string}; + if (action_list[i].hasOwnProperty('module')) { + display_options = { + jio_key: new URI(action_list[i].module).segment(2), + extended_search: query_string, + page: 'form', + view: 'view' + }; + } else { + display_options = { + extended_search: query_string, + page: 'search' + }; + } promise_list.push(RSVP.all([ gadget.getUrlFor({command: 'display', options: display_options}), // Remove the counter from the title - result[i].action_name, - result[i].action_count + action_list[i].name, + action_list[i].count ])); + } return RSVP.all(promise_list); }) .push(function (result_list) { - var line_list = [], i; + var line_list = [], + i; for (i = 0; i < result_list.length; i += 1) { line_list.push({ link: result_list[i][0], @@ -83,4 +97,5 @@ }); }); }); -}(window, rJS, RSVP, Handlebars)); \ No newline at end of file + +}(window, rJS, RSVP, Handlebars, URI)); \ No newline at end of file diff --git a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.xml b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.xml index 04fac03ed6..5bbcfd9149 100644 --- a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.xml +++ b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_page_worklist_js.xml @@ -234,7 +234,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>962.26499.5927.24507</string> </value> + <value> <string>962.13948.13888.3242</string> </value> </item> <item> <key> <string>state</string> </key> @@ -252,7 +252,7 @@ </tuple> <state> <tuple> - <float>1506651141.01</float> + <float>1506505200.17</float> <string>UTC</string> </tuple> </state> diff --git a/bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.py b/bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.py deleted file mode 100644 index 32189402ef..0000000000 --- a/bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.py +++ /dev/null @@ -1,31 +0,0 @@ -import json - -portal = context.getPortalObject() - -count_list = [] -state_dict = { - "submitted": "Support Request to Open", - "draft": "Support Request to Submit", - "validated": "Support Request to Close", - "suspended": "Suspended Support Requests" -} - -# XXX hardcoded, these lines below reflect portal_workflow/ticket_workflow worklists -count_list.append({ - 'query_string': 'portal_type:"Support Request" AND simulation_state:"draft" AND local_roles:"Owner"', - 'action_name': state_dict["draft"], - 'action_count': portal.support_request_module.countFolder(portal_type="Support Request", simulation_state="draft", local_roles="Owner")[0][0]}) -count_list.append({ - 'query_string': 'portal_type:"Support Request" AND simulation_state:"submitted" AND local_roles:"Assignor"', - 'action_name': state_dict["submitted"], - 'action_count': portal.support_request_module.countFolder(portal_type="Support Request", simulation_state="submitted", local_roles="Assignor")[0][0]}) -count_list.append({ - 'query_string': 'portal_type:"Support Request" AND simulation_state:"validated" AND local_roles:("Assignee" OR "Assignor")', - 'action_name': state_dict["validated"], - 'action_count': portal.support_request_module.countFolder(portal_type="Support Request", simulation_state="validated", local_roles=("Assignee", "Assignor"))[0][0]}) -count_list.append({ - 'query_string': 'portal_type:"Support Request" AND simulation_state:"suspended" AND local_roles:("Assignee" OR "Assignor")', - 'action_name': state_dict["suspended"], - 'action_count': portal.support_request_module.countFolder(portal_type="Support Request", simulation_state="suspended", local_roles=("Assignee", "Assignor"))[0][0]}) - -return json.dumps(count_list) diff --git a/bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.xml b/bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.xml deleted file mode 100644 index 4bc34045b0..0000000000 --- a/bt5/erp5_officejs_support_request_ui/SkinTemplateItem/portal_skins/erp5_officejs_support_request/SupportRequestModule_getWorklistAsJson.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>Script_magic</string> </key> - <value> <int>3</int> </value> - </item> - <item> - <key> <string>_bind_names</string> </key> - <value> - <object> - <klass> - <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> - </klass> - <tuple/> - <state> - <dictionary> - <item> - <key> <string>_asgns</string> </key> - <value> - <dictionary> - <item> - <key> <string>name_container</string> </key> - <value> <string>container</string> </value> - </item> - <item> - <key> <string>name_context</string> </key> - <value> <string>context</string> </value> - </item> - <item> - <key> <string>name_m_self</string> </key> - <value> <string>script</string> </value> - </item> - <item> - <key> <string>name_subpath</string> </key> - <value> <string>traverse_subpath</string> </value> - </item> - </dictionary> - </value> - </item> - </dictionary> - </state> - </object> - </value> - </item> - <item> - <key> <string>_params</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>SupportRequestModule_getWorklistAsJson</string> </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> -- 2.30.9