Skip to content

Commit

Permalink
Add relative path widget for faceted
Browse files Browse the repository at this point in the history
  • Loading branch information
laulaz committed Nov 14, 2019
1 parent 1264404 commit 5e24957
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/plonemeeting/portal/core/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<include file="permissions.zcml" />
<include package=".browser" />
<include package=".content" />
<include package=".faceted" />


<genericsetup:registerProfile
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions src/plonemeeting/portal/core/faceted/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<configure
xmlns:faceted="http://namespaces.zope.org/faceted"
i18n_domain="plonemeeting.portal.core">

<faceted:widget
factory=".widget.RelativePathWidget"
schema="eea.facetednavigation.widgets.interfaces.ISchema"
/>

</configure>
17 changes: 17 additions & 0 deletions src/plonemeeting/portal/core/faceted/widget.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="faceted-widget" style="display: none"
i18n:domain="eea" tal:define="
error_view nocall:context/@@faceted.widget.error;
wid python:view.data.getId();
hidden python:view.hidden;
css string:faceted-widget ${view/css_class};
css python:hidden and css + ' faceted-widget-hidden' or css;
title python:view.translate(view.data.get('title', ''));
"
tal:attributes="id string:${wid}_widget; class css;">

<fieldset class="widget-fieldset">
<legend tal:content="title" i18n:translate="">HTML Widget</legend>
<tal:facet on-error="structure python:error_view(error=error, cid=wid)">
</tal:facet>
</fieldset>
</div>
34 changes: 34 additions & 0 deletions src/plonemeeting/portal/core/faceted/widget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

from eea.facetednavigation.widgets import ViewPageTemplateFile
from eea.facetednavigation.widgets.interfaces import DefaultSchemata as DS
from eea.facetednavigation.widgets.interfaces import ISchema
from eea.facetednavigation.widgets.widget import Widget
from z3c.form import field

from plonemeeting.portal.core import _


class DefaultSchemata(DS):
""" Schemata default
"""

fields = field.Fields(ISchema).select(u"title")


class RelativePathWidget(Widget):
""" Filter on objects from current folder
"""

widget_type = "relative_path"
widget_label = _("Relative path widget")
groups = (DefaultSchemata,)

index = ViewPageTemplateFile("widget.pt")

def query(self, form):
""" Returns only objects from current folder
"""
current_path = "/".join(self.context.getPhysicalPath())
query = {"path": {"query": current_path}}
return query

0 comments on commit 5e24957

Please sign in to comment.