cancel
Showing results for 
Search instead for 
Did you mean: 

Share - filter out nodes based on custom property

filip
Champ on-the-rise
Champ on-the-rise

Hello everyone,

I am struggling with implementation of a filter which would display only specific nodes under a folder.

Let's be more specific: I have custom type with property called status. This property can have values such as Draft, In Review, Approved, ... It is set by constraints by the content model. Then I will go to folder ABC under a site and my goal is to create an action in Share that would display only Approved files under the folder ABC.

At first, I checked Options -> Hide/Show Folders functionality. If I understand that well, it works in following way:

  • documentlist.js will build URL for Share webscript in _buildDocListParams and then it will send a request in _updateDocList
  • surf-doclist.get.js (more accurately surf-doclist.lib.js) is called on Share side. Among other things, it will construct URL for Alfresco webscript "/slingshot/doclib2/doclist/" with help of DefaultDoclistDataUrlResolver
  • Alfresco webscript "/slingshot/doclib2/doclist/" returns proper nodes in JSON format

So far, I created an extension module which adds my custom filter buttons under Options tab. Then I extended default Alfresco.DocumentList by a new one in my custom JS so I am able to react on clicked custom filter. And here I stopped because I did not find any easy way how to extend it for my custom property.

Maybe, I could create a new DataUrlResolver or totally a new logic which would requite changes in custom JS, similar Share webscript as "surf-doclist.get.js" and finally Alfresco webscript (similar to "slingshot/doclib2/doclist") to return only relevant nodes.

Another solution, which can be consider as "nasty hack" can be to extend surf-doclist.lib.js and do changes directly in model.json. So it would remove not needed nodes as a post processing method.

By the way, I tried to extend filters on left side (similar to All documents, I'm Editing, ...) but they will filter out everything for a whole site, not only for a specific folder.

Do you know what is a correct approach to create such filters?

PS: I am using 5.1.

Thank you for comments,

Filip

2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator

When you are using Alfresco 5.1 you may want to check out the "Smart Folders" feature. This allows you to define virtual folders that use search-based operations to determine which elements should be displayed. That could allow you to filter nodes in the Share view without having to customize any webscripts / UI components. It also allows you to provide different kinds of views with different filter logic instead of forcing all views to use the same logic from the backend.

filip
Champ on-the-rise
Champ on-the-rise

Hi Axel,

Thank you, that's definitely good idea.

Since I would need to use it in all sites and maybe even in some other folders under repository. Should I be afraid of any performance issues in case I use it in almost whole repository?

So far I set it by "smart.folders.config.type.templates.qname.filter=cm:folder" with smart folder template "cm_folder.json":

{

    "name": "Smart Folders Example",

    "nodes": [{

        "id": "1",

        "name": "Approved",

        "description": "Approved nodes",

        "search": {

            "language": "fts-alfresco",

            "query": "(PATH:'%ACTUAL_PATH%/*') AND (TYPE:'tieto:type') AND (=tieto:status:'Approved')"

        }

    }]

}

Maybe it will help someone how to set it.

Br,

Filip