diff --git a/fec/fec/static/js/modules/typeahead.js b/fec/fec/static/js/modules/typeahead.js index 1dc2e3f5c..135bd5687 100644 --- a/fec/fec/static/js/modules/typeahead.js +++ b/fec/fec/static/js/modules/typeahead.js @@ -76,11 +76,18 @@ function getUrl_names(resource) { } function getUrl_legal(resource) { + // Which parameters do we know we're going to query? + const queryParams = { + api_key: window.API_KEY_PUBLIC + }; + + // If there's a doc_type, let's add that to the query + const docTypeInput = document.querySelector('input[name="doc_type"]'); + if (docTypeInput && docTypeInput.value != '') queryParams.doc_type = docTypeInput.value; + return URI(window.API_LOCATION) .path([window.API_VERSION, 'legal', resource, encodeURIComponent('%QUERY')].join('/')) - .query({ - api_key: window.API_KEY_PUBLIC - }) + .query(queryParams) .readable(); } @@ -342,6 +349,42 @@ const aoStatutoryCitationDataset = { } }; +const caseRegulatoryCitationDataset = { + name: 'caseRegulatoryCitation', + display: 'name', + limit: 10, + source: citationRegulationEngine, + templates: { + header: 'Select a citation:', + pending: + 'Loading citations…', + notFound: compileHBS(''), // This has to be empty to not show anything + suggestion: function(datum) { + return ( + '' + datum.name + '' + ); + } + } +}; + +const caseStatutoryCitationDataset = { + name: 'caseStatutoryCitation', + display: 'name', + limit: 10, + source: citationStatuteEngine, + templates: { + header: 'Select a citation:', + pending: + 'Loading citations…', + notFound: compileHBS(''), // This has to be empty to not show anything + suggestion: function(datum) { + return ( + '' + datum.name + '' + ); + } + } +}; + export const datasets = { candidates: candidateDataset, committees: committeeDataset, @@ -350,6 +393,8 @@ export const datasets = { regulations: regulationDataset, aoRegulatoryCitations: aoRegulatoryCitationDataset, aoStatutoryCitations: aoStatutoryCitationDataset, + caseRegulatoryCitations: caseRegulatoryCitationDataset, + caseStatutoryCitations: caseStatutoryCitationDataset, allData: [candidateDataset, committeeDataset], all: [candidateDataset, committeeDataset, individualDataset, siteDataset, legalDataset] }; diff --git a/fec/legal/templates/layouts/legal-doc-search-results.jinja b/fec/legal/templates/layouts/legal-doc-search-results.jinja index 9e315f138..1ea8e6c00 100644 --- a/fec/legal/templates/layouts/legal-doc-search-results.jinja +++ b/fec/legal/templates/layouts/legal-doc-search-results.jinja @@ -100,7 +100,8 @@ const tag = this.getAttribute('data-tag'); const url = new URL(window.location); - // Remove tags logic + // "Remove tags" logic + // Assigns a URL to each remove/"⤫" button that removes its own value from the URL if (tag === 'query') { url.searchParams.delete('search'); url.searchParams.delete('search_exclude'); @@ -135,6 +136,32 @@ } else if (tag && tag == 'secondary_subject_id') { // Check if tag is not null or undefined // Remove 'secondary_subject_id' from the URL url.searchParams.delete('secondary_subject_id'); + } else if (tag && tag == 'case_citation_require_all') { + url.searchParams.delete('case_citation_require_all'); + } else if (tag && tag.startsWith('case_regulatory_citation')) { + // Get the 0-indexed position of this item + const index = tag.split('_').at(-1); + // Hold all the case_regulatory_citation from the URL + const citations = url.searchParams.getAll('case_regulatory_citation'); + // Remove all of the case_regulatory_citation from the URL + url.searchParams.delete('case_regulatory_citation'); + // For all of the held citations, + citations.forEach((cite, i) => { + // Add all but this element back to the URL + if (i != index) url.searchParams.append('case_regulatory_citation', cite); + }); + } else if (tag && tag.startsWith('case_statutory_citation')) { + // Get the 0-indexed position of this item + const index = tag.split('_').at(-1); + // Hold all the case_statutory_citation from the URL + const citations = url.searchParams.getAll('case_statutory_citation'); + // Remove all of the case_statutory_citation from the URL + url.searchParams.delete('case_statutory_citation'); + // For all of the held citations, + citations.forEach((cite, i) => { + // Add all but this element back to the URL + if (i != index) url.searchParams.append('case_statutory_citation', cite); + }); } else { url.searchParams.delete(tag); } diff --git a/fec/legal/templates/legal-search-results-advisory_opinions.jinja b/fec/legal/templates/legal-search-results-advisory_opinions.jinja index e5d446b59..a800cc473 100644 --- a/fec/legal/templates/legal-search-results-advisory_opinions.jinja +++ b/fec/legal/templates/legal-search-results-advisory_opinions.jinja @@ -49,10 +49,10 @@
Document date range does not search archived cases
+