Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-9124

productivity is low when creating Share search forms - dynamical SELECT OPTIONS should be part of the templating syntax.

    Details

    • Bug Priority:
      Category 2
    • ACT Numbers:

      0068140

    • Premier Customer:
      Yes

      Description

      Below I describe the simplest solution I could think of, on the simpelst search form I could think of.

      How to reproduce?
      ================

      Customer has a business requirement to make a lot of Share search forms.
      On some forms he wants to have drop down menu (HTML SELECT) that takes values dynamically, e.g from datalists in the repo.
      After talking with Marco, it seems the customer could use a FTL containing Javascript.

      1) create a plain vanilla 4.1.4
      2) log in as 'admin' in Share and create a site 'site1'
      3) click on more->customize and add the Data Lists tab.
      4) create a contact lists called 'contact1'
      5) add two contacts 'foo1' and 'foo2' (screen shot shot1.png)
      6) get the nodeRef for this list (e.g sniffing the network when reading it, or going to the node browser)
      7) set your shared/classes/alfresco/web-extension/share-config-custom.xml

      -------------------- share-config-custom.xml ---------------------
      <alfresco-config>
      
      <config evaluator="model-type" condition="cm:content">
      <forms>
      <form id="search">
      <appearance>
      <field id="mimetype" mandatory="true">
      <control template="/org/alfresco/components/form/controls/alex1.ftl" />
      <constraint-handlers>
      </constraint-handlers>
      </field>
      </appearance>
      </form>
      </forms>
      </config>
      
      
      <config evaluator="string-compare" condition="CSRFPolicy" replace="true">
         <filter/>
      </config>
      
      </alfresco-config>
      --------------------------------------------------
      

      8) in /webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/form/controls or equivalent put your alex1.ftl

      ------------------ alex1.ftl ---------
      <script src="http://yui.yahooapis.com/2.9.0/build/yahoo/yahoo-min.js"></script>
      <script src="http://yui.yahooapis.com/2.9.0/build/event/event-min.js"></script>
      <script src="http://yui.yahooapis.com/2.9.0/build/connection/connection-min.js"></script>
      <script src="http://yui.yahooapis.com/2.9.0/build/yahoo/yahoo-min.js"></script>
      <script src="http://yui.yahooapis.com/2.9.0/build/json/json-min.js"></script>
      <script>
      //<![CDATA[
      var sURL="http://localhost:8080/share/proxy/alfresco/slingshot/datalists/data/node/workspace/SpacesStore/16a88b9a-6632-4606-87d4-173023a86d74";
      
      var data2post='{"fields":["dl_contactFirstName","dl_contactLastName"]}';
      var responseSuccess = function(o) {
      var messages = YAHOO.lang.JSON.parse(o.responseText); 
      var select=document.getElementById("alex1")
      for (var i = 0, len = messages.items.length;  i < len; ++i) { 
        var option = document.createElement("option");
        option.text = messages.items[i].itemData.prop_dl_contactFirstName.displayValue; 
        option.value = messages.items[i].itemData.prop_dl_contactFirstName.value; 
        select.appendChild(option);
       };
      };
       
      var responseFailure = function(o) {
        alert(o.statusText);
      };
       
      var callback = {
        success:responseSuccess,
        failure:responseFailure
      };
      
      YAHOO.util.Connect.setDefaultPostHeader("application/json; charset=utf-8");
      var request = YAHOO.util.Connect.asyncRequest('POST',sURL,callback,data2post);
      //]]>
      </script>
      alex:<select id="alex1">
      </select>
      ---------------------------------------
      

      This sets the simplest possible search form, and turns off CSRF

      9) go to
      http://localhost:8080/share/page/site/site1/advsearch

      Result:
      =======
      it works, see screen shot shot2.png, but even this basic example is rather long and tedious.

      Expected result:
      ================
      1) Alfresco provide a templating syntax that allows in few lines to populate forms SELECT tags using dataLists
      2) the presentation of the form does NOT rely on AJAX but is done server-side

      Notes:
      ======
      Use case: customer have hundreds of search forms in Share.
      Each time a user wants to add a value to a SELECT menu, that requires a code change hence is lengthy process. They want to make users autonomous.

        Attachments

        1. alex1.ftl
          2 kB
        2. share-config-custom.xml
          0.4 kB
        3. shot1.png
          shot1.png
          127 kB
        4. shot2.png
          shot2.png
          86 kB

          Issue Links

            Structure

              Activity

                People

                • Assignee:
                  uiteam Web Apps (Inactive)
                  Reporter:
                  amadon Alex Madon [X] (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:

                    Structure Helper Panel