Commit 732d1356 authored by Valentin Benozillo's avatar Valentin Benozillo Committed by Valentin Benozillo

erp5_web_renderjs_ui: Add missed invalid message translation

parent 5e4454e0
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!--
data-i18n=Input is required but no input given.
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>MultiListfield</title> <title>MultiListfield</title>
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
} }
rJS(window) rJS(window)
.declareAcquiredMethod("translate", "translate")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var field_json = options.field_json || {}, var field_json = options.field_json || {},
item_list = ensureArray(field_json.items).map(function (item) { item_list = ensureArray(field_json.items).map(function (item) {
...@@ -171,9 +172,16 @@ ...@@ -171,9 +172,16 @@
var gadget = this, var gadget = this,
empty = true; empty = true;
if (this.state.editable && this.state.required) { if (this.state.editable && this.state.required) {
return this.getContent() return new RSVP.Queue()
.push(function (result) { .push(function () {
var value_list = result[gadget.state.sub_select_key], return RSVP.all([
gadget.getContent(),
gadget.translate("Input is required but no input given.")
]);
})
.push(function (all_result) {
var value_list = all_result[0][gadget.state.sub_select_key],
error_message = all_result[1],
i; i;
for (i = 0; i < value_list.length; i += 1) { for (i = 0; i < value_list.length; i += 1) {
if (value_list[i]) { if (value_list[i]) {
...@@ -181,7 +189,7 @@ ...@@ -181,7 +189,7 @@
} }
} }
if (empty) { if (empty) {
return gadget.notifyInvalid("Please fill out this field."); return gadget.notifyInvalid(error_message);
} }
return gadget.notifyValid(); return gadget.notifyValid();
}) })
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!--
data-i18n=Input is required but no input given.
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>ERP5 Radiofield</title> <title>ERP5 Radiofield</title>
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
rJS(window) rJS(window)
.declareAcquiredMethod("notifyValid", "notifyValid") .declareAcquiredMethod("notifyValid", "notifyValid")
.declareAcquiredMethod("notifyInvalid", "notifyInvalid") .declareAcquiredMethod("notifyInvalid", "notifyInvalid")
.declareAcquiredMethod("translate", "translate")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var field_json = options.field_json || {}, var field_json = options.field_json || {},
state_dict = { state_dict = {
...@@ -153,14 +154,22 @@ ...@@ -153,14 +154,22 @@
.declareMethod('checkValidity', function () { .declareMethod('checkValidity', function () {
var name = this.state.name, var name = this.state.name,
gadget = this, gadget = this,
empty; empty;
if (this.state.editable && this.state.required) { if (this.state.editable && this.state.required) {
return this.getContent() return new RSVP.Queue()
.push(function (result) { .push(function () {
empty = !result[name]; return RSVP.all([
gadget.getContent(),
gadget.translate("Input is required but no input given.")
]);
})
.push(function (all_result) {
var content = all_result[0],
error_message = all_result[1];
empty = !content[name];
if (empty) { if (empty) {
return gadget.notifyInvalid("Please fill out this field."); return gadget.notifyInvalid(error_message);
} }
return gadget.notifyValid(); return gadget.notifyValid();
}) })
......
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>valentin</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.30669.46484.853</string> </value> <value> <string>976.61321.38056.58231</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1556896193.1</float> <float>1562581079.03</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
data-i18n=No such document was found data-i18n=No such document was found
data-i18n=Create New data-i18n=Create New
data-i18n=Explore the Search Result List data-i18n=Explore the Search Result List
data-i18n=No such document was found
--> -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
......
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getFormContent", "getFormContent") .declareAcquiredMethod("getFormContent", "getFormContent")
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("translate", "translate")
// .declareAcquiredMethod("addRelationInput", "addRelationInput") // .declareAcquiredMethod("addRelationInput", "addRelationInput")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -494,12 +495,17 @@ ...@@ -494,12 +495,17 @@
}, true, false) }, true, false)
.declareMethod('checkValidity', function () { .declareMethod('checkValidity', function () {
var gadget = this;
if ((this.state.value_text) && ( if ((this.state.value_text) && (
(this.state.value_relative_url === null) && (this.state.value_relative_url === null) &&
(this.state.value_uid === null) && (this.state.value_uid === null) &&
(this.state.value_portal_type === null) (this.state.value_portal_type === null)
)) { )) {
return this.notifyInvalid("No such document was found") return gadget.translate("No such document was found")
.push(function (error_message) {
return gadget.notifyInvalid(error_message);
})
.push(function () { .push(function () {
return false; return false;
}); });
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!--
data-i18n=Invalid DateTime
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>HTML5 Input</title> <title>HTML5 Input</title>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
} }
rJS(window) rJS(window)
.declareAcquiredMethod("translate", "translate")
.declareMethod('render', function render(options) { .declareMethod('render', function render(options) {
return this.changeState({ return this.changeState({
value: getFirstNonEmpty(options.value, ""), value: getFirstNonEmpty(options.value, ""),
...@@ -192,7 +192,10 @@ ...@@ -192,7 +192,10 @@
if (value) { if (value) {
date = Date.parse(value); date = Date.parse(value);
if (isNaN(date)) { if (isNaN(date)) {
return gadget.notifyInvalid("Invalid DateTime") return gadget.translate("Invalid DateTime")
.push(function (error_message) {
return gadget.notifyInvalid(error_message);
})
.push(function () { .push(function () {
return false; return false;
}); });
......
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