CRM-14996 Reports county filter option shows all counties regardless of state or states chosen

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5
    • Fix Version/s: 4.5
    • Component/s: CiviReport
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      When you add counties to a profile, we have some nice javascript that will limit the counties listed depending on the state chosen. This doesn't exist for reports.

        Attachments

          Issue Links

            Activity

            [CRM-14996] Reports county filter option shows all counties regardless of state or states chosen
            David Greenberg added a comment -

            Monish - please review the PR and merge as appropriate. Thanks.

            Monish Deb added a comment -

            Submitted the new PR https://github.com/civicrm/civicrm-core/pull/3699

            Jamie there are some reasons for which I have submitted a new PR:
            1) There is a possibility that we can use the same chain-selection functionality between country>state-province>county(CSC) that we use in profile. Difference lies on the multi-selection nature of CSC fields in report, only thing we can is to extend the functionality to handle multi-selection nature of CSC field that you can in my patch.
            2) If we achieve #1 changes then I guess there is no need to introduce any new file to handle that task.

            So Jamie/Dave can you please check my changes if its ready to merge, just need a assurance as I've already tested on my end

            Thanks,
            Monish

            David Greenberg added a comment -

            Jamie - This works nicely for me (tested in Contribution Details report after enabling County in Address Settings and installing US County Loader extension). Can you try it out on your reports please.

            Monish Deb added a comment -

            Also existing behavior for CSC fields are not broken for profile. On the otherhand for reports, when you select say two countries then all of the states of both the countries got listed out, same change for counties option list on multiple state-selection.

            Jamie McClelland added a comment -

            I think the replacement pull request makes a lot of sense. I can't apply it to our 4.4 installs to test, though, because of all the changes in in templates/CRM/common/stateCountry.tpl, but I think this is the way to go.

            David Greenberg added a comment -

            Jamie - we'll reopen if for some reason this doesn't fix things in your environments.

            Coleman Watts added a comment - - edited

            Monish, there are 2 problems with your js logic:
            1) You are checking the wrong "multiple" property. You are trying to find out if the country is multiple but checking the state instead.
            2) Firing the same ajax request multiple times simultaneously is going to cause race conditions with unpredictable results. In this case it would be better to update the server-side callback be able to handle multi-values rather than calling it repeatedly with a single value each time.

            Coleman Watts added a comment -

            https://github.com/civicrm/civicrm-core/pull/3891

            This does a couple things:

            • Adds support for multiselects to the server side code
            • Groups states and counties into optgroups to help usability (when > 1 country/state is chosen)
            • Applies select2 to all country/state/county fields for consistency
            David Greenberg added a comment -

            Tested in reports (Contribution Details) and Advanced Search (with and without Counties enabled and loaded). Works great except for one problem:

            • Localization => Lanaguages etc => Enable countries Canada and Mexico
            • Edit a contact to have an address in a Mexican province
            • Advanced Search => Country = Mexico, State = Baja California Sur (for example).

            The search returns the correct record BUT the selected province is LOST from the form values and not shown in the QILL.

            Repeated this for Canada - same result. Somehow any non US province gets lost. (weird)

            Assuming you find / fix - go ahead and merge. The new UI is great!

            Coleman Watts added a comment -

            Thanks. Fixed the adv-search bugs so I think it's good to go.

            Coleman Watts added a comment -

            Ok there's one more problem here. If we're going to add chain-select to reports, we need it to also handle populating the option lists correctly when it reloads. Right now if you select a different country, it will lose your state and county selections when you submit or save the report.

            Coleman Watts added a comment -

            I'm closing this and opening CRM-15172. A good all-around chainSelect solution will serve us better than trying to hack around these problems in this one instance.

              People

              • Assignee:
                Coleman Watts
                Reporter:
                Jamie McClelland

                Dates

                • Created:
                  Updated:
                  Resolved: