cancel
Showing results for 
Search instead for 
Did you mean: 

Changing document link in Share to another control

bengrah
Champ on-the-rise
Champ on-the-rise
Hi all

In Share when you click on the document in the document list, it takes you to the Details Page of the document. What we require is instead of taking you to this page, clicking on the document automatically triggers another action such as Edit Online.

Has anyone done this type of thing before? Taking a quick look through the Share directory I couldn't find anything that allows to change the control in this manner. Help on this would be greatly appreciated.

Cheers!
bengrah
9 REPLIES 9

croc
Champ in-the-making
Champ in-the-making
Hi,

This should be very easy if you want it to execute an action which is already defined. So you only need to edit documentlist.get.config.xml

E.g if you want it to execute Edit Online then you need to change

         <action type="action-link" id="onActionDetails" permission="edit" label="actions.document.edit-metadata" />

to


         <action type="action-link" id="onActionEditOnline" permission="edit" label="actions.document.edit-metadata" />

But if you want to use a new action then you'll need to check the link below:
http://wiki.alfresco.com/wiki/Custom_Document_Library_Action

Thanks
Croc

bengrah
Champ on-the-rise
Champ on-the-rise
Hi Croc

That functionality works fine from the Document Actions. But what I was referring to was when you click on the actual LINK of the document I.E the document name, it takes you to the Details page by default. It's the action on this click that we want to change to something like Edit Online.

There might be some cluest to this in repo-documentlist.js which constructs the URL for each document in the list.

var desc = "", docDetailsUrl, tags, tag, categories, category, i, j;

The variable desc is used for the actual link to the document, and I think the fact that the docDetailsURL variable is included in this means that the link contains the path to the Details Page when clicked on.

Does that make sense?

Thanks
bengrah

croc
Champ in-the-making
Champ in-the-making
Hi  Bengrah,

I am sorry for not understanding your problem.
Hopefully I now understand what you want.

For that to work you need to go to generateFileFolderLinkMarkup in documentlist.js and make the changes there.

E.g, if you want to download the file when the link (filename) is clicked you will change the function below

from:


Alfresco.DocumentList.generateFileFolderLinkMarkup = function DL_generateFileFolderLinkMarkup(scope, oRecord)
   {
      var record = oRecord.getData(),
         html;

      if (record.isLink && scope.options.workingMode === Alfresco.doclib.MODE_SITE && record.location.site !== scope.options.siteId)
      {
         if (record.isFolder)
         {
            html = $siteURL("documentlibrary?path=" + encodeURIComponent(record.location.path),
            {
               site: record.location.site
            });
         }
         else
         {
            html = scope.getActionUrls(record, record.location.site).documentDetailsUrl;
         }
      }
      else
      {
         if (record.isFolder)
         {
            html = '#" class="filter-change" rel="' + Alfresco.DocumentList.generatePathMarkup(record.location);
         }
         else
         {
            html = scope.getActionUrls(record).documentDetailsUrl;
         }
      }

      return '<a href="' + html + '">';
   };

to:


   Alfresco.DocumentList.generateFileFolderLinkMarkup = function DL_generateFileFolderLinkMarkup(scope, oRecord)
   {
      var record = oRecord.getData(),
         html;

      if (record.isLink && scope.options.workingMode === Alfresco.doclib.MODE_SITE && record.location.site !== scope.options.siteId)
      {
         if (record.isFolder)
         {
            html = $siteURL("documentlibrary?path=" + encodeURIComponent(record.location.path),
            {
               site: record.location.site
            });
         }
         else
         {
            html = scope.getActionUrls(record, record.location.site).downloadUrl;
         }
      }
      else
      {
         if (record.isFolder)
         {
            html = '#" class="filter-change" rel="' + Alfresco.DocumentList.generatePathMarkup(record.location);
         }
         else
         {
            html = scope.getActionUrls(record).downloadUrl;
         }
      }

      return '<a href="' + html + '">';
   };


so the difference there is changing or replacing documentDetailsUrl with downloadUrl, those two variable are declared and assigned inside the function called getActionUrls as you can see it is html = scope.getActionUrls(record).downloadUrl; which I am sure you'll understand it better.

Now if you want to execute an action which already exist, you'll have to change those two function: generateFileFolderLinkMarkup and getActionUrls, and if it's a new link then you'll have to look at getActionUrls to build a working link.

Hope this helps.

Thanks,
Croc

bengrah
Champ on-the-rise
Champ on-the-rise
Hi croc. I think that's more to what we're actually referring to. I'm amazed by your Share knowledge! Honestly, half the problem is that none of this stuff is truly documented anywhere. I'll give this a shot and let you know in a bit.

