-
Notifications
You must be signed in to change notification settings - Fork 48
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
Problem: customizing tabular view is hard #595
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ | ||
Enable customization of tabular_view via views for fields of contentlisting items. |
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
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
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
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,55 @@ | ||
from Products.Five import BrowserView | ||
|
||
# BEWARE: the cell views are registered for ContentListingObject | ||
# which are not acquisition aware. | ||
# That precludes using Products.Five.ViewPageTemplateFile | ||
# and imposes to use zope.browserpage.viewpagetemplatefile. | ||
from zope.browserpage.viewpagetemplatefile import ViewPageTemplateFile | ||
# BEWARE | ||
|
||
class TitleCell(BrowserView): | ||
__call__ = ViewPageTemplateFile('templates/titlecell.pt') | ||
|
||
@property | ||
def title(self): | ||
return self.context.Title() or self.context.getId() | ||
|
||
@property | ||
def link(self): | ||
suffix = ( | ||
'/view' | ||
if self.context.PortalType in self.table_view.use_view_action | ||
else '' | ||
) | ||
return self.context.getURL() + suffix | ||
|
||
@property | ||
def type_class(self): | ||
return ('contenttype-' + | ||
self.table_view.normalizeString(self.context.PortalType()) | ||
if self.table_view.show_icons else '') | ||
|
||
@property | ||
def wf_state_class(self): | ||
return ('state-' + | ||
self.table_view.normalizeString(self.context.review_state())) | ||
|
||
def render_image(self): | ||
thumb_scale_table = self.table_view.get_thumb_scale_table() | ||
img_class = self.table_view.img_class | ||
return self.table_view.image_scale.tag( | ||
self.context, 'image', | ||
scale=thumb_scale_table, css_class=img_class | ||
) | ||
|
||
|
||
class CreatorCell(BrowserView): | ||
__call__ = ViewPageTemplateFile('templates/creatorcell.pt') | ||
|
||
@property | ||
def author(self): | ||
return self.table_view.pas_member.info(self.context.Creator) | ||
|
||
@property | ||
def author_name(self): | ||
return self.author['fullname'] or self.author['username'] |
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,5 @@ | ||
<td> | ||
<a tal:condition="view/author" | ||
tal:attributes="href string:${view/table_view/navigation_root_url}/author/${context/Creator}" | ||
tal:content="view/author_name">Jos Henken</a> | ||
</td> |
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
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,19 @@ | ||
<td tal:define="table_view nocall:view/table_view; | ||
thumb_scale_table view/table_view/get_thumb_scale_table;"> | ||
<a tal:condition="python:context.PortalType == 'File' and table_view.show_icons()" | ||
tal:attributes="href view/link; | ||
class string:${view/type_class} ${view/wf_state_class} url; | ||
title context/PortalType"> | ||
<img class="mime-icon" | ||
tal:attributes="src context/MimeTypeIcon"> | ||
</a> | ||
<a tal:attributes="href view/link; | ||
class string:${view/type_class} ${view/wf_state_class} url; | ||
title context/PortalType" | ||
tal:content="view/title">Item Title | ||
</a> | ||
<a tal:condition="python:context.getIcon and thumb_scale_table"> | ||
<img tal:attributes="href view/link" | ||
tal:replace="structure view/render_image" /> | ||
</a> | ||
</td> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks for anyone who currently calls
view.tabular_fields()
in custom code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right !