Commit 22287a1b authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: only display worklists involving Support Requests

Because this was displaying all worklists from ticket_worklist, which is
also used for all tickets (including for example Campaigns) and that
displaying other kind of tickets that Support Request is not supported
on this app, we should filter the worklists to display only support requests.
parent 74c44681
Pipeline #5629 failed with stage
"""Returns the worklists queries for ticket workflow, as a mapping where the key is the worklist ID and the value a JIO query. """Returns the worklists queries for ticket workflow, as a mapping where the key is the worklist ID and the value a JIO query.
If `portal_type` is provided, only return worklists that apply for this portal type.
This script has proxy role, as only manager can access workflow configuration. This script has proxy role, as only manager can access workflow configuration.
""" """
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
...@@ -11,6 +13,11 @@ workflow = portal.portal_workflow.ticket_workflow ...@@ -11,6 +13,11 @@ workflow = portal.portal_workflow.ticket_workflow
workflow_state_var = workflow.variables.getStateVar() workflow_state_var = workflow.variables.getStateVar()
for worklist in workflow.worklists.objectValues(): for worklist in workflow.worklists.objectValues():
if portal_type \
and 'portal_type' in worklist.getVarMatchKeys() \
and portal_type not in worklist.getVarMatch('portal_type'):
continue
query_list = [{ query_list = [{
'type': 'complex', 'type': 'complex',
'operator': 'OR', 'operator': 'OR',
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>portal_type=None</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -3,8 +3,9 @@ from Products.ERP5Type.Message import translateString ...@@ -3,8 +3,9 @@ from Products.ERP5Type.Message import translateString
import json import json
portal = context.getPortalObject() portal = context.getPortalObject()
worklist_query_dict = portal.ERP5Site_getTicketWorkflowWorklistInfoDict(
worklist_query_dict = portal.ERP5Site_getTicketWorkflowWorklistInfoDict() portal_type='Support Request'
)
# Query portal actions to get the worklist count and # Query portal actions to get the worklist count and
# extend this information with the query from our helper script. # extend this information with the query from our helper script.
...@@ -15,7 +16,9 @@ worklist_action_list = [ ...@@ -15,7 +16,9 @@ worklist_action_list = [
'query': worklist_query_dict[action['worklist_id']], 'query': worklist_query_dict[action['worklist_id']],
} }
for action in portal.portal_actions.listFilteredActionsFor(context)['global'] for action in portal.portal_actions.listFilteredActionsFor(context)['global']
if action['category'] == 'global' and action.get('workflow_id') == 'ticket_workflow' if action['category'] == 'global'
and action.get('workflow_id') == 'ticket_workflow'
and action.get('worklist_id') in worklist_query_dict
] ]
return json.dumps(worklist_action_list) return json.dumps(worklist_action_list)
...@@ -59,6 +59,11 @@ ...@@ -59,6 +59,11 @@
<td>//section[@class="document_list"]//li/a[contains(text(), "Suspended Support Requests")]/span[text() = "1"]</td> <td>//section[@class="document_list"]//li/a[contains(text(), "Suspended Support Requests")]/span[text() = "1"]</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>assertElementNotPresent</td>
<td>//section[@class="document_list"]//li/a[contains(text(), "Campaign")]/span[text() = "1"]</td>
<td></td>
</tr>
<!-- clicking on one worklist open the module --> <!-- clicking on one worklist open the module -->
<tr> <tr>
......
...@@ -52,4 +52,12 @@ portal.support_request_module.newContent( ...@@ -52,4 +52,12 @@ portal.support_request_module.newContent(
source_project_value=portal.project_module.erp5_officejs_support_request_ui_test_project_001, source_project_value=portal.project_module.erp5_officejs_support_request_ui_test_project_001,
).validate() ).validate()
# create a campaign that should not appear in this worklist
if portal.portal_workflow.ticket_workflow.worklists.get('0A_draft_campaign_list', None) is None:
raise ValueError('Without this worklist, tests have to be updated.')
portal.campaign_module.newContent(
portal_type='Campaign',
title="Should not appear in support request app",
)
return "Done." return "Done."
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