cancel
Showing results for 
Search instead for 
Did you mean: 

Bug with custom actions overrides ?

tonyrivet
Champ in-the-making
Champ in-the-making
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.
4 REPLIES 4

tonyrivet
Champ in-the-making
Champ in-the-making
Any help from the Alfresco Team ?

mrogers
Star Contributor
Star Contributor
What "help" we're you expecting?  You seem to have found and diagnosed a problem. 

If you want to report a potential bug then please use JIRA.  

tonyrivet
Champ in-the-making
Champ in-the-making
I just wanted to know if someone could or have already reproduced this, but it seems it isn't the right place…
I'll raise a JIRA.

tonyrivet
Champ in-the-making
Champ in-the-making
FYI, here is the JIRA I just created : https://issues.alfresco.com/jira/browse/ALF-20851