深度定制odoo面包屑导航

odoo.define('galaxy.web.ActionManager', function (require) {
"use strict";

/**
 * ActionManager
 *
 * The ActionManager is one of the centrepieces in the WebClient architecture.
 * Its role is to makes sure that Odoo actions are properly started and
 * coordinated.
 */

var AbstractAction = require('web.AbstractAction');
var concurrency = require('web.concurrency');
var Context = require('web.Context');
var core = require('web.core');
var Dialog = require('web.Dialog');
var dom = require('web.dom');
var framework = require('web.framework');
var pyUtils = require('web.py_utils');
var Widget = require('web.Widget');
var ActionManager = require('web.ActionManager');

var _t = core._t;
var galaxy_ActionManager = ActionManager.include({
    
    /**
     * Returns a description of the controllers in the given  controller stack.
     * It is used to render the breadcrumbs. It is an array of Objects with keys
     * 'title' (what to display in the breadcrumbs) and 'controllerID' (the ID
     * of the corresponding controller, used to restore it when this part of the
     * breadcrumbs is clicked).
     *
     * @private
     * @param {string[]} controllerStack
     * @returns {Object[]
     重载这个方法的目的是为了不重复显示相同title的面包屑
     */
    _getBreadcrumbs: function (controllerStack) {
        var self = this;
        
        var title_set = '';
        var pos = 0;
        var rt = _.map(controllerStack, function (controllerID) {
            var title = self.controllers[controllerID].title;
            if (title_set.indexOf(title) == -1 && pos<2){
                title_set += title;
                pos++;
                return {
                controllerID: controllerID,
                title: title,
                }
            }
        });
       
        return rt
    },
});

return galaxy_ActionManager;

});

通常的方法只能完全禁用或启用面包屑导航,重写action manager里面的 _getBreadcrumbs方法,可以设置重复内容的title不显示,避免在更新内容的时候,出现很长的导航字符串,看起来很难看,用户也很困惑。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值