-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add relative path widget for faceted
Waiting for eea/eea.facetednavigation#183
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |