You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mo...@apache.org on 2008/07/11 14:26:41 UTC

svn commit: r675934 - in /ofbiz/trunk/applications: ecommerce/script/org/ofbiz/ecommerce/customer/ ecommerce/webapp/ecommerce/WEB-INF/ ecommerce/webapp/ecommerce/images/ ecommerce/webapp/ecommerce/order/ ecommerce/widget/ party/script/org/ofbiz/party/p...

Author: mor
Date: Fri Jul 11 05:26:40 2008
New Revision: 675934

URL: http://svn.apache.org/viewvc?rev=675934&view=rev
Log:
Applied patch (for Autocomplete feature on Country and State field on Step 2: Shipping Information of One Page Checkout) from Jira Issue OFBIZ-1871(https://issues.apache.org/jira/browse/OFBIZ-1871). Thanks to Rishi Solanki, Jyotsna Rathore, Sumit Pandit and 'Gurudev' aka Brajesh Patel :)

Modified:
    ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
    ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
    ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js
    ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl
    ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml
    ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml
    ofbiz/trunk/applications/party/servicedef/services_view.xml

Modified: ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=675934&r1=675933&r2=675934&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml (original)
+++ ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml Fri Jul 11 05:26:40 2008
@@ -850,6 +850,7 @@
         <set field="shoppingCart" from-field="parameters.shoppingCart"/>
         <set field="partyId" from-field="parameters.partyId"/>
         <set field="userLogin" from-field="parameters.userLogin"/>
+        <set field="parameters.shipToCountryGeoId" from-field="parameters.countryGeoId"/>
 
         <if-empty field="userLogin">
             <session-to-field field-name="userLogin" session-name="userLogin"/>
@@ -1113,6 +1114,7 @@
 
     <simple-method method-name="createUpdateBillingAndPayment" short-description="Create/update billing address and payment information" login-required="false">
         <set field="shoppingCart" from-field="parameters.shoppingCart"/>
+        <set field="parameters.billToCountryGeoId" from-field="parameters.countryGeoId"/>
         <if-empty field="shoppingCart">
             <session-to-field field-name="shoppingCart"/>
         </if-empty>

Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=675934&r1=675933&r2=675934&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Fri Jul 11 05:26:40 2008
@@ -1585,6 +1585,18 @@
         <response name="error" type="view" value="main"/>        
     </request-map>
 
+    <request-map uri="getCountryList">
+        <event type="jsonservice" invoke="getCountryList"/>
+        <response name="success" type="none"/>
+        <response name="error" type="none"/>
+    </request-map>
+
+    <request-map uri="getAssociatedStateList">
+        <event type="jsonservice" invoke="getAssociatedStateList"/>
+        <response name="success" type="none"/>
+        <response name="error" type="none"/>
+    </request-map>
+     
     <request-map uri="createUpdateShippingAddress">
         <security https="true" auth="false"/>
         <event type="jsonsimple" path="org/ofbiz/ecommerce/customer/CustomerEvents.xml" invoke="createUpdateCustomerAndShippingContact"/>

Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js?rev=675934&r1=675933&r2=675934&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js (original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js Fri Jul 11 05:26:40 2008
@@ -96,8 +96,15 @@
     
     // Initiate Observing Edit Cart Events
     initCartProcessObservers();
-    
+
     Event.observe('processOrderButton', 'click', processOrder);
+
+    // Autocompleter for shipping panel
+    Event.observe($('shipToCountryGeo'), 'focus', getCountryList);
+    Event.observe($('shipToCountryGeo'), 'blur', splitCountryNameFromIds);
+    
+    Event.observe($('shipToStateProvinceGeo'), 'focus', getAssociatedStateList);
+    Event.observe($('shipToStateProvinceGeo'), 'blur', splitStateNameFromIds);
 });
 
 // Cart
@@ -471,4 +478,75 @@
     Effect.Fade('processOrderButton', {duration: 0.1});
     Effect.Appear('processingOrderButton', {duration: 0.1});
     $('orderSubmitForm').submit();
