Content Management and Capture

Content Management and Capture

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
Expand all | Collapse all

Change the folder icon based on the value of item attribute - Contentlist Grid

  • 1.  Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Mon November 09, 2020 06:19 PM
    I need to change the folder icon based on the value of item attribute,. For example, currently when sync is enabled ICN automatically changes the icon to use ftFolderSyncedIcon class. SImilarly, i need to show different icons based on the value of our custom property available in the Item.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 2.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Tue November 10, 2020 05:23 AM

    Hi,

    Custom property is not retrieved by default when the content list is displayed. You may configure the repository, go to the Browse tab, and add the custom property to the Selected Properties, with the two checkboxes for Details View and Magazine View checked.

    Then you may override the ecm.model.Item.getMimeClass() function to set the icon class per your custom property value.

    Item.prototype.getMimeClass = function() { var mimeType = this.mimetype || ""; var iconClass; if (this.isFolder()) { ... if (this.attributes["EmailSubject"] != null) { // <<<<<< a custom property iconClass = "ftFolderSyncedIcon"; }

    If you want to hide the custom property column on the content list, you may override ecm.widget.listView.ContentList._createGrid() function, and set your custom property as a hidden column.

    require([... "dojo/dom-construct", // "dojo/sniff", // "gridx/Grid", // "ecm/widget/listView/gridModules/Async", // "ecm/widget/ListViewPaginationBar", // "gridx/modules/HiddenColumns", // "ecm/widget/listView/ContentList", // "ecm/model/Item", // ... ContentList.prototype._createGrid = function() { ... this.store = this._resultSet.getStore(); var modules = this._getModules(); modules.push(HiddenColumns); // add module to hide columns this.grid = new Grid({ cacheClass: Cache, pageSize: this._resultSet.pageSize, store: this.store, structure: structure, selectRowTriggerOnCell: !has("ecmMobile") && !this._allowCheckboxes, modules: modules, textDir: has("text-direction"), headerHidden: this.headerHidden, contentList: this, barBottom: this._isShowPaginationBar() ? [ListViewPaginationBar] : null }); this.grid.hiddenColumns.add("8"); // <<<<<< column id of the custom property ...

    Regards,

    Angie



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 3.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Tue November 10, 2020 06:53 PM

    Thanks Angie. ecm.model.Item.getMimeClass() should be written inside the Customplugin.js file? Also, object valued custom property is not listed in the Browse tab while configuring the properties to be displayed in Content List grid.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 4.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Wed November 11, 2020 01:49 AM

    Hi,

    Yes, the function can be written inside the Customplugin.js file.

    In my testings, the custom property of Object type are listed in the Browse tab of Repository configuration. What is your ICN version?

    Regards,

    Angie



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 5.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Wed November 11, 2020 02:15 AM

    Hi,

    You may also use a response filter in your custom plugin to set additional attribute when the content items are listed. The additional attribute can be a property or a dynamic value such as the icon class. Refer to the SamplePluginResponseFilter.

    Regards,

    Angie



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 6.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Wed November 11, 2020 04:29 PM

    I can see the object valued property after adding the property both at the folder and document class. Currently, I am not able to access the attributes/properties of the object valued property in JavaScript below code. In this case, I am trying to get the name of the customer from object valued property objCustomerInfo.


    if (this.attributes["objCustomerInfo.name"] != null) { // <<<<<< a custom property

    iconClass = "ftFolderSyncedIcon";

    }





    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 7.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Thu November 12, 2020 02:33 AM

    Hi,

    You may call retrieveItem() function of ecm.model.Repository in your JS code to get the properties of the object.

    See ICN javascript API https://www.ibm.com/support/knowledgecenter/en/SSEUEX_3.0.8/com.ibm.developingeuc.doc/doc/JavaScriptdoc/symbols/ecm.model.Repository.html .

    Regards,

    Angie



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 8.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Thu November 12, 2020 02:37 AM

    Will it have performance impact if we have a make a round trip to the server to get the object valued property for each folder. right?



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 9.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Thu November 12, 2020 07:57 AM

    Hi,

    There will be performance impact if item retrieval is done for each folder in JS code.

    It would be better to use the mentioned response filter in your custom plugin. Refer to the SamplePluginResponseFilter. Here is an example, which returns the name property of custom objects when folder is opened, and sets icon class per the added property.

    SamplePluginResponseFilter.java ->

    import com.filenet.api.core.IndependentlyPersistableObject; import com.filenet.api.property.Properties; import com.filenet.api.property.Property; import com.ibm.ecm.util.p8.P8Connection; import com.ibm.ecm.util.p8.P8Util; ... public void filter(String serverType, PluginServiceCallbacks callbacks, HttpServletRequest request, JSONObject jsonResponse) throws Exception { ... customColumn = new JSONResultSetColumn("ObjectName", "50px", "ObjectName", null, true); jsonResultSetResponse.addColumn(customColumn); String repositoryId = request.getParameter("repositoryId"); P8Connection connection = P8Util.getConnection(request, repositoryId); for (int i = 0; i < jsonResultSetResponse.getRowCount(); i++) { JSONResultSetRow row = jsonResultSetResponse.getRow(i); if (row.getMimetype().equals("folder")) { // retrieve the object String docid = (String) row.getAttributeValue("NPSOVP2DO"); if (connection != null && docid != null) { IndependentlyPersistableObject objItem = P8Util.getPersistableObject(request, connection, docid); Properties props = objItem.getProperties(); Property prop = props.get("Name"); // object property row.addAttribute("ObjectName", prop.getStringValue(), JSONResultSetRow.TYPE_STRING, null, null); } } }

    SamplePlugin.js ->

    if (this.attributes["ObjectName"] != null) { iconClass = "ftFolderSyncedIcon"; }

    Regards,

    Angie



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 10.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Thu November 12, 2020 10:38 PM

    Thanks Angie. After I override the getMimeClass then how do I call getMimeType class of actual ICN's function if I need to in some cases.


    Item.prototype.getMimeClass = function() {

    var mimeType = this.mimetype || "";



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 11.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Fri November 13, 2020 01:58 AM

    Hi,

    You cannot call the actual ICN's function after it is overridden. So you need to copy the whole function from ICN and revise it per your need.

    Regards,

    Angie



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 12.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Sun November 15, 2020 04:57 PM

    You may also use a response filter in your custom plugin to set additional attribute when the content items are listed.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 13.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Mon November 16, 2020 10:56 AM

    You may also use a response filter in your custom plugin to set additional attribute when the content items are listed.

    https://tutuapp.uno/ , https://9apps.ooo/ , https://showbox.kim/



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 14.  RE: Change the folder icon based on the value of item attribute - Contentlist Grid

    Posted Mon November 16, 2020 02:16 PM

    Yes, we can use response filter. I didn't go with response filter due to performance reasons as making a round trip to CE for getting the properties of custom object for each row will be expensive,.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration