summaryrefslogtreecommitdiff
path: root/addons/edi/static/src/js
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-01-31 22:01:31 +0100
committerAntony Lesuisse <al@openerp.com>2012-01-31 22:01:31 +0100
commitf2aea7dfc2c21bc88ef75d1c7bd27c8149d604ab (patch)
tree3beba6d5e9adcd7851318ab97179fd1d3f88d3d1 /addons/edi/static/src/js
parent60c47d9f98793d5591807722dc1352ee7fe94861 (diff)
parentdb1ffb561b704d76a6ee80faf94fbce906df82e5 (diff)
[MERGE] ask for login when importing edi file if needed
bzr revid: al@openerp.com-20120131210131-k1141eoel0l3b26c
Diffstat (limited to 'addons/edi/static/src/js')
-rw-r--r--addons/edi/static/src/js/edi.js45
1 files changed, 31 insertions, 14 deletions
diff --git a/addons/edi/static/src/js/edi.js b/addons/edi/static/src/js/edi.js
index 5493077e831..0f59768bc4e 100644
--- a/addons/edi/static/src/js/edi.js
+++ b/addons/edi/static/src/js/edi.js
@@ -109,7 +109,7 @@ openerp.edi.EdiView = openerp.web.OldWidget.extend({
openerp.edi.edi_view = function (db, token) {
openerp.connection.bind().then(function () {
- new openerp.edi.EdiView(null,db,token).appendTo($("body"));
+ new openerp.edi.EdiView(null,db,token).appendTo($("body").addClass('openerp'));
});
}
@@ -117,27 +117,44 @@ openerp.edi.EdiImport = openerp.web.OldWidget.extend({
init: function(parent,url) {
this._super();
this.url = url;
- var params = {};
-
- this.template = "EdiImport";
- this.session = openerp.connection;
- this.login = new openerp.web.Login(this);
- this.header = new openerp.web.Header(this);
},
start: function() {
- // TODO fix by explicitly asking login if needed
- //this.session.on_session_invalid.add_last(this.do_ask_login);
- this.header.appendTo($("#oe_header"));
- this.login.appendTo($('#oe_login'));
+ if (!this.session.session_is_valid()) {
+ this.show_login();
+ this.session.on_session_valid.add({
+ callback: this.proxy('show_import'),
+ unique: true,
+ });
+ } else {
+ this.show_import();
+ }
+ },
+
+ show_import: function() {
+ this.destroy_content();
this.do_import();
},
+
+ show_login: function() {
+ this.destroy_content();
+ this.login = new openerp.web.Login(this);
+ this.login.appendTo(this.$element);
+ },
+
+ destroy_content: function() {
+ _.each(_.clone(this.widget_children), function(el) {
+ el.stop();
+ });
+ this.$element.children().remove();
+ },
+
do_import: function() {
this.rpc('/edi/import_edi_url', {url: this.url}, this.on_imported, this.on_imported_error);
},
on_imported: function(response) {
if ('action' in response) {
this.rpc("/web/session/save_session_action", {the_action: response.action}, function(key) {
- window.location = "/web/webclient/home?debug=1&s_action="+encodeURIComponent(key);
+ window.location = "/web/webclient/home#sa="+encodeURIComponent(key);
});
}
else {
@@ -147,7 +164,7 @@ openerp.edi.EdiImport = openerp.web.OldWidget.extend({
buttons: {
Ok: function() {
$(this).dialog("close");
- window.location = "/web/webclient/home";
+ window.location = "/";
}
}
}).html('The document has been successfully imported!');
@@ -172,7 +189,7 @@ openerp.edi.EdiImport = openerp.web.OldWidget.extend({
openerp.edi.edi_import = function (url) {
openerp.connection.bind().then(function () {
- new openerp.edi.EdiImport(null,url).appendTo($("body"));
+ new openerp.edi.EdiImport(null,url).appendTo($("body").addClass('openerp'));
});
}