Author: jleroux
Date: Sun Apr 15 18:58:17 2012 New Revision: 1326397 URL: http://svn.apache.org/viewvc?rev=1326397&view=rev Log: A modified patch from Tom Burns for "Add Support for Dependent Country State Drop Downs to SFA New Postal Address " https://issues.apache.org/jira/browse/OFBIZ-4801 Using Dependent drop-downs to filter the State drop down based on the selection in the Country drop-down will improve the usability of the component. Current Behavior: 1. Open eCommerce application 2. Log in as user with Postal Address say Demo Customer 3. In the menu bar select Profile 4. In "Contact Information" > "Postal Address" select update. 5. The "Country" drop-down value is "United States" and the "State/Province" drop-down list displays all geo values. After improvement: 5. The "Country" drop-down value is "United States" and the "State/Province" drop-down list is limited to States in the United States. 6. Changing the value in the "Country" drop-down will update "State/Province" drop-down list with values for the selected country. jleroux: Tom's patch had only a small issue: duplicated line (but this had any impact since overriden by the following line) <set field="selectedDependentOption" value="_none_"/> The problem was more in EditContactMech.groovy: context.selectedStateName = geoValue.geoName; was used, instead of needed by setDependentDropdownValuesJs.ftl context.selectedStateName = geoValue.geoId; Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy?rev=1326397&r1=1326396&r2=1326397&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy Sun Apr 15 18:58:17 2012 @@ -93,11 +93,11 @@ if (parameters.countryGeoId) { if (parameters.stateProvinceGeoId) { geoValue = delegator.findByPrimaryKeyCache("Geo", [geoId : parameters.stateProvinceGeoId]); if (geoValue) { - context.selectedStateName = geoValue.geoName; + context.selectedStateName = geoValue.geoId; } } else if (postalAddressData?.stateProvinceGeoId) { geoValue = delegator.findByPrimaryKeyCache("Geo", [geoId : postalAddressData.stateProvinceGeoId]); if (geoValue) { - context.selectedStateName = geoValue.geoName; + context.selectedStateName = geoValue.geoId; } } Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl?rev=1326397&r1=1326396&r2=1326397&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl Sun Apr 15 18:58:17 2012 @@ -50,7 +50,7 @@ under the License. <a href='<@ofbizUrl>editcontactmechdone</@ofbizUrl>' class="button">${uiLabelMap.CommonGoBack}</a> <a href="javascript:document.editcontactmechform.submit()" class="button">${uiLabelMap.CommonSave}</a> <table width="90%" border="0" cellpadding="2" cellspacing="0"> - <form method="post" action='<@ofbizUrl>${requestName}</@ofbizUrl>' name="editcontactmechform"> + <form method="post" action='<@ofbizUrl>${reqName}</@ofbizUrl>' name="editcontactmechform" id="editcontactmechform"> <div> <input type='hidden' name='contactMechTypeId' value='${contactMechTypeId}' /> <#if contactMechPurposeType?exists> @@ -116,7 +116,7 @@ under the License. </table> </td> </tr> - <form method="post" action='<@ofbizUrl>${requestName}</@ofbizUrl>' name="editcontactmechform"> + <form method="post" action='<@ofbizUrl>${reqName}</@ofbizUrl>' name="editcontactmechform" id="editcontactmechform"> <div> <input type="hidden" name="contactMechId" value='${contactMechId}' /> <input type="hidden" name="contactMechTypeId" value='${contactMechTypeId}' /> @@ -159,16 +159,14 @@ under the License. *</td> </tr> <tr> - <td align="right" valign="top">${uiLabelMap.PartyState}</td> + <td align="right" valign="top"> ${uiLabelMap.PartyState} -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Selected\Expected State Name = ${selectedStateName}</td> <td> </td> - <td> - <select name="stateProvinceGeoId" class='selectBox'> - <#if postalAddressData.stateProvinceGeoId?exists><option value='${postalAddressData.stateProvinceGeoId}'>${selectedStateName?default(postalAddressData.stateProvinceGeoId)}</option></#if> - <option value="">${uiLabelMap.PartyNoState}</option> - ${screens.render("component://common/widget/CommonScreens.xml#states")} + <td> + <select name="stateProvinceGeoId" id="editcontactmechform_stateProvinceGeoId"> </select> - *</td> - </tr> + </td> + </tr> <tr> <td align="right" valign="top">${uiLabelMap.PartyZipCode}</td> <td > </td> @@ -176,15 +174,24 @@ under the License. <input type="text" class='inputBox' size="12" maxlength="10" name="postalCode" value="${postalAddressData.postalCode?if_exists}" /> *</td> </tr> - <tr> - <td align="right" valign="top">${uiLabelMap.CommonCountry}</td> - <td> </td> - <td> - <select name="countryGeoId" class='selectBox'> - <#if postalAddressData.countryGeoId?exists><option value='${postalAddressData.countryGeoId}'>${selectedCountryName?default(postalAddressData.countryGeoId)}</option></#if> - ${screens.render("component://common/widget/CommonScreens.xml#countries")} + <tr> + <td align="right" valign="top">${uiLabelMap.CommonCountry} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Postal address geoId ${postalAddress.countryGeoId}</td> + <td> </td> + <td> + <select name="countryGeoId" id="editcontactmechform_countryGeoId"> + ${screens.render("component://common/widget/CommonScreens.xml#countries")} + <#if (postalAddress?exists) && (postalAddress.countryGeoId?exists)> + <#assign defaultCountryGeoId = postalAddress.countryGeoId> + <#else> + <#assign defaultCountryGeoId = Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("general.properties", "country.geo.id.default")> + </#if> + <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> - *</td> + </td> </tr> <#elseif contactMechTypeId = "TELECOM_NUMBER"> <tr> Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml?rev=1326397&r1=1326396&r2=1326397&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml Sun Apr 15 18:58:17 2012 @@ -63,6 +63,7 @@ under the License. <entity-and list="webAnalyticsConfigs" entity-name="WebAnalyticsConfig"> <field-map field-name="webSiteId"/> </entity-and> + <set field="layoutSettings.javaScripts[]" value="/images/getDependentDropdownValues.js" global="true" /> </actions> <widgets> <section> Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml?rev=1326397&r1=1326396&r2=1326397&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/widget/CustomerScreens.xml Sun Apr 15 18:58:17 2012 @@ -42,13 +42,29 @@ under the License. <screen name="editcontactmech"> <section> <actions> - <set field="titleProperty" value="PageTitleEditContactMechanism"/> <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"/> + <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" from-field="selectedStateName" 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/editcontactmech.ftl"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="component://common/webcommon/includes/setDependentDropdownValuesJs.ftl"/> + <html-template location="component://ecommerce/webapp/ecommerce/customer/editcontactmech.ftl"/> + </html> + </platform-specific> </decorator-section> </decorator-screen> </widgets> |
Free forum by Nabble | Edit this page |