[MERGE] correct hashchange check of current_state to do not coerce values. only push active_ids in state if relevant
bzr revid: chs@openerp.com-20130220174455-gsobu19naslo1h73
This commit is contained in:
commit
544c8f2dd7
|
@ -1323,8 +1323,9 @@ instance.web.WebClient = instance.web.Client.extend({
|
|||
},
|
||||
on_hashchange: function(event) {
|
||||
var self = this;
|
||||
var stringstate = event.getState(false);
|
||||
if (!_.isEqual(this._current_state, stringstate)) {
|
||||
var state = event.getState(true);
|
||||
if (!_.isEqual(this._current_state, state)) {
|
||||
if(!state.action && state.menu_id) {
|
||||
self.menu.has_been_loaded.done(function() {
|
||||
self.menu.do_reload().done(function() {
|
||||
|
@ -1336,13 +1337,13 @@ instance.web.WebClient = instance.web.Client.extend({
|
|||
this.action_manager.do_load_state(state, !!this._current_state);
|
||||
}
|
||||
}
|
||||
this._current_state = state;
|
||||
this._current_state = stringstate;
|
||||
},
|
||||
do_push_state: function(state) {
|
||||
this.set_title(state.title);
|
||||
delete state.title;
|
||||
var url = '#' + $.param(state);
|
||||
this._current_state = _.clone(state);
|
||||
this._current_state = $.deparam($.param(state), false); // stringify all values
|
||||
$.bbq.pushState(url);
|
||||
this.trigger('state_pushed', state);
|
||||
},
|
||||
|
|
|
@ -191,11 +191,15 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
|||
state = _.extend(params || {}, state);
|
||||
}
|
||||
if (this.inner_action.context) {
|
||||
if (this.inner_action.context.active_id) {
|
||||
state["active_id"] = this.inner_action.context.active_id;
|
||||
var active_id = this.inner_action.context.active_id;
|
||||
if (active_id) {
|
||||
state["active_id"] = active_id;
|
||||
}
|
||||
if (this.inner_action.context.active_ids) {
|
||||
//state["active_ids"] = this.inner_action.context.active_ids.join(',');
|
||||
var active_ids = this.inner_action.context.active_ids;
|
||||
if (active_ids && !(active_ids.length === 1 && active_ids[0] === active_id)) {
|
||||
// We don't push active_ids if it's a single element array containing the active_id
|
||||
// This makes the url shorter in most cases.
|
||||
state["active_ids"] = this.inner_action.context.active_ids.join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,6 +235,8 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
|||
add_context.active_ids = state.active_ids.toString().split(',').map(function(id) {
|
||||
return parseInt(id, 10) || id;
|
||||
});
|
||||
} else if (state.active_id) {
|
||||
add_context.active_ids = [state.active_id];
|
||||
}
|
||||
this.null_action();
|
||||
action_loaded = this.do_action(state.action, { additional_context: add_context });
|
||||
|
|
Loading…
Reference in New Issue