Commit 5f48698d authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: show user on the logout page

Drop user informations from language page
parent 660d01f0
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!-- <!--
data-i18n=User
data-i18n=Language data-i18n=Language
data-i18n=Update data-i18n=Update
--> -->
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>981.54790.20438.51626</string> </value> <value> <string>991.57853.23997.31232</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1581677271.66</float> <float>1620830688.79</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -20,45 +20,26 @@ ...@@ -20,45 +20,26 @@
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this, var gadget = this;
first_result_list;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
gadget.getUrlForList([{command: 'display'}]), gadget.getUrlForList([{command: 'display'}]),
gadget.getSettingList(['me', 'language_map', 'selected_language', gadget.getSettingList(['language_map', 'selected_language',
'default_selected_language']), 'default_selected_language']),
gadget.getDeclaredGadget("erp5_form"), gadget.getDeclaredGadget("erp5_form"),
gadget.getTranslationList(['Language', 'User', 'Update']) gadget.getTranslationList(['Language', 'Update'])
]); ]);
}) })
.push(function (result_list) { .push(function (first_result_list) {
first_result_list = result_list; var selected_language = first_result_list[1][1] ||
var me = result_list[1][0]; first_result_list[1][2],
if (me !== undefined) {
return gadget.jio_allDocs({
query: 'relative_url:"' + me + '"',
select_list: ['title']
});
}
})
.push(function (result) {
var user,
selected_language = first_result_list[1][2] ||
first_result_list[1][3],
key, key,
list_item = [], list_item = [],
options = JSON.parse(first_result_list[1][1]); options = JSON.parse(first_result_list[1][0]);
gadget.state.old_selected_lang = selected_language; gadget.state.old_selected_lang = selected_language;
// Calculate user name
if (result === undefined) {
user = "Who are you?";
} else {
user = result.data.rows[0].value.title;
}
// Calculate possible language list // Calculate possible language list
for (key in options) { for (key in options) {
if (options.hasOwnProperty(key)) { if (options.hasOwnProperty(key)) {
...@@ -81,13 +62,6 @@ ...@@ -81,13 +62,6 @@
first_result_list[2].render({ first_result_list[2].render({
erp5_document: {"_embedded": {"_view": { erp5_document: {"_embedded": {"_view": {
'User': {
"default": user,
"editable": 0,
"key": "field_user",
"title": first_result_list[3][1],
"type": "StringField"
},
'Language': { 'Language': {
"default": selected_language, "default": selected_language,
"editable": 1, "editable": 1,
...@@ -107,7 +81,7 @@ ...@@ -107,7 +81,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["User"], ["Language"]] [["Language"]]
]] ]]
} }
}) })
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>981.54793.39964.17766</string> </value> <value> <string>992.854.10678.4949</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1581677388.59</float> <float>1620830966.27</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!-- <!--
data-i18n=User
data-i18n=Confirm data-i18n=Confirm
--> -->
<head> <head>
<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 PT Loginpage</title> <title>ERP5 PT Logoutpage</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html"> <link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<!-- renderjs --> <!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script> <script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script> <script src="jiodev.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<!-- custom script --> <!-- custom script -->
<script src="gadget_erp5_page_logout.js" type="text/javascript"></script> <script src="gadget_erp5_page_logout.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<article> <form>
<section> <button type="submit" class="ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<form> <div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="erp5_form"
<input type="submit" /> data-gadget-sandbox="public">
</div>
</form> <div class="dialog_button_container">
</section> </div>
</article> </form>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.52441.15467.16503</string> </value> <value> <string>992.824.37160.29132</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542905896.75</float> <float>1620830587.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, UriTemplate */ /*global window, rJS, UriTemplate, domsugar, RSVP */
/*jslint indent: 2, maxerr: 3, nomen: true */ /*jslint indent: 2, maxerr: 3, nomen: true */
(function (window, rJS, UriTemplate) { (function (window, rJS, UriTemplate, domsugar, RSVP) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList") .declareAcquiredMethod("getUrlForDict", "getUrlForDict")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("getTranslationDict", "getTranslationDict")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -20,25 +22,78 @@ ...@@ -20,25 +22,78 @@
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this; var gadget = this;
return gadget.getUrlForList([ return new RSVP.Queue(RSVP.hash({
// Back url translation: gadget.getTranslationDict([
{command: 'display'}, 'Confirm',
// Change language 'User'
{command: 'display', options: {page: 'language'}} ]),
]) me: gadget.getSetting('me')
.push(function (url_list) { .push(function (me) {
return gadget.updateHeader({ if (me !== undefined) {
page_title: 'Logout', return gadget.jio_allDocs({
page_icon: 'power-off', query: 'relative_url:"' + me + '"',
front_url: url_list[0], select_list: ['title']
language_url: url_list[1] });
}); }
}) })
.push(function () { .push(function (result) {
return gadget.translate('Confirm'); var user;
// Calculate user name
if (result === undefined) {
user = "Who are you?";
} else {
user = result.data.rows[0].value.title;
}
return user;
}),
erp5_form: gadget.getDeclaredGadget("erp5_form"),
url_dict: gadget.getUrlForDict({
// Back url
back: {command: 'display'},
// Change language
change_language: {command: 'display', options: {page: 'language'}}
}) })
.push(function (translated_text) { }))
gadget.element.querySelector('input').value = translated_text; .push(function (result_dict) {
domsugar(gadget.element.querySelector('.dialog_button_container'), [
domsugar('input', {name: 'action_update',
type: 'submit',
value: result_dict.translation.Confirm})
]);
return RSVP.all([
gadget.updateHeader({
page_title: 'Logout',
page_icon: 'power-off',
front_url: result_dict.url_dict.back,
language_url: result_dict.url_dict.change_language
}),
result_dict.erp5_form.render({
erp5_document: {"_embedded": {"_view": {
'User': {
"default": result_dict.me,
"editable": 0,
"key": "field_user",
"title": result_dict.translation.User,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["User"]]
]]
}
})
]);
}); });
}) })
...@@ -67,4 +122,4 @@ ...@@ -67,4 +122,4 @@
.declareMethod("triggerSubmit", function () { .declareMethod("triggerSubmit", function () {
return; return;
}); });
}(window, rJS, UriTemplate)); }(window, rJS, UriTemplate, domsugar, RSVP));
\ No newline at end of file \ No newline at end of file
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.7721.48108.61320</string> </value> <value> <string>992.849.18457.2065</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542905890.66</float> <float>1620831029.04</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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