Skip to content

Commit

Permalink
Merge branch 'main' of github.com:uktrade/orp into feature/ORPD-47-pa…
Browse files Browse the repository at this point in the history
…gination
  • Loading branch information
gdbarnes committed Oct 16, 2024
2 parents 545d0ed + 7c4eed0 commit 3eab980
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 32 deletions.
36 changes: 28 additions & 8 deletions orp/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,32 @@ class RegulationSearchForm(forms.Form):
("guidance", "Guidance"),
("standard", "British Standard"),
],
widget=forms.CheckboxSelectMultiple(
attrs={
"class": "govuk-checkboxes__input",
"data-module": "govuk-checkboxes",
}
),
label="Select document types",
help_text="You can select multiple document types.",
# widget=forms.CheckboxSelectMultiple(
# attrs={
# "class": "govuk-checkboxes__input",
# "data-module": "govuk-checkboxes",
# }
# ),
# label="Select document types",
# help_text="You can select multiple document types.",
)

publisher = forms.MultipleChoiceField(
required=False,
choices=[
("healthandsafetyexecutive", "Health and Safety Executive"),
("civilaviationauthority", "Civil Aviation Authority"),
("environmentagency", "Environment Agency"),
("defra", "Defra"),
(
"officeofgasandelectricitymarkets",
"Office of Gas and Electricity Markets",
),
("officeofrailandroad", "Office of Rail and Road"),
("naturalengland", "Natural England"),
("historicengland", "Historic England"),
("nationalhighways", "National Highways"),
("homesengland", "Homes England"),
("departmentfortransport", "Department for Transport"),
],
)
1 change: 1 addition & 0 deletions orp/orp_search/public_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def finalise_results(
context["paginator"] = paginator
context["is_paginated"] = paginator.num_pages > 1
context["results"] = paginated_documents
context["results_count"] = len(paginated_documents)
context["results_total_count"] = paginator.count
context["results_page_total"] = paginator.num_pages
context["current_page"] = config.offset
Expand Down
48 changes: 25 additions & 23 deletions orp/orp_search/templates/orp.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ <h2 class="govuk-fieldset__heading">
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes">
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="document_type" name="document_type" type="checkbox"
value="legislation">
value="legislation" {% if 'legislation' in form.document_type.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="document_type">
Legislation
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="document_type-2" name="document_type" type="checkbox"
value="guidance">
value="guidance" {% if 'guidance' in form.document_type.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="document_type-2">
Guidance
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="document_type-3" name="document_type" type="checkbox"
value="standard">
value="standard" {% if 'standard' in form.document_type.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="document_type-3">
British Standards
</label>
Expand All @@ -94,89 +94,91 @@ <h2 class="govuk-fieldset__heading">
<!-- <div id="status-hint" class="govuk-hint govuk-!-font-size-14">
1 selected
</div> -->
<div class="govuk-form-group {% if form.query.errors %}govuk-form-group--error{% endif %} search-group">
<label class="govuk-label govuk-visually-hidden" for="{{ form.query.id_for_label }}">
<!-- <div class="govuk-form-group {% if form.query.errors %}govuk-form-group--error{% endif %} search-group"> -->
<!-- <label class="govuk-label govuk-visually-hidden" for="{{ form.query.id_for_label }}">
Search by publisher
</label>
<!-- The below will be added as a JavaScript enhancement -->
<!-- <div class="search-input-button search-input-button--black orp-publisher-search">
</label> -->
<!-- The below will be added as a JavaScript enhancement -->
<!-- <div class="search-input-button search-input-button--black orp-publisher-search">
<input class="govuk-input orp-publisher-search__input app-site-search__input--default"
name="input-autocomplete" placeholder="Search" type="text" role="combobox">
</div> -->
</div>
<div class="govuk-checkboxes govuk-checkboxes--small orp-max-height-250" data-module="govuk-checkboxes">
<!-- </div> -->
<!-- <div class="govuk-checkboxes govuk-checkboxes--small orp-max-height-250" data-module="govuk-checkboxes"> -->
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes">
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher" name="publisher" type="checkbox"
value="healthandsafetyexecutive">
value="healthandsafetyexecutive" {% if 'healthandsafetyexecutive' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher">
Health and Safety Executive
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-2" name="publisher" type="checkbox"
value="civilaviationauthority">
value="civilaviationauthority" {% if 'civilaviationauthority' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-2">
Civil Aviation Authority
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-3" name="publisher" type="checkbox"
value="environmentagency">
value="environmentagency" {% if 'environmentagency' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-3">
Environment Agency
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-4" name="publisher" type="checkbox" value="defra">
<input class="govuk-checkboxes__input" id="publisher-4" name="publisher" type="checkbox" value="defra"
{% if 'defra' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-4">
Defra
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-5" name="publisher" type="checkbox"
value="officeofgasandelectricitymarkets">
value="officeofgasandelectricitymarkets" {% if 'officeofgasandelectricitymarkets' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-5">
Office of Gas and Electricity Markets
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-6" name="publisher" type="checkbox"
value="officeofrailandroad">
value="officeofrailandroad" {% if 'officeofrailandroad' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-6">
Office of Rail and Road
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-7" name="publisher" type="checkbox"
value="naturalengland">
value="naturalengland" {% if 'naturalengland' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-7">
Natural England
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-8" name="publisher" type="checkbox"
value="historicengland">
value="historicengland" {% if 'historicengland' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-8">
Historic England
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-9" name="publisher" type="checkbox"
value="nationalhighways">
value="nationalhighways" {% if 'nationalhighways' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-9">
National Highways
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-10" name="publisher" type="checkbox"
value="homesengland">
value="homesengland" {% if 'homesengland' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-10">
Homes England
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="publisher-11" name="publisher" type="checkbox"
value="departmentfortransport">
value="departmentfortransport" {% if 'departmentfortransport' in form.publisher.value %}checked{% endif %}>
<label class="govuk-label govuk-checkboxes__label" for="publisher-11">
Department for Transport
</label>
Expand All @@ -201,7 +203,7 @@ <h2 class="govuk-fieldset__heading">
<div class="orp-flex orp-flex--space-between">
<p class="govuk-body govuk-!-font-weight-bold govuk-!-margin-bottom-0">
{% if results %}
{{ results_count }} documents
{{ results_total_count }} documents
{% else %}
{% if form.is_bound %}
No documents found
Expand Down Expand Up @@ -251,7 +253,7 @@ <h2 class="govuk-fieldset__heading">
<div class="govuk-summary-list orp-search-results">
{% for result in results %}
<div class="govuk-summary-list__row--no-border">
<span class="govuk-caption-m">{{ result.document_type }}</span>
<span class="govuk-caption-m">{{ result.type }}</span>
<h2 class="govuk-heading-m">
<a href="/document/{{ result.id }}" class="govuk-link">
{{result.title}}
Expand Down
2 changes: 1 addition & 1 deletion orp/orp_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,5 @@ def search(request: HttpRequest) -> HttpResponse:
context = public_gateway.finalise_results(config, search_results, context)

logger.info("search results: %s", context["results"])
logger.info("search results count: %s", context["results_count"])
# logger.info("search results count: %s", context["results_count"])
return render(request, template_name="orp.html", context=context)

0 comments on commit 3eab980

Please sign in to comment.