+}
+
+var countryChange = 0;
+var autoCompleteCountries = null;
+var countryList = [];
+
+function getCountryList() {
+    if (countryChange == 0) {
+    new Ajax.Request("getCountryList",
+        { asynchronous: false,
+          onSuccess: function(transport) {
+          var data = transport.responseText.evalJSON(true);
+          countryList = data.countryList;
+          autoCompleteCountries = new Autocompleter.Local("shipToCountryGeo", "shipToCountries", countryList, {partialSearch: false});
+        }
+    });
+    countryChange++;
+    }
+    stateChange = 0;
+}
+
+function splitCountryNameFromIds() {
+    $('shipToStateProvinceGeo').value = "";
+    geoValues = $('shipToCountryGeo').value.split(': ');
+    if(geoValues) {
+        $('shipToCountryGeo').value = geoValues[0];
+        if(geoValues[1] == 'undefined' || geoValues[1] == null) {
+            countryList.each(function(country){
+                geo = country.split(': ');
+                if(geoValues[0] == geo[0]){
+                    geoValues[1] = geo[1];
+                }
+            });
+        }
+        $('shipToCountryGeoId').value = geoValues[1];
+    }
+}
+
+var stateChange = 0;
+var autoCompleteStates = null;
+var stateList = [];
+
+function getAssociatedStateList() {
+    if(stateChange == 0) {
+    new Ajax.Request("getAssociatedStateList",
+        { asynchronous: false,
+          parameters: $('shippingForm').serialize(),
+          onSuccess: function(transport) {
+          var data = transport.responseText.evalJSON(true);
+          stateList = data.stateList;
+          autoCompleteStates = new Autocompleter.Local("shipToStateProvinceGeo", "shipToStates", stateList, {partialSearch: false});
+        }
+    });
+    stateChange++;
+    }
+}
+
+function splitStateNameFromIds() {
+    geoValues = $('shipToStateProvinceGeo').value.split(': ');
+    if(geoValues) {
+        $('shipToStateProvinceGeo').value = geoValues[0];
+        if(geoValues[1] == 'undefined' || geoValues[1] == null) {
+            stateList.each(function(state){
+                geo = state.split(': ');
+                if(geoValues[0] == geo[0]){
+                    geoValues[1] = geo[1];
+                }
+            });
+        }
+        $('shipToStateProvinceGeoId').value = geoValues[1];
+    }
 }
