cancel
Showing results for 
Search instead for 
Did you mean: 

Set current content type in upload new version

johnpelquingua
Champ in-the-making
Champ in-the-making
Hi All,

I have a question how do I set the current content type of a document when uploading it in a new version? The default behavior is when I upload a new version it is resetting into the default content type.

I have tweaked the flash-upload.js and so far no luck.

I'll appreciate your help.


Best Regards,
8 REPLIES 8

sanket
Champ on-the-rise
Champ on-the-rise
Keep the changes made inside your flash-upload.get.js file as it is.

You need to re-enable flash uploader in order to do it.

Go to the following path - tomcat/conf/context.xml

change the context element as follows:


<Context useHttpOnly="false">


This will enable the Flash Uploader

Restart server and check.


Reference link : http://wiki.alfresco.com/wiki/Alfresco_Community_4.2.b_Release_Notes

johnpelquingua
Champ in-the-making
Champ in-the-making
Hi Sanket,


Thank you for your reply.

I couldn't seem to find the context.xml file. For development I am using maven in alfresco I've tried to do a deep search on my alfresco files and can't seem to find the file.

Is there any file that I can tweaked?


Regards,

It's not an alfresco file.
You will find it in your tomcat directory.
For ex:, if you have installed Alfresco in windows under 😧 drive, you can find it under D:\Alfresco\tomcat\conf

Hi Santek,

My project is still under development so I haven't installed anything yet in my system. But instead I'll just have to disable or hide the select content type when uploading a new version do you have any idea on how to do this?

I have added this code on to this funciton: function FlashUpload__applyConfig()

// Get the reference to the files gui components

         var fileInfo = this.fileStore[event.id];

         // Hide the contentType drop down if it wasn't hidden already
         if (fileInfo.contentType)
         {
            Dom.addClass(fileInfo.contentType, "hidden");
         }


But so far I am having no luck.

Your help is very appreciated.


Regards

I am not getting why do you need to disable the drop down for selecting the content type.
What I understand is, your requirement is to upload a custom type content, that is why you wanted the flash-uploader (giving the facility to select custom content type).
Now you want to hide it. Why ?

If you want that the user uploading documents should only be able to upload the contents of custom type, then keep that custom content type entry in
flash-upload.get.js file as the first entry, and keep the cm:content as the 2nd entry after your custom type.

Assuming that your custom content type is kb:knowledgebase.
Like this :


function getContentTypes()
{
   // TODO: Data webscript call to return list of available types
   var contentTypes = [
   {
      id: "kb:knowledgebase",
      value: "kb_knowledgebase"
    
   },
   {
      id: "cm:content",
      value: "cm_content"
   }];

   return contentTypes;
}


By default, the uploaded document will have the type as mentioned in the 1st entry (in flash-upload.get.js)

OR



function getContentTypes()
{
   // TODO: Data webscript call to return list of available types
   var contentTypes = [
   {
      id: "kb:knowledgebase",
      value: "kb_knowledgebase"
    
   }];

   return contentTypes;
}


The drop down that you want to hide won't be visible. By default, only the contents of type kb:knowledgebase will be uploaded.

NOTE: Make these changes in your extension environment, and not directly at your original file location.

Hi Santek,

Thank you for your prompt reply..

Basically when you upload a document then select a content type that is fine. It is when we upload a new version of that document, that I want to disable or hide the select option of the content type so that the user will no longer have the option to choose another content type.

Because we don't want to change the current doctype of the document into another. So I've thought by just disabling the select option I am restricting the user to not select a content type.

Hope I made it clearer for you.

I have been having trouble to disable or hide the select option of the content type:

Here is my current code on the flash-upload.js file




