AnsweredAssumed Answered

Bug with custom actions overrides ?

Question asked by tonyrivet on Feb 10, 2014
Latest reply on Feb 19, 2014 by tonyrivet
Hi,

I think I found some bug defining custom actions that override native actions in Share.

I created 2 custom actions that override both "document-edit-properties" and "folder-view-details" Share actions. My configuration looks like this :

<action id="custom-folder-view-details" type="pagelink" label="actions.folder.view-details" icon="folder-view-details">
<param name="page">custom-folder-details?nodeRef={node.nodeRef}</param>
<override>folder-view-details</override>
</action>

<action id="custom-document-edit-properties" type="javascript" icon="folder-edit-properties" label="actions.folder.edit-metadata">
<param name="function">onCustomEdit</param>
<override>document-edit-properties</override>
</action>


When the actions are rendered in the document library, the "custom-document-edit-properties" action successfully overrides the native one, but both "custom-folder-view-details" and "folder-view-details" actions are displayed.

I made some debugging in the surf-doclist.lib.js and found that the filterOverrides method loops over the actions to filter and removes (in the loop !) the actions which are overridden by other ones. The problem is, when overridden actions are removed from the beginning of the list, all actions are shifted and some actions are never processed.


Here is what happens with my custom actions :

Step 1 : The "custom-document-edit-properties" is processed
[
document-edit-properties,
custom-document-edit-properties, <– Loop cursor
custom-folder-view-details,
folder-view-details
]

Step 2 : The "document-edit-properties" is removed and all action are shifted
[
custom-document-edit-properties,
custom-folder-view-details,
folder-view-details
]

Step 3 : The next action is processed, i.e. "folder-view-details" instead of "custom-folder-view-details"
[
custom-document-edit-properties,
custom-folder-view-details,
folder-view-details             <– Loop cursor
]


Here is the filterOverrides method :

   filterOverrides: function filterOverrides(p_array)
   {
      // Remove any indicators overridden by others
      var item, override, i, ii, j, jj;
      for each (item in p_array)
      {
         if (item.overrides)
         {
            for (i = 0, ii = item.overrides.length; i < ii; i++)
            {
               override = item.overrides;
               for (j = 0; j < p_array.length; j++)
               {
                  if (p_array[j].id == override)
                  {
                     DocList.arrayRemove(p_array, j);
                     break;
                  }
               }
            }
         }
      }

      return p_array;
   },



I just wanted to know if anyone had/could reproduce this bug.
I'm suprised this has not been reported yet, so maybe I'm just doing this the wrong way. Don't hesitate to tell me so.

Thanks in advance for your feedback.

Outcomes