AnsweredAssumed Answered

Sort results after searching - Ordenar resultados después de una búsqueda

Question asked by wns on Jan 27, 2016
Hola,

puedo escribir el post en castellano, pero prefiero hacerlo en inglés si no es mucha molestia. Podéis contestar en castellano, por supuesto. Gracias por la ayuda de antemano.


The target is having two buttons to sort the results after searching. One of them is to sort the results in ascending mode and the other button is to sort the results in descending mode.

At the moment, I can show the both buttons in the web page. I'm describing the stepts to get this:

1.- Add two buttons: Add the following code into the file "search_noiframe.get.html.ftl" located in "config/alfresco/web-extension/site-webscripts/org/alfresco/components/search/":


       …
           <div class="sort-direction">
           <span class="sort-descending">
              <span id="${el}-sortDescending-button" class="yui-button yui-push-button">
                 <span class="first-child">
                     <button name="doclist-sortDescending-button"></button>
                  </span>
               </span>
           </span>
           <span id="${el}-sortAscending-button" class="yui-button yui-push-button">
              <span class="first-child">
                  <button name="doclist-sortAscending-button"></button>
               </span>
           </span>
     </div>
       …



2.- Set the style: Add the following code into the file "search.css" placed in "..\resources\components\search\":



  .search .sort-direction
{
   float: right;
}

.search .sort-direction span.yui-button
{
   margin-right: 0;
}

.search .sort-direction span.first-child
{
   background-image: url(../images/sort-ascending-16.png);
   background-position: 50% 50%;
   background-repeat: no-repeat;
   min-height: 16px;
   padding: 0 2px;
}

.search .sort-direction span.sort-descending span.first-child
{
   background-image: url(../images/sort-descending-16.png);
}




3.- Add the control on the buttons: I added the following code into the files "search_xxx_noiframe.js" and "search_xxx_noiframe-min.js" located in "\resources\components\search\":


    ….
         // sort ascending YUI button
         this.widgets.sortAscendingButton = Alfresco.util.createYUIButton(this, "sortAscending-button", this.onSortAscendingClick);
        
         // sort descending YUI button
         this.widgets.sortDescendingButton = Alfresco.util.createYUIButton(this, "sortDescending-button", this.onSortDescendingClick);
    ….



4.- Create the functions "onSortAscendingClick" and "onSortDescendingClick" into the files "search_xxx_noiframe.js" and "search_xxx_noiframe-min.js" located in "\resources\components\search\":


   ….
     onSortAscendingClick: function Search_onSortAscendingClick(e, p_obj)
      {
         //Here it should be wroten the code to sort the information in the ascending mode
      },

      onSortDescendingClick: function Search_onSortDescendingClick(e, p_obj)
      {
         //Here it should be wroten the code to sort the information in the ascending mode
      },
   ….



To resolve the step 4 I should do the following steps into the files "search_xxx_noiframe.js" and "search_xxx_noiframe-min.js" located in "\resources\components\search\":

a) create a new variable calls "searchDirectionSort" of boolean type. The value "true" for the ascending sort and "false" for the descending sort.

b) add this new variable to the functions "onSearch", "_performSearch" and "_buildSearchParams".

c) determine how can I specify the sort type. The problem that I have is that I don't know how can I indicate the sort type for this URI:

"localhost:8080/share/page/search_noiframe?t=&s=cm:name&q={"prop_cm_name":"","prop_das_category":"","prop_cm_created-date-range":"","prop_cm_creator":"","prop_cm_modified-date-range":"","prop_cm_modifier":"","prop_das_tag1":"","das_toPublish":"","prop_das_archived":"0","datatype":"das:customAtpDocument"}&a=true&r=true"

Where and how can I write into this URI the sort type? This is the URI after searching and I don't know how can I specify the sort type (ascending or descending) here.

Could you help me, please?

Thanks a lot.

Kind regards

Outcomes