cancel
Showing results for 
Search instead for 
Did you mean: 

Add a link to document-versions

thbaymet
Champ in-the-making
Champ in-the-making
Hi,

I want to add a link with an icon for each version of documents in Share document-details page. (like "invert", "download", "view properties" links.)

I've done this before for Alfresco E. 4.0. But it doesn't work any more in Alfresco Enterprise 4.2.1.

Can I extend
getDocumentVersionMarkup
function of
Alfresco.DocumentVersions
?

Thanks.
3 REPLIES 3

thbaymet
Champ in-the-making
Champ in-the-making
These three links are defined in document-versions.js file as :


getDocumentVersionMarkup: function DocumentVersions_getDocumentVersionMarkup(doc)
      {
         var downloadURL = Alfresco.constants.PROXY_URI + '/api/node/content/' + doc.nodeRef.replace(":/", "") + '/' + doc.name + '?a=true',
            html = '';

         html += '<div class="version-panel-left">'
         html += '   <span class="document-version">' + $html(doc.label) + '</span>';
         html += '</div>';
         html += '<div class="version-panel-right">';
         html += '   <h3 class="thin dark" style="width:' + (Dom.getViewportWidth() * 0.25) + 'px;">' + $html(doc.name) +  '</h3>';
         html += '   <span class="actions">';
         if (this.options.allowNewVersionUpload)
         {
            html += '   <a href="#" name=".onRevertVersionClick" rel="' + doc.label + '" class="' + this.id + ' revert" title="' + this.msg("label.revert") + '"> </a>';
         }
         html += '      <a href="' + downloadURL + '" class="download" title="' + this.msg("label.download") + '"> </a>';
         html += '      <a href="#" name=".onViewHistoricPropertiesClick" rel="' + doc.nodeRef + '" class="' + this.id + ' historicProperties" title="' + this.msg("label.historicProperties") + '"> </a>';
         html += '   </span>';
         html += '   <div class="clear"></div>';
         html += '   <div class="version-details">';
         html += '      <div class="version-details-left">'
         html += $userAvatar(doc.creator.userName, 32);
         html += '      </div>';
         html += '      <div class="version-details-right">';
         html += $userProfileLink(doc.creator.userName, doc.creator.firstName + ' ' + doc.creator.lastName, 'class="theme-color-1"') + ' ';
         html += Alfresco.util.relativeTime(Alfresco.util.fromISO8601(doc.createdDateISO)) + '<br />';
         html += ((doc.description || "").length > 0) ? $html(doc.description, true) : '<span class="faded">(' + this.msg("label.noComment") + ')</span>';
         html += '      </div>';
         html += '   </div>';
         html += '</div>';

         html += '<div class="clear"></div>';
         return html;
      },


I need to add a new one. I don't want to change it. Is it possible to extend this method and change only this method ?
Thanks,

romschn
Star Collaborator
Star Collaborator
You can customize the js as required. Keep the out-of-the-box copy of the file as it is. Create a new one from it and add your changes to it and put the customized file at location tomcat/shared/classes/META-INF/components/. Make sure you also create the folder where the js reside under components folder.

Hope this helps.

thbaymet
Champ in-the-making
Champ in-the-making
Thanks. It's working.

Is it the best way to do in Alfresco, 4.2. ?