Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2547 Improvements to Custom report v2.1 #2599

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 17 additions & 69 deletions src/views/Exercise/Reports/Custom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
</select>
<button
class="govuk-button govuk-button--primary moj-button-menu__item moj-page-header-actions__action"
@click="openModal('modalRefSaveReport')"
:disabled="isLoading || columns.length === 0"
@click="generateReport"
>
Save Report
Generate Report
</button>
<button
class="govuk-button govuk-button--primary moj-button-menu__item moj-page-header-actions__action"
:disabled="isLoading || !data"
:disabled="isLoading || !data || columns.length === 0"
@click="downloadReport"
>
Download Report
Expand All @@ -61,7 +62,8 @@
/>
<div class="govuk-inset-text govuk-!-margin-bottom-7">
<p class="govuk-body">
This report is experimental. Please provide feedback if something doesn't look right.
<!-- This report is experimental. Please provide feedback if something doesn't look right. -->
Choose the fields you wish to include in your custom report from the dropdown below and then click 'generate' to produce your report on screen. Only candidates with the status 'Applied' will be included in the report.<br>Download the report when you are satisfied with the content.
</p>
</div>
<div class="govuk-grid-row">
Expand Down Expand Up @@ -137,67 +139,9 @@
</div>
</div>

<div class="govuk-grid-row govuk-!-margin-top-3 govuk-!-margin-bottom-3">
<div class="govuk-grid-column-one-third">
<h2>Application status</h2>
<CheckboxGroup
id="select-status"
v-model="statuses"
label=""
>
<CheckboxItem
v-for="(status) in STATUS"
:key="status"
:value="status"
:label="$filters.lookup(status)"
/>
</CheckboxGroup>
</div>

<div class="govuk-grid-column-two-thirds">
<h2>Stage</h2>
<div class="govuk-button-group">
<select
v-model="selectedStage"
class="govuk-select"
>
<option value="all">
All
</option>
<option
v-for="stage in availableStages"
:key="stage"
:value="stage"
>
{{ $filters.lookup(stage) }} ({{ $filters.formatNumber(applicationRecordCounts[stage]) }})
</option>
</select>
</div>
<div class="govuk-button-group">
<select
v-if="availableStatuses && availableStatuses.length > 0"
v-model="selectedStageStatus"
class="govuk-select"
>
<option
value="all"
>
All
</option>
<option
v-for="item in availableStatuses"
:key="item"
:value="item"
>
{{ $filters.lookup(item) }}
</option>
</select>
</div>
</div>
</div>

<div
v-if="columns.length > 0"
id="column-list"
class="panel govuk-!-margin-bottom-3"
>
<h2 class="govuk-!-margin-bottom-0 govuk-!-margin-top-0">
Expand Down Expand Up @@ -381,8 +325,6 @@ import _ from 'lodash';
import Modal from '@jac-uk/jac-kit/components/Modal/Modal.vue';
import LoadingMessage from '@jac-uk/jac-kit/draftComponents/LoadingMessage.vue';
import Banner from '@jac-uk/jac-kit/draftComponents/Banner.vue';
import CheckboxGroup from '@jac-uk/jac-kit/draftComponents/Form/CheckboxGroup.vue';
import CheckboxItem from '@jac-uk/jac-kit/draftComponents/Form/CheckboxItem.vue';
import { STATUS } from '@jac-uk/jac-kit/helpers/constants';
import { applicationRecordCounts, availableStages, availableStatuses } from '@/helpers/exerciseHelper';
import permissionMixin from '@/permissionMixin';
Expand All @@ -398,8 +340,6 @@ export default {
draggable,
LoadingMessage,
Banner,
CheckboxGroup,
CheckboxItem,
},
mixins: [permissionMixin],
data() {
Expand All @@ -416,7 +356,7 @@ export default {
customReportName: null,
selectedColumn: '',
whereClauses: [],
columns: [],
columns: ['referenceNumber', 'personalDetails.fullName', 'status'],
warnings: '',
warningTimeout: null,
groups: [
Expand Down Expand Up @@ -694,7 +634,7 @@ export default {
},
columns: {
handler: function() {
this.getApplicationRecords();
this.data = null;
},
deep: true,
},
Expand Down Expand Up @@ -812,6 +752,14 @@ export default {
this.columns = report.columns;
this.whereClauses = report.whereClauses;
},
generateReport() {
this.getApplicationRecords();
// Scroll to the list of columns
const element = document.querySelector('#column-list'); // Replace with the actual element selector
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
},
downloadReport() {
const header = [...this.columns].map(col => this.keys[col].label);
const csv = [[...header]];
Expand Down
Loading