-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2801 from uktrade/feat/move-analysis-accordion
Feat: copy code snippets to detail/preview page
- Loading branch information
Showing
9 changed files
with
352 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
dataworkspace/dataworkspace/templates/datasets/data-preview/data_cut_source_preview.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
{% extends '_main_no_container.html' %} | ||
{% load static core_tags humanize waffle_tags datasets_tags %} | ||
|
||
{% block page_title %}View {{ object.name }} - {{ block.super }}{% endblock %}data-grid | ||
|
||
{% block footer_scripts %} | ||
<script src="{% static 'ag-grid-community.min.js' %}"></script> | ||
<script src="{% static 'dayjs.min.js' %}"></script> | ||
<script src="{% static 'js/grid-utils.js' %}"></script> | ||
<script src="{% static 'data-grid.js' %}"></script> | ||
{# We *have* to include the stylesheet after the ag-grid js as it overrides the default styles #} | ||
<link rel="stylesheet" type="text/css" href="{% static 'data-grid.css' %}"/> | ||
{{ object.get_column_config|json_script:"column_data" }} | ||
{% saved_grid_config user object as grid_config %} | ||
{{ grid_config|json_script:"grid-config" }} | ||
<script nonce="{{ request.csp_nonce }}"> | ||
window.initDataGrid( | ||
JSON.parse(document.getElementById('column_data').textContent), | ||
'{{ object.get_grid_data_url }}', | ||
'?download=1', | ||
null, | ||
'{{ object.name }}-custom-export.csv', | ||
{% flag CHART_BUILDER_BUILD_CHARTS_FLAG %} | ||
'{% url 'datasets:create_chart_from_grid' object.dataset.id object.id %}', | ||
{% else %} | ||
null, | ||
{% endflag %} | ||
null, | ||
'{{ object.dataset.id }}', | ||
'{{ object.dataset.name }}', | ||
'{{ object.dataset.get_type_display }}', | ||
null, | ||
'{% url 'datasets:log_data_preview_load_time' object.dataset.id object.id %}' | ||
); | ||
</script> | ||
{% endblock footer_scripts %} | ||
{% block content %} | ||
{% with object.get_metadata_row_count as row_count %} | ||
<div class="govuk-breadcrumbs govuk-!-padding-left-2 govuk-!-padding-bottom-2 govuk-!-margin-bottom-0 app-grid-breadcrumbs"> | ||
<ol class="govuk-breadcrumbs__list"> | ||
<li class="govuk-breadcrumbs__list-item"> | ||
<a class="govuk-breadcrumbs__link" href="">Home</a> | ||
</li> | ||
<li class="govuk-breadcrumbs__list-item"> | ||
<a class="govuk-breadcrumbs__link" | ||
href="{% url "datasets:dataset_detail" dataset_uuid=object.dataset.id %}#{{ object.dataset.slug }}">{{ object.dataset }}</a> | ||
</li> | ||
<li class="govuk-breadcrumbs__list-item">{{ object.name }}</li> | ||
{% flag SECURITY_CLASSIFICATION_FLAG %} | ||
<div style="float: right" class="govuk-!-padding-right-3"> | ||
{% if not object.dataset.government_security_classification %} | ||
<strong class="govuk-tag govuk-tag--yellow">Awaiting classification</strong> | ||
{% else %} | ||
{% if object.dataset.get_government_security_classification_display == "OFFICIAL" %} | ||
<strong | ||
class="govuk-tag govuk-tag--blue">{{ object.dataset.get_government_security_classification_display }}</strong> | ||
{% else %} | ||
<strong | ||
class="govuk-tag govuk-tag--red">{{ object.dataset.get_government_security_classification_display }} | ||
{% if object.dataset.sensitivity.all %} | ||
{% for sensitivity in object.dataset.sensitivity.all %} | ||
{% if not forloop.first %}and{% endif %}</span> {{ sensitivity }} | ||
{% endfor %} | ||
{% endif %} </strong> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
{% endflag %} | ||
</ol> | ||
</div> | ||
<div id="collapsible-header" class="govuk-!-margin-top-4"> | ||
{% if object.disable_data_grid_interaction %} | ||
{% include "datasets/partials/grid-interaction-disabled.html" %} | ||
{% endif %} | ||
{% include "datasets/partials/grid-view-saved.html" %} | ||
{% if object.dataset.enquiries_contact %} | ||
<a class="govuk-link govuk-link--no-visited-state govuk-!-padding-right-3" style="float: right" | ||
href="mailto:{{ object.dataset.enquiries_contact.email }}?subject=Reporting an issue - {{ object.name }}"> | ||
{% include "partials/report_an_issue_icon.html" %} | ||
</a> | ||
{% endif %} | ||
<div class="govuk-!-padding-top-3 govuk-!-padding-left-2"> | ||
<span class="govuk-caption-xl"> | ||
Data table{% if object.schema %} ({{ object.schema }}.{{ object.table }}){% endif %} | ||
</span> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full"> | ||
<h2 class="govuk-heading-l">{{ object.name }}</h2> | ||
</div> | ||
<div class="govuk-grid-column-full"> | ||
{% if columns or code_snippets and has_access %} | ||
{% if columns %} | ||
{% include "partials/column_list.html" with columns=columns dataset=dataset source=datacut_link %} | ||
{% endif %} | ||
{% if code_snippets and has_access %} | ||
<details class="govuk-details govuk-!-margin-bottom-2" data-module="govuk-details"> | ||
<summary class="govuk-details__summary"> | ||
<span class="govuk-details__summary-text"> | ||
Use this data for analysis<span | ||
class="govuk-visually-hidden"> "{{ source_table.schema }}"."{{ source_table.table }}"</span> | ||
</span> | ||
</summary> | ||
<div class="govuk-details__text"> | ||
{% include 'partials/code_snippets.html' with code_snippets=code_snippets source_table=datacut_link tools_links=tools_links %} | ||
</div> | ||
</details> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
<div class="govuk-grid-column-full"> | ||
<p class="govuk-body govuk-!-padding-top-0 govuk-!-padding-right-3 govuk-!-margin-bottom-2 govuk-!-text-align-right"> | ||
<span class="govuk-!-font-weight-bold">Data last updated:</span> | ||
{{ object.get_data_last_updated_date|gmt_date|default_if_none:"N/A" }} {{ object.get_data_last_updated_date|time_with_gmt_offset|default_if_none:"N/A" }} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="app-compressed-grid"> | ||
<div class="app-grid-header"> | ||
<div class="grid-header-left"> | ||
<div class="govuk-button-group"> | ||
<p class="govuk-body govuk-!-font-weight-bold" id="data-grid-rowcount"> | ||
{% if row_count is not None %} | ||
{% if row_count > 5000 %}Over 5,000{% else %}{{ row_count|intcomma }}{% endif %} rows | ||
{% else %} | ||
Loading data... | ||
{% endif %} | ||
</p> | ||
{% flag CHART_BUILDER_BUILD_CHARTS_FLAG %} | ||
<button class="govuk-button" id="data-grid-create-chart">Create a chart</button> | ||
{% endflag %} | ||
<button class="govuk-button govuk-button--secondary" data-module="govuk-button" id="data-grid-save-view" data-prevent-double-click="true"> | ||
Save view | ||
</button> | ||
<button class="govuk-button govuk-button--secondary" data-module="govuk-button" id="data-grid-reset-view"> | ||
Reset view | ||
</button> | ||
{% if object.data_grid_download_enabled %} | ||
<button class="govuk-button govuk-button--secondary" data-module="govuk-button" id="downloadData"> | ||
Download this data | ||
</button> | ||
{% endif %} | ||
{# We only support data dictionaries for master and reference datasets currently #} | ||
{# reference datagrid uses reference_dataset_grid.html btw #} | ||
{% if object.type == 1 %} | ||
{% if object.dataset.dictionary_published or request.user|can_edit_dataset:object.dataset %} | ||
<a href="{% url "datasets:data_dictionary" source_uuid=object.id %}?dataset_uuid={{ object.dataset.id }}" target="_blank" class="govuk-link govuk-!-margin-top-1 govuk-!-font-size-16"> | ||
Data dictionary | ||
</a> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="grid-header-right govuk-!-padding-right-3"> | ||
<button id="increase-grid-button" class="govuk-button govuk-button--secondary" data-module="govuk-button">Show more rows</button> | ||
</div> | ||
</div> | ||
<div | ||
id="data-grid" | ||
class="ag-theme-alpine" | ||
data-save-view-url="{{ object.get_save_grid_view_url }}" | ||
{% if row_count is not None %} | ||
data-initial-row-count="{{ row_count }}" | ||
{% endif %} | ||
data-source-name= "{{ object.name }}{% if object.schema %} ({{ object.schema }}.{{ object.table }}){% endif %}" | ||
{% if object.disable_data_grid_interaction %} | ||
data-disable-interaction="true" | ||
{% endif %} | ||
></div> | ||
</div> | ||
{% include "datasets/partials/dialog-data-cut.html" %} | ||
{% endwith %} | ||
{% csrf_token %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.