cityofaustin / atd-data-tech

Austin Transportation Data & Technology Services
17 stars 2 forks source link

[Enhancement] Switch to decoded URL params for tracking project list view state #14588

Closed johnclary closed 10 months ago

johnclary commented 1 year ago

On the project list, we currently base64-encode advanced search params into the browser URL. We should switch to using decoded search params, because:


Notes on current implementation:

Example of current config that is encoded and stored in filter query string:

// Some of the top level key/value pairs come from PROJECT_LIST_VIEW_FILTERS_CONFIG
{
    "cfc6e3aa-5edf-4be2-a77a-d1315ccac3cb": {
        "id": "cfc6e3aa-5edf-4be2-a77a-d1315ccac3cb",
        "field": "project_sponsor",
        "operator": "string_equals_case_sensitive",
        "availableOperators": [
        ...this is a copy of config available in `FiltersCommonOperators`
        ],
        "gqlOperator": "_ilike",
        "envelope": null,
        "placeholder": "Project sponsor",
        "value": "COA ATD Transit Enhancement",
        "type": "string",
        "label": "Sponsor",
        "lookup_table": "moped_entity",
        "lookup_field": "entity_name"
    }
}
mddilley commented 11 months ago

Going to start by figuring out the reason for the uuids. My first thought is that it is a way to keep filters on the same column from merging in the gql abstract code. We build the project list view query differently now so hopefully we can avoid that dependency.

Some inspiration

mddilley commented 11 months ago

Update to keep me on track

I'm focusing on the the filters state defined in useAdvancedSearch first, and I've whittled down the data that needs to be set in the URL params to 3 fields:

I've been able to build the needed query from these three details, and, now, I need to update the logic to set and get the URL params to only rely on the same three. My goal is to demo this in the next dev sync.

I'll keep down this path, and I think a second PR could take on paring down the internal state the Filter component which is called filterParameters. We could follow the same pattern of only storing what is needed to piece together the rest for the UI updates.

johnclary commented 11 months ago

sounds good @mddilley! happy to pair / rubber duck anytime it would be helpful.

mddilley commented 10 months ago

@johnclary I walked through each field and operator to make sure nothing broke, and I tripped over some quirks. I'm dropping notes here for now, but I can help make some issues too if you feel like any of these need attention soon.