\ No newline at end of file

Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl?rev=675934&r1=675933&r2=675934&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl (original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl Fri Jul 11 05:26:40 2008
@@ -356,32 +356,26 @@
                             </div>
                             <div class="form-row">
                               <div class="field-label">
-                                <label for="shipToCountryGeoId">${uiLabelMap.PartyCountry}<span class="requiredLabel"> *</span></label>
+                                <label for="shipToCountryGeoId">${uiLabelMap.PartyCountry}<span class="requiredLabel"> *</span><span id="advice-required-shipToCountryGeo" style="display:none">(required)</span></label>
                               </div>
                               <div class="field-widget">
-                                <select name="shipToCountryGeoId" id="shipToCountryGeoId" class="required selectBox">
-                                  <#if (parameters.shipToCountryGeoId)?exists>
-                                    <option>${parameters.shipToCountryGeoId}</option>
-                                    <option value="${parameters.shipToCountryGeoId}">---</option>
-                                  </#if>
-                                   ${screens.render("component://common/widget/CommonScreens.xml#countries")}
-                                  </select>
+                                <div>
+                                  <input name="shipToCountryGeo" id="shipToCountryGeo" size="30" class="inputBox required" type="text" value="${parameters.shipToCountryGeo?if_exists}"/>
+                                  <input name="countryGeoId" id="shipToCountryGeoId" type="hidden" value="${parameters.countryGeoId?if_exists}"/>
+                                  <div id="shipToCountries" class="autocomplete" style="display:none"></div> 
+                                </div>
                               </div>
                             </div>
                             <div class="form-row">
                               <div class="field-label">
-                                <label for="state">${uiLabelMap.CommonState}<span>*</span><span id="advice-required-shipToStateProvinceGeoId" style="display:none">(required)</span></label>
+                                <label for="state">${uiLabelMap.CommonState}<span>*</span><span id="advice-required-shipToStateProvinceGeo" style="display:none">(required)</span></label>
                               </div>
                               <div class="field-widget"> 
-                                  <select name="shipToStateProvinceGeoId" id="shipToStateProvinceGeoId" class="required selectBox">
-                                    <#if (parameters.shipToStateProvinceGeoId)?exists>
-                                      <option>${parameters.shipToStateProvinceGeoId}</option>
-                                        <option value="${parameters.shipToStateProvinceGeoId}"></option>
-                                    <#else>
-                                      <option value="">${uiLabelMap.PartyNoState}</option>
-                                    </#if>
-                                    ${screens.render("component://common/widget/CommonScreens.xml#states")}
-                                  </select>
+                                <div>
+                                  <input name="shipToStateProvinceGeo" id="shipToStateProvinceGeo" size="30" class="inputBox required" type="text" value="${parameters.shipToStateProvinceGeo?if_exists}"/>
+                                  <input name="shipToStateProvinceGeoId" id="shipToStateProvinceGeoId" type="hidden" value="${parameters.shipToStateProvinceGeoId?if_exists}"/>
+                                  <div id="shipToStates" class="autocomplete" style="display:none"></div> 
+                                </div>
                               </div> 
                             </div>
                         </td></tr>
@@ -589,10 +583,10 @@
                               <label for="billToCountryGeoId">${uiLabelMap.PartyCountry}<span>*</span><span id="advice-required-billToCountryGeoId" style="display:none">(required)</span></label>
                             </div>
                             <div class="field-widget">
-                              <select name="billToCountryGeoId" id="billToCountryGeoId" class="required selectBox">
-                                <#if (parameters.billToCountryGeoId)?exists>
-                                  <option>${parameters.billToCountryGeoId}</option>
-                                  <option value="${parameters.billToCountryGeoId}">---</option>
+                              <select name="countryGeoId" id="billToCountryGeoId" class="required selectBox">
+                                <#if (parameters.countryGeoId)?exists>
+                                  <option>${parameters.countryGeoId}</option>
+                                  <option value="${parameters.countryGeoId}">---</option>
                                 </#if>
                                 ${screens.render("component://common/widget/CommonScreens.xml#countries")}
                               </select>

Modified: ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml?rev=675934&r1=675933&r2=675934&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml (original)
+++ ofbiz/trunk/applications/ecommerce/widget/OrderScreens.xml Fri Jul 11 05:26:40 2008
@@ -612,8 +612,11 @@
         <section>
             <actions>
                 <set field="titleProperty" value="EcommerceOnePageCheckout"/>
+                <set field="layoutSettings.styleSheets[+0]" value="/images/prototypejs/scriptaculouscontrols.css" global="true"/>
+                <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/scriptaculous.js" global="true"/>
                 <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/effects.js" global="true"/>
-                <set field="layoutSettings.javaScripts[+0]" value="/ecommerce/images/checkoutProcess.js" global="true"/>            
+                <set field="layoutSettings.javaScripts[]" value="/images/prototypejs/controls.js" global="true"/>
+                <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/checkoutProcess.js" global="true"/>
                 <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/cart/showcart.bsh"/>
             </actions>
             <widgets>

Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml?rev=675934&r1=675933&r2=675934&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml (original)
+++ ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml Fri Jul 11 05:26:40 2008
@@ -888,5 +888,33 @@
             </if-not-empty>
         </if-not-empty>
     </simple-method>
+
+    <simple-method method-name="getCountryList" short-description="Returns a list of country" login-required="false">
+        <call-class-method method-name="getCountryList" class-name="org.ofbiz.common.CommonWorkers" ret-field-name="geoList">
+            <field field-name="delegator" type="org.ofbiz.entity.GenericDelegator"/>
+        </call-class-method>
+        <iterate list-name="geoList" entry-name="countryGeo">
+            <set field="countryName" value="${countryGeo.geoName}: ${countryGeo.geoId}"/>
+            <field-to-list list-name="countryList" field-name="countryName"/>
+        </iterate>
+        <field-to-result field-name="countryList"/>
+    </simple-method>
+
+    <simple-method method-name="getAssociatedStateList" short-description="set the state options for selected country" login-required="false">
+        <set field="countryGeoId" from-field="parameters.countryGeoId"/>
+        <call-class-method method-name="getAssociatedStateList" class-name="org.ofbiz.common.CommonWorkers" ret-field-name="geoList">
+            <field field-name="delegator" type="org.ofbiz.entity.GenericDelegator"/>
+            <field field-name="countryGeoId" type="String"/>
+        </call-class-method>
+        <iterate list-name="geoList" entry-name="stateGeo">
+            <set field="stateName" value="${stateGeo.geoName}: ${stateGeo.geoId}"/>
+            <field-to-list list-name="stateList" field-name="stateName"/>
+        </iterate>
+        <if-empty field="stateList">
+            <set field="noOption" value="No States/Provinces exists"/>
+            <field-to-list list-name="stateList" field-name="noOption"/>
+        </if-empty>
+        <field-to-result field-name="stateList"/>
+    </simple-method>
     
 </simple-methods>

Modified: ofbiz/trunk/applications/party/servicedef/services_view.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/services_view.xml?rev=675934&r1=675933&r2=675934&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/servicedef/services_view.xml (original)
+++ ofbiz/trunk/applications/party/servicedef/services_view.xml Fri Jul 11 05:26:40 2008
@@ -174,4 +174,17 @@
         <attribute name="contactMechId" type="String" mode="IN" optional="false"/>
         <attribute name="geos" type="java.util.List" mode="OUT" optional="true"/>
     </service>
+
+    <!-- Get a list of country and associated states from Geo -->
+    <service name="getCountryList" engine="simple" auth="false"
+            location="org/ofbiz/party/party/PartyServices.xml" invoke="getCountryList">
+        <attribute name="countryList" mode="OUT" type="java.util.List"/>
+    </service>
+
+    <service name="getAssociatedStateList" engine="simple" auth="false"
+            location="org/ofbiz/party/party/PartyServices.xml" invoke="getAssociatedStateList">
+        <attribute name="countryGeoId" mode="IN" type="String" optional="false"/>
+        <attribute name="stateList" mode="OUT" type="java.util.List"/>
+    </service>
+
 </services>