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