fecgov / fec-cms

The content management system (CMS) for the new Federal Election Commission website.
https://www.fec.gov
Other
97 stars 39 forks source link

Links to filings datatable with committee_id do not work-Front-end Redirects Research #5707

Open johnnyporkchops opened 1 year ago

johnnyporkchops commented 1 year ago

Summary

The link to an unverified committee doesn't seem to work anymore., https://www.fec.gov/data/filings/?data_type=processed&committee_id=C00780197, but links to unverified candidates seem to still work, https://www.fec.gov/data/filings/?data_type=processed&candidate_id=H8NC00023.

What happened? https://www.fec.gov/data/filings/?data_type=processed&committee_id=C00780197 shows all filings with no filter

What should have happened? https://www.fec.gov/data/filings/?data_type=processed&committee_id=C00780197 should show nine filings for the unverified committee.

~Completion Criteria~ Possible tech steps

Completion criteria

johnnyporkchops commented 1 year ago

Three brainstorming ideas: 1) We can put a hidden text field with id="committee_id" using the simple text field macro (don't necessarily need a hidden typeahead field) in the filings_filter.jinja which would allow committee_id to work in a URL (including unverified comms)

 Remaining issues with this solution:

  - FIXED with https://github.com/fecgov/openFEC/pull/5424 unverified committees still need to be fixed for `q_filer` typeahead (@fec-jli  and @hcaofec  have fix)
 - **Frontend  issue:** How to display the tag checkboxes in the filter panel to make sense to the user
 - **API issue:** You cannot combine `committee_id` and `q_filer` in the same URL or  API query to the filings endpoint. (Tested on OpenFEC.)

2) Or we could put two fields here instead:

3) Or maybe we can just redirect( in proxy app), URLS with /filings/?committee_id... to filings/?q_filer... because arguably it is a legacy pattern. Or redirect with this JS, with a pushState or replaceState to convert committee_id to q_filer in URLS: (Tested and works well)

      const queryx = this.parseParams(this.getVars());
      if (queryx.committee_id &&  /\/filings/.test(window.location.href)){

         if (queryx.q_filer) {
           queryx.q_filer  = urls.ensureArray(queryx.q_filer)
           queryx.q_filer.push(...urls.ensureArray(queryx.committee_id))
        }
       else {
          queryx.q_filer = queryx.committee_id
       }
    delete queryx.committee_id
    const urlx = new URL(window.location.href.split('?')[0])
    let new_query = URI.buildQuery(queryx) 
    let new_url = `${urlx}?${new_query}`
    history.pushState(null, '', new_url);
    //OR TO USE `replaceState` INSTEAD 

NOTE: Also @fec-jli mentioned that, of the two parameters, q_filer is the more "expensive" option and we should only call it when doing a free-text search, otherwise call the API, with committee_id, but which endpoint? This changes everything mentioned above :-(

fec-jli commented 1 year ago

sample api urls: https://fec-dev-api.app.cloud.gov/v1/filings/?q_filer=C00780197 (return 9 rows) https://fec-dev-api.app.cloud.gov/v1/filings/?q_filer=C007801 (return 122 rows)

JonellaCulmer commented 1 year ago

Had a convo with back-end and database about this issue and we came to the following three issues that need resolution:

  1. Front-end solution to resolve issue - need to understand front-end limitations before addressing 2 and 3.
  2. Bookmarks need to function
  3. Database generated table can potentially be updated to reflect q-filer
cnlucas commented 1 year ago

Follow-up Typeahead research ticket https://github.com/fecgov/fec-cms/issues/5800