Moving the discussion here to gain a wider audience. (quoting the all history).
Jean-Marc Orliaguet wrote:
Olivier Grisel wrote:Jean-Marc Orliaguet wrote:CPS3/CPSPortlets/skins/cpsportlets_widgets_cps3/getNavigationItems.py 1.11 => 1.12 === if depth >= end_depth: continue
+ # filter out hidden folders + if object.get('hidden_folder', False): + continue +maybe this should be made optional since getNavigationItems.py will be used to get folder contents items and they must be visible otherwise hidden folder will never be accessible for edition.
I'll add an option to the Navigation Portlet's layout.
Yes but usually, hidden_folders are only viewable with the 'manage content' view of the folders, not the listing view.
+ The TreeBox filters out the hidden_folder in a more clever way, based on the current path of the object :
""" # now remove hidden_folder that are not in the current path if not self.display_hidden_folder: cur_url = current_url + '/' hidden = [item for item in tree if item.get('hidden_folder')] if hidden: hidden = [item for item in hidden if not cur_url.startswith(item['rpath'] + '/')] if hidden: items = [] for item in tree: is_hidden = 0 for h in hidden: if (item['rpath'] + '/').startswith(h['rpath'] + '/'): is_hidden = 1 break if not is_hidden: items.append(item) tree = items """
Furthermore, the navigation portlet lacks other features of the TreeBox such as the 'display_managers' (computed by getFolderInfo), 'display_description' and 'authorized_only' options. The latter is a restricted option that defaults to True.
Finally, there is an identation problem with authorized folders whose parents are unauthorized: for instance when a portal member is connected, she can view her member's workspace but cannot view the 'workspaces' and 'members' folders. Therefor it gets depth 2 even though it has no parent ... The TreeBox fixes this display problem with the computation of a 'local_depth' parameter:
""" # compute relativ depth # we need to copy items as we modify depth items = deepcopy(tree) if items: local_depth = items[0]['depth'] items[0]['depth'] = 0 local_rpath = items[0]['rpath'] + '/' for item in items[1:]: if not (item['rpath'] + '/').startswith(local_rpath): local_rpath = item['rpath'] + '/' local_depth = item['depth'] item['depth'] = 0 else: item['depth'] = item['depth'] - local_depth tree = items """
Thus it might be interesting to add the following options to the navigation portlet's schema/layout and reuse/adapt the correspondig code snippets from TreeBox.getTree(context) in the getNavigationItems.py script.
Summary of the missing options to add to the schema: - 'authorized_only' - 'display_hidden_folder' - 'display_managers' - 'display_description'
+ the local_depth fix
I can do it if you want, just let me know!
Yes, if you wish! definitely.
I'm checking in the 'display_hidden_folder' layout option in 2 minutes.
Tested, it looks alright to me.
and to remember that navigation portlets are not cached in RAM so make sure that the code is ignored if the options are not selected. Shouldn't this be implemented in CPSNavigation by the way?
Yes, this is a problem since in the constructor or CPSNavigation, 'filter' (which corresponds to the 'authorized_only' option) is set to 1 (hardcoded).
Furthermore I don't really know which options out of the previous list should be part of the CPSNavigation filters set, esp. should the local_depth fix be part of it? Same question applies for the 'display_hidden_folder' filter. I am not really aware of where and how CPSNavigation is used elsewhere ...
Somebody with more insight could please give me instructions on where to put that code?
Cheers,
-- Olivier _______________________________________________ cps-devel mailing list http://lists.nuxeo.com/mailman/listinfo/cps-devel
