Commit c496ff02 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: don't crash interface for failing query

parent d9259433
master DateTime.equalTo_fix TMP-2to3 UpdateValidationStateFromConsistency UserPropertySheet_backward_compatibility acquisition-on-transformation addToDate_implicit_localtime api-ai-new api-json-form arnau arnau-RD-Components-CacheTool arnau-RD-Components-ERP5Form-ERP5Report arnau-RD-Components-ERP5Form-SelectionTool-MemcachedTool arnau-RD-Components-ERP5OOo arnau-RD-Components-PreferenceTool-Preference arnau-RD-Components-Products-import-compat arnau-RD-Components-astroid_cache_per_component_reset arnau-RD-Components-erp5_crm arnau-RD-Components-erp5_trade-TODO-Interactor arnau-RD-ERP5ify-portal_workflow-1-seb-merged-with-recent-master arnau-RD-ERP5ify-portal_workflow-2-do-not-rename-erp5_workflow-portal_types arnau-RD-ERP5ify-portal_workflow-BAK arnau-RD-ERP5ify-portal_workflow-WIP arnau-RD-ERP5ify-portal_workflow-WITHOUT-MIGRATION arnau-RD-ERP5ify-portal_workflow-WORKFLOWS-NOT-MIGRATED arnau-RD-py3-master-TM arnau-RD-py3-master-TM-BAK arnau-RD-py3-master-WIP arnau-RD-py3-master-WIP-BAK arnau-RD-py3-master-WIP-bt5-and-tests arnau-RD-zope4py3 arnau-TM-Components-Migrate-PortalTransforms arnau-TM-Components-ModuleSecurityInfo arnau-TM-FEC-output arnau-TM-WIP arnau-TM-isBuildable-with-multiple-BusinessLinks arnau-TM-newContent-temp_object arnau-TM-runUnitTest-clear-previous-execution-catalog arnau-TM-wkhtmltopdf arnau-WIP arnau-my2to3 arnau-real-time-inventory-accounting arnau-zope4py2 aurel-zope4py2 bt5_config cache-control-304-response callable-jupyter-storage catalog_filter cherry-pick-4a8e045d cleanup_acquisition_base_category cloud_reliability_test cribjs-bootloader delivery_item_barcode drop-ZServer dsn-phase3 e2e-erp5 enhance_scalability_testing erp5-component erp5-component-bak erp5-imt erp5-messenger erp5-vifib erp5-vifib-cleanup erp5-vifib-no-Products.DCWorkflowGraph erp5_catalog erp5_catalog_final erp5_corporate_identity erp5_drone_simulator erp5_hal_json_style_fix_restricted_access_with_traverse erp5_payslip_migration erp5testnode_max_timeout feat/cloudooo_libreoffice_7.5.2.2 feat/dedup_roles_in_pickles feat/dms_implicit_predecessor_successor_fields feat/erp5_ide feat/erp5pt feat/inventory_api_group_by_time_interval_list feat/lxml-html-snapshot feat/notification-message-ignore-missing feat/olapy feat/python_language_support feat/slapos_agent_distributor feature/renderjs-ui-no-header fix/TALES_hide_error fix/ZMI_editor_preference fix/advance_ecommerce_coding_crimes fix/erp5_site_global_id fix/login_validate_check_consistency fix/mariadb-1927 fix/monaco-altClick fix/officejs_support_request_rss_secu fix/state_var fix/support-request-app-empty fix/workflow_method_security fix_web_illustration for-mr-caterpillar for-mr-mouse for-mr-pig for-mr-pigeon for_testrunner_1 for_testrunner_2 for_testrunner_3 fusion-monster gadget-json-value graphic_gadget_js hotfix/rjs-formfields-padding initsite inventory isDeletable jm/form-action-guard js-ui limit_accelerated_http_cache_manager listbox_url lle-bout/metadata-modules macros_fix master_w mic_wind monitoring-graph mr1362 my2to3 nicolas-slice-price no_longer_simulated_state notebook_roque override_cache_control_header_by_caching_policy_manager poc/json-forms-study portal_callables publish_recursiveReindexObject refactor/base_edit reindex_calendar_after_change_calendar_exception restore-from-trashbin revert-192c2000 revert-38554dbe rfc/activate_default rjs_listbox_sort_icon roque_quick scalability-master scalability-roque scalability-roque-2 scalability-run-command scalability_crash_mariadb shop-box-rebase slapos-api-reborn streaming_fix streaming_fix-0 support_legacy_sftp_server support_relative_url_in_hyperlink_field support_request taskdistribution-xmlrpc-binary test-renderjs-float-field-step test_dynamic_methods tomo_testnode_slap_request translatable_path_master trustable-x-forwarded-for ttrm unify_predicate_edit view-aggregated-amounts without_legacy_workflow wsgi wsgi-gevent wsgi_backport_setbody_lock wsgi_medusa_stream_fix zope2zope4py2 zope4py3 zope4py3-master-rebase 0.4.59.1 0.4.59 test-ui test-rjsacc test-rjs renderjs-test nexedi-erp5-vifib-20201105 erp5.util-0.4.74 erp5.util-0.4.73 erp5.util-0.4.72 erp5.util-0.4.71 erp5.util-0.4.69 erp5.util-0.4.68 erp5.util-0.4.67 erp5.util-0.4.66 erp5.util-0.4.65 erp5.util-0.4.64 erp5.util-0.4.63 erp5.util-0.4.62 erp5.util-0.4.61 erp5.util-0.4.60 erp5.util-0.4.59.1 erp5.util-0.4.59 erp5.util-0.4.58 erp5.util-0.4.57 erp5.util-0.4.56 erp5.util-0.4.55 erp5.util-0.4.54 erp5.util-0.4.53 erp5.util-0.4.52 erp5.util-0.4.49 erp5.util-0.4.46 erp5.util-0.4.44 erp5-vifib-20230331 erp5-vifib-20230201 erp5-vifib-20220526 erp5-vifib-20220302 erp5-vifib-20210707 erp5-vifib-20201229 erp5-vifib-20200129
No related merge requests found
......@@ -1121,6 +1121,10 @@ html table thead th[colspan] {\n
text-align: center;\n
}\n
\n
html .ui-listbox-error {\n
text-align: center;\n
}\n
\n
/* cell background */\n
html table thead tr,\n
html table tfoot tr,\n
......@@ -5215,7 +5219,7 @@ html .ui-panel .ui-content .ui-btn[class*="ui-icon-"]:after {\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>948.40163.31953.33774</string> </value>
<value> <string>949.1052.3508.62634</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -5233,7 +5237,7 @@ html .ui-panel .ui-content .ui-btn[class*="ui-icon-"]:after {\n
</tuple>
<state>
<tuple>
<float>1453373898.88</float>
<float>1454957135.51</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -253,7 +253,18 @@
</table>\n
</div>\n
</script>\n
\n
\n
\n
\n
<script id="error-message-template" type="text/x-handlebars-template">\n
<div class="ui-listbox-error">\n
\t\t <a class="ui-btn ui-corner-all ui-btn-inline" href="{{reset_url}}">\n
\t\t <span style="color:red" data-i18n="Invalid Search Criteria">Invalid Search Criteria</span>\n
\t\t <span>-</span>\n
<span data-i18n="Reset">Reset</span>\n
</a>\n
</div>\n
</script>\n
\n
</head>\n
<body>\n
......@@ -397,7 +408,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>948.8903.55441.44066</string> </value>
<value> <string>949.1053.41653.819</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -415,7 +426,7 @@
</tuple>
<state>
<tuple>
<float>1451495552.88</float>
<float>1454957159.48</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -109,9 +109,9 @@
/*jslint indent: 2, maxerr: 3, nomen: true */\n
/*global window, document, rJS, URI, RSVP, loopEventListener,\n
SimpleQuery, ComplexQuery, Query, Handlebars*/\n
SimpleQuery, ComplexQuery, Query, Handlebars, console*/\n
(function (window, document, rJS, URI, RSVP, loopEventListener,\n
SimpleQuery, ComplexQuery, Query, Handlebars) {\n
SimpleQuery, ComplexQuery, Query, Handlebars, console) {\n
"use strict";\n
var gadget_klass = rJS(window),\n
listbox_hidden_thead_source = gadget_klass.__template_element\n
......@@ -140,7 +140,12 @@
listbox_source = gadget_klass.__template_element\n
.getElementById("listbox-template")\n
.innerHTML,\n
listbox_template = Handlebars.compile(listbox_source);\n
listbox_template = Handlebars.compile(listbox_source),\n
\n
error_message_source = gadget_klass.__template_element\n
.getElementById("error-message-template")\n
.innerHTML,\n
error_message_template = Handlebars.compile(error_message_source);\n
\n
\n
function renderListboxThead(gadget, template) {\n
......@@ -248,6 +253,22 @@
));\n
}\n
\n
\n
function renderErrorMessage(gadget) {\n
return gadget.getUrlFor({\n
command: \'store_and_change\',\n
options: {\n
"extended_search": ""\n
}\n
})\n
.push(function (url) {\n
return gadget.translateHtml(error_message_template(\n
{\n
\'reset_url\' : url\n
}\n
));\n
});\n
}\n
\n
rJS(window)\n
/////////////////////////////////////////////////////////////////\n
......@@ -388,6 +409,7 @@
select_list = [],\n
dataset,\n
counter,\n
queue,\n
i;\n
\n
if (field_json.query === undefined) {\n
......@@ -411,14 +433,26 @@
select_list.push(field_json.column_list[i][0]);\n
}\n
select_list.push("uid");\n
return gadget.jio_allDocs({\n
queue = gadget.jio_allDocs({\n
// XXX Not jIO compatible, but until a better api is found...\n
"list_method_template": field_json.list_method_template,\n
"query": query_string,\n
"limit": [begin_from, lines + 1],\n
"select_list": select_list,\n
"sort_on": gadget.props.sort_list\n
}).push(function (result) {\n
});\n
queue\n
.push(undefined, function (error) {\n
//XXXXX hack to not crash interface\n
//this will catch all error, not only search criteria invalid error\n
console.warn(error);\n
return renderErrorMessage(gadget)\n
.push(function (error_html) {\n
gadget.props.element.querySelector(".document_table").innerHTML = error_html;\n
queue.cancel();\n
});\n
})\n
.push(function (result) {\n
var promise_list = [result];\n
counter = Math.min(result.data.total_rows, lines);\n
for (i = 0; i < counter; i += 1) {\n
......@@ -514,6 +548,7 @@
}).push(function (my_html) {\n
gadget.props.element.querySelector(".tfoot").innerHTML = my_html;\n
});\n
return queue;\n
})\n
\n
\n
......@@ -657,7 +692,7 @@
});\n
\n
}(window, document, rJS, URI, RSVP, loopEventListener,\n
SimpleQuery, ComplexQuery, Query, Handlebars));
SimpleQuery, ComplexQuery, Query, Handlebars, console));
]]></string> </value>
</item>
......@@ -794,7 +829,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>948.8931.54995.63897</string> </value>
<value> <string>949.2121.3637.17544</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -812,7 +847,7 @@
</tuple>
<state>
<tuple>
<float>1451497439.76</float>
<float>1455022186.29</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -103,9 +103,9 @@
/*jslint indent: 2, maxerr: 3, maxlen: 100, nomen: true */\n
/*global window, document, rJS, RSVP, Handlebars, $, loopEventListener,\n
QueryFactory, SimpleQuery, ComplexQuery, Query*/\n
QueryFactory, SimpleQuery, ComplexQuery, Query, console*/\n
(function (window, document, rJS, RSVP, Handlebars, $, loopEventListener,\n
QueryFactory, SimpleQuery, ComplexQuery, Query) {\n
QueryFactory, SimpleQuery, ComplexQuery, Query, console) {\n
"use strict";\n
var gadget_klass = rJS(window),\n
filter_item_source = gadget_klass.__template_element\n
......@@ -319,7 +319,14 @@
query_list;\n
if (gadget.props.extended_search) {\n
//string to query\n
try {\n
query_list = QueryFactory.create(gadget.props.extended_search);\n
} catch (error) {\n
//XXXX hack to not crash interface\n
//it catch all error, not only search criteria invalid error\n
console.warn(error);\n
return;\n
}\n
if (query_list.operator === "OR") {\n
or.checked = true;\n
and.checked = false;\n
......@@ -476,7 +483,7 @@
});\n
\n
}(window, document, rJS, RSVP, Handlebars, $, loopEventListener,\n
QueryFactory, SimpleQuery, ComplexQuery, Query));
QueryFactory, SimpleQuery, ComplexQuery, Query, console));
]]></string> </value>
</item>
......@@ -613,7 +620,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>947.29484.5127.28433</string> </value>
<value> <string>949.2121.59518.17646</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -631,7 +638,7 @@
</tuple>
<state>
<tuple>
<float>1448903443.33</float>
<float>1455022145.56</float>
<string>UTC</string>
</tuple>
</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