Thanks
bengrah

bengrah
Champ on-the-rise
Champ on-the-rise
Hi again croc, just one more question, do you know what file the code for getActionUrls resides in? Thanks

Ben.

croc
Champ in-the-making
Champ in-the-making
Hi,

It's inside the same file(documentlist.js).  it's on line 1783 if you haven't made any changes to the file. or you can use find or search inside that file.

Good luck.

bengrah
Champ on-the-rise
Champ on-the-rise
Hi,

It's inside the same file(documentlist.js).  it's on line 1783 if you haven't made any changes to the file. or you can use find or search inside that file.

Good luck.

So I've gotten some success with this croc thanks to you. The thing we really want to do is have the user to an Edit Online via webdav? So what I'm doing is created a new variable called editOnlineUrl which has the value of "http://<ip>:8080/alfresco/webdav/<filename>" this works if I hardcode it, obviously that won't work in real life. So I'm wondering do you know of any way to get the current document name and location in this class? That way I can piece together this URL

Thanks
Ben.

croc
Champ in-the-making
Champ in-the-making
Hi,

Please send the code changes that you have made, and point where an how you want your changes made. hopefully I or someone will be able to help you.

Thanks,
Kwena

bengrah
Champ on-the-rise
Champ on-the-rise
Hi croc

Very sorry for inundating you with requests here, usually I ask the question then make progress so it's always like the other person is playing catchup! But we got the Edit Online functionality working. in documentlist.js, we added a new variable called editOnlineUrl:

getActionUrls: function DL_getActionUrls(recordData, siteId)
      {
         var nodeRef = recordData.isLink ? recordData.linkedNodeRef : recordData.nodeRef,
            nodeRefUri = new Alfresco.util.NodeRef(nodeRef).uri,
            contentUrl = recordData.contentUrl,
            custom = recordData.custom,
            siteObj = YAHOO.lang.isString(siteId) ? { site: siteId } : null,
            fnPageURL = Alfresco.util.bind(function(page)
            {
               return Alfresco.util.siteURL(page, siteObj);
            }, this);

         return (
         {
         editOnlineUrl: "http://10.20.12.8:8080/alfresco/webdav" + recordData.location.path + "/" + recordData.displayName,
            downloadUrl: Alfresco.constants.PROXY_URI + contentUrl + "?a=true",
            viewUrl:  Alfresco.constants.PROXY_URI + contentUrl + "\" target=\"_blank",
            documentDetailsUrl: fnPageURL("document-details?nodeRef=" + nodeRef),
            folderDetailsUrl: fnPageURL("folder-details?nodeRef=" + nodeRef),
            folderRulesUrl: fnPageURL("folder-rules?nodeRef=" + nodeRef),
            editMetadataUrl: fnPageURL("edit-metadata?nodeRef=" + nodeRef),
            inlineEditUrl: fnPageURL("inline-edit?nodeRef=" + nodeRef),
            managePermissionsUrl: fnPageURL("manage-permissions?nodeRef=" + nodeRef),
            workingCopyUrl: fnPageURL("document-details?nodeRef=" + (custom.workingCopyNode || nodeRef)),
            viewGoogleDocUrl: custom.googleDocUrl + "\" target=\"_blank",
            originalUrl: fnPageURL("document-details?nodeRef=" + (custom.workingCopyOriginal || nodeRef)),
            explorerViewUrl: $combine(this.options.repositoryUrl, "/n/showSpaceDetails/", nodeRefUri) + "\" target=\"_blank",
            sourceRepositoryUrl: this.viewInSourceRepositoryURL(recordData) + "\" target=\"_blank"
         });
      },

I noticed that the item.lib.ftl file you pointed me toward before has similar variables, so recordData is actually just using the variables in item.lib.ftl. That's how I constructed the WebDAV URL. Then in repo-documentlist.js I changed the link type for documents:

else
            {
               /**
                * Documents and Links
                */
               docDetailsUrl = scope.getActionUrls(oRecord.getData()).editOnlineUrl;

               // Locked / Working Copy handling

So now when the user clicks on the document link it's opened via WebDAV.  It's then locked in the repo (which is default WebDAV behaviour I believe) and available to edit via whatever application. Only MS Office documents are available to edit via this method.

Thanks for help on that. There's just one more thing now to this. When the user clicks on the document link, they get a standard IE prompt allowing the user to Open, Save or Cancel the document. When we do an Edit Online through Document Details in a site, we get a different prompt that just gives you the option to either Open or Cancel a document. So we were wondering if there was any way to generate this second prompt? Since it gives the user less options to worry about.

Thanks
Ben.