[FIX] priorities when selecting view modes in dashboard
In the case of ``list`` view mode, code would fail to use provided ``views`` array (and therefore lose the view id), overriding it with ``[false, 'list']`` instead. Original issue seemed to be that the dashboard's ``view_mode`` may contain view names which are not in the original action's ``views`` array (?) in which case the _.find call returns ``undefined`` and then blows up. This was fixed by pre-checking the dashboard's view mode against the action's view_mode, which is: 1. Wrong, as the action's view_mode will always contain ``tree`` never ``list`` 2. Weird, why not fallback *instead of returning ``undefined``*? So that's what was changed: instead of returning ``undefined`` the mapping function now returns a default ``[false, mode]`` pair. bzr revid: xmo@openerp.com-20120518085105-job3luim44ih6nps
This commit is contained in:
parent
f64b43b370
commit
9b6e1a876f
|
@ -162,16 +162,10 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({
|
|||
var action_orig = _.extend({ flags : {} }, action);
|
||||
|
||||
if (view_mode && view_mode != action.view_mode) {
|
||||
var action_view_mode = action.view_mode.split(',');
|
||||
action.views = _.map(view_mode.split(','), function(mode) {
|
||||
if (_.indexOf(action_view_mode, mode) < 0) {
|
||||
return [false, mode == 'tree' ? 'list': mode];
|
||||
} else {
|
||||
mode = mode === 'tree' ? 'list' : mode;
|
||||
return _.find(action.views, function(view) {
|
||||
return view[1] == mode;
|
||||
});
|
||||
}
|
||||
mode = mode === 'tree' ? 'list' : mode;
|
||||
return _(action.views).find(function(view) { return view[1] == mode; })
|
||||
|| [false, mode];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue