You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2012/04/28 23:53:54 UTC

svn commit: r1331842 - in /ofbiz/trunk/specialpurpose/ecommerce: webapp/ecommerce/WEB-INF/actions/customer/NewCustomer.groovy webapp/ecommerce/customer/newcustomer.ftl widget/CustomerScreens.xml

Author: jleroux
Date: Sat Apr 28 21:53:54 2012
New Revision: 1331842

URL: http://svn.apache.org/viewvc?rev=1331842&view=rev
Log:
A patch from Tom Burns for "eCommerce Create New Customer Improvement" https://issues.apache.org/jira/browse/OFBIZ-4831

1. Add support for dependent Country / State drop down to newcustomer.ftl
This change makes the behavior of the Country / State drop downs in newcustomer.ftl consistent with the Profile > Contact Information > Postal Address > "Create New" and "Update" behavior.

2. When an eCommerce user, who is not Logged In, clicks "Register" the newcustomer.ftl from opens with a "Go Back" button.
This button navigates to a Login form that prompts the user for a user name and password.
This makes no sense in the context.
A better design is to have a Cancel button. When the user clicks Cancel the application returns to the Main display for the current session.

jleroux: 
1. I wondered about returning to main page when coming from login screen and asking to create a new user. But it makes sense as well and is better when coming directly from main page. Anyway this is purely cosmetic
2. We don't need to get back to this screen (new profile) so no needs to use from-field="selectedStateName" in
<set field="selectedDependentOption" from-field="selectedStateName" default-value="_none_"/>
It makes things clearer

