cancel
Showing results for 
Search instead for 
Did you mean: 

object-finder.js limits its search to authority

stondini
Champ in-the-making
Champ in-the-making
Hello,

I'm looking for a component like association.ftl which allows search on nodes instead of authorities.
I'd like my user searches for documents when they have to set an association property in a form.

I looked in file object-finder.js (used by association.ftl) and a comment scares me :

      _createNavigationControls: function ObjectFinder__createNavigationControls()
      {
         var me = this;
        
         if (this._inAuthorityMode())
         {
            // only show the search box for authority mode
            Dom.setStyle(this.pickerId + "-folderUpContainer", "display", "none");
            Dom.setStyle(this.pickerId + "-navigatorContainer", "display", "none");
            Dom.setStyle(this.pickerId + "-searchContainer", "display", "block");



Is someone has this need and could help me ?
Do you know if it exists a component I could use to execute a full text search on an specific aspect or document type ?

Thank you.
8 REPLIES 8

tonyrivet
Champ in-the-making
Champ in-the-making
Yeah, the search box is only available for authorities…
As far as I know it doesn't exist (I've never heard about an extra plugin like that).
But it could be an interesting custom control to create !

stondini
Champ in-the-making
Champ in-the-making
Thanks Tony.

I'd like to extend <em>Alfresco.ObjectFinder</em> located in <em>object-finder.js</em> to override the specific authority search method but I don't know how !
And then how to use the new object in my own <em>association.ftl</em>.

tonyrivet
Champ in-the-making
Champ in-the-making
To override the object-finder.js, create a new JS component file (for example custom-object-finder.js with a Alfresco.CustomObjectFinder component), add your component constructor, and make it extend the native object finder using :
YAHOO.extend(Alfresco.CustomObjectFinder, Alfresco.ObjectFinder, {
// Add here the functions you want to override
}


Add the dependency to your custom-object-finder.js. If your component is allways used in the document library context, you can add the dependency using the DocLibCustom config in your share-config-custom.xml :

<config evaluator="string-compare" condition="DocLibCustom">
   <dependencies>
      <js src="path/to/my/dependency/custom-object-finder.js" />
   </dependencies>
</config>


Then, to use it in your own association.ftl, just instanciate it in your control. See the picker.inc.ftl for example.

I hope this can help.

stondini
Champ in-the-making
Champ in-the-making
Thank you Tony.
I did a copy of object-finder.js and kept the constructor only :


(function() {
   Alfresco.RTObjectSearcher = function Alfresco_RTObjectSearcher(htmlId,
         currentValueHtmlId) {
      Alfresco.RTObjectSearcher.superclass.constructor.call(this,
            "Alfresco.RTObjectSearcher", htmlId, [ "button", "menu",
                  "container", "resize", "datasource", "datatable" ]);
      this.currentValueHtmlId = currentValueHtmlId;

      this.eventGroup = htmlId;
      YAHOO.Bubbling
            .on("renderCurrentValue", this.onRenderCurrentValue, this);
      YAHOO.Bubbling.on("selectedItemAdded", this.onSelectedItemAdded, this);
      YAHOO.Bubbling.on("selectedItemRemoved", this.onSelectedItemRemoved,
            this);
      YAHOO.Bubbling.on("parentChanged", this.onParentChanged, this);
      YAHOO.Bubbling.on("parentDetails", this.onParentDetails, this);
      YAHOO.Bubbling.on("formContainerDestroyed",
            this.onFormContainerDestroyed, this);
      YAHOO.Bubbling.on("removeListItem", this.onRemoveListItem, this);

      // Initialise prototype properties
      this.pickerId = htmlId + "-picker";
      this.columns = [];
      this.selectedItems = {};
      this.isReady = false;

      this.options.objectRenderer = new Alfresco.ObjectRenderer(this);

      return this;
   };

   YAHOO.extend(Alfresco.RTObjectSearcher, Alfresco.ObjectFinder, {});
})();


Next I customised picker.inc.ftl to searcher.inc.ftl :

   var ${picker} = new Alfresco.RTObjectSearcher("${controlId}", "${fieldHtmlId}").setOptions(
   …


Eventually I did a copy of association.ftl to searchPicker.ftl and changed the include only :

<#include "common/searcher.inc.ftl" />


I have 2 problems :

1. The new class is not visible in searcher.inc.ftl even the dependency of the script in share-config-custom.xml.
I added
<@script type="text/javascript" src="${url.context}/res/components/redtape/object-searcher/object-searcher.js"/>
in searcher.inc.ftl
to resolve it. But I don't know why the dependency doesn't work.

2. After that,  only the label of the control is visible in share page.
When I debug the client site, I see the script and the instance of by object.

tonyrivet
Champ in-the-making
Champ in-the-making
Yeah, you may have some JavaScript error, do you ?

As you are extending the Alfresco.ObjectFinder component, you also have to change the constructor.
The first thing you do in the constructor is to call the parent constructor so you don't have to copy the rest of the instructions.
Moreover, you have to change the call to the parent constructor beacause the parameters of the Alfresco.ObjectFinder constructor are not the same as the Alfresco.component.Base constructor.

Your constructor should look like this :

Alfresco.RTObjectSearcher = function Alfresco_RTObjectSearcher(htmlId, currentValueHtmlId) {
   Alfresco.RTObjectSearcher.superclass.constructor.call(this, htmlId, currentValueHtmlId);
   return this;
};


For your dependency problem, my bad… I told you to use the DoclibCusom config instead of the form dependencies config.
This is what you should add in your share-config-custom.xml :

<config>
   <forms>
      <dependencies>
         <js src="path/to/my/dependency/custom-object-finder.js" />
      </dependencies>
   </forms>
</config>

stondini
Champ in-the-making
Champ in-the-making
Hi Tony,

Merci beaucoup Smiley Happy
It works !

I found the Share Client API documentation : http://sharextras.org/jsdoc/share/enterprise-3.4.4/symbols/Alfresco.ObjectFinder.html
I missed the constructor !

Now my component works like its parent.
I have to customize the search process to call the right webscript API.

Thank you very much.

Hello all,
here is a great tutorial on how to override object-finder.js It is generic solution and can be used on any place you require.

http://alfrescoblog.com/2014/05/28/alfresco-share-custom-object-finder-js/

Thanks for sharing that article.