A reference browser widget (Maintainer Timon Tschanz)
Project description
ftw.referencewidget
===================
This Widget provides a Referencebrowser and a searchfield, which allows users to select references.
The basequery is all types which are not in the types_not_searched property all modification to the allowed types are relative to this query.
Traversal or Selectability can be changed for all widgets with the IReferenceSettings registry interface or per widget with the widget parameters.
The widget takes the following parameters:
- allow_traversal: These Types are traversable
- block_traversal: These Types are not traversable
- selectable: These Types are selectable
- nonselectable: These Types are not selectable
- start: The path first opened. Can either be a callable or a path. Additionaly the strings "parent", "navroot", "ploneroot" can be used.
- allow_nonsearched_types: If this is set to true all the types will be traversable and selectable.
- override: drops all global config and the base query if a list is passed to the widget. All types need to be added to be selectable.
- traversal_query: Updates the query used vor traversing by the given dict. The dict passed will be updated after everything is allready done. So make sure not to override sort_on/sort_order attributes.
ContextSourceBinder
-------------------
With a `RelationeChoice` or `RelationList` of `RelationChoice` a source can be configured along with the field.
The `ContextSourceBinder` makes sure that only valid content can be selected.
By default, the source binder only checks for a valid portal_type when selecting content.
The default_filter implementation therefore looks like this:
.. code:: python
def default_filter(source, value):
""""
Return ``True`` when the object is selectable, ``False``
when it is not selectable.
""""
return value.portal_type in get_selectable_types_by_source(source)
Feel free to add your own filter method as source parameter in your field.
Example:
.. code:: python
from ftw.referencewidget.filter import DefaultSelectable
class CustomClass(DefaultSelectable):
def is_selectable(self):
return bool(..)
...
directives.widget(realtionchoice_restricted_title=ReferenceWidgetFactory)
realtionchoice_restricted_title = RelationChoice(
title=_(u'Related Choice Restricted Title'),
source=ReferenceObjSourceBinder(
selectable_class=CustomClass),
default=None,
required=False,
)
The `filter` takes two parameter the actual source object and a value, which is the content object.
Only `ReferenceObjSourceBinder` are supported. The SourceBinder takes the following parameters:
- selectable: These types are selectable
- nonselectable: These Types are not selectable
- allow_nonsearched_types: If this is set to true all the types will be traversable and selectable.
- override: drops all global config and the base query if a list is passed to the widget. All types need to be added to be selectable.
- selectable_class: Custom ISelectable Class to determine if a content is selectable or not.
The parameters are same as for the widget (Backwards compatibility with 1.x releases).
Fields combinations (Registered converter)
------------------------------------------
The following combinations are supported:
- RelationList with value_type Relation --> Stores a List of RelationValues
- RelationList with value_type RelationChoice --> Stores a List of RelationValues
- Relation --> Stores a RelationValue
- List of RelationChoice --> Stores a list of absolute paths, without the portal root part
- TextLine --> Stores a absolute path as string, without the portal root part
Screenshots
-----------
The general Listing:
![Listing](https://github.com/4teamwork/ftw.referencewidget/raw/master/docs/static/list.png)
The Search Listing:
![Search Listing](https://github.com/4teamwork/ftw.referencewidget/raw/master/docs/static/search.png)
The Selected Items
![Selected](https://github.com/4teamwork/ftw.referencewidget/raw/master/docs/static/selected.png)
Links
-----
- Github: https://github.com/4teamwork/ftw.referencewidget
- Issues: https://github.com/4teamwork/ftw.referencewidget/issues
- Continuous integration: https://jenkins.4teamwork.ch/search?q=ftw.referencewidget
Copyright
---------
This package is copyright by `4teamwork <http://www.4teamwork.ch/>`_.
``ftw.referencewidget`` is licensed under GNU General Public License, version 2.
Changelog
=========
1.4.0 (2017-07-07)
------------------
- Implement display mode for the reference widget.
[mathias.leimgruber]
- Change name of sample content buildour registry entry to avoid conflicts.
[mathias.leimgruber]
- Implement path restriction option.
[mathias.leimgruber]
- Render hidden input elements for given references, instead of
render them only by Javascript. This way the widget behaves more
like all other plone widgets.
[mathias.leimgruber]
- Implement a additional `traversal_query` parameter for the widget.
[mathias.leimgruber]
- Implement ReferenceObjPathSource for IRelationChoice fields.
[mathias.leimgruber]
1.3.0 (2016-11-09)
------------------
- Implement some sort options.
[mathias.leimgruber]
- Use plone.app.redirector to follow renamed and moved content.
Also do not fail if the content has been removed.
[mathias.leimgruber]
1.2.3 (2016-10-18)
------------------
- Fix edge case (mainly for tests) if the value passed to the
IList/Widget converter is not a list, but a string.
[raphael-s]
1.2.2 (2016-10-18)
------------------
- Implement testbrowser widget.
[raphael-s]
1.2.1 (2016-10-17)
------------------
- Respect missing_value set by the field.
[tschanzt]
- Implement support for ITextLine only with ReferenceWidget.
[mathias.leimgruber]
1.2.0 (2016-10-04)
------------------
- Show absolute path starting at the plone root for the selected value.
[mathias.leimgruber]
- Remove the list style type and the obsolete spacing for the selected elements.
[mathias.leimgruber]
- Implement support for IList of IRelationChoice explicitly.
Check Readme for more informations
[mathias.leimgruber]
1.1.0 (2016-09-27)
------------------
- Ignore empty value for multiple value field.
[mathias.leimgruber]
- Support chameleon by not rendering handlebar templates. [jone]
1.0.4 (2016-09-19)
------------------
- Make it possible to remove an given internal reference (radio button).
[mathias.leimgruber]
- Ignore empty value for single value field.
[mathias.leimgruber]
- Fix search by pressing the "enter" button.
[mathias.leimgruber]
- Always unbind the click event before binding a new one on the ref button.
[mathias.leimgruber]
1.0.3 (2016-09-14)
------------------
- Same as 1.0.2 but uploaded to PyPI.
[mbaechtold]
1.0.2 (2016-09-14)
------------------
- Reload Items when overlay is reloaded.
[tschanzt]
- Respect Type constraints on search.
[tschanzt]
1.0.1 (2016-09-09)
------------------
- Ignore empty strings in converter.
[tschanzt]
- Improve overlay behavior (close on click outside the overlay + close on ESC).
[mathias.leimgruber]
- Get Widget name on overlay creation.
[tschanzt]
1.0.0 (2016-09-07)
------------------
- Initial release
[tschanzt]
===================
This Widget provides a Referencebrowser and a searchfield, which allows users to select references.
The basequery is all types which are not in the types_not_searched property all modification to the allowed types are relative to this query.
Traversal or Selectability can be changed for all widgets with the IReferenceSettings registry interface or per widget with the widget parameters.
The widget takes the following parameters:
- allow_traversal: These Types are traversable
- block_traversal: These Types are not traversable
- selectable: These Types are selectable
- nonselectable: These Types are not selectable
- start: The path first opened. Can either be a callable or a path. Additionaly the strings "parent", "navroot", "ploneroot" can be used.
- allow_nonsearched_types: If this is set to true all the types will be traversable and selectable.
- override: drops all global config and the base query if a list is passed to the widget. All types need to be added to be selectable.
- traversal_query: Updates the query used vor traversing by the given dict. The dict passed will be updated after everything is allready done. So make sure not to override sort_on/sort_order attributes.
ContextSourceBinder
-------------------
With a `RelationeChoice` or `RelationList` of `RelationChoice` a source can be configured along with the field.
The `ContextSourceBinder` makes sure that only valid content can be selected.
By default, the source binder only checks for a valid portal_type when selecting content.
The default_filter implementation therefore looks like this:
.. code:: python
def default_filter(source, value):
""""
Return ``True`` when the object is selectable, ``False``
when it is not selectable.
""""
return value.portal_type in get_selectable_types_by_source(source)
Feel free to add your own filter method as source parameter in your field.
Example:
.. code:: python
from ftw.referencewidget.filter import DefaultSelectable
class CustomClass(DefaultSelectable):
def is_selectable(self):
return bool(..)
...
directives.widget(realtionchoice_restricted_title=ReferenceWidgetFactory)
realtionchoice_restricted_title = RelationChoice(
title=_(u'Related Choice Restricted Title'),
source=ReferenceObjSourceBinder(
selectable_class=CustomClass),
default=None,
required=False,
)
The `filter` takes two parameter the actual source object and a value, which is the content object.
Only `ReferenceObjSourceBinder` are supported. The SourceBinder takes the following parameters:
- selectable: These types are selectable
- nonselectable: These Types are not selectable
- allow_nonsearched_types: If this is set to true all the types will be traversable and selectable.
- override: drops all global config and the base query if a list is passed to the widget. All types need to be added to be selectable.
- selectable_class: Custom ISelectable Class to determine if a content is selectable or not.
The parameters are same as for the widget (Backwards compatibility with 1.x releases).
Fields combinations (Registered converter)
------------------------------------------
The following combinations are supported:
- RelationList with value_type Relation --> Stores a List of RelationValues
- RelationList with value_type RelationChoice --> Stores a List of RelationValues
- Relation --> Stores a RelationValue
- List of RelationChoice --> Stores a list of absolute paths, without the portal root part
- TextLine --> Stores a absolute path as string, without the portal root part
Screenshots
-----------
The general Listing:
![Listing](https://github.com/4teamwork/ftw.referencewidget/raw/master/docs/static/list.png)
The Search Listing:
![Search Listing](https://github.com/4teamwork/ftw.referencewidget/raw/master/docs/static/search.png)
The Selected Items
![Selected](https://github.com/4teamwork/ftw.referencewidget/raw/master/docs/static/selected.png)
Links
-----
- Github: https://github.com/4teamwork/ftw.referencewidget
- Issues: https://github.com/4teamwork/ftw.referencewidget/issues
- Continuous integration: https://jenkins.4teamwork.ch/search?q=ftw.referencewidget
Copyright
---------
This package is copyright by `4teamwork <http://www.4teamwork.ch/>`_.
``ftw.referencewidget`` is licensed under GNU General Public License, version 2.
Changelog
=========
1.4.0 (2017-07-07)
------------------
- Implement display mode for the reference widget.
[mathias.leimgruber]
- Change name of sample content buildour registry entry to avoid conflicts.
[mathias.leimgruber]
- Implement path restriction option.
[mathias.leimgruber]
- Render hidden input elements for given references, instead of
render them only by Javascript. This way the widget behaves more
like all other plone widgets.
[mathias.leimgruber]
- Implement a additional `traversal_query` parameter for the widget.
[mathias.leimgruber]
- Implement ReferenceObjPathSource for IRelationChoice fields.
[mathias.leimgruber]
1.3.0 (2016-11-09)
------------------
- Implement some sort options.
[mathias.leimgruber]
- Use plone.app.redirector to follow renamed and moved content.
Also do not fail if the content has been removed.
[mathias.leimgruber]
1.2.3 (2016-10-18)
------------------
- Fix edge case (mainly for tests) if the value passed to the
IList/Widget converter is not a list, but a string.
[raphael-s]
1.2.2 (2016-10-18)
------------------
- Implement testbrowser widget.
[raphael-s]
1.2.1 (2016-10-17)
------------------
- Respect missing_value set by the field.
[tschanzt]
- Implement support for ITextLine only with ReferenceWidget.
[mathias.leimgruber]
1.2.0 (2016-10-04)
------------------
- Show absolute path starting at the plone root for the selected value.
[mathias.leimgruber]
- Remove the list style type and the obsolete spacing for the selected elements.
[mathias.leimgruber]
- Implement support for IList of IRelationChoice explicitly.
Check Readme for more informations
[mathias.leimgruber]
1.1.0 (2016-09-27)
------------------
- Ignore empty value for multiple value field.
[mathias.leimgruber]
- Support chameleon by not rendering handlebar templates. [jone]
1.0.4 (2016-09-19)
------------------
- Make it possible to remove an given internal reference (radio button).
[mathias.leimgruber]
- Ignore empty value for single value field.
[mathias.leimgruber]
- Fix search by pressing the "enter" button.
[mathias.leimgruber]
- Always unbind the click event before binding a new one on the ref button.
[mathias.leimgruber]
1.0.3 (2016-09-14)
------------------
- Same as 1.0.2 but uploaded to PyPI.
[mbaechtold]
1.0.2 (2016-09-14)
------------------
- Reload Items when overlay is reloaded.
[tschanzt]
- Respect Type constraints on search.
[tschanzt]
1.0.1 (2016-09-09)
------------------
- Ignore empty strings in converter.
[tschanzt]
- Improve overlay behavior (close on click outside the overlay + close on ESC).
[mathias.leimgruber]
- Get Widget name on overlay creation.
[tschanzt]
1.0.0 (2016-09-07)
------------------
- Initial release
[tschanzt]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ftw.referencewidget-1.4.0.tar.gz
(607.7 kB
view hashes)
Close
Hashes for ftw.referencewidget-1.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f6c56de1275d16eaef555093140513aab9af1327d5a1c60519f40c43d3cabce |
|
MD5 | 2459d67bcbbbe7d0f703e4366a0c6b85 |
|
BLAKE2b-256 | 68652df8ff7b1ba44e7fa7e320a5d5bdbd86f35155fd59b88bbed7151eabb54a |