--- a/src/pyams_skin/interfaces/container.py Tue Apr 14 16:34:46 2015 +0200
+++ b/src/pyams_skin/interfaces/container.py Tue Apr 14 16:35:23 2015 +0200
@@ -44,6 +44,12 @@
"""Marker interface for table with inner actions menus"""
+class ITableElementName(Interface):
+ """Table element name column value interface"""
+
+ name = TextLine(title="Table element name")
+
+
class ITableElementEditor(Interface):
"""Table element editor interface"""
--- a/src/pyams_skin/table.py Tue Apr 14 16:34:46 2015 +0200
+++ b/src/pyams_skin/table.py Tue Apr 14 16:35:23 2015 +0200
@@ -16,7 +16,7 @@
# import standard library
# import interfaces
-from pyams_skin.interfaces.container import ITable, ITableElementEditor, ITableWithActions
+from pyams_skin.interfaces.container import ITable, ITableElementEditor, ITableWithActions, ITableElementName
from pyams_skin.layer import IPyAMSLayer
from pyams_viewlet.interfaces import IViewletManager
from z3c.table.interfaces import IColumn
@@ -142,6 +142,18 @@
attrName = '__name__'
weight = 10
+ def getValue(self, obj):
+ registry = self.request.registry
+ adapter = registry.queryMultiAdapter((obj, self.request, self.table), ITableElementName)
+ if adapter is None:
+ adapter = registry.queryMultiAdapter((obj, self.request), ITableElementName)
+ if adapter is None:
+ adapter = registry.queryAdapter(obj, ITableElementName)
+ if adapter is not None:
+ return adapter.name
+ else:
+ return super(NameColumn, self).getValue(obj)
+
class ActionColumn(Column):
"""Base action icon column"""
@@ -171,16 +183,26 @@
return '''<a class="hint" title="{title}" href="{url}"
data-ams-stop-propagation="true"
{target} {modal} data-ams-hint-gravity="e">
- <i class="{icon_class}"></i>
+ {icon}
</a>'''.format(title=translate(self.icon_hint),
url=self.get_url(item),
target='data-ams-target="{0}"'.format(self.target) if self.target else '',
modal='data-toggle="modal"' if self.modal_target else '',
- icon_class=self.icon_class)
+ icon=self.get_icon(item))
def get_url(self, item):
return absolute_url(item, self.request, self.url)
+ def get_icon(self, item):
+ return '<i class="{icon_class}"></i>'.format(icon_class=self.icon_class)
+
+
+class JsActionColumn(ActionColumn):
+ """Javascript function caller action column"""
+
+ def get_url(self, item):
+ return self.url
+
@adapter_config(name='actions', context=(Interface, IPyAMSLayer, ITableWithActions), provides=IColumn)
class MenuActionsColumn(I18nColumn, Column):