Ticket #1760 (closed Bug: fixed)
allowedContentTypes needs sort arg
| Reported by: | runyaga | Owned by: | fschulze |
|---|---|---|---|
| Priority: | major | Milestone: | 2.5.1 |
| Component: | Javascript | Keywords: | |
| Cc: |
Description (last modified by hannosch) (diff)
We need to add a spec arg (similair to listFolderContents) for listAllowedTypes on PortalFolder so you can pass in a sort by variable criteria.. maybe sort by image, or id, or other attributes. currently we sort using sortObjects which sucks
Change History
comment:2 Changed 7 years ago by alecm
What's the use case here? It seems as long as the order is consistent (which it is), it should be fine. It wouldn't be too hard to do the sort on the translated Type if alphabetical order is deemed important. This should generally be a short list, so ordering logic is perhaps not so important. The ActionTool uses a simple OFS.Folder as its base, so there's no Ordering support, if we wanted it we'd have to roll our own.
comment:3 Changed 7 years ago by limi
I can't speak for Alan, but the thing I'm talking about is better solved using javascript, so we'll do that. I'm not sure what Alan is referring to. :)
comment:4 Changed 7 years ago by fschulze
I have done the sorting on the translated title in getAddableTypesInMenu. Could be added to 2.1.1 I think.
Index: getAddableTypesInMenu.py =================================================================== --- getAddableTypesInMenu.py (Revision 7786) +++ getAddableTypesInMenu.py (Arbeitskopie) @@ -12,17 +12,24 @@
from Products.CMFCore.utils import getToolByName itool = getToolByName(context, 'portal_interface') mtool = getToolByName(context, 'portal_membership')
+utranslate = context.utranslate
folder = context if folder.isDefaultPageInFolder() or not folder.isPrincipiaFolderish:
folder = context.aq_inner.getParentNode()
if not itool.objectImplements(folder, INTERFACE):
- return allowedTypes + result = [(utranslate(ctype.Title()), ctype) for ctype in allowedTypes] + result.sort() + result = [ctype[-1] for ctype in result] + return result
if mtool.checkPermission('View', folder):
immediateIds = folder.getImmediatelyAddableTypes()
- return [ctype for ctype in allowedTypes if ctype.getId() in immediateIds] + result = [(utranslate(ctype.Title()), ctype) for ctype in allowedTypes if ctype.getId() in immediateIds] + result.sort() + result = [ctype[-1] for ctype in result] + return result else:
return []
comment:5 Changed 6 years ago by hannosch
- Priority changed from minor to major
- Description modified (diff)
- Milestone changed from 2.5 to 2.1.x
comment:7 Changed 6 years ago by hannosch
- Owner set to fschulze
- Component changed from Infrastructure to Javascript
- Milestone changed from 2.5.x to 2.5
Ordering of the entries per JS is something we should really do.

Another related problem that might not be solvable is that alphabetizing the entries happens before translation, so they are all jumbled when they are displayed in other languages. Would be solved if we could order them logically, though - ie: always Document first, then News Item etc.
Is it possible to use an ordering property here somehow?