From 2471a65da8ffb6bb99a77d91b23c688e509bfa91 Mon Sep 17 00:00:00 2001 From: Ayush Date: Mon, 24 Sep 2018 11:47:51 +0200 Subject: [PATCH 1/5] [erp5_core] Revert view for Historical Comparison. Partial revert from 2f121c199baa9537e803e --- .../document_zuite/testHistory.zpt | 57 +- .../testFormViewHistoricalRevisionLink.zpt | 29 +- ...e_getHistoricalComparisonDifferenceList.py | 67 ++- .../Base_viewHistoricalComparison.xml | 4 +- .../Base_viewHistoricalComparison/listbox.xml | 495 +++++++++++++++++- .../listbox_diff.xml | 169 ------ product/ERP5/tests/testXHTML.py | 1 - 7 files changed, 547 insertions(+), 275 deletions(-) delete mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox_diff.xml diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistory.zpt b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistory.zpt index 283ccb0c226..ade305f01a4 100644 --- a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistory.zpt +++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistory.zpt @@ -130,21 +130,20 @@ title - assertElementPresent - //tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"] - + assertText + //tr[@class='listbox-data-line-0 DataA']/td[2] + Title 0 - storeEval - document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value'); - _data_gadget_value + assertText + //tr[@class='listbox-data-line-0 DataA']/td[3] + Version 1 - verifyEval - storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '') - ---+++@@-1+1@@-Title0+Version1 + assertText + //tr[@class='listbox-data-line-0 DataA']/td[4] + Version 3 - @@ -191,21 +190,20 @@ title - assertElementPresent - //tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"] - + assertText + //tr[@class='listbox-data-line-0 DataA']/td[2] + Version 1 - storeEval - document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value'); - _data_gadget_value + assertText + //tr[@class='listbox-data-line-0 DataA']/td[3] + Version 2 - verifyEval - storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '') - ---+++@@-1+1@@-Version1+Version2 + assertText + //tr[@class='listbox-data-line-0 DataA']/td[4] + Version 3 - @@ -270,21 +268,20 @@ title - assertElementPresent - //tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"] - + assertText + //tr[@class='listbox-data-line-0 DataA']/td[2] + Version 2 - storeEval - document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value'); - _data_gadget_value + assertText + //tr[@class='listbox-data-line-0 DataA']/td[3] + Version 3 - verifyEval - storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '') - ---+++@@-1+1@@-Version2+Version3 + assertText + //tr[@class='listbox-data-line-0 DataA']/td[4] + Version 3 - diff --git a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt index ad3e106bfad..baa5999dd2f 100644 --- a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt @@ -130,32 +130,19 @@ verifyText //div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[2] - Diff Viewer - - - - waitForElementPresent - //div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe - + Old Value - pause - 1000 - - - - - storeEval - document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.contentWindow.document.body.textContent - diff_content + verifyText + //div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[3] + New Value - verifyEval - - storedVars['diff_content'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '') - 1-1+Anewfoo + verifyText + //div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[4] + Current Value - \ No newline at end of file + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py index 86bd29144a9..92525c9acec 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py @@ -1,42 +1,65 @@ -from Products.ERP5Type.Document import newTempBase +from Products.PythonScripts.standard import Object from ZODB.POSException import ConflictError from zExceptions import Unauthorized Base_translateString = context.Base_translateString -portal = context.getPortalObject() -portal_diff = portal.portal_diff try: context.HistoricalRevisions[serial] except (ConflictError, Unauthorized): raise -except Exception: - return [newTempBase(portal, Base_translateString('Historical revisions are' +except Exception: # POSKeyError + return [Object(property_name=Base_translateString('Historical revisions are' ' not available, maybe the database has been packed'))] if next_serial == '0.0.0.0': - # In case the next serial is 0.0.0.0, we should always be considering the - # new object as the current context new_getProperty = context.getProperty - new = context else: new = context.HistoricalRevisions[next_serial] new_getProperty = new.getProperty old = context.HistoricalRevisions[serial] result = [] -# XXX: Instead of creating a separate property list here, we can use DiffTool -# to directly find out the beautified diff and send it to the listbox +binary_data_explanation = Base_translateString("Binary data can't be displayed") +base_error_message = Base_translateString('(value retrieval failed)') -diff = portal_diff.diffPortalObject(old, new).asBeautifiedJSONDiff() +for prop_dict in context.getPropertyMap(): + prop = prop_dict['id'] + error = False + try: + current_value = context.getProperty(prop) + except TypeError: + error = True + current_value = base_error_message + try: + old_value = old.getProperty(prop) + except TypeError: + error = True + old_value = base_error_message + try: + new_value = new_getProperty(prop) + except TypeError: + error = True + new_value = base_error_message + if new_value != old_value or error: + # check if values are unicode convertible (binary are not) + if isinstance(new_value, (str, unicode)): + try: + unicode(str(new_value), 'utf-8') + except UnicodeDecodeError: + new_value = binary_data_explanation + if isinstance(old_value, (str, unicode)): + try: + unicode(str(old_value), 'utf-8') + except UnicodeDecodeError: + old_value = binary_data_explanation + if isinstance(current_value, (str, unicode)): + try: + unicode(str(current_value), 'utf-8') + except UnicodeDecodeError: + current_value = binary_data_explanation -tempbase_list = [] -uid = 900 -for x in diff: - temp_obj = newTempBase(portal, - x['path'], - **x) - temp_obj.setUid('new_%s' % uid) - uid = uid + 1 - tempbase_list.append(temp_obj) - -return tempbase_list + result.append( Object( property_name=prop, + new_value=new_value, + old_value=old_value, + current_value=current_value)) +return result diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml index 9dccd9a7848..ee9d3acf19c 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml @@ -90,9 +90,7 @@ hidden - - listbox_diff - + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml index 7021c08dc4d..46c0467b30f 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml @@ -2,24 +2,10 @@ - + - - delegated_list - - - columns - count_method - lines - list_method - selection_name - title - url_columns - - - id listbox @@ -40,11 +26,135 @@ - field_id + all_columns + + + + alternate_name + + + + columns + + + + count_method + + + + css_class + + + + default_params + + + + description + + + + domain_root_list + + + + domain_tree + + + + editable + + + + editable_columns + + + + enabled + + + + external_validator + + + + global_attributes + + + + hidden + + + + lines + + + + list_action + + + + list_method + + + + meta_types + + + + page_template + + + + portal_types + + + + report_root_list + + + + report_tree + + + + search + + + + search_columns + + + + select + + + + selection_name + + + + sort + + + + sort_columns + + + + stat_columns - form_id + stat_method + + + + title + + + + url_columns @@ -55,11 +165,137 @@ - field_id + all_columns + + + + alternate_name + + + + columns + + + + count_method + + + + css_class + + + + default_params + + + + description + + + + domain_root_list + + + + domain_tree + + + + editable + + + + editable_columns + + + + enabled + + + + external_validator + + + + global_attributes + + + + hidden + + + + lines + + + + list_action + + AAAAAAAAAAI= + + + + list_method + + + + meta_types + + + + page_template + + + + portal_types - form_id + report_root_list + + + + report_tree + + + + search + + + + search_columns + + + + select + + + + selection_name + + + + sort + + + + sort_columns + + + + stat_columns + + + + stat_method + + + + title + + + + url_columns @@ -69,17 +305,39 @@ values + + all_columns + + + + + + alternate_name + + + + anchor + 0 + columns - path + property_name Property Name - diff - Diff Viewer + old_value + Old Value + + + new_value + New Value + + + current_value + Current Value @@ -89,12 +347,82 @@ - field_id - my_view_mode_listbox + css_class + + + + default_display_style + table + + + default_params + + + + + + description + + + + display_style_list + + + + + + domain_root_list + + + - form_id - Base_viewFieldLibrary + domain_tree + 0 + + + editable + 1 + + + editable_columns + + + + + + enabled + 1 + + + external_validator + + + + global_attributes + + + + + + global_search_column + + + + hidden + 0 + + + hide_rows_on_no_search_criterion + 0 + + + lines + 20 + + + list_action + list lines @@ -103,27 +431,117 @@ list_method - AAAAAAAAAAI= + AAAAAAAAAAM= + + + + meta_types + + + + + + page_navigation_template + ListBox_viewSliderPageNavigationRenderer + + + page_template + + + + portal_types + + + + + + report_root_list + + + + + + report_tree + 0 + + + row_css_method + + + + search + 0 + + + search_columns + + + + select + 0 + selection_name + historical_comparison_selection + + + sort + + + + + + sort_columns + + + + + + stat_columns + + + + + + stat_method + + style_columns + + + + title Differences + + untranslatable_columns + + + + url_columns - path + property_name - diff + old_value + + + + new_value + + + + current_value @@ -136,6 +554,25 @@ + + + + Products.Formulator.TALESField + TALESMethod + + + + + + + + _text + string:${here/getRelativeUrl}/HistoricalRevisions/${request/serial}/view?portal_status_message=Version%20from%20${request/time} + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox_diff.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox_diff.xml deleted file mode 100644 index 2581464c01d..00000000000 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox_diff.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - delegated_list - - - css_class - default - gadget_url - js_sandbox - title - - - - - id - listbox_diff - - - message_values - - - - external_validator_failed - The input failed the external validator. - - - - - - overrides - - - - field_id - - - - form_id - - - - - - - tales - - - - css_class - - - - default - - AAAAAAAAAAI= - - - - field_id - - - - form_id - - - - gadget_url - - AAAAAAAAAAM= - - - - js_sandbox - - AAAAAAAAAAQ= - - - - title - - - - - - - values - - - - css_class - listbox-gadget - - - default - - - - field_id - my_gadget_field - - - form_id - Base_viewFieldLibrary - - - gadget_url - - - - js_sandbox - - - - title - Diff Viewer - - - - - - - - - - - - - - - _text - python: cell.diff - - - - - - - - - - - - _text - python: field.restrictedTraverse(\'gadget_erp5_side_by_side_diff.html\').absolute_url() - - - - - - - - - - - - _text - python: context.Base_getDiffGadgetSandbox() - - - - - diff --git a/product/ERP5/tests/testXHTML.py b/product/ERP5/tests/testXHTML.py index 74d9b7f4908..91ae73f169a 100644 --- a/product/ERP5/tests/testXHTML.py +++ b/product/ERP5/tests/testXHTML.py @@ -50,7 +50,6 @@ class TestXHTMLMixin(ERP5TypeTestCase): # some forms have intentionally empty listbox selections like RSS generators FORM_LISTBOX_EMPTY_SELECTION_PATH_LIST = ['erp5_web_widget_library/WebSection_viewContentListAsRSS', - 'erp5_core/Base_viewHistoricalComparison', 'erp5_diff/ERP5Site_viewDiffTwoObjectDialog',] JSL_IGNORE_FILE_LIST = ( 'diff2html.js', -- 2.30.9 From 94349f9de2588e5c552ff17f37569331d55ac7b9 Mon Sep 17 00:00:00 2001 From: Ayush Date: Mon, 24 Sep 2018 13:44:22 +0200 Subject: [PATCH 2/5] [erp5_core] Use DiffTool to display historical revision diff --- .../document_zuite/testHistoricalDiff.xml | 58 ++++++ .../document_zuite/testHistoricalDiff.zpt | 197 ++++++++++++++++++ ...stHistoricalDiffNoLinkForCurrentChange.xml | 58 ++++++ ...stHistoricalDiffNoLinkForCurrentChange.zpt | 177 ++++++++++++++++ .../testFormViewHistoricalRevisionLink.zpt | 75 +++++++ .../portal_actions/view_historical_diff.xml | 71 +++++++ .../erp5_core/Base_getCurrentDiffUrl.py | 48 +++++ .../erp5_core/Base_getCurrentDiffUrl.xml | 62 ++++++ .../portal_skins/erp5_core/Base_getDiffUrl.py | 40 ++++ .../erp5_core/Base_getDiffUrl.xml | 62 ++++++ ...e_getHistoricalComparisonDifferenceList.py | 20 +- ..._getHistoricalComparisonDifferenceList.xml | 2 +- .../Base_getHistoricalComparisonUrl.py | 11 +- .../Base_viewHistoricalComparison.xml | 6 +- .../Base_viewHistoricalComparison/listbox.xml | 94 +++++++-- .../Base_viewHistoricalComparisonDiff.xml | 138 ++++++++++++ .../listbox.xml | 84 ++++++++ .../listbox_diff.xml | 78 +++++++ .../my_action.xml | 121 +++++++++++ .../my_actor.xml | 117 +++++++++++ .../my_datetime.xml | 132 ++++++++++++ .../erp5_diff/Base_getObjectDiffList.py | 137 +++++++----- .../erp5_diff/Base_getObjectDiffList.xml | 2 +- .../erp5_core/bt/template_action_path_list | 1 + product/ERP5/tests/testERP5Core.py | 12 +- 25 files changed, 1725 insertions(+), 78 deletions(-) create mode 100644 bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.xml create mode 100644 bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.zpt create mode 100644 bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.xml create mode 100644 bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.zpt create mode 100644 product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/portal_actions/view_historical_diff.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox_diff.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_action.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_actor.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_datetime.xml diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.xml b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.xml new file mode 100644 index 00000000000..a02490dbe7e --- /dev/null +++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.xml @@ -0,0 +1,58 @@ + + + + + + + + + + _bind_names + + + + + + + + + + _asgns + + + + name_subpath + traverse_subpath + + + + + + + + + + + content_type + text/html + + + expand + 0 + + + id + testHistoricalDiff + + + output_encoding + utf-8 + + + title + + + + + + diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.zpt b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.zpt new file mode 100644 index 00000000000..d09e5bdcf94 --- /dev/null +++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiff.zpt @@ -0,0 +1,197 @@ + + + +Test History Available from edit_workflow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test History and edit_workflow
storehttp://example.com/erp5base_url
open${base_url}/bar_module/ListBoxZuite_reset
assertTextPresentReset Successfully.
open${base_url}/bar_module/Zuite_waitForActivities
assertTextPresentDone.
open${base_url}/bar_module/FooModule_createObjects?portal_type=Bar&num:int=1
open${base_url}/bar_module/0
typefield_my_titleVersion 1
clickAndWaitBase_edit:method
typefield_my_titleVersion 2
clickAndWaitBase_edit:method
typefield_my_titleVersion 3
clickAndWaitBase_edit:method
clickAndWaitlink=History
verifyText//span[@class="listbox-current-page-total-number x0_listbox-current-page-total-number"]4 records
clickAndWait//tr[@class='x0_listbox-data-line-1 DataB']/td[4]/a
assertTitleHistorical Comparison - Version 3*
verifyText//span[@class="listbox-current-page-total-number"]1 records
assertText//tr[@class='listbox-data-line-0 DataA']/td[1]title
assertText//tr[@class='listbox-data-line-0 DataA']/td[2]Title 0
assertText//tr[@class='listbox-data-line-0 DataA']/td[3]Version 1
assertText//tr[@class='listbox-data-line-0 DataA']/td[4]Version 3
clickAndWait//tr[@class='listbox-data-line-0 DataA']/td[3]//a
assertText//tr[@class='listbox-data-line-0 DataA']/td[1]title
assertElementPresent//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]
storeEvaldocument.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');_data_gadget_value
verifyEvalstoredVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')---+++@@-1+1@@-Title0+Version1
clickAndWaitlink=History
verifyText//span[@class="listbox-current-page-total-number x0_listbox-current-page-total-number"]4 records
clickAndWait//tr[@class='x0_listbox-data-line-1 DataB']/td[4]/a
assertTitleHistorical Comparison - Version 3*
clickAndWait//tr[@class='listbox-data-line-0 DataA']/td[4]//a
assertText//tr[@class='listbox-data-line-0 DataA']/td[1]title
assertElementPresent//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]
storeEvaldocument.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');_data_gadget_value
verifyEvalstoredVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')---+++@@-1+1@@-Version1+Version3
+ + \ No newline at end of file diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.xml b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.xml new file mode 100644 index 00000000000..41e5ffd9e17 --- /dev/null +++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.xml @@ -0,0 +1,58 @@ + + + + + + + + + + _bind_names + + + + + + + + + + _asgns + + + + name_subpath + traverse_subpath + + + + + + + + + + + content_type + text/html + + + expand + 0 + + + id + testHistoricalDiffNoLinkForCurrentChange + + + output_encoding + utf-8 + + + title + + + + + + diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.zpt b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.zpt new file mode 100644 index 00000000000..b531a36a286 --- /dev/null +++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testHistoricalDiffNoLinkForCurrentChange.zpt @@ -0,0 +1,177 @@ + + + +Test History Available from edit_workflow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test Historical Diff For Links
storehttp://example.com/erp5base_url
open${base_url}/bar_module/ListBoxZuite_reset
assertTextPresentReset Successfully.
open${base_url}/bar_module/Zuite_waitForActivities
assertTextPresentDone.
open${base_url}/bar_module/FooModule_createObjects?portal_type=Bar&num:int=1
open${base_url}/bar_module/0
typefield_my_titleVersion 1
clickAndWaitBase_edit:method
typefield_my_titleVersion 2
clickAndWaitBase_edit:method
typefield_my_titleVersion 3
clickAndWaitBase_edit:method
clickAndWaitlink=History
verifyText//span[@class="listbox-current-page-total-number x0_listbox-current-page-total-number"]4 records
clickAndWait//tr[@class='x0_listbox-data-line-3 DataB']/td[4]/a
assertTitleHistorical Comparison - Version 3*
verifyText//span[@class="listbox-current-page-total-number"]1 records
assertText//tr[@class='listbox-data-line-0 DataA']/td[1]title
assertText//tr[@class='listbox-data-line-0 DataA']/td[2]Version 2
assertText//tr[@class='listbox-data-line-0 DataA']/td[3]Version 3
assertText//tr[@class='listbox-data-line-0 DataA']/td[4]Version 3
clickAndWait//tr[@class='listbox-data-line-0 DataA']/td[3]//a
assertText//tr[@class='listbox-data-line-0 DataA']/td[1]title
assertElementPresent//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]
storeEvaldocument.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');_data_gadget_value
verifyEvalstoredVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')---+++@@-1+1@@-Version2+Version3
clickAndWaitlink=History
verifyText//span[@class="listbox-current-page-total-number x0_listbox-current-page-total-number"]4 records
clickAndWait//tr[@class='x0_listbox-data-line-3 DataB']/td[4]/a
assertTitleHistorical Comparison - Version 3*
assertElementNotPresent//tr[@class='listbox-data-line-0 DataA']/td[4]//a
+ + \ No newline at end of file diff --git a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt index baa5999dd2f..042925dda16 100644 --- a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testFormViewHistoricalRevisionLink.zpt @@ -64,6 +64,21 @@ A new foo + + waitForElementPresent + //textarea[@name='field_my_lines_list'] + + + + + type + //textarea[@name='field_my_lines_list'] + +Foo +Bar + + + @@ -142,6 +157,66 @@ //div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[4] Current Value + + verifyText + //div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[3] + New Value + + + verifyText + //div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[4] + Current Value + + + + verifyText + //div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[1] + short_title + + + verifyText + //div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[2] + + + + verifyText + //div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[3] + A new foo + + + verifyText + //div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[4] + A new foo + + + + + click + //div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[3]/a + + + + waitForElementPresent + //div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe + + + + pause + 1000 + + + + + storeEval + document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.contentWindow.document.body.textContent + diff_content + + + verifyEval + + storedVars['diff_content'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '') + 1-1+('Foo','Bar') + diff --git a/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/portal_actions/view_historical_diff.xml b/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/portal_actions/view_historical_diff.xml new file mode 100644 index 00000000000..c8ff211f039 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/portal_actions/view_historical_diff.xml @@ -0,0 +1,71 @@ + + + + + + + + + + action + + AAAAAAAAAAI= + + + + category + object_hidden + + + condition + + + + description + + + + icon + + + + id + view_historical_diff + + + permissions + + + View + + + + + priority + 108.0 + + + title + View Historical Diff + + + visible + 1 + + + + + + + + + + + + text + python: object.absolute_url() + \'/Base_viewHistoricalComparisonDiff\' + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.py new file mode 100644 index 00000000000..5038bc57520 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.py @@ -0,0 +1,48 @@ +""" +This URL script is used for Historical comparison list +to show the diff between the new value and current value. + +In case there new value is the current value, there is no +need to show the diff link. +""" +request = context.REQUEST + +# In this case, the second serial should be the current value, i.e, 0.0.0.0 +first_serial = getattr(brain, 'next_serial', '0.0.0.0') +second_serial = '0.0.0.0' +time = getattr(brain, 'time', '') +action = getattr(brain, 'action', '') +actor = getattr(brain, 'actor', '') + +# There is no need to compare revisions in case its the +# first version. +if first_serial != second_serial: + if url_dict: + return {'command': 'index', + 'options': { + # XXX: This shouldn't be the referred way to get + # relative URL, but if we directly use context here + # to get the relative URL, it will return us the + # URL of tempbase object of list, which is not + # what we desire, thus taking the approach to + # get it via REQUEST + 'jio_key': request.get('relative_url'), + }, + 'view_kw': { + 'view': 'view_historical_diff', + 'jio_key': request.get('relative_url'), + 'extra_param_json': { + 'first_serial': first_serial, + 'second_serial': second_serial, + 'time': time, + 'action': action, + 'actor': actor, + } + } + } + + return 'Base_viewHistoricalComparisonDiff?first_serial=%s&second_serial=%s&time=%s&action=%s&actor=%s'\ + % ( first_serial, second_serial, time, action, actor ) + +elif url_dict: + return {} diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.xml new file mode 100644 index 00000000000..330bacc9e4f --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getCurrentDiffUrl.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + brain, url_dict=False, **kw + + + id + Base_getCurrentDiffUrl + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.py new file mode 100644 index 00000000000..dbb0ce987b6 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.py @@ -0,0 +1,40 @@ +""" +This URL script is used for Historical comparison list +to get diff between old and new value +""" +request = context.REQUEST + +first_serial = getattr(brain, 'serial', '0.0.0.0') +second_serial = getattr(brain, 'next_serial', '0.0.0.0') +time = getattr(brain, 'time', '') +action = getattr(brain, 'action', '') +actor = getattr(brain, 'actor', '') + +# There is no need to compare revisions in case its the +# first version. +if url_dict: + return {'command': 'index', + 'options': { + # XXX: This shouldn't be the referred way to get + # relative URL, but if we directly use context here + # to get the relative URL, it will return us the + # URL of tempbase object of list, which is not + # what we desire, thus taking the approach to + # get it via REQUEST + 'jio_key': request.get('relative_url'), + }, + 'view_kw': { + 'view': 'view_historical_diff', + 'jio_key': request.get('relative_url'), + 'extra_param_json': { + 'first_serial': first_serial, + 'second_serial': second_serial, + 'time': time, + 'action': action, + 'actor': actor, + } + } + } + +return 'Base_viewHistoricalComparisonDiff?first_serial=%s&second_serial=%s&time=%s&action=%s&actor=%s'\ + % ( first_serial, second_serial, time, action, actor ) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.xml new file mode 100644 index 00000000000..c4149705938 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getDiffUrl.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + brain, url_dict=False, serial=None, next_serial=None, **kw + + + id + Base_getDiffUrl + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py index 92525c9acec..c56ace431ec 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.py @@ -1,6 +1,7 @@ from Products.PythonScripts.standard import Object from ZODB.POSException import ConflictError from zExceptions import Unauthorized +from Products.ERP5Type.Document import newTempBase Base_translateString = context.Base_translateString try: @@ -57,9 +58,18 @@ for prop_dict in context.getPropertyMap(): unicode(str(current_value), 'utf-8') except UnicodeDecodeError: current_value = binary_data_explanation - - result.append( Object( property_name=prop, - new_value=new_value, - old_value=old_value, - current_value=current_value)) + x = {'property_name': prop, + 'new_value': new_value, + 'old_value': old_value, + 'current_value': current_value, + } + tmp_obj = newTempBase(context, + '', + **x) + tmp_obj.setProperty('serial', serial) + tmp_obj.setProperty('next_serial', next_serial) + tmp_obj.setProperty('action', action) + tmp_obj.setProperty('actor', actor) + tmp_obj.setProperty('time', time) + result.append(tmp_obj) return result diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml index 92c2c9aac35..07218f0875d 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml @@ -50,7 +50,7 @@
_params - serial, next_serial, **kw + serial, next_serial, action, actor, time, **kw id diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonUrl.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonUrl.py index 0ca4cdaf5c3..3b2b17eaf61 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonUrl.py +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonUrl.py @@ -11,6 +11,9 @@ request = context.REQUEST serial = getattr(brain, 'serial', '0.0.0.0') next_serial = getattr(brain, 'next_serial', '0.0.0.0') +time = getattr(brain, 'time', '') +action = getattr(brain, 'action', '') +actor = getattr(brain, 'actor', '') # There is no need to compare revisions in case its the # first version. @@ -32,12 +35,14 @@ if serial != '0.0.0.0': 'extra_param_json': { 'serial': serial, 'next_serial': next_serial, - 'time': brain.time + 'time': time, + 'action': action, + 'actor': actor, } } } - return 'Base_viewHistoricalComparison?serial=%s&next_serial=%s&time=%s'\ - % ( serial, next_serial, brain.time ) + return 'Base_viewHistoricalComparison?serial=%s&next_serial=%s&time=%s&action=%s&actor=%s'\ + % ( serial, next_serial, time, action, actor ) elif url_dict: return {} diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml index ee9d3acf19c..ed9df7872cd 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison.xml @@ -39,7 +39,7 @@ description - bar + edit_order @@ -144,6 +144,10 @@ update_action + + update_action_title + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml index 46c0467b30f..4169aede719 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparison/listbox.xml @@ -18,6 +18,10 @@ external_validator_failed The input failed the external validator. + + required_not_found + Input is required but no input given. + @@ -33,6 +37,10 @@ alternate_name + + anchor + + columns @@ -45,6 +53,10 @@ css_class + + default_display_style + + default_params @@ -53,6 +65,10 @@ description + + display_style_list + + domain_root_list @@ -81,10 +97,18 @@ global_attributes + + global_search_column + + hidden + + hide_rows_on_no_search_criterion + + lines @@ -101,6 +125,10 @@ meta_types + + page_navigation_template + + page_template @@ -117,6 +145,10 @@ report_tree + + row_css_method + + search @@ -149,10 +181,18 @@ stat_method + + style_columns + + title + + untranslatable_columns + + url_columns @@ -172,6 +212,10 @@ alternate_name + + anchor + + columns @@ -184,6 +228,10 @@ css_class + + default_display_style + + default_params @@ -192,6 +240,10 @@ description + + display_style_list + + domain_root_list @@ -220,10 +272,18 @@ global_attributes + + global_search_column + + hidden + + hide_rows_on_no_search_criterion + + lines @@ -242,6 +302,10 @@ meta_types + + page_navigation_template + + page_template @@ -258,6 +322,10 @@ report_tree + + row_css_method + + search @@ -290,10 +358,18 @@ stat_method + + style_columns + + title + + untranslatable_columns + + url_columns @@ -422,11 +498,7 @@ list_action - list - - - lines - 0 + list_method @@ -538,11 +610,11 @@ new_value - + Base_getDiffUrl current_value - + Base_getCurrentDiffUrl @@ -555,13 +627,7 @@ - - - Products.Formulator.TALESField - TALESMethod - - - + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff.xml new file mode 100644 index 00000000000..6a7c995f175 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff.xml @@ -0,0 +1,138 @@ + + + + + + + + + + _objects + + + + + + action + + + + description + + + + edit_order + + + + + + encoding + UTF-8 + + + enctype + + + + group_list + + + left + right + center + bottom + hidden + + + + + groups + + + + bottom + + + listbox + + + + + center + + + + + + hidden + + + listbox_diff + + + + + left + + + my_action + my_actor + + + + + right + + + my_datetime + + + + + + + + id + Base_viewHistoricalComparisonDiff + + + method + POST + + + name + Base_viewHistoricalComparisonDiff + + + pt + form_view + + + row_length + 4 + + + stored_encoding + UTF-8 + + + title + Historical Differences + + + unicode_mode + 0 + + + update_action + + + + update_action_title + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox.xml new file mode 100644 index 00000000000..4549a5fbce8 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox.xml @@ -0,0 +1,84 @@ + + + + + + + + + + delegated_list + + + selection_name + + + + + id + listbox + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + field_id + + + + form_id + + + + + + + values + + + + field_id + listbox + + + form_id + ERP5Site_viewDiffTwoObjectDialog + + + selection_name + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox_diff.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox_diff.xml new file mode 100644 index 00000000000..261b17f7869 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/listbox_diff.xml @@ -0,0 +1,78 @@ + + + + + + + + + + delegated_list + + + + + + id + listbox_diff + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + field_id + + + + form_id + + + + + + + values + + + + field_id + listbox_diff + + + form_id + ERP5Site_viewDiffTwoObjectDialog + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_action.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_action.xml new file mode 100644 index 00000000000..ef0565b8d0a --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_action.xml @@ -0,0 +1,121 @@ + + + + + + + + + + delegated_list + + + default + editable + title + + + + + id + my_action + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + default + + AAAAAAAAAAI= + + + + editable + + + + field_id + + + + form_id + + + + title + + + + + + + values + + + + default + + + + editable + 0 + + + field_id + my_string_field + + + form_id + Base_viewFieldLibrary + + + title + Action + + + + + + + + + + + + + + + _text + python: request.get(\'action\', \'\') + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_actor.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_actor.xml new file mode 100644 index 00000000000..cc2bb87e2f2 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_actor.xml @@ -0,0 +1,117 @@ + + + + + + + + + + delegated_list + + + default + editable + title + + + + + id + my_actor + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + default + + AAAAAAAAAAI= + + + + editable + + + + field_id + + + + form_id + + + + + + + values + + + + default + + + + editable + 0 + + + field_id + my_string_field + + + form_id + Base_viewFieldLibrary + + + title + Actor + + + + + + + + + + + + + + + _text + python: request.get(\'actor\', \'\') + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_datetime.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_datetime.xml new file mode 100644 index 00000000000..c0c06b90899 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistoricalComparisonDiff/my_datetime.xml @@ -0,0 +1,132 @@ + + + + + + + + + + delegated_list + + + date_only + default + editable + title + + + + + id + my_datetime + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + date_only + + + + default + + AAAAAAAAAAI= + + + + editable + + + + field_id + + + + form_id + + + + title + + + + + + + values + + + + date_only + 0 + + + default + + + + + + editable + 0 + + + field_id + my_date_time_field + + + form_id + Base_viewFieldLibrary + + + title + Date Time + + + + + + + + + + + + + + + _text + python: request.get(\'time\', \'\') + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.py index 24a4b391a66..5194cfda600 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.py +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.py @@ -1,10 +1,13 @@ """ -Script that returns the list of diff of 2 historical states of ERP5 object(s). +This script gets 2 ERP5 objects based on the parameters provided, either by +using path and datetime or by using context and serial and then creates a +diff between the 2 objects. -This should is used as a 'list method' as it returns a list of temp base object -which have its properties as : `path` and `diff`. +The diff returned is a list of Tempbase object with properties `path` and `diff`. """ from Products.ERP5Type.Document import newTempBase +from ZODB.POSException import ConflictError +from zExceptions import Unauthorized portal = context.getPortalObject() portal_diff = portal.portal_diff @@ -12,6 +15,9 @@ request = context.REQUEST object_revision_list = [] history_size = portal.portal_preferences.getPreferredHtmlStyleZodbHistorySize() +first_object = None +second_object = None + # In case the request has been made via action on any ERP5 object, we get the # paths as `your_` as this is what use as field in dialog. Hence, # its better to check for path in the request also. @@ -20,69 +26,100 @@ if first_path is None: if second_path is None: second_path = request.get('your_second_path', None) -# Case I: When we try to access the dialog directly from `portal_diff` or from -# selections in a module. If the paths are None, then return an empty list -# or try to get the paths from selection and then return the diff. -if first_path is None and second_path is None: - list_selection_name = request.get('list_selection_name', None) - # In case the list_selection_name is there, it can be the case of selection - # from the module, hence we get the paths from the selection and use them to - # create diff. - if list_selection_name is not None: - selected_obj_list = portal.portal_selections.getSelectionCheckedValueList(selection_name=list_selection_name) - object_revision_list.extend(selected_obj_list) +# If first_path and second_path exists, get their current revision from ZODB +if first_path not in (None, ''): + first_object = portal.restrictedTraverse(first_path) +if second_path not in (None, ''): + second_object = portal.restrictedTraverse(second_path) + +# Try to get the objects from the serials. +if first_serial: + if not first_object: + first_object = context + try: + first_object = first_object.HistoricalRevisions[first_serial] + except (ConflictError, Unauthorized): + raise + except Exception: + return [newTempBase(portal, context.Base_translateString('Historical revisions are' + ' not available, maybe the database has been packed'))] + +if second_serial: + if second_serial == '0.0.0.0': + # In case the second serial is 0.0.0.0, we should consider the second object as + # the current version of context + second_object = context else: - # Return an empty list here. This would be the case when we first access - # the dialog and then it try to get list of items to dipslay on the listbox - return [] + if not second_object: + second_object = context + try: + second_object = second_object.HistoricalRevisions[second_serial] + except (ConflictError, Unauthorized): + raise + except Exception: + return [newTempBase(portal, context.Base_translateString('Historical revisions are' + ' not available, maybe the database has been packed'))] -# Case II: Get object revision from the date of the revisions. -# The default dates for revision are the 1st and 2nd -# revision dates. -if first_date not in (None, ''): - first_obj = portal.restrictedTraverse(first_path) - old_state_revision = context.Base_getRevisionFromDate(first_obj, first_date) - object_revision_list.append(old_state_revision) -if second_date not in (None, ''): - second_obj = portal.restrictedTraverse(second_path) - new_state_revision = context.Base_getRevisionFromDate(second_obj, second_date) - object_revision_list.append(new_state_revision) +# Here if the datetime and the paths exist in params, we always give priority +# to get the objects via these params. -# Case III: When the paths exist, but there is no revision given -# for the paths, we diff the current revision -if first_path != second_path: - # Diff the current verison if both the paths are different - if first_path is not None and first_date in (None, ''): - object_revision_list.append(portal.restrictedTraverse(first_path)) - if second_path is not None and second_date in (None, ''): - object_revision_list.append(portal.restrictedTraverse(second_path)) -else: - # If both the paths are same, diff between the current version +if (first_object is not None and (first_object == second_object)): + # If both the objects are same, diff between the current version # and the last version(if it exists) # Get the historical revisions for the object and check if there # is more than one revision - obj = portal.restrictedTraverse(first_path) - revision_date_list = obj.Base_getRevisionDateList(obj, size=history_size) + revision_date_list = first_object.Base_getRevisionDateList(first_object, size=history_size) if len(revision_date_list) > 1: - object_revision_list.append(obj.Base_getRevisionFromDate(obj, revision_date_list[1])) - object_revision_list.append(obj.Base_getRevisionFromDate(obj, revision_date_list[0])) + first_object = first_object.Base_getRevisionFromDate(first_object, revision_date_list[1]) + second_object = second_object.Base_getRevisionFromDate(second_object, revision_date_list[0]) + +# Get object revision from the date of the revisions. +# The default dates for revision are the 1st and 2nd +# revision dates. +if first_date not in (None, ''): + if isinstance(first_object, dict): + # If the object type is dictionary because historical revisions are present + # as dictionaries, then we get the object using restrictedTraverse + first_object = portal.restrictedTraverse(first_path) + first_object = context.Base_getRevisionFromDate(first_object, first_date) +if second_date not in (None, ''): + if isinstance(second_object, dict): + second_object = portal.restrictedTraverse(second_path) + second_object = context.Base_getRevisionFromDate(second_object, second_date) + +# When we try to access the dialog directly from `portal_diff` or from +# selections in a module. If the paths are None, then return an empty list +# or try to get the paths from selection and then return the diff. +if ((first_path is None and second_path is None) and + (first_object is None and second_object is None)): + # Make sure to always check if the first_object and second_object is empty, because this script + # is used outside of Diff Tool also, where we might have list_selection_name which will + # end up getting useless selection. + list_selection_name = request.get('list_selection_name', None) + # In case the list_selection_name is there, it can be the case of selection + # from the module, hence we get the paths from the selection and use them to + # create diff. + if list_selection_name is not None: + selected_object_list = portal.portal_selections.getSelectionCheckedValueList( + selection_name=list_selection_name) + first_object = selected_object_list[0] + second_object = selected_object_list[1] # Use DiffTool to get the diff between the 2 objects in object_revision_list List. # These 2 objects can be revisions of same object, 2 different revisions of # different objects or 2 current ERP5 object. -if len(object_revision_list) > 1: - # Using this last 2 Historical revision dicts, create a Diff - diff_list = portal_diff.diffPortalObject(object_revision_list[0], object_revision_list[1]).asBeautifiedJSONDiff() +if first_object and second_object: + diff_list = portal_diff.diffPortalObject(first_object, second_object).asBeautifiedJSONDiff() # Return a list of TempBase objects which can be displayed in a listbox uid = 1 tempbase_list = [] for diff_unit in diff_list: - temp_obj = newTempBase(portal, - diff_unit['path'], - **diff_unit) - temp_obj.setUid(uid) + temp_object = newTempBase(portal, + diff_unit['path'], + **diff_unit) + temp_object.setUid(uid) uid = uid + 1 - tempbase_list.append(temp_obj) + tempbase_list.append(temp_object) return tempbase_list diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.xml index 13a21bbe30c..6340deb46bc 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getObjectDiffList.xml @@ -50,7 +50,7 @@ _params - first_date=None, second_date=None, first_path=None, second_path=None, **kw + first_date=None, second_date=None, first_path=None, second_path=None, first_serial=None, second_serial=None, **kw id diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list b/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list index 099c9dabe71..12a613ab35f 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list @@ -172,6 +172,7 @@ portal_actions | search portal_actions | sort_on portal_actions | types_tool portal_actions | view_historical_comparison +portal_actions | view_historical_diff portal_membership | login portal_membership | logout portal_membership | preferences diff --git a/product/ERP5/tests/testERP5Core.py b/product/ERP5/tests/testERP5Core.py index 0c94a454d49..01ac2b178a5 100644 --- a/product/ERP5/tests/testERP5Core.py +++ b/product/ERP5/tests/testERP5Core.py @@ -239,7 +239,9 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): 'object_action': [{'id': 'post_query', 'title': 'Post a Query'}, {'id': 'diff_object_action', 'title': 'Diff Object'}], 'object_hidden': [{'id': 'view_historical_comparison', - 'title': 'View Historical Comparison'}], + 'title': 'View Historical Comparison'}, + {'id': 'view_historical_diff', + 'title': 'View Historical Diff'}], 'object_jump': [{'id': 'jump_related_object', 'title': 'Related Objects'}, {'id': 'jump_query', 'title': 'Queries'}], 'object_search': [{'title': 'Search', 'id': 'search'}], @@ -263,7 +265,9 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): 'object': [], 'object_action': [{'id': 'diff_object_action', 'title': 'Diff Object'}], 'object_hidden': [{'id': 'view_historical_comparison', - 'title': 'View Historical Comparison'}], + 'title': 'View Historical Comparison'}, + {'id': 'view_historical_diff', + 'title': 'View Historical Diff'}], 'object_jump': [{'id': 'jump_related_object', 'title': 'Related Objects'}], 'object_search': [{'title': 'Search', 'id': 'search'}], 'object_sort': [{'title': 'Sort', 'id': 'sort_on'}], @@ -282,7 +286,9 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): 'object': [], 'object_action': [{'id': 'diff_object_action', 'title': 'Diff Object'}], 'object_hidden': [{'id': 'view_historical_comparison', - 'title': 'View Historical Comparison'}], + 'title': 'View Historical Comparison'}, + {'id': 'view_historical_diff', + 'title': 'View Historical Diff'}], 'object_jump': [{'id': 'jump_related_object', 'title': 'Related Objects'}], 'object_search': [{'title': 'Search', 'id': 'search'}], 'object_sort': [{'title': 'Sort', 'id': 'sort_on'}], -- 2.30.9 From 95352144a8526be3c43a8cdaa888af3c8d48ab10 Mon Sep 17 00:00:00 2001 From: Ayush Date: Thu, 13 Sep 2018 16:27:10 +0200 Subject: [PATCH 3/5] [erp5_core] Add ERP5 Property History --- .../extension.erp5.ZODBHistory.py | 28 ++ .../erp5_core/Base_viewHistory.xml | 12 +- .../your_property_history.xml | 185 ++++++++++++ .../erp5_core/Base_viewZODBHistory.xml | 8 +- .../Base_getPropertyChangeHistoryList.xml | 28 ++ .../erp5_diff/Base_getPropertyHistoryList.py | 29 ++ .../erp5_diff/Base_getPropertyHistoryList.xml | 70 +++++ .../erp5_diff/Base_getPropertyHistoryURL.py | 26 ++ .../erp5_diff/Base_getPropertyHistoryURL.xml | 62 ++++ .../erp5_diff/Base_getPropertyList.py | 15 + .../erp5_diff/Base_getPropertyList.xml | 62 ++++ .../erp5_diff/Base_viewProperty.py | 30 ++ .../erp5_diff/Base_viewProperty.xml | 62 ++++ .../Base_viewPropertyHistoryList.xml | 157 ++++++++++ .../Base_viewPropertyHistoryList/listbox.xml | 275 ++++++++++++++++++ .../listbox_change.xml | 169 +++++++++++ .../listbox_datetime.xml | 106 +++++++ .../my_property_name.xml | 97 ++++++ .../erp5_diff/Base_viewPropertyList.xml | 112 +++++++ .../Base_viewPropertyList/listbox.xml | 185 ++++++++++++ .../listbox_current_value.xml | 72 +++++ .../Base_viewPropertyList/listbox_name.xml | 89 ++++++ .../gadget_erp5_link_field.html.html | 20 ++ .../erp5_diff/gadget_erp5_link_field.html.xml | 28 ++ .../erp5_diff/gadget_erp5_link_field.js.js | 32 ++ .../erp5_diff/gadget_erp5_link_field.js.xml | 28 ++ 26 files changed, 1978 insertions(+), 9 deletions(-) create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_property_history.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyChangeHistoryList.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_change.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_datetime.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_current_value.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_name.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.html create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.js create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.xml diff --git a/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py index f529f6a8f37..b85ad36c493 100644 --- a/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py +++ b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py @@ -140,6 +140,34 @@ def getChangeHistoryList(document, size=50, attribute_name=None): return history +def getChangeHistoryListForProperty(document, + property_name, + size=50, + attribute_name=None + ): + """ + Returns the list of change per property for the document. + + Parameters: + size -- How long history do you need + property_name -- Name of the property which we need the change list + """ + history_list = getChangeHistoryList(document, size) + property_change_list = [] + for change_dict in history_list: + if property_name.endswith('list'): + property_name = property_name[:-5] + if property_name in change_dict['changes']: + property_dict = { + 'action': change_dict['action'], + 'datetime': change_dict['datetime'], + 'user': change_dict['user'], + 'change': change_dict['changes'][property_name] + } + property_change_list.append(property_dict) + + return property_change_list + def getHistoricalRevisionsDateList(document, size=50): """ Returns the list dates in float format for the last diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory.xml index 97108dc2438..ea8f47ef9f4 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory.xml @@ -74,9 +74,7 @@ center - - your_zodb_history - + @@ -90,13 +88,17 @@ left - + + your_zodb_history + right - + + your_property_history + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_property_history.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_property_history.xml new file mode 100644 index 00000000000..4f749829745 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_property_history.xml @@ -0,0 +1,185 @@ + + + + + + + + + + delegated_list + + + css_class + default + editable + enabled + title + + + + + id + your_property_history + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + css_class + + + + default + + AAAAAAAAAAI= + + + + editable + + + + enabled + + AAAAAAAAAAM= + + + + field_id + + + + form_id + + + + gadget_url + + AAAAAAAAAAQ= + + + + js_sandbox + + + + title + + + + + + + values + + + + css_class + invisible + + + default + + + + editable + 0 + + + enabled + 1 + + + field_id + my_link_field + + + form_id + Base_viewFieldLibrary + + + gadget_url + + + + js_sandbox + public + + + title + View Property History + + + + + + + + + + + + + + + _text + string:${here/absolute_url}/Base_viewPropertyList + + + + + + + + + + + + _text + python: modules[\'AccessControl\'].getSecurityManager().getUser().has_permission(\'View History\', context) + + + + + + + + + + + + _text + python: field.restrictedTraverse(\'gadget_erp5_link_field.html\').absolute_url() + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml index 352787e4df3..ffd7ad568d4 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml @@ -82,7 +82,9 @@ center - + + your_workflow_history + @@ -96,9 +98,7 @@ left - - your_workflow_history - + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyChangeHistoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyChangeHistoryList.xml new file mode 100644 index 00000000000..a2fbe5ef58b --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyChangeHistoryList.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _function + getChangeHistoryListForProperty + + + _module + ZODBHistory + + + id + Base_getPropertyChangeHistoryList + + + title + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.py new file mode 100644 index 00000000000..ed13912bc78 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.py @@ -0,0 +1,29 @@ +from Products.ERP5Type.Document import newTempBase + +portal = context.getPortalObject() +result = [] +portal_diff = portal.portal_diff + +def beautifyChange(change_dict): + return ["%s:%s" % (k, change_dict[k]) for k in sorted(change_dict.keys())] + +try: + history_size = portal.portal_preferences.getPreferredHtmlStyleZodbHistorySize() +except AttributeError: + history_size = 50 + +history_list = context.Base_getPropertyChangeHistoryList(context, size=history_size, property_name=property_name) + +for i in range(1, len(history_list)): + dict1 = history_list[i] + dict2 = history_list[i-1] + tmp = newTempBase(context, '') + diff_list = portal_diff.diffPortalObject(dict2, dict1).asBeautifiedJSONDiff() + dict_ = dict2.copy() + dict_['change'] = [l for l in diff_list if l['path'] == 'change'][0]['diff'] + tmp.edit(**dict_) + + result.append(tmp) + +result.sort(key=lambda x: x.getProperty('datetime'), reverse=True) +return result diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.xml new file mode 100644 index 00000000000..9b97a30551b --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryList.xml @@ -0,0 +1,70 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + property_name, **kw + + + _proxy_roles + + + Manager + + + + + id + Base_getPropertyHistoryList + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.py new file mode 100644 index 00000000000..2fc095b0e72 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.py @@ -0,0 +1,26 @@ +if brain is None: + brain = context + +# Get the name of property from the brain and send it as +# parameter to the next view +path = brain.getProperty('name') +property_name = path.split('/')[-1] + +if url_dict: + parent = brain.aq_parent + jio_key = parent.getRelativeUrl() + return { + 'command': 'push_history', + 'options': { + 'jio_key': jio_key, + }, + 'view_kw': { + 'jio_key': jio_key, + 'view': 'property_history_view', + 'extra_param_json': { + 'property_name': property_name, + } + } + } + +return 'Base_viewPropertyHistoryList?property_name=%s' % property_name diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.xml new file mode 100644 index 00000000000..7d85e9c9c80 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyHistoryURL.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + url_dict=False, brain=None, selection=None, selection_name=None, **kw + + + id + Base_getPropertyHistoryURL + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.py new file mode 100644 index 00000000000..983c2aa14ef --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.py @@ -0,0 +1,15 @@ +from Products.ERP5Type.Document import newTempBase + +portal = context.getPortalObject() +result = [] + +for key, val in context.propertyItems(): + + if val: + temp_obj = newTempBase(context, '') + temp_obj.setProperty('name', key) + temp_obj.setProperty('current_value', val) + result.append(temp_obj) + +result.sort(key=lambda x: x.getProperty('name')) +return result diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.xml new file mode 100644 index 00000000000..854cc5a9e4e --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_getPropertyList.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + **kw + + + id + Base_getPropertyList + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.py new file mode 100644 index 00000000000..01fc9c4b3b2 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.py @@ -0,0 +1,30 @@ +def escape(data): + """ + Escape &, <, and > in a string of data. + This is a copy of the xml.sax.saxutils.escape function. + """ + # must do ampersand first + data = data.replace("&", "&") + data = data.replace(">", ">") + data = data.replace("<", "<") + return data + +from pprint import pformat + +ret = '\n' + +# Get the dict only for the properties having non-empty property values +dict = [(k, v) for k, v in context.propertyItems() if v] +dict.sort() +i = 0 +for k,v in dict: + if (i % 2) == 0: + c = '#88dddd' + else: + c = '#dddd88' + i += 1 + ret += '\n' % (escape(c), escape(k), escape(k), escape(pformat(v))) + +ret += '
%s
%s
\n' + +return ret diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.xml new file mode 100644 index 00000000000..148ee5d2505 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewProperty.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + + + + id + Base_viewProperty + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml new file mode 100644 index 00000000000..37b9f61a777 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml @@ -0,0 +1,157 @@ + + + + + + + + + + _bind_names + + + + + + + + + + _asgns + + + + + + + + + + + _objects + + + + + + action + + + + description + + + + edit_order + + + + + + encoding + UTF-8 + + + enctype + + + + group_list + + + left + right + center + bottom + hidden + + + + + groups + + + + bottom + + + listbox + + + + + center + + + my_property_name + + + + + hidden + + + listbox_change + listbox_datetime + + + + + left + + + + + + right + + + + + + + + + id + Base_viewPropertyHistoryList + + + method + POST + + + name + Base_viewZODBHistory + + + pt + report_view + + + row_length + 4 + + + stored_encoding + UTF-8 + + + title + History + + + unicode_mode + 0 + + + update_action + + + + update_action_title + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox.xml new file mode 100644 index 00000000000..1b387d25c75 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox.xml @@ -0,0 +1,275 @@ + + + + + + + + + + delegated_list + + + columns + editable_columns + list_action + list_method + sort + sort_columns + title + url_columns + + + + + id + listbox + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + target + + + + + + + tales + + + + columns + + + + editable_columns + + + + field_id + + + + form_id + + + + list_action + + + + list_method + + + + target + + + + title + + + + url_columns + + + + + + + values + + + + Base_viewSearchResultList + 0 + + + all_editable_columns + + + + + + columns + + + + datetime + Date Time + + + action + Action + + + user + User + + + change + Value + + + + + + disable_link + 0 + + + editable_columns + + + + time + Time + + + + + + editable_permission + + + + + + editable_role + + + + + + field_id + my_view_mode_listbox + + + form_id + Base_viewFieldLibrary + + + list_action + + + + list_method + + AAAAAAAAAAI= + + + + not_viewable + 0 + + + read_only + 0 + + + sort + + + + datetime + ascending + + + + + + sort_columns + + + + datetime + Date Time + + + + + + target + Click to edit the target + + + title + Property History + + + url_columns + + + + action + + + + user + + + + change + + + + datetime + + + + + + + viewable_permission + + + + + + viewable_role + + + + + + + + + + + + + + + + + + method_name + Base_getPropertyHistoryList + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_change.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_change.xml new file mode 100644 index 00000000000..c749431dc3d --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_change.xml @@ -0,0 +1,169 @@ + + + + + + + + + + delegated_list + + + css_class + default + gadget_url + js_sandbox + title + + + + + id + listbox_change + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + css_class + + + + default + + AAAAAAAAAAI= + + + + field_id + + + + form_id + + + + gadget_url + + AAAAAAAAAAM= + + + + js_sandbox + + AAAAAAAAAAQ= + + + + title + + + + + + + values + + + + css_class + listbox-gadget + + + default + + + + field_id + my_gadget_field + + + form_id + Base_viewFieldLibrary + + + gadget_url + + + + js_sandbox + + + + title + Diff Viewer + + + + + + + + + + + + + + + _text + python: cell.change + + + + + + + + + + + + _text + python: field.restrictedTraverse(\'gadget_erp5_side_by_side_diff.html\').absolute_url() + + + + + + + + + + + + _text + python: context.Base_getDiffGadgetSandbox() + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_datetime.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_datetime.xml new file mode 100644 index 00000000000..c4629aeacb7 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/listbox_datetime.xml @@ -0,0 +1,106 @@ + + + + + + + + + + delegated_list + + + date_only + editable + title + + + + + id + listbox_datetime + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + target + + + + + + + tales + + + + field_id + + + + form_id + + + + target + + + + + + + values + + + + date_only + 0 + + + editable + 0 + + + field_id + my_date + + + form_id + Base_viewWebFieldLibrary + + + target + Click to edit the target + + + title + Modification Date + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml new file mode 100644 index 00000000000..8b30f505db9 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml @@ -0,0 +1,97 @@ + + + + + + + + + + delegated_list + + + editable + title + + + + + id + my_property_name + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + editable + + + + field_id + + + + form_id + + + + title + + + + + + + values + + + + editable + 0 + + + field_id + my_string_field + + + form_id + Base_viewFieldLibrary + + + title + Property Name + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList.xml new file mode 100644 index 00000000000..097ba4fecc8 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList.xml @@ -0,0 +1,112 @@ + + + + + + + + + + _objects + + + + + + action + + + + encoding + UTF-8 + + + enctype + + + + group_list + + + left + right + center + bottom + hidden + + + + + groups + + + + bottom + + + listbox + + + + + center + + + + + + hidden + + + listbox_name + listbox_current_value + + + + + left + + + + + + right + + + + + + + + + id + Base_viewPropertyList + + + method + POST + + + name + Base_viewPropertyList + + + row_length + 4 + + + stored_encoding + UTF-8 + + + title + + + + unicode_mode + 0 + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml new file mode 100644 index 00000000000..e45f51ca976 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml @@ -0,0 +1,185 @@ + + + + + + + + + + delegated_list + + + columns + lines + list_method + sort + sort_columns + title + url_columns + + + + + id + listbox + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + columns + + + + field_id + + + + form_id + + + + lines + + + + list_method + + + + title + + + + url_columns + + + + + + + values + + + + columns + + + + name + Property Name + + + current_value + Blame + + + + + + field_id + my_view_mode_listbox + + + form_id + Base_viewFieldLibrary + + + lines + 20 + + + list_method + + AAAAAAAAAAI= + + + + sort + + + + name + descending + + + + + + sort_columns + + + + name + Property Name + + + + + + title + Property Items + + + url_columns + + + + name + Base_getPropertyHistoryURL + + + current_value + + + + + + + + + + + + + + + + + + + method_name + Base_getPropertyList + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_current_value.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_current_value.xml new file mode 100644 index 00000000000..1b8ebab27b1 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_current_value.xml @@ -0,0 +1,72 @@ + + + + + + + + + + id + listbox_current_value + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + field_id + + + + form_id + + + + + + + values + + + + field_id + my_text_content + + + form_id + Base_viewWebFieldLibrary + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_name.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_name.xml new file mode 100644 index 00000000000..52fb154f8f7 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox_name.xml @@ -0,0 +1,89 @@ + + + + + + + + + + delegated_list + + + default + title + + + + + id + listbox_name + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + field_id + + + + form_id + + + + + + + values + + + + default + History + + + field_id + my_string_field + + + form_id + Base_viewFieldLibrary + + + title + History Link + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.html b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.html new file mode 100644 index 00000000000..5b825ae3f8c --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.html @@ -0,0 +1,20 @@ + + + + + + + + OfficeJS Link Input + + + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.xml new file mode 100644 index 00000000000..e26085a04af --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.html.xml @@ -0,0 +1,28 @@ + + + + + + + + + + __name__ + gadget_erp5_link_field.html + + + content_type + text/html + + + precondition + + + + title + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.js b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.js new file mode 100644 index 00000000000..befce8e7c19 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.js @@ -0,0 +1,32 @@ +/*global window, rJS, jIO, Handlebars, navigator, MediaRecorder, Blob, loopEventListener*/ +/*jslint nomen: true, indent: 2, maxerr: 3 */ +(function (window, rJS) { + "use strict"; + rJS(window) + .declareAcquiredMethod("getUrlFor", "getUrlFor") + .declareMethod('render', function (params) { + var gadget = this, + a = gadget.element.querySelector("a"); + a.setAttribute('id', params.value.target_type); + a.textContent = params.value.textContent || ""; + + if (params.value.target_type === "download") { + a.setAttribute('download', params.value.textContent); + } + if (!params.value.direct_url) { + return gadget.getUrlFor({ + command: 'display', + options: {page: params.value.target} + }) + .push(function (url) { + a.setAttribute('href', url); + }); + } + a.setAttribute('href', params.value.direct_url); + + }) + .declareMethod('getContent', function () { + return {}; + }); + +}(window, rJS)); \ No newline at end of file diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.xml new file mode 100644 index 00000000000..de36f7ef287 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/gadget_erp5_link_field.js.xml @@ -0,0 +1,28 @@ + + + + + + + + + + __name__ + gadget_erp5_link_field.js + + + content_type + application/javascript + + + precondition + + + + title + + + + + + -- 2.30.9 From 5eac04837ca42be2f20f11e5837e3859cf7cd624 Mon Sep 17 00:00:00 2001 From: Ayush Date: Thu, 27 Sep 2018 17:26:45 +0200 Subject: [PATCH 4/5] [erp5_core]: Add functions for property history in ZODB History component --- .../extension.erp5.ZODBHistory.py | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py index b85ad36c493..bbbd8af3660 100644 --- a/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py +++ b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py @@ -28,6 +28,8 @@ # ############################################################################## from DateTime import DateTime +from OFS.History import historicalRevision +from Products.ERP5Type.Log import log def _parseCategory(category): if category is None or category.find('/') < 0: @@ -110,7 +112,8 @@ def getChangeHistoryList(document, size=50, attribute_name=None): current_state = connection.oldstate(document, d_['tid']) changes = {} current_datetime = toDateTime(d_['time']) - record = {'datetime':current_datetime, + record = {'serial': d_['tid'], + 'datetime':current_datetime, 'user':d_['user_name'], 'action':d_['description'], 'changes':changes @@ -140,6 +143,49 @@ def getChangeHistoryList(document, size=50, attribute_name=None): return history +def getChangeHistoryListDiffFormat(document, size=50, attribute_name=None): + """ + Returns ZODB History in the format which can be used to create diff, + i.e, just follow the basic key value pair format of a python dictionary. + """ + connection = document._p_jar + result = document._p_jar.db().history(document._p_oid, size=size) + if result is None: + return [] + result = list(reversed(result)) + + history = [] + previous_state = None + for d_ in result: + current_state = connection.oldstate(document, d_['tid']) + changes = {} + current_datetime = toDateTime(d_['time']) + record = {'serial': d_['tid'], + 'datetime':current_datetime, + 'user':d_['user_name'], + 'action':d_['description'], + 'changes':changes + } + log(record) + if previous_state is None: + previous_state = {} + for key in current_state: + if key.startswith('_') or key == 'workflow_history': + continue + if previous_state.get(key) != current_state[key]: + changes[key] = current_state[key] + if key == 'categories': + for cat in current_state.get('categories', ()): + ck, cv = _parseCategory(cat) + if ck in changes: + changes[ck].append(cv) + else: + changes[ck] = [cv] + history.append(record) + previous_state = current_state + + return history + def getChangeHistoryListForProperty(document, property_name, size=50, @@ -168,6 +214,9 @@ def getChangeHistoryListForProperty(document, return property_change_list +def getHistoricalRevisionFromSerial(document, serial): + return historicalRevision(document, serial).showDict() + def getHistoricalRevisionsDateList(document, size=50): """ Returns the list dates in float format for the last -- 2.30.9 From f7844c15aaa6d50c13c219156a9044384ccb15c1 Mon Sep 17 00:00:00 2001 From: Ayush Date: Thu, 27 Sep 2018 17:33:52 +0200 Subject: [PATCH 5/5] [erp5_core] Update view for property history --- .../Base_viewPropertyHistoryList.xml | 2 +- .../my_property_name.xml | 97 ------------------- .../Base_viewPropertyList/listbox.xml | 2 +- 3 files changed, 2 insertions(+), 99 deletions(-) delete mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml index 37b9f61a777..72480b25d5b 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList.xml @@ -83,7 +83,7 @@ center - my_property_name + your_name
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml deleted file mode 100644 index 8b30f505db9..00000000000 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyHistoryList/my_property_name.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - delegated_list - - - editable - title - - - - - id - my_property_name - - - message_values - - - - external_validator_failed - The input failed the external validator. - - - - - - overrides - - - - field_id - - - - form_id - - - - - - - tales - - - - editable - - - - field_id - - - - form_id - - - - title - - - - - - - values - - - - editable - 0 - - - field_id - my_string_field - - - form_id - Base_viewFieldLibrary - - - title - Property Name - - - - - - - - diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml index e45f51ca976..f3ec705f184 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_diff/Base_viewPropertyList/listbox.xml @@ -99,7 +99,7 @@ current_value - Blame + Annotate -- 2.30.9