onFileSelect: function FlashUpload_onFileSelect(event)
      {
         // Reset the page title if IE because the file select will have changed it…

         if (YAHOO.env.ua.ie)
         {
            document.title = this._iePageTitleBackup;
         }

         // Disable upload button until all files have been rendered and added
         this.widgets.uploadButton.set("disabled", true);

         // For each time the user select new files, all the previous selected
         // files also are included in the event.fileList. Make sure we only
         // add files to the table that haven's been added before.
         var newFiles = [],
            data,
            uniqueFileToken;
         for (var i in event.fileList)
         {
            data = YAHOO.widget.DataTable._cloneObject(event.fileList);
            uniqueFileToken = this._getUniqueFileToken(data);
            if (!this.addedFiles[uniqueFileToken])
            {
               if (data.size === 0 && !this.addedFiles[uniqueFileToken])
               {
                  Alfresco.util.PopupManager.displayMessage(
                  {
                     text: this.msg("message.zeroByteFileSelected", data.name)
                  });
               }
               else
               {
                  // Add file to file table
                  newFiles.push(data);
               }
               // Since the flash movie allows the user to select one file several
               // times we need to keep track of the selected files by our selves
               this.addedFiles[uniqueFileToken] = uniqueFileToken;
            }
         }
         // Add all files to table
         this.widgets.dataTable.addRows(newFiles, 0);
         
          //THIS IS WHERE MY CODE STARTS
          if (this.showConfig.mode === this.MODE_SINGLE_UPDATE) {
              var fileupsel = Dom.get(this.id + "-left-div");
              Dom.setStyle(fileupsel, "display", "none !important");

          }

      }



Thank you for your reply.


Regards,


sanket
Champ on-the-rise
Champ on-the-rise
Remove "!important" from the last line.
Make it : Dom.setStyle(fileupsel, "display", "none");
This should make the drop down invisible.
Clear browser cookies, refresh webscripts and then check if its not reflected immediately.

johnpelquingua
Champ in-the-making
Champ in-the-making
Hi Santek,

Thank you for your help. I have finally got it to work. On how to hide the select option when you try to upload a new version.

Here's the code:

On file-upload.js file

I added this code:



  if (this.showConfig.mode === this.MODE_SINGLE_UPDATE)  {
              var fileupsel = Dom.getElementsByClassName("fileupload-contentType-select");
              Dom.addClass(fileupsel, "hidden");
  }



The code above is on the onFileSelect method:

Here's the full implementation of the method


onFileSelect: function FlashUpload_onFileSelect(event)
      {
         // Reset the page title if IE because the file select will have changed it…

         if (YAHOO.env.ua.ie)
         {
            document.title = this._iePageTitleBackup;
         }

         // Disable upload button until all files have been rendered and added
         this.widgets.uploadButton.set("disabled", true);

         // For each time the user select new files, all the previous selected
         // files also are included in the event.fileList. Make sure we only
         // add files to the table that haven's been added before.
         var newFiles = [],
            data,
            uniqueFileToken;
         for (var i in event.fileList)
         {
            data = YAHOO.widget.DataTable._cloneObject(event.fileList);
            uniqueFileToken = this._getUniqueFileToken(data);
            if (!this.addedFiles[uniqueFileToken])
            {
               if (data.size === 0 && !this.addedFiles[uniqueFileToken])
               {
                  Alfresco.util.PopupManager.displayMessage(
                  {
                     text: this.msg("message.zeroByteFileSelected", data.name)
                  });
               }
               else
               {
                  // Add file to file table
                  newFiles.push(data);
               }
               // Since the flash movie allows the user to select one file several
               // times we need to keep track of the selected files by our selves
               this.addedFiles[uniqueFileToken] = uniqueFileToken;
            }
         }
         // Add all files to table
         this.widgets.dataTable.addRows(newFiles, 0);

            if (this.showConfig.mode === this.MODE_SINGLE_UPDATE)  {
              var fileupsel = Dom.getElementsByClassName("fileupload-contentType-select");             
              Dom.addClass(fileupsel, "hidden");
            }
      }




Regards,