Catalysts / cat-angular

Basic support for Angular Apps
Apache License 2.0
7 stars 16 forks source link

disable link in menu if the user is currently on it #28

Closed mangei closed 9 years ago

mangei commented 9 years ago

this function can be used in the template, to disable the link or to render an element differently, if the user is currently on the page of the link

in a subproject, we overwrite the cat-main-menu.tpl.html to use this method. This can also be integrated into cat-angular itself. If so, please create a ticket and we will do so.

<ul class="nav-sidemenu">
    <li ng-repeat="menu in menus" ng-if="isVisible(menu)">
        <div class="menu">
            <span cat-i18n="cc.catalysts.cat-menu.menu.{{menu.completeId}}">{{menu.getOptions().name}}</span>
        </div>
        <ul>
            <li ng-repeat="entry in menu.getFlattened() track by entry.id" ng-if="isVisible(entry)"
                ng-class="entry.isGroup() ? 'group' : 'item'"
                ng-attr-id="{{'menu-' + (entry.isGroup() ? 'group' : 'item') + '.' + entry.completeId}}"
                role="presentation">

                <!-- Link -->
                <a ng-href="#{{entry.getOptions().path}}"
                   ng-if="!entry.isGroup() && !isActive(entry.getOptions().path)"
                   ng-class="{active: isActive(entry.getOptions().path)}">
                    <span cat-i18n="cc.catalysts.cat-menu.entry.{{entry.completeId}}">
                        {{entry.getOptions().name}}
                    </span> <span ng-if="entry.getOptions().keymap"
                                  class="text-muted">{{entry.getOptions().keymap}}</span>
                </a>

                <!-- Current Link -->
                <span ng-if="!entry.isGroup() && isActive(entry.getOptions().path)" class="active"
                      cat-i18n="cc.catalysts.cat-menu.entry.{{entry.completeId}}">
                    {{entry.getOptions().name}}
                </span>

                <!-- Group -->
                <span ng-if="entry.isGroup()"
                      cat-i18n="cc.catalysts.cat-menu.group.{{entry.completeId}}">
                    {{entry.getOptions().name}}
                </span>
            </li>
        </ul>
    </li>
</ul>