Skip to content

Commit

Permalink
Add option tho show thumbs for images in content listing and rename-p…
Browse files Browse the repository at this point in the history
…opover

plone/Products.CMFPlone#1074
fixes to related items
  • Loading branch information
fgrcon committed Oct 19, 2015
1 parent 8368086 commit d0463c8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
2.1.0 (Unreleased)
-------------------

- Add option tho show thumbs for images in content listing and rename-popover
https://github.com/plone/Products.CMFPlone/issues/1074
[fgrcon]

- use window.pushState instead of setting hash for autotoc pattern
when tabs change
[vangheem]
Expand Down
21 changes: 11 additions & 10 deletions mockup/patterns/relateditems/pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,28 @@ define([
homeText: _t('home'),
folderTypes: ['Folder'],
selectableTypes: null, // null means everything is selectable, otherwise a list of strings to match types that are selectable
attributes: ['UID', 'Title', 'portal_type', 'path', 'getIcon'],
attributes: ['UID', 'Title', 'portal_type', 'path','getURL', 'getIcon','contenttype_class','is_folderish','review_state'],

This comment has been minimized.

Copy link
@fgrcon

fgrcon Oct 19, 2015

Author Member

contenttype_class needs to be supplied from p.a.contenttypes vocublary to support e.g.: news-item, my-custom-dex-type etc. requires plone/plone.app.content#57

dropdownCssClass: 'pattern-relateditems-dropdown',
maximumSelectionSize: -1,
resultTemplate: '' +
'<div class="pattern-relateditems-result pattern-relateditems-type-<%= portal_type %> <% if (selected) { %>pattern-relateditems-active<% } %>">' +
' <a href="#" class="pattern-relateditems-result-select <% if (selectable) { %>selectable<% } %> contenttype-<%= portal_type.toLowerCase() %>">' +
' <% if (typeof getIcon !== "undefined" && getIcon) { %><span class="pattern-relateditems-result-icon"><img src="<%= getIcon %>" /></span><% } %>' +
' <span class="pattern-relateditems-result-title"><%= Title %></span>' +
'<div class="pattern-relateditems-result <% if (selected) { %>pattern-relateditems-active<% } %>">' +
' <a href="#" class="pattern-relateditems-result-select <% if (selectable) { %>selectable<% } %>">' +
' <% if (typeof getIcon !== "undefined" && getIcon) { %><img src="<%= getURL %>/@@images/image/icon "> <% } %>' +
' <span class="pattern-relateditems-result-title <%= contenttype_class %> <% if (typeof review_state !== "undefined") { %> state-<%= review_state %> <% } %>" /span>' +
' <span class="pattern-relateditems"><%= Title %></span>' +
' <span class="pattern-relateditems-result-path"><%= path %></span>' +
' </a>' +
' <span class="pattern-relateditems-buttons">' +
' <% if (folderish) { %>' +
' <% if (is_folderish) { %>' +

This comment has been minimized.

Copy link
@fgrcon

fgrcon Oct 19, 2015

Author Member

(folderish) only made Folder expandable but not other folderish dex-types ....

' <a class="pattern-relateditems-result-browse" href="#" data-path="<%= path %>"></a>' +
' <% } %>' +
' </span>' +
'</div>',
resultTemplateSelector: null,
selectionTemplate: '' +
'<span class="pattern-relateditems-item pattern-relateditems-type-<%= portal_type %>">' +
' <% if (typeof getIcon !== "undefined" && getIcon) { %><span class="pattern-relateditems-result-icon"><img src="<%= getIcon %>" /></span><% } %>' +
' <span class="pattern-relateditems-item-title"><%= Title %></span>' +
'<span class="pattern-relateditems-item">' +
' <% if (typeof getIcon !== "undefined" && getIcon) { %> <img src="<%= getURL %>/@@images/image/icon"> <% } %>' +
' <span class="pattern-relateditems-item-title <%= contenttype_class %> <% if (typeof review_state !== "undefined") { %> state-<%= review_state %> <% } %>" ><%= Title %></span>' +

This comment has been minimized.

Copy link
@fgrcon

fgrcon Oct 19, 2015

Author Member

catalog query returns null for review_state for images

This comment has been minimized.

Copy link
@petschki

petschki Oct 19, 2015

Member

Images and Files do not have any workflow assigned. this is OOTB behavior.

This comment has been minimized.

Copy link
@fgrcon

fgrcon Oct 19, 2015

Author Member

that is exactly why I have to check if catalog returns none!
(or did I overlook something?)

This comment has been minimized.

Copy link
@vangheem

vangheem Oct 19, 2015

Member

undefined != null. Might want to revise this check to just if(review_state)

' <span class="pattern-relateditems-item-path"><%= path %></span>' +
'</span>',
selectionTemplateSelector: null,
Expand Down Expand Up @@ -374,7 +375,7 @@ define([
Select2.prototype.initializeOrdering.call(self);

self.options.formatResult = function(item) {
if (!item.portal_type || _.indexOf(self.options.folderTypes, item.portal_type) === -1) {
if (item.is_folderish) {

This comment has been minimized.

Copy link
@fgrcon

fgrcon Oct 19, 2015

Author Member

not sure about this - do we need that ? (my js expertise is far from sufficient yet)

This comment has been minimized.

Copy link
@vangheem

vangheem Oct 19, 2015

Member

is_folderish is from the catalog. why was your change necessary here?

item.folderish = false;
} else {
item.folderish = true;
Expand Down
7 changes: 4 additions & 3 deletions mockup/patterns/structure/pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* moveUrl:/moveitem;
* indexOptionsUrl:/tests/json/queryStringCriteria.json;
* contextInfoUrl:{path}/context-info;"></div>
*
*
*/


Expand Down Expand Up @@ -53,7 +53,7 @@ define([
'UID', 'Title', 'portal_type', 'path', 'review_state',
'ModificationDate', 'EffectiveDate', 'CreationDate',
'is_folderish', 'Subject', 'getURL', 'id', 'exclude_from_nav',
'getObjSize', 'last_comment_date', 'total_comments'
'getObjSize', 'last_comment_date', 'total_comments','thumb'
],
activeColumns: [
'ModificationDate',
Expand All @@ -73,7 +73,8 @@ define([
'exclude_from_nav': 'Excluded from navigation',
'getObjSize': 'Object Size',
'last_comment_date': 'Last comment date',
'total_comments': 'Total comments'
'total_comments': 'Total comments',
'thumb':'Thumb'
},
momentFormat: 'relative',
rearrange: {
Expand Down
9 changes: 7 additions & 2 deletions mockup/patterns/structure/templates/tablerow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
</td>
<% _.each(activeColumns, function(column){ %>
<% if(_.has(availableColumns, column)) { %>
<td class="<%- column %>"><%- attributes[column] %></td>
<% } %>
<% if (column !== 'thumb') { %>
<td class="<%- column %>"><%- attributes[column] %></td>
<% } else { %>
<td class="thumb"><% if(attributes["thumb"] ){ %>
<img src="<%- attributes["thumb"] %>" > <% } %></td>
<% } %>
<% } %>
<% }); %>
<td class="actionmenu-container">
</td>

3 comments on commit d0463c8

@fgrcon
Copy link
Member Author

@fgrcon fgrcon commented on d0463c8 Oct 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vangheem

the changes in relateditems results to:
relateditem-browser
please review / see inline commets above

the contenttype icons are not rendered in the dropdown though i think the tags are correctly rendered ??? :

<a href="#" class="pattern-relateditems-result-select selectable">
        <span class="pattern-relateditems-result-title   state-published " span="">
       <span class="pattern-relateditems contenttype-news-item">newsitem 3</span>
       <span class="pattern-relateditems-result-path">/news/newsitem-3</span>  </span>
</a> 

The search result looks funny to me (most probably a different issue):
No searchstring given: I would expect something like

 folder 1     >
 folder 2   >
 folder 3  >
 page     
 ...

when expandig folder 1:

folder 11   >
image 1
...

etc.

what I get is something like

image 1
folder1\folder11 >
folder 1  >
folder3/folder33/images/image.jpg
folder 2 >
....

etc. (this is rather unsorted, and does not stop reloading if you have many items,....)
the search should be restrictréd to the first level.

when you enter a searchstring it should search only the title but it seems also to search pathnames

@vangheem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It searches SearchableText index which includes text, tags, etc.

I see we have the double icon issue going on again too. If the result has a "thumb", it shouldn't render the markup to provide the contenttype icon.

@fgrcon
Copy link
Member Author

@fgrcon fgrcon commented on d0463c8 Oct 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well searching paths is a little bit confusing for me (tags ar ok) but thats a minor thing for now.

No I dont have the double icon issue anymore. You might need the changes in p.a.contenttypes (indexer) and p.a.content as well. Reindexing will be necessary (Upgradestep ???).
If item has an image/leadimage the icon sized thumb is also shown (i think this a very usefull feature ...).
The old contenttype icons are not shown anymore - see screenshot above.

Next thing (i am just learning the whole js/pattern stuff): in related items (add rel items) wee need to respect all folderish types even custom types, but I have yet a problem with the relateditems used for tinymce for selecting links and images - i dont get the new attributes contenttype_class and is_folderish
there (... CMFPlone/patterns/init.py ???), then folders selected should be filtered against object contains settings in tinymce-control-panel but only when selecting images and not links.

Please sign in to comment.