Commit 125a0481 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: display all texts in view mode

parent 854e8e3e
...@@ -1125,6 +1125,13 @@ html .ui-listbox-error {\n ...@@ -1125,6 +1125,13 @@ html .ui-listbox-error {\n
text-align: center;\n text-align: center;\n
}\n }\n
\n \n
\n
\n
html .ui-content-non-editable {\n
word-wrap: break-word;\n
white-space: pre-line;\n
}\n
\n
/* cell background */\n /* cell background */\n
html table thead tr,\n html table thead tr,\n
html table tfoot tr,\n html table tfoot tr,\n
...@@ -5219,7 +5226,7 @@ html .ui-panel .ui-content .ui-btn[class*="ui-icon-"]:after {\n ...@@ -5219,7 +5226,7 @@ html .ui-panel .ui-content .ui-btn[class*="ui-icon-"]:after {\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>949.1052.3508.62634</string> </value> <value> <string>949.22640.50771.7816</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -5237,7 +5244,7 @@ html .ui-panel .ui-content .ui-btn[class*="ui-icon-"]:after {\n ...@@ -5237,7 +5244,7 @@ html .ui-panel .ui-content .ui-btn[class*="ui-icon-"]:after {\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1454957135.51</float> <float>1456317267.11</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -122,7 +122,6 @@ ...@@ -122,7 +122,6 @@
\n \n
</head>\n </head>\n
<body>\n <body>\n
<input type=\'text\' />\n
</body>\n </body>\n
</html> </html>
...@@ -247,7 +246,7 @@ ...@@ -247,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>romain</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -261,7 +260,7 @@ ...@@ -261,7 +260,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>937.51526.35217.14489</string> </value> <value> <string>949.22501.55314.65245</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -279,8 +278,8 @@ ...@@ -279,8 +278,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1412257603.97</float> <float>1456252782.83</float>
<string>GMT</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
...@@ -99,15 +99,16 @@ ...@@ -99,15 +99,16 @@
</item> </item>
<item> <item>
<key> <string>text_content</string> </key> <key> <string>text_content</string> </key>
<value> <string>/*global window, rJS, RSVP, loopEventListener */\n <value> <string>/*global window, rJS, RSVP, loopEventListener, document */\n
/*jslint indent: 2, maxerr: 3 */\n /*jslint indent: 2, maxerr: 3 */\n
(function (window, rJS, RSVP, loopEventListener) {\n (function (window, rJS, RSVP, loopEventListener, document) {\n
"use strict";\n "use strict";\n
\n \n
rJS(window)\n rJS(window)\n
.ready(function (gadget) {\n .ready(function (gadget) {\n
return gadget.getElement()\n return gadget.getElement()\n
.push(function (element) {\n .push(function (element) {\n
gadget.props = {};\n
gadget.element = element;\n gadget.element = element;\n
});\n });\n
})\n })\n
...@@ -116,37 +117,47 @@ ...@@ -116,37 +117,47 @@
.declareAcquiredMethod("notifyInvalid", "notifyInvalid")\n .declareAcquiredMethod("notifyInvalid", "notifyInvalid")\n
.declareAcquiredMethod("notifyChange", "notifyChange")\n .declareAcquiredMethod("notifyChange", "notifyChange")\n
.declareMethod(\'getTextContent\', function () {\n .declareMethod(\'getTextContent\', function () {\n
return this.element.querySelector(\'input\').getAttribute(\'value\');\n return this.props.value;\n
})\n })\n
.declareMethod(\'render\', function (options) {\n .declareMethod(\'render\', function (options) {\n
var input = this.element.querySelector(\'input\'),\n var element,\n
text,\n
field_json = options.field_json || {};\n field_json = options.field_json || {};\n
input.setAttribute(\n this.props.value = field_json.value || field_json.default || "";\n
\'value\',\n this.props.editable = field_json.editable;\n
field_json.value || field_json.default || ""\n if (field_json.editable) {\n
);\n element = document.createElement(\'input\');\n
input.setAttribute(\'name\', field_json.key);\n element.setAttribute("type", "text");\n
input.setAttribute(\'title\', field_json.title);\n element.setAttribute(\'value\', this.props.value);\n
if (field_json.required === 1) {\n element.setAttribute(\'name\', field_json.key);\n
input.setAttribute(\'required\', \'required\');\n element.setAttribute(\'title\', field_json.title);\n
}\n if (field_json.required === 1) {\n
if (field_json.editable !== 1) {\n element.setAttribute(\'required\', \'required\');\n
input.setAttribute(\'readonly\', \'readonly\');\n }\n
input.setAttribute(\'data-wrapper-class\', \'ui-state-readonly\');\n } else {\n
// input.setAttribute(\'disabled\', \'disabled\');\n element = document.createElement("p");\n
\n element.setAttribute("class", "ui-content-non-editable");\n
text = document.createTextNode(this.props.value);\n
element.appendChild(text);\n
}\n }\n
this.element.appendChild(element);\n
})\n })\n
\n \n
.declareMethod(\'getContent\', function () {\n .declareMethod(\'getContent\', function () {\n
var input = this.element.querySelector(\'input\'),\n var input,\n
result = {};\n result = {};\n
result[input.getAttribute(\'name\')] = input.value;\n if (this.props.editable) {\n
input = this.element.querySelector(\'input\');\n
result[input.getAttribute(\'name\')] = input.value;\n
}\n
return result;\n return result;\n
})\n })\n
\n \n
.declareMethod(\'checkValidity\', function () {\n .declareMethod(\'checkValidity\', function () {\n
var result;\n var result;\n
if (!this.props.editable) {\n
return true;\n
}\n
result = this.element.querySelector(\'input\').checkValidity();\n result = this.element.querySelector(\'input\').checkValidity();\n
if (result) {\n if (result) {\n
return this.notifyValid()\n return this.notifyValid()\n
...@@ -162,6 +173,9 @@ ...@@ -162,6 +173,9 @@
// Check field validity when the value changes\n // Check field validity when the value changes\n
////////////////////////////////////\n ////////////////////////////////////\n
var field_gadget = this;\n var field_gadget = this;\n
if (!field_gadget.props.editable) {\n
return;\n
}\n
\n \n
function notifyChange() {\n function notifyChange() {\n
return RSVP.all([\n return RSVP.all([\n
...@@ -184,7 +198,9 @@ ...@@ -184,7 +198,9 @@
// Inform when the field input is invalid\n // Inform when the field input is invalid\n
////////////////////////////////////\n ////////////////////////////////////\n
var field_gadget = this;\n var field_gadget = this;\n
\n if (!field_gadget.props.editable) {\n
return;\n
}\n
function notifyInvalid(evt) {\n function notifyInvalid(evt) {\n
return field_gadget.notifyInvalid(evt.target.validationMessage);\n return field_gadget.notifyInvalid(evt.target.validationMessage);\n
}\n }\n
...@@ -198,7 +214,7 @@ ...@@ -198,7 +214,7 @@
);\n );\n
});\n });\n
\n \n
}(window, rJS, RSVP, loopEventListener));</string> </value> }(window, rJS, RSVP, loopEventListener, document));</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -333,7 +349,7 @@ ...@@ -333,7 +349,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>949.15479.27859.47018</string> </value> <value> <string>949.22535.16679.23876</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -351,7 +367,7 @@ ...@@ -351,7 +367,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1455899182.71</float> <float>1456317346.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -140,6 +140,7 @@ ...@@ -140,6 +140,7 @@
this.property_dict.textarea_deferred.resolve(new_element);\n this.property_dict.textarea_deferred.resolve(new_element);\n
} else {\n } else {\n
new_element = document.createElement(\'pre\');\n new_element = document.createElement(\'pre\');\n
new_element.setAttribute("class", "ui-content-non-editable");\n
new_element.textContent = value;\n new_element.textContent = value;\n
}\n }\n
this.property_dict.element.appendChild(new_element);\n this.property_dict.element.appendChild(new_element);\n
...@@ -157,9 +158,6 @@ ...@@ -157,9 +158,6 @@
value = field.textContent;\n value = field.textContent;\n
}\n }\n
result[this.property_dict.name] = value;\n result[this.property_dict.name] = value;\n
console.log(result);\n
console.log(field);\n
console.log(this.property_dict.element);\n
return result;\n return result;\n
})\n })\n
\n \n
...@@ -316,7 +314,7 @@ ...@@ -316,7 +314,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>948.41930.30032.34201</string> </value> <value> <string>949.24043.58938.21367</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -334,7 +332,7 @@ ...@@ -334,7 +332,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1453477730.87</float> <float>1456336348.49</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -190,8 +190,8 @@ ...@@ -190,8 +190,8 @@
</tr>\n </tr>\n
\n \n
<tr>\n <tr>\n
<td>verifyValue</td>\n <td>verifyText</td>\n
<td>//input[@title="Title"]</td>\n <td>//div[@data-gadget-scope="field_my_title"]</td>\n
<td>Title 3</td>\n <td>Title 3</td>\n
</tr>\n </tr>\n
\n \n
...@@ -217,8 +217,8 @@ ...@@ -217,8 +217,8 @@
</tr>\n </tr>\n
\n \n
<tr>\n <tr>\n
<td>verifyValue</td>\n <td>verifyText</td>\n
<td>//input[@title="Title"]</td>\n <td>//div[@data-gadget-scope="field_my_title"]</td>\n
<td>Title 4</td>\n <td>Title 4</td>\n
</tr>\n </tr>\n
\n \n
...@@ -244,8 +244,8 @@ ...@@ -244,8 +244,8 @@
</tr>\n </tr>\n
\n \n
<tr>\n <tr>\n
<td>verifyValue</td>\n <td>verifyText</td>\n
<td>//input[@title="Title"]</td>\n <td>//div[@data-gadget-scope="field_my_title"]</td>\n
<td>Title 3</td>\n <td>Title 3</td>\n
</tr>\n </tr>\n
\n \n
......
...@@ -92,10 +92,17 @@ ...@@ -92,10 +92,17 @@
</tr>\n </tr>\n
<tr>\n <tr>\n
<td>assertElementPresent</td>\n <td>assertElementPresent</td>\n
<td>//input[@value=\'1\' and @name=\'field_my_id\' and @readonly=\'readonly\']</td>\n <td>//div[@data-gadget-scope=\'field_my_id\']</td>\n
<td></td>\n <td></td>\n
</tr>\n </tr>\n
\n \n
<tr>\n
<td>verifyText</td>\n
<td>//div[@data-gadget-scope=\'field_my_id\']</td>\n
<td>1</td>\n
</tr>\n
\n
\n
<!-- Listbox are always displayed without label -->\n <!-- Listbox are always displayed without label -->\n
<tr>\n <tr>\n
<td>assertElementNotPresent</td>\n <td>assertElementNotPresent</td>\n
......
...@@ -232,14 +232,14 @@ ...@@ -232,14 +232,14 @@
\n \n
<tr>\n <tr>\n
<td>waitForElementPresent</td>\n <td>waitForElementPresent</td>\n
<td>//input[@title="Short Title"]</td>\n <td>//div[@data-gadget-scope="field_my_short_title"]</td>\n
<td></td>\n <td></td>\n
</tr>\n </tr>\n
\n \n
\n \n
<tr>\n <tr>\n
<td>verifyValue</td>\n <td>verifyText</td>\n
<td>//input[@title="Short Title"]</td>\n <td>//div[@data-gadget-scope="field_my_short_title"]</td>\n
<td>test_clone</td>\n <td>test_clone</td>\n
</tr>\n </tr>\n
\n \n
...@@ -262,8 +262,8 @@ ...@@ -262,8 +262,8 @@
</tr>\n </tr>\n
\n \n
<tr>\n <tr>\n
<td>storeValue</td>\n <td>storeText</td>\n
<td>//input[@name=\'field_my_id\']</td>\n <td>//div[@data-gadget-scope=\'field_my_id\']</td>\n
<td>original_id</td>\n <td>original_id</td>\n
</tr>\n </tr>\n
\n \n
......
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
</tr>\n </tr>\n
<tr>\n <tr>\n
<td>waitForElementPresent</td>\n <td>waitForElementPresent</td>\n
<td>//input[@title=\'ID\']</td>\n <td>//div[@data-gadget-scope=\'field_my_id\']</td>\n
<td></td>\n <td></td>\n
</tr>\n </tr>\n
<tr>\n <tr>\n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment