cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Share Document Library button action

sanoojkt
Champ in-the-making
Champ in-the-making
how the "New Folder" button action is triggered within the document library of Alfreso share
and which is the exact action script file?
12 REPLIES 12

mikeh
Star Contributor
Star Contributor
"New Folder" is implemented in toolbar.js

Thanks,
Mike

sanoojkt
Champ in-the-making
Champ in-the-making
Yes, it's correct. The action script is there.

The New Folder button definition is given in toolbar.lib.ftl file
as shown below.

<div class="hideable toolbar-hidden DocListTree">
            <div class="new-folder"><button id="${el}-newFolder-button" name="newFolder">${msg("button.new-folder")}</button></div>

But it doesn't contain the action call to the script method.

Then how it's happening?

mikeh
Star Contributor
Star Contributor
That's the Freemarker template, whereas I pointed you to the toolbar.js JavaScript file.
// New Folder button: user needs "create" access
this.widgets.newFolder = Alfresco.util.createYUIButton(this, "newFolder-button", this.onNewFolder,
{
   disabled: true,
   value: "CreateChildren"
});

Thanks,
Mike

sanoojkt
Champ in-the-making
Champ in-the-making
The javascript new folder action is called based on the id 
"${el}-newFolder-button" specified in the ftl???

davidcognite
Star Contributor
Star Contributor
Yes, that's correct. If the full element id isn't explicitly passed in then the createYUIButton method constructs it by joining the scope's id element and the button name together.

In the case of the new folder button it will construct it from:
this.id + "-" + "newFolder-button"
('this' is the first parameter in the createYUIButton method call).

which is exactly the same as the form used in the FTL:
${el}-newFolder-button

sanoojkt
Champ in-the-making
Champ in-the-making
I have created a Button "Create" in Document Library as shown below.

toolbar.get.html.ftl

<div class="separator hideable DocListTree"> </div>
<div class="file-create hideable DocListTree"><button id="${args.htmlid}-fileCreate-button" name="fileCreate">${msg("button.create")}</button></div>
—————————————————————————————————————–
toolbar.css

.toolbar .file-create button
{
background: transparent url(images/create-16.png) no-repeat 12px 4px;
padding-left: 32px;
}
.toolbar .file-create .yui-button-disabled button
{
background-image: url(images/create-disabled-16.png);
}
———————————————————————————————————————-
toolbar.js

added a line to instantiate the YUI button named in the toolbar template in the 'onReady' YUI event listener


   // File Create button: user needs  "create" access
   this.widgets.fileCreate = Alfresco.util.createYUIButton(this, "fileCreate-button", this.onFileCreate,
   {
      disabled: true,
      value: "create"
   });
   // done added


The event is also added in toolbar.js

 /**
* File Create click handler
*
* @method onFileCreate
* @param e {object} DomEvent
* @param p_obj {object} Object passed back from addListener method
*/
onFileCreate: function DLTB_onFileCreate(e, p_obj)
{
/*
   var url = YAHOO.lang.substitute(Alfresco.constants.URL_CONTEXT + "page/site/{site}/blog-postedit?container={container}",
   {
      site: this.options.siteId,
      container: this.options.containerId
   });
   window.location = url;
   Event.preventDefault(e);
*/
   var notimpTitle = this._msg("title.notimp");
   var notimpMsg = this._msg("message.notimp", "Create Content");

   Alfresco.util.PopupManager.displayPrompt(
   {
      title: notimpTitle,
      text: Alfresco.util.decodeHTML(notimpMsg),
      noEscape: true,
      modal: true,
      buttons: [
      {
         text: this._msg("button.cancel"),
         handler: function DLTB_onActionDelete_cancel()
         {
            this.destroy();
         }
      }]
   });

},
——————————————————————————————————
toobar.get.properties


button.create=Create
title.notimp=Not Implemented
message.notimp = Feature {0} is not implemented yet.

———————————————————————————————————

Here the Button is displaying in Document Library.
But can't trigger the button action.
Any other configurations or modifications is needed for triggering the button action???

davidcognite
Star Contributor
Star Contributor

   // File Create button: user needs  "create" access
   this.widgets.fileCreate = Alfresco.util.createYUIButton(this, "fileCreate-button", this.onFileCreate,
   {
      disabled: true,
      value: "create"
   });
   // done added

Try using "CreateChildren" in place of "create" for the permission value.

sanoojkt
Champ in-the-making
Champ in-the-making
It's tried. Not working…….

davidcognite
Star Contributor
Star Contributor
Then you're going to need to step through it with a Javascript debugger.

Three likely scenarios (off the top of my head) are that the button isn't being correctly created, the target function isn't found (check the context of "this") or that the target function is hitting an error: set a break point just after this.widgets.fileCreate is assigned & check the value isn't null - if it is, the problem is that the createYUIButton wrapper method hit a problem. You'll also want to add a break point immediately inside the onFileCreate function to double check that it is being called & then step through it to see if it hits any issues.