From 2c0d6e8aaf4c915f802f57687cb8eded04231010 Mon Sep 17 00:00:00 2001 From: Xiaowu Zhang <xiaowu.zhang@tiolive.com> Date: Thu, 5 Feb 2015 12:23:04 +0000 Subject: [PATCH] Add requied functionality for listfield gadget --- .../rjs_gadget_erp5_listfield_js.xml | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listfield_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listfield_js.xml index 90a558a43b..dfdaeb1cd9 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listfield_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listfield_js.xml @@ -101,7 +101,7 @@ <key> <string>text_content</string> </key> <value> <string encoding="cdata"><![CDATA[ -/*global window, rJS, Handlebars, document, RSVP */\n +/*global window, rJS, Handlebars, document, RSVP, loopEventListener*/\n /*jslint nomen: true, indent: 2, maxerr: 3 */\n (function (window, rJS, Handlebars, document, RSVP) {\n "use strict";\n @@ -132,7 +132,8 @@ // acquired method\n //////////////////////////////////////////////\n .declareAcquiredMethod("translateHtml", "translateHtml")\n -\n + .declareAcquiredMethod("notifyValid", "notifyValid")\n + .declareAcquiredMethod("notifyInvalid", "notifyInvalid")\n .declareMethod(\'render\', function (options) {\n var i,\n template,\n @@ -164,9 +165,7 @@ })\n .push(function (my_translated_html) {\n // XXX: no fan...\n - var option_list,\n - i_len,\n - select_div,\n + var select_div,\n div = document.createElement("div");\n \n div.innerHTML = my_translated_html;\n @@ -185,12 +184,40 @@ }\n });\n })\n -\n + .declareMethod(\'checkValidity\', function () {\n + var result;\n + result = this.element.querySelector(\'select\').checkValidity();\n + if (result) {\n + return this.notifyValid()\n + .push(function () {\n + return result;\n + });\n + }\n + return result;\n + })\n .declareMethod(\'getContent\', function () {\n var input = this.element.querySelector(\'select\'),\n result = {};\n result[input.getAttribute(\'name\')] = input.options[input.selectedIndex].value;\n return result;\n + })\n + .declareService(function () {\n + ////////////////////////////////////\n + // Inform when the field input is invalid\n + ////////////////////////////////////\n + var field_gadget = this;\n +\n + function notifyInvalid(evt) {\n + return field_gadget.notifyInvalid(evt.target.validationMessage);\n + }\n +\n + // Listen to input change\n + return loopEventListener(\n + field_gadget.element.querySelector(\'select\'),\n + \'invalid\',\n + false,\n + notifyInvalid\n + );\n });\n \n }(window, rJS, Handlebars, document, RSVP)); @@ -316,7 +343,7 @@ </item> <item> <key> <string>actor</string> </key> - <value> <string>xiaowu</string> </value> + <value> <string>zope</string> </value> </item> <item> <key> <string>comment</string> </key> @@ -330,7 +357,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>940.21609.3247.37922</string> </value> + <value> <string>940.49457.43407.46148</string> </value> </item> <item> <key> <string>state</string> </key> @@ -348,7 +375,7 @@ </tuple> <state> <tuple> - <float>1421405407.17</float> + <float>1423135404.46</float> <string>UTC</string> </tuple> </state> -- 2.30.9