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

Moved contentmenu provider into core #1529

Merged
merged 3 commits into from
Feb 12, 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**

- #1529 Moved contentmenu provider into core
- #1523 Moved Installation Screens into core
- #1520 JavaScripts/CSS Integration and Cleanup
- #1517 Integrate senaite.core.spotlight
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 @@ -19,6 +19,7 @@
<include file="calcs.zcml"/>
<include file="clientfolder.zcml"/>
<include file="contact.zcml"/>
<include file="contentmenu.zcml"/>
<include file="controlpanel.zcml"/>
<include file="dynamic_analysisspec.zcml"/>
<include file="instrument.zcml"/>
Expand Down
35 changes: 31 additions & 4 deletions bika/lims/browser/contentmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,37 @@
# Some rights reserved, see README and LICENSE.

from plone.app.contentmenu.menu import WorkflowMenu as BaseClass
from plone.app.contentmenu.view import ContentMenuProvider
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope.component import getUtility
from zope.browsermenu.interfaces import IBrowserMenu


class WorkflowMenu(BaseClass):
class SenaiteContentMenuProvider(ContentMenuProvider):
"""Provides a proper styled content menu
"""
index = ViewPageTemplateFile(
"templates/plone.app.contentmenu.contentmenu.pt")

def render(self):
return self.index()

# From IContentMenuView

def available(self):
return True

def menu(self):
menu = getUtility(IBrowserMenu, name="plone_contentmenu")
items = menu.getMenuItems(self.context, self.request)
# always filter out the selection of the default view
items = filter(
lambda a: not a["action"].endswith("/select_default_view"), items)
items.reverse()
return items


class WorkflowMenu(BaseClass):
def getMenuItems(self, context, request):
"""Overrides the workflow actions menu displayed top right in the
object's view. Displays the current state of the object, as well as a
Expand All @@ -32,6 +59,6 @@ def getMenuItems(self, context, request):
"""
actions = super(WorkflowMenu, self).getMenuItems(context, request)
# Remove status history menu item ('Advanced...')
actions = [action for action in actions
if not action['action'].endswith('/content_status_history')]
return actions
return filter(
lambda a: not a["action"].endswith("/content_status_history"),
actions)
16 changes: 16 additions & 0 deletions bika/lims/browser/contentmenu.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="senaite.core">

<!-- Content Menu -->
<adapter
name="plone.contentmenu"
for="*
bika.lims.interfaces.IBikaLIMS
*"
factory=".contentmenu.SenaiteContentMenuProvider"
provides="zope.contentprovider.interfaces.IContentProvider"
/>

</configure>
89 changes: 89 additions & 0 deletions bika/lims/browser/templates/plone.app.contentmenu.contentmenu.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<div id="editContentActionMenus"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:tal="http://xml.zope.org/namespaces/tal"
tal:define="menu view/menu"
tal:condition="view/available"
i18n:domain="plone"
class="pull-right btn-toolbar">

<tal:menuItem repeat="menuItem menu">
<div class="editActionMenu dropdown btn-group pull-right"
tal:attributes="id menuItem/extra/id"
tal:define="submenu menuItem/submenu">
<button tal:define="state_class menuItem/extra/class | nothing;
state_class python:state_class and state_class or ''"
data-toggle="dropdown"
tal:omit-tag="not:menuItem/action"
tal:attributes="href menuItem/action;
title menuItem/description;
class string:btn btn-default dropdown-toggle actionMenuHeader label-${state_class}"
i18n:attributes="title;">
<span tal:omit-tag="menuItem/action"
class="noMenuAction">
<span tal:content="menuItem/title"
i18n:translate="">
Title
</span>
<span tal:condition="menuItem/extra/stateTitle | nothing"
tal:attributes="class menuItem/extra/class | nothing"
tal:define="title menuItem/extra/stateTitle | nothing"
tal:content="python:title.capitalize()"
i18n:translate="">
State title
</span>
<span class="caret"
tal:condition="not:menuItem/extra/hideChildren | not:submenu | nothing"></span>
</span>
</button>
<ul class="dropdown-menu editActionMenuContent" role="menu"
tal:condition="not:menuItem/extra/hideChildren | not:submenu | nothing">
<tal:block repeat="subMenuItem submenu">
<tal:separator condition="subMenuItem/extra/separator">
<li class="divider"></li>
</tal:separator>
<li tal:attributes="class python:subMenuItem.get('selected', None) and 'active' or None">
<a href="#"
tal:condition="subMenuItem/action"
tal:attributes="href subMenuItem/action;
title subMenuItem/description;
id subMenuItem/extra/id | nothing;
class subMenuItem/extra/class | nothing"
i18n:attributes="title">
<img width="16"
height="16"
alt=""
tal:condition="subMenuItem/icon"
tal:attributes="src subMenuItem/icon;
title subMenuItem/description;
width subMenuItem/width|string:16;
height subMenuItem/height|string:16;"
i18n:attributes="alt;"/>
<span tal:replace="structure subMenuItem/title"
i18n:translate=""
class="editSubMenuTitle">
Title
</span>
</a>
<a tal:condition="not:subMenuItem/action"
href="#"
tal:attributes="id subMenuItem/extra/id | nothing;
class subMenuItem/extra/class | nothing">
<img width="16"
height="16"
alt=""
tal:condition="subMenuItem/icon"
tal:attributes="src subMenuItem/icon;
title subMenuItem/description"
i18n:attributes="alt;"/>
<span tal:replace="structure subMenuItem/title"
i18n:translate=""
class="subMenuTitle">
Title
</span>
</a>
</li>
</tal:block>
</ul>
</div>
</tal:menuItem>
</div>