Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move navigation portlet into core #1499

Merged
merged 23 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changelog

**Added**

- #1499 Moved navigation portlet into core
- #1498 Moved all viewlets from senaite.lims to senaite.core
- #1505 Display partition link in analyses listing
- #1491 Enable Audit-logging for Dexterity Contents
Expand Down
1 change: 1 addition & 0 deletions bika/lims/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<include package=".department"/>
<include package=".fields"/>
<include package=".idserver"/>
<include package=".portlets"/>
<include package=".publish"/>
<include package=".reports"/>
<include package=".resultsimport"/>
Expand Down
Empty file.
17 changes: 17 additions & 0 deletions bika/lims/browser/portlets/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:cmf="http://namespaces.zope.org/cmf"
i18n_domain="senaite.core">

<!-- Navigation Portlet -->
<include package="plone.app.portlets"/>

<plone:portletRenderer
portlet="plone.app.portlets.portlets.navigation.INavigationPortlet"
class=".navigation.NavigationPortletRenderer"
layer="bika.lims.interfaces.IBikaLIMS"
/>

</configure>
11 changes: 11 additions & 0 deletions bika/lims/browser/portlets/navigation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-

from plone.app.portlets.portlets.navigation import Renderer as BaseRenderer
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile


class NavigationPortletRenderer(BaseRenderer):
_template = ViewPageTemplateFile(
"templates/plone.app.portlets.portlets.navigation.pt")
recurse = ViewPageTemplateFile(
"templates/plone.app.portlets.portlets.navigation_recurse.pt")
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<tal:sidebar i18n:domain="plone">
<div class="sidebar-nav"
tal:define="root view/navigation_root">

<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button"
class="navbar-toggle"
data-toggle="collapse"
data-target=".sidebar-navbar-collapse">
<span class="sr-only" i18n:translate="">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="visible-xs navbar-brand" tal:content="view/title">
Navigation
</span>
</div>

<div class="navbar-collapse collapse sidebar-navbar-collapse">
<ul class="nav navbar-nav">
<li tal:replace="structure view/createNavTree">
SUBTREE
</li>
</ul>
</div>

</div>
</div>
</tal:sidebar>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<tal:master define="level options/level|python:0;
children options/children | nothing;
bottomLevel options/bottomLevel | nothing;
bootstrapview nocall:context/@@bootstrapview"
i18n:domain="plone">

<metal:main define-macro="nav_main">

<tal:navitem repeat="node children">
<li tal:define="show_children node/show_children;
children node/children;
has_children python:len(children)>0;
item_url node/getURL;
item_remote_url node/getRemoteUrl;
use_remote_url node/useRemoteUrl | nothing;
item nocall:node/item;
item_icon python:bootstrapview.get_icon_for(item);
item_type node/portal_type;
is_current node/currentItem;
is_in_path node/currentParent;
li_class python:is_current and ' active' or '';
li_extr_class python:is_in_path and ' expanded' or '';
li_folder_class python:show_children and ' folderish' or '';
normalizeString nocall: context/plone_utils/normalizeString;"
tal:attributes="class string:nav-item${li_class}${li_extr_class}${li_folder_class} section-${node/normalized_id}"
tal:condition="python:bottomLevel &lt;= 0 or level &lt;= bottomLevel">

<tal:level define="item_class string:senaite-state-${node/normalized_review_state};
item_type_class python:'senatite-contenttype-' + normalizeString(item_type);
item_class python:is_current and item_class + ' active' or item_class;">

<a tal:attributes="href python:use_remote_url and item_remote_url or item_url;
title node/Description;
class string:$item_class${li_class}${li_extr_class}${li_folder_class} $item_type_class">
<tal:root tal:condition="python: level==1">
<img tal:replace="structure item_icon"/>
<span tal:condition="not:item_icon">
<span class="glyphicon glyphicon-folder-close" aria-hidden="true"></span>
</span>
<span tal:replace="node/Title">Selected Item Title</span>
</tal:root>
<tal:children tal:condition="python: level>1">
<div style="white-space:nowrap;">
<span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
<span tal:replace="node/Title">Selected Item Title</span>
</div>
</tal:children>
</a>

<tal:children condition="has_children">
<ul tal:attributes="class python:'nav submenu nav-level-'+str(level)"
tal:condition="python: len(children) > 0 and show_children and bottomLevel and level < bottomLevel or True">
<span tal:replace="structure python:view.recurse(children=children, level=level+1, bottomLevel=bottomLevel)" />
</ul>
</tal:children>

</tal:level>
</li>
</tal:navitem>
</metal:main>
</tal:master>