OFBiz
  1. OFBiz
  2. OFBIZ-4797

eCommerce Edit Contact Information use Dependent drop-downs

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: Trunk
    • Labels:
      None
    • Environment:

      demo-trunk

      Description

      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.

        Activity

        Hide
        Tom Burns added a comment -

        Need a second pair of eyes.

        This patch follows the pattern of other implementations of the "dependent drop down" but does not display the State/Province field correctly. The first State/Province on the list is displayed when the recorded State/Province is expected.

        For example:
        Login as DemoCustomer
        Select the Profile tab
        In "Contact Information" > "Postal Address" > Click "Update"
        Select "United Kingdom" from the "Country Postal address" drop down
        Select any value after the first value from the "State/Province" drop down Say "Catithnees"
        Click "Save"

        Expect "State/Province" = "Catithnees"
        Actual "State/Province" = "Anglesey/Sir Fon"

        Click Profile
        Note: In Postal Address GB-CTHN and GBR. The change was saved but is not being displayed in the detail display.

        Also Note: The term "requestName" is used by both editcontactmech.ftl for the form target as well as a dependent drop field name. To resolve the conflict in "editcontactmech.ftl" "reqName" replaces "requestName".

        The patch includes some println's for debugging.

        Show
        Tom Burns added a comment - Need a second pair of eyes. This patch follows the pattern of other implementations of the "dependent drop down" but does not display the State/Province field correctly. The first State/Province on the list is displayed when the recorded State/Province is expected. For example: Login as DemoCustomer Select the Profile tab In "Contact Information" > "Postal Address" > Click "Update" Select "United Kingdom" from the "Country Postal address" drop down Select any value after the first value from the "State/Province" drop down Say "Catithnees" Click "Save" Expect "State/Province" = "Catithnees" Actual "State/Province" = "Anglesey/Sir Fon" Click Profile Note: In Postal Address GB-CTHN and GBR. The change was saved but is not being displayed in the detail display. Also Note: The term "requestName" is used by both editcontactmech.ftl for the form target as well as a dependent drop field name. To resolve the conflict in "editcontactmech.ftl" "reqName" replaces "requestName". The patch includes some println's for debugging.
        Hide
        Jacques Le Roux added a comment -

        Sorry Tom,

        Your patch does not apply:

        D:\workspace\ofbizClean>patch -N -p0 0<"OFBIZ-4797 eCommerce Draft.patch"
        patching file specialpurpose/ecommerce/widget/CustomerScreens.xml
        patching file specialpurpose/ecommerce/widget/CommonScreens.xml
        patching file specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy
        patching file specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl
        Hunk #4 FAILED at 173.
        1 out of 4 hunks FAILED – saving rejects to file specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl.rej

        rejected:

        --- specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl
        +++ specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl
        @@ -176,15 +173,23 @@
                   <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.PartyCountry}</td>
        -        <td>&nbsp;</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>&nbsp;</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>
        
        Show
        Jacques Le Roux added a comment - Sorry Tom, Your patch does not apply: D:\workspace\ofbizClean>patch -N -p0 0<" OFBIZ-4797 eCommerce Draft.patch" patching file specialpurpose/ecommerce/widget/CustomerScreens.xml patching file specialpurpose/ecommerce/widget/CommonScreens.xml patching file specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/customer/EditContactMech.groovy patching file specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl Hunk #4 FAILED at 173. 1 out of 4 hunks FAILED – saving rejects to file specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl.rej rejected: --- specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl +++ specialpurpose/ecommerce/webapp/ecommerce/customer/editcontactmech.ftl @@ -176,15 +173,23 @@ <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.PartyCountry}</td> - <td>&nbsp;</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>&nbsp;</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>
        Hide
        Tom Burns added a comment -

        Jacques,

        You will probably have to fix this conflict manually. In editcontactmech.ftl table record below...
        <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>
        </tr>

        ... replaces the table record above
        Above <#elseif contactMechTypeId = "TELECOM_NUMBER">

        It is the same table record used by your fix for countryGeoId

        By the way while working on the above I noticed a few additional issues in the eCommerce profile and the dependent drop down fix.

        Dependent Drop Down
        The Dependent drop down State/Province defaults to the first record after a refresh from the "Country Postal address".
        The State/Province should be blank after a refresh and throw an alert if none is selected.
        For example if the Country changes from US to United Kingdom then Aberdeenshire is selected.
        The selection should be the responsibility of the user.

        eCommerce profile
        1. The "Go Back" button in the "Contact Information" Create and update screens (Postal Address, Phone Number etc.)
        does not return to the Profile screen (viewprofile).
        Return to the Profile screen is the behavior for all similar buttons in the feature.

        2. The buttons in "Payment Method Information" labeled Cancel/Done and are of two styles class="buttontext" and class="button".
        "Cancel/Done" text may be confusing. After making a change in one for these forms the user may think that Cancel would undo the change. "Go Back" would be better.

        3. The buttons in the Profile screen itself use different styles.

        I'll create issues for these unless you are of a different mind.

        Tom

        Show
        Tom Burns added a comment - Jacques, You will probably have to fix this conflict manually. In editcontactmech.ftl table record below... <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> </tr> ... replaces the table record above Above <#elseif contactMechTypeId = "TELECOM_NUMBER"> It is the same table record used by your fix for countryGeoId By the way while working on the above I noticed a few additional issues in the eCommerce profile and the dependent drop down fix. Dependent Drop Down The Dependent drop down State/Province defaults to the first record after a refresh from the "Country Postal address". The State/Province should be blank after a refresh and throw an alert if none is selected. For example if the Country changes from US to United Kingdom then Aberdeenshire is selected. The selection should be the responsibility of the user. eCommerce profile 1. The "Go Back" button in the "Contact Information" Create and update screens (Postal Address, Phone Number etc.) does not return to the Profile screen (viewprofile). Return to the Profile screen is the behavior for all similar buttons in the feature. 2. The buttons in "Payment Method Information" labeled Cancel/Done and are of two styles class="buttontext" and class="button". "Cancel/Done" text may be confusing. After making a change in one for these forms the user may think that Cancel would undo the change. "Go Back" would be better. 3. The buttons in the Profile screen itself use different styles. I'll create issues for these unless you are of a different mind. Tom
        Hide
        Jacques Le Roux added a comment -

        Tom,

        For the rejected part forget it. I just figured out that it came from http://svn.apache.org/viewvc?rev=1326270&view=rev

        For those interested here is an updated patch

        Show
        Jacques Le Roux added a comment - Tom, For the rejected part forget it. I just figured out that it came from http://svn.apache.org/viewvc?rev=1326270&view=rev For those interested here is an updated patch
        Hide
        Jacques Le Roux added a comment -

        About

        Dependent Drop Down
        The Dependent drop down State/Province defaults to the first record after a refresh from the "Country Postal address".
        The State/Province should be blank after a refresh and throw an alert if none is selected.
        For example if the Country changes from US to United Kingdom then Aberdeenshire is selected.
        The selection should be the responsibility of the user.

        I will not change the way the dependent dropdowns work, too much work and regression possibilities. Anyway, it's the user responsability to change the province/state value. Feel free to customise locally...

        For other points I agree that issues should be created

        Show
        Jacques Le Roux added a comment - About Dependent Drop Down The Dependent drop down State/Province defaults to the first record after a refresh from the "Country Postal address". The State/Province should be blank after a refresh and throw an alert if none is selected. For example if the Country changes from US to United Kingdom then Aberdeenshire is selected. The selection should be the responsibility of the user. I will not change the way the dependent dropdowns work, too much work and regression possibilities. Anyway, it's the user responsability to change the province/state value. Feel free to customise locally... For other points I agree that issues should be created
        Hide
        Jacques Le Roux added a comment -

        Thanks Tom,

        A slightly modified version of your patch is in trunk at r1326397

        Your 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;

        Show
        Jacques Le Roux added a comment - Thanks Tom, A slightly modified version of your patch is in trunk at r1326397 Your 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;
        Hide
        Tom Burns added a comment -

        Grasshopper Thanks You

        Show
        Tom Burns added a comment - Grasshopper Thanks You

          People

          • Assignee:
            Jacques Le Roux
            Reporter:
            Tom Burns
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development