Modified:
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/NewCustomer.groovy
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/newcustomer.ftl
    ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/NewCustomer.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/NewCustomer.groovy?rev=1331842&r1=1331841&r2=1331842&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/NewCustomer.groovy (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/NewCustomer.groovy Sat Apr 28 21:53:54 2012
@@ -28,21 +28,6 @@ context.productStore = productStore;
 context.createAllowPassword = "Y".equals(productStore.allowPassword);
 context.getUsername = !"Y".equals(productStore.usePrimaryEmailUsername);
 
-// load the geo names for selected countries and states/regions
-if (parameters.CUSTOMER_COUNTRY) {
-    geoValue = delegator.findByPrimaryKeyCache("Geo", [geoId : parameters.CUSTOMER_COUNTRY]);
-    if (geoValue) {
-        context.selectedCountryName = geoValue.geoName;
-    }
-}
-
-if (parameters.CUSTOMER_STATE) {
-    geoValue = delegator.findByPrimaryKeyCache("Geo", [geoId : parameters.CUSTOMER_STATE]);
-    if (geoValue) {
-        context.selectedStateName = geoValue.geoName;
-    }
-}
-
 previousParams = parameters._PREVIOUS_PARAMS_;
 if (previousParams) {
     previousParams = "?" + previousParams;
@@ -68,3 +53,6 @@ if (userInfoMap) {
     requestParameters.USERNAME = userInfoMap.preferredUsername;
     request.getSession().setAttribute("userInfoMap", userInfoMap);
 }
+
+donePage = "main;" + parameters.visit.sessionId
+context.donePage = donePage;

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/newcustomer.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/newcustomer.ftl?rev=1331842&r1=1331841&r2=1331842&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/newcustomer.ftl (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/newcustomer.ftl Sat Apr 28 21:53:54 2012
@@ -23,6 +23,7 @@ under the License.
      lastFocusedName = null;
      function setLastFocused(formElement) {
          lastFocusedName = formElement.name;
+         document.write.lastFocusedName;
      }
      function clickUsername() {
          if (document.getElementById('UNUSEEMAIL').checked) {
@@ -93,10 +94,10 @@ will generally always be reserved for th
   </#if>
 </#macro>
 
-  &nbsp;<a href="<@o...@ofbizUrl>" class="button">${uiLabelMap.CommonGoBack}</a>
+  &nbsp;<a href="<@o...@ofbizUrl>" class="button">${uiLabelMap.CommonCancel}</a>
   &nbsp;<a href="javascript:document.getElementById('newuserform').submit()" class="button">${uiLabelMap.CommonSave}</a>
 
-<form method="post" action="<@o...@ofbizUrl>" id="newuserform">
+<form method="post" action="<@o...@ofbizUrl>" id="newuserform" name="newuserform">
   
   
   <#----------------------------------------------------------------------
@@ -203,32 +204,29 @@ will generally always be reserved for th
       <@fieldErrors fieldName="CUSTOMER_POSTAL_CODE"/>
       <input type="text" name="CUSTOMER_POSTAL_CODE" id="CUSTOMER_POSTAL_CODE" value="${requestParameters.CUSTOMER_POSTAL_CODE?if_exists}" />
     </div>
-
-    <div>
-      <label for="customerCountry">${uiLabelMap.CommonCountry}*</label>
-      <@fieldErrors fieldName="CUSTOMER_COUNTRY"/>
-      <select name="CUSTOMER_COUNTRY" onclick="hideShowUsaStates();" id="customerCountry">
-        <#if requestParameters.CUSTOMER_COUNTRY?exists>
-          <option value='${requestParameters.CUSTOMER_COUNTRY}'>${selectedCountryName?default(requestParameters.CUSTOMER_COUNTRY)}</option>
-        </#if>
-        ${screens.render("component://common/widget/CommonScreens.xml#countries")}
-      </select>
-    </div>
-
+  
     <div>
-      <label for="customerState">${uiLabelMap.PartyState}*</label>
-      <@fieldErrors fieldName="CUSTOMER_STATE"/>
-      <select name="CUSTOMER_STATE" id="customerState">
-        <#if requestParameters.CUSTOMER_STATE?exists>
-          <option value='${requestParameters.CUSTOMER_STATE}'>${selectedStateName?default(requestParameters.CUSTOMER_STATE)}</option>
-        </#if>
-        <option value="">${uiLabelMap.PartyNoState}</option>
-        ${screens.render("component://common/widget/CommonScreens.xml#states")}
-      </select>
-    </div>
+        <label for="customerCountry">${uiLabelMap.CommonCountry}*</label>
+        <@fieldErrors fieldName="CUSTOMER_COUNTRY"/>
+        <select name="CUSTOMER_COUNTRY" id="newuserform_countryGeoId">
+            ${screens.render("component://common/widget/CommonScreens.xml#countries")}        
+            <#assign defaultCountryGeoId = Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("general.properties", "country.geo.id.default")>
+            <option selected="selected" value="${defaultCountryGeoId}">
+                <#assign countryGeo = delegator.findByPrimaryKey("Geo",Static["org.ofbiz.base.util.UtilMisc"].toMap("geoId",defaultCountryGeoId))>
+                ${countryGeo.get("geoName",locale)}
+            </option>
+        </select>
+    <div/>
+    
+    <div>
+        <label for="customerState">${uiLabelMap.PartyState}*</label>
+        <@fieldErrors fieldName="CUSTOMER_STATE"/>
+        <select name="CUSTOMER_STATE" id="newuserform_stateProvinceGeoId"></select>
+    <div/>
 
     <div>
       <label for="CUSTOMER_ADDRESS_ALLOW_SOL">${uiLabelMap.PartyAllowAddressSolicitation}</label>
+      <@fieldErrors fieldName="CUSTOMER_ADDRESS_ALLOW_SOL"/>
       <select name="CUSTOMER_ADDRESS_ALLOW_SOL" id="CUSTOMER_ADDRESS_ALLOW_SOL">
         <#if (((requestParameters.CUSTOMER_ADDRESS_ALLOW_SOL)!"") == "Y")><option value="Y">${uiLabelMap.CommonY}</option></#if>
         <#if (((requestParameters.CUSTOMER_ADDRESS_ALLOW_SOL)!"") == "N")><option value="N">${uiLabelMap.CommonN}</option></#if>
@@ -400,7 +398,7 @@ class name of "button". No other class n
 button actions.
 ------------------------------------------------------------------------------->
 <div class="buttons">  
-  &nbsp;<a href="<@o...@ofbizUrl>" class="button">${uiLabelMap.CommonGoBack}</a>
+  &nbsp;<a href="<@o...@ofbizUrl>" class="button">${uiLabelMap.CommonCancel}</a>
   &nbsp;<a href="javascript:document.getElementById('newuserform').submit()" class="button">${uiLabelMap.CommonSave}</a>   
 </div>
 

Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml?rev=1331842&r1=1331841&r2=1331842&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml Sat Apr 28 21:53:54 2012
@@ -44,7 +44,7 @@ under the License.
             <actions>
                 <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy"/>
                 <set field="reqName" from-field="requestName" />
-
+                
                 <set field="dependentForm" value="editcontactmechform"/>
                 <set field="paramKey" value="countryGeoId"/>
                 <set field="mainId" value="countryGeoId"/>
@@ -497,11 +497,27 @@ under the License.
             <actions>
                 <set field="titleProperty" value="PageTitleNewCustomer"/>
                 <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/customer/NewCustomer.groovy"/>
+
+                <set field="dependentForm" value="newuserform"/>
+                <set field="paramKey" value="countryGeoId"/>
+                <set field="mainId" value="countryGeoId"/>
+                <set field="dependentId" value="stateProvinceGeoId"/>
+                <set field="requestName" value="getAssociatedStateList"/>
+                <set field="responseName" value="stateList"/>
+                <set field="dependentKeyName" value="geoId"/>
+                <set field="descName" value="geoName"/>
+                <set field="selectedDependentOption" default-value="_none_"/>
+                
             </actions>
             <widgets>
                 <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                     <decorator-section name="body">
-                        <platform-specific><html><html-template location="component://ecommerce/webapp/ecommerce/customer/newcustomer.ftl"/></html></platform-specific>
+                        <platform-specific>
+                            <html>
+                                <html-template location="component://common/webcommon/includes/setDependentDropdownValuesJs.ftl"/>
+                                <html-template location="component://ecommerce/webapp/ecommerce/customer/newcustomer.ftl"/>
+                            </html>
+                        </platform-specific>
                     </decorator-section>
                 </decorator-screen>
             </widgets>