From e0d260487d68a56ca3f7135b3ab442cd4820e22b Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Thu, 20 Jun 2019 10:12:01 +0000 Subject: [PATCH] [erp5_web_renderjs_ui] Display update action title if configured --- .../ERP5Document_getHateoas.py | 1 + .../rjs_gadget_erp5_pt_form_dialog_js.js | 27 ++++++++++++++----- .../rjs_gadget_erp5_pt_form_dialog_js.xml | 4 +-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py index 0f90b9b90e..73ee5a3264 100644 --- a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py @@ -1129,6 +1129,7 @@ def renderFormDefinition(form, response_dict): response_dict["pt"] = form.pt response_dict["action"] = form.action response_dict["update_action"] = form.update_action + response_dict["update_action_title"] = Base_translateString(form.update_action_title) def statusLevelToString(level): """Transform any level format to lowercase string representation""" diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js index b0994d3c65..2a119477b9 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js @@ -1,6 +1,8 @@ /*jslint nomen: true, indent: 2, maxerr: 3 */ -/*global window, rJS, RSVP, calculatePageTitle, Handlebars, ensureArray */ -(function (window, rJS, RSVP, calculatePageTitle, Handlebars, ensureArray) { +/*global window, document, rJS, RSVP, calculatePageTitle, Handlebars, + ensureArray */ +(function (window, document, rJS, RSVP, calculatePageTitle, Handlebars, + ensureArray) { "use strict"; function checkValidity() { @@ -173,6 +175,7 @@ erp5_form: options.erp5_form || {}, // editable: true, // ignore global editable state (be always editable) has_update_action: Boolean(options.form_definition.update_action), + update_action_title: options.form_definition.update_action_title, // pass extended_search from previous view in case any gadget is curious extended_search: extended_search, redirect_to_parent: options.erp5_document._embedded._view.field_your_redirect_to_parent !== undefined @@ -221,13 +224,25 @@ return new RSVP.Queue() .push(function () { // Set the dialog button - if (modification_dict.hasOwnProperty('has_update_action')) { + if (modification_dict.hasOwnProperty('has_update_action') || + modification_dict.hasOwnProperty('update_action_title')) { return form_gadget.translateHtml(dialog_button_template({ show_update_button: form_gadget.state.has_update_action })) .push(function (html) { - form_gadget.element.querySelector('.dialog_button_container') - .innerHTML = html; + var div = document.createElement('div'), + dialog_button_container = form_gadget.element + .querySelector('.dialog_button_container'); + div.innerHTML = html; + if (form_gadget.state.update_action_title) { + div.querySelector('button[name="action_update"]') + .textContent = form_gadget.state.form_definition + .update_action_title; + } + while (dialog_button_container.firstChild) { + dialog_button_container.firstChild.remove(); + } + dialog_button_container.innerHTML = div.innerHTML; }); } }) @@ -312,4 +327,4 @@ } }); -}(window, rJS, RSVP, calculatePageTitle, Handlebars, ensureArray)); +}(window, document, rJS, RSVP, calculatePageTitle, Handlebars, ensureArray)); diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml index b2b82fc672..3266f4f693 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml @@ -222,7 +222,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>976.20956.15292.37495</string> </value> + <value> <string>976.34018.48815.32699</string> </value> </item> <item> <key> <string>state</string> </key> @@ -240,7 +240,7 @@ </tuple> <state> <tuple> - <float>1560246152.37</float> + <float>1561041762.03</float> <string>UTC</string> </tuple> </state> -- 2.30.9