Commit f58bdefb authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Simplify logout page code

parent 5035d2b8
/*global window, rJS, RSVP, promiseEventListener, UriTemplate */ /*global window, rJS, UriTemplate */
/*jslint indent: 2, maxerr: 3, nomen: true */ /*jslint indent: 2, maxerr: 3, nomen: true */
(function (window, rJS, RSVP, promiseEventListener, UriTemplate) { (function (window, rJS, UriTemplate) {
"use strict"; "use strict";
rJS(window) rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Init local properties
.ready(function (g) {
g.props = {};
})
// Assign the element to a variable
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// handle acquisition // handle acquisition
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -33,35 +18,20 @@ ...@@ -33,35 +18,20 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this; var gadget = this;
return new RSVP.Queue() return gadget.updateHeader({page_title: 'Logout'})
.push(function () {
return gadget.updateHeader({page_title: 'Logout'});
})
.push(function () { .push(function () {
return gadget.translateHtml(gadget.props.element.innerHTML); return gadget.translateHtml(gadget.element.innerHTML);
}) })
.push(function (my_translated_html) { .push(function (my_translated_html) {
gadget.props.element.innerHTML = my_translated_html; gadget.element.innerHTML = my_translated_html;
}); });
}) })
.declareService(function () {
.onEvent('submit', function () {
var gadget = this, var gadget = this,
logout_url_template; logout_url_template;
// Listen to form submit
return new RSVP.Queue() return gadget.jio_getAttachment('acl_users', 'links')
.push(function () {
return promiseEventListener(
gadget.props.element.querySelector('form'),
'submit',
false
);
})
.push(function () {
return gadget.jio_getAttachment(
'acl_users',
'links'
);
})
.push(function (links) { .push(function (links) {
logout_url_template = links._links.logout.href; logout_url_template = links._links.logout.href;
return gadget.getUrlFor({ return gadget.getUrlFor({
...@@ -79,4 +49,4 @@ ...@@ -79,4 +49,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP, promiseEventListener, UriTemplate)); }(window, rJS, UriTemplate));
\ No newline at end of file \ No newline at end of file
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.53322.52034.23569</string> </value> <value> <string>954.47195.16803.17902</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1469543750.01</float> <float>1476953978.0</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