summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js30
-rw-r--r--addons/web/static/src/js/corelib.js9
-rw-r--r--addons/web/static/src/js/data.js8
-rw-r--r--addons/web/static/src/js/view_form.js43
4 files changed, 45 insertions, 45 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 2e8ca8ba997..af6d4f0cf18 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -181,7 +181,7 @@ instance.web.Dialog = instance.web.Widget.extend({
});
instance.web.CrashManager = instance.web.CallbackEnabled.extend({
- on_rpc_error: function(error) {
+ rpc_error: function(error) {
if (error.data.fault_code) {
var split = ("" + error.data.fault_code).split('\n')[0].split(' -- ');
if (split.length > 1) {
@@ -190,12 +190,12 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({
}
}
if (error.code === 200 && error.type) {
- this.on_managed_error(error);
+ this.show_warning(error);
} else {
- this.on_traceback(error);
+ this.show_error(error);
}
},
- on_managed_error: function(error) {
+ show_warning: function(error) {
instance.web.dialog($('<div>' + QWeb.render('CrashManager.warning', {error: error}) + '</div>'), {
title: "OpenERP " + _.str.capitalize(error.type),
buttons: [
@@ -203,7 +203,7 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({
]
});
},
- on_traceback: function(error) {
+ show_error: function(error) {
var self = this;
var buttons = {};
buttons[_t("Ok")] = function() {
@@ -219,8 +219,8 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({
}).open();
dialog.$el.html(QWeb.render('CrashManager.error', {session: instance.session, error: error}));
},
- on_javascript_exception: function(exception) {
- this.on_traceback({
+ show_message: function(exception) {
+ this.show_error({
type: _t("Client Error"),
message: exception,
data: {debug: ""}
@@ -236,7 +236,7 @@ instance.web.Loading = instance.web.Widget.extend({
this.blocked_ui = false;
this.session.on("request", this, this.request_call);
this.session.on("response", this, this.response_call);
- this.session.on("error", this, this.response_call);
+ this.session.on("response_failed", this, this.response_call);
},
destroy: function() {
this.on_rpc_event(-this.count);
@@ -957,7 +957,7 @@ instance.web.Client = instance.web.Widget.extend({
show_common: function() {
var self = this;
this.crashmanager = new instance.web.CrashManager();
- instance.session.on_rpc_error.add(this.crashmanager.on_rpc_error);
+ instance.session.on('error', this.crashmanager, this.crashmanager.rpc_error);
self.notification = new instance.web.Notification(this);
self.notification.appendTo(self.$el);
self.loading = new instance.web.Loading(self);
@@ -1007,7 +1007,7 @@ instance.web.WebClient = instance.web.Client.extend({
var self = this;
this._super();
window.onerror = function (message, file, line) {
- self.crashmanager.on_traceback({
+ self.crashmanager.show_error({
type: _t("Client Error"),
message: message,
data: {debug: file + ':' + line}
@@ -1016,15 +1016,13 @@ instance.web.WebClient = instance.web.Client.extend({
},
show_login: function() {
this.toggle_bars(false);
-
+
+ var state = $.bbq.getState(true);
var action = {
'type': 'ir.actions.client',
- 'tag': 'login'
+ 'tag': 'login',
+ 'params': state
};
- var state = $.bbq.getState(true);
- if (state.action === "login") {
- action.params = state;
- }
this.action_manager.do_action(action);
this.action_manager.inner_widget.on('login_successful', this, function() {
diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js
index 7a9af79b4fb..b5fbacc7927 100644
--- a/addons/web/static/src/js/corelib.js
+++ b/addons/web/static/src/js/corelib.js
@@ -980,7 +980,8 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
triggers: {
'request': 'Request sent',
'response': 'Response received',
- 'error': 'HTTP Error response or timeout received',
+ 'response_failed': 'HTTP Error response or timeout received',
+ 'error': 'The received response is an JSON-RPC error',
},
/**
* @constructs instance.web.JsonRPC
@@ -1336,7 +1337,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
}
},
function(jqXHR, textStatus, errorThrown) {
- self.trigger('error');
+ self.trigger('response_failed', jqXHR);
var error = {
code: -32098,
message: "XmlHttpRequestError " + errorThrown,
@@ -1348,7 +1349,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
deferred.fail(function() {
deferred.fail(function(error, event) {
if (!event.isDefaultPrevented()) {
- self.on_rpc_error(error, event);
+ self.trigger('error', error, event);
}
});
});
@@ -1434,8 +1435,6 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
return deferred;
}
},
- on_rpc_error: function(error) {
- },
get_url: function (file) {
return this.prefix + file;
},
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index 220d42737da..ce85e0ac43f 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -575,6 +575,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
* @param {Number|String} ids identifier of the record to delete
*/
unlink: function(ids) {
+ this.trigger('unlink', ids);
return this._model.call('unlink', [ids], {context: this._model.context()});
},
/**
@@ -690,6 +691,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
instance.web.DataSetStatic = instance.web.DataSet.extend({
init: function(parent, model, context, ids) {
+ var self = this;
this._super(parent, model, context);
// all local records
this.ids = ids || [];
@@ -711,12 +713,10 @@ instance.web.DataSetStatic = instance.web.DataSet.extend({
}
},
unlink: function(ids) {
- this.on_unlink(ids);
+ this.set_ids(_.without.apply(null, [this.ids].concat(ids)));
+ this.trigger('unlink', ids);
return $.Deferred().resolve({result: true});
},
- on_unlink: function(ids) {
- this.set_ids(_.without.apply(null, [this.ids].concat(ids)));
- }
});
instance.web.DataSetSearch = instance.web.DataSet.extend({
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index a095ab129c1..afb5e258c0b 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -615,7 +615,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
return self.on_processed_onchange(response, processed);
} catch(e) {
console.error(e);
- instance.webclient.crashmanager.on_javascript_exception(e);
+ instance.webclient.crashmanager.show_message(e);
return $.Deferred().reject();
}
});
@@ -650,7 +650,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
return $.Deferred().resolve();
} catch(e) {
console.error(e);
- instance.webclient.crashmanager.on_javascript_exception(e);
+ instance.webclient.crashmanager.show_message(e);
return $.Deferred().reject();
}
},
@@ -784,7 +784,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var def = $.Deferred();
$.when(this.has_been_loaded).then(function() {
self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
- return self.on_created({ result : new_id });
+ return self.record_created({ result : new_id });
}).then(function() {
return self.to_edit_mode();
}).then(function() {
@@ -861,7 +861,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
if (!self.datarecord.id) {
// Creation save
save_deferral = self.dataset.create(values).pipe(function(r) {
- return self.on_created(r, prepend_on_create);
+ return self.record_created(r, prepend_on_create);
}, null);
} else if (_.isEmpty(values) && ! self.force_dirty) {
// Not dirty, noop save
@@ -870,7 +870,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
self.force_dirty = false;
// Write save
save_deferral = self.dataset.write(self.datarecord.id, values, {}).pipe(function(r) {
- return self.on_saved(r);
+ return self.record_saved(r);
}, null);
}
return save_deferral;
@@ -897,12 +897,15 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
*
* @param {Object} r result of the write function.
*/
- on_saved: function(r) {
+ record_saved: function(r) {
+ var self = this;
if (!r) {
// should not happen in the server, but may happen for internal purpose
+ this.trigger('record_saved', r);
return $.Deferred().reject();
} else {
return $.when(this.reload()).pipe(function () {
+ self.trigger('record_saved', r);
return r;
});
}
@@ -920,9 +923,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
* @param {Boolean} [prepend_on_create=false] adds the newly created record
* at the beginning of the dataset instead of the end
*/
- on_created: function(r, prepend_on_create) {
+ record_created: function(r, prepend_on_create) {
+ var self = this;
if (!r) {
// should not happen in the server, but may happen for internal purpose
+ this.trigger('record_created', r);
return $.Deferred().reject();
} else {
this.datarecord.id = r;
@@ -936,9 +941,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.do_update_pager();
if (this.sidebar) {
this.sidebar.do_attachement_update(this.dataset, this.datarecord.id);
- }
+ }
//openerp.log("The record has been created with id #" + this.datarecord.id);
return $.when(this.reload()).pipe(function () {
+ self.trigger('record_created', r);
return _.extend(r, {created: true});
});
}
@@ -1630,13 +1636,14 @@ instance.web.form.FormDialog = instance.web.Dialog.extend({
return this;
},
start: function() {
+ var self = this;
this._super();
this.form = new instance.web.FormView(this, this.dataset, this.view_id, {
pager: false
});
this.form.appendTo(this.$el);
- this.form.on_created.add_last(this.on_form_dialog_saved);
- this.form.on_saved.add_last(this.on_form_dialog_saved);
+ this.form.on('record_created', self, this.on_form_dialog_saved);
+ this.form.on('record_saved', this, this.on_form_dialog_saved);
return this;
},
select_id: function(id) {
@@ -3309,11 +3316,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
var views = [];
_.each(modes, function(mode) {
if (! _.include(["list", "tree", "graph", "kanban"], mode)) {
- try {
- throw new Error(_.str.sprintf("View type '%s' is not supported in One2Many.", mode));
- } catch(e) {
- instance.webclient.crashmanager.on_javascript_exception(e)
- }
+ throw new Error(_.str.sprintf("View type '%s' is not supported in One2Many.", mode));
}
var view = {
view_id: false,
@@ -3820,7 +3823,7 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({
colspan: columns,
'class': 'oe_form_field_one2many_list_row_add'
}).append(
- $('<a>', {href: '#'}).text(_t("Add a row"))
+ $('<a>', {href: '#'}).text(_t("Add an item"))
.mousedown(function () {
// FIXME: needs to be an official API somehow
if (self.view.editor.is_editing()) {
@@ -4023,7 +4026,7 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({
this.dataset = new instance.web.form.Many2ManyDataSet(this, this.field.relation);
this.dataset.m2m = this;
- this.dataset.on_unlink.add_last(function(ids) {
+ this.dataset.on('unlink', self, function(ids) {
self.dataset_changed();
});
@@ -4156,7 +4159,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
this.dataset = new instance.web.form.Many2ManyDataSet(this, this.field.relation);
this.dataset.m2m = this;
- this.dataset.on_unlink.add_last(function(ids) {
+ this.dataset.on('unlink', self, function(ids) {
self.dataset_changed();
});
@@ -4817,9 +4820,9 @@ instance.web.form.FieldBinaryFile = instance.web.form.FieldBinary.extend({
this._super();
if (this.get("effective_readonly")) {
var self = this;
- this.$el.find('a').click(function() {
+ this.$el.find('a').click(function(ev) {
if (self.get('value')) {
- self.on_save_as();
+ self.on_save_as(ev);
}
return false;
});