[FIX] web: always update breadcrumb on change title
Revision on https://github.com/odoo/odoo/commit/32b8cec5361174c92c45a4975d4e02f1fb448aa2 Before this commit, when we switch channels in the Discuss app, the breadcrumb was visually not updated: it keeps the name of the first opened channel. With this commit, the breadcrumb is updated on each change of channel, so that it displays the name of the currently opened channel. Technical details: This is due to a change of logic of updating the GUI of the breadcrumb: before the refactoring above, discuss had to pass the content of the breadcrumb to the control panel, in order to update the breadcrumb visually. After the refactoring, the action manager should warn the control panel to update the breadcrumb on any change of the title. This is already the case for `ir.actions.act_window`, but not for all types of client actions.
This commit is contained in:
@@ -835,12 +835,27 @@ var ActionManager = Widget.extend({
|
||||
* is ready when it will be appended to the DOM. This allows to prevent
|
||||
* flickering for widgets doing async stuff in willStart() or start().
|
||||
*
|
||||
* Also updates the control panel on any change of the title on controller's
|
||||
* widget.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} controller
|
||||
* @returns {Deferred<Object>} resolved with the controller when it is ready
|
||||
*/
|
||||
_startController: function (controller) {
|
||||
var self = this;
|
||||
var fragment = document.createDocumentFragment();
|
||||
// AAB: change this logic to stop using the properties mixin
|
||||
controller.widget.on("change:title", this, function () {
|
||||
if (self.getCurrentController() !== controller) {
|
||||
return;
|
||||
}
|
||||
var action = self.actions[controller.actionID];
|
||||
if (!action.flags || !action.flags.headless) {
|
||||
var breadcrumbs = self._getBreadcrumbs();
|
||||
self.controlPanel.update({breadcrumbs: breadcrumbs}, {clear: false});
|
||||
}
|
||||
});
|
||||
return controller.widget.appendTo(fragment).then(function () {
|
||||
return controller;
|
||||
});
|
||||
|
||||
@@ -202,15 +202,7 @@ ActionManager.include({
|
||||
// the action has been removed, so simply destroy the widget
|
||||
widget.destroy();
|
||||
} else {
|
||||
// AAB: change this logic to stop using the properties mixin
|
||||
widget.on("change:title", this, function () {
|
||||
if (!action.flags.headless) {
|
||||
var breadcrumbs = self._getBreadcrumbs();
|
||||
self.controlPanel.update({breadcrumbs: breadcrumbs}, {clear: false});
|
||||
}
|
||||
});
|
||||
controller.widget = widget;
|
||||
|
||||
def.resolve(controller);
|
||||
}
|
||||
}).fail(def.reject.bind(def));
|
||||
|
||||
@@ -1532,6 +1532,36 @@ QUnit.module('ActionManager', {
|
||||
delete core.action_registry.map.HelloWorldTest;
|
||||
});
|
||||
|
||||
QUnit.test('breadcrumb is updated on title change', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var ClientAction = Widget.extend(ControlPanelMixin, {
|
||||
className: 'o_client_action_test',
|
||||
events: {
|
||||
click: function () {
|
||||
this.set("title", 'new title');
|
||||
},
|
||||
},
|
||||
start: function () {
|
||||
this.set("title", 'initial title');
|
||||
this.$el.text('Hello World');
|
||||
},
|
||||
});
|
||||
var actionManager = createActionManager();
|
||||
core.action_registry.add('HelloWorldTest', ClientAction);
|
||||
actionManager.doAction('HelloWorldTest');
|
||||
|
||||
assert.strictEqual($('ol.breadcrumb').text(), "initial title",
|
||||
"should have initial title as breadcrumb content");
|
||||
|
||||
actionManager.$('.o_client_action_test').click();
|
||||
assert.strictEqual($('ol.breadcrumb').text(), "new title",
|
||||
"should have updated title as breadcrumb content");
|
||||
|
||||
actionManager.destroy();
|
||||
delete core.action_registry.map.HelloWorldTest;
|
||||
});
|
||||
|
||||
QUnit.module('Server actions');
|
||||
|
||||
QUnit.test('can execute server actions from db ID', function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user