Skip to content

Commit

Permalink
Merge pull request #550 from jac-uk/feature/#463_prevent_application_…
Browse files Browse the repository at this point in the history
…with_issues_moving_to_handover

applications with issues cant be moved to handover
  • Loading branch information
lloback authored Jun 4, 2020
2 parents 2913082 + 3169bed commit 22dbdd4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 64 deletions.
36 changes: 34 additions & 2 deletions src/views/Exercises/Stages/RecommendedEdit.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<template>
<form @submit.prevent="validateAndSave">
<div
v-if="showWarning"
>
<Banner
:message="warningMessage"
/>
</div>
<ErrorSummary
:errors="errors"
/>
Expand All @@ -24,13 +31,16 @@
</template>

<script>
import { APPLICATION_STATUS } from '@/helpers/constants';
import Banner from '@/components/Page/Banner';
import Form from '@/components/Form/Form';
import ErrorSummary from '@/components/Form/ErrorSummary';
import RadioGroup from '@/components/Form/RadioGroup';
import RadioItem from '@/components/Form/RadioItem';
export default {
components: {
Banner,
ErrorSummary,
RadioGroup,
RadioItem,
Expand All @@ -39,9 +49,14 @@ export default {
data() {
return {
newSelectedStatus: null,
showWarning: false,
confirmedSave: false,
};
},
computed: {
applicationRecords() {
return this.$store.state.stageRecommended.records;
},
applicationId() {
return this.$route.params.applicationId;
},
Expand All @@ -52,6 +67,9 @@ export default {
const selectedItems = this.$store.state.stageRecommended.selectedItems;
return selectedItems;
},
warningMessage() {
return (this.itemsWithIssues() > 1) ? `${this.itemsWithIssues()} candidates have issues` : '1 candidate has issues';
},
},
created() {
// on refresh if there's no IDs to change => redirect to the list
Expand All @@ -60,9 +78,23 @@ export default {
}
},
methods: {
itemsWithIssues() {
const selectedApplications = this.applicationRecords.filter(item => this.itemsToChange.indexOf(item.application.id) >= 0);
return selectedApplications.filter(item => item.flags.eligibilityIssues || item.flags.characterIssues).length;
},
confirm(){
this.confirmedSave = true;
},
cancel(){
this.showWarning = false;
},
async save() {
await this.$store.dispatch('stageRecommended/updateStatus', { status: this.newSelectedStatus });
this.$router.push({ name: 'exercise-stages-recommended-list' });
if (this.itemsWithIssues() && this.newSelectedStatus === APPLICATION_STATUS.APPROVED_FOR_IMMEDIATE_APPOINTMENT){
this.showWarning = true;
} else {
await this.$store.dispatch('stageRecommended/updateStatus', { status: this.newSelectedStatus });
this.$router.push({ name: 'exercise-stages-recommended-list' });
}
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/views/Exercises/Stages/SelectedEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default {
if (!this.confirmedSave && this.itemsHaveIssues()){
this.showWarning = true;
} else {
await this.$store.dispatch('stageSelected/updateStatus', { status: this.newSelectedStatus });
await this.$store.dispatch('stageSelected/updateStatus', { applicationId: this.applicationId, status: this.newSelectedStatus });
this.$router.push({ name: 'exercise-stages-selected-list' });
}
},
Expand Down
62 changes: 1 addition & 61 deletions src/views/Sandbox.vue
Original file line number Diff line number Diff line change
@@ -1,68 +1,8 @@
<template>
<div>
<Banner
:message="'gabe'"
:status="'success'"
/>
<TabsList
:tabs="tabs"
:active-tab.sync="activeTab"
/>
{{ activeTab }}
{{ selectedItems }}
<Table
data-key="id"
:data="tableData"
:columns="[
{ title: 'Reference number' },
{ title: 'Candidate' },
{ title: 'Status' },
]"
multi-select
:selection.sync="selectedItems"
>
<template #row="{row}">
<TableCell>{{ row.application.referenceNumber }}</TableCell>
<TableCell>{{ row.candidate.fullName }}</TableCell>
<TableCell>{{ row.status | lookup }}</TableCell>
</template>
</Table>
</div>
<div />
</template>
<script>
import Banner from '@/components/Page/Banner';
import TabsList from '@/components/Page/TabsList';
import Table from '@/components/Page/Table/Table';
import TableCell from '@/components/Page/Table/TableCell';
export default {
components: {
TabsList,
Table,
TableCell,
Banner,
},
data() {
return {
tabs: [
{
ref: 'one',
title: 'this is tab 1',
},
{
ref: 'two',
title: 'here is tab 2',
},
],
activeTab: 'one',
tableData: [
{ id: 'row-1', application: { referenceNumber: 'app-1' }, candidate: { fullName: 'Candidate 1' }, status: 'passedFirstTest' },
{ id: 'row-2', application: { referenceNumber: 'app-2' }, candidate: { fullName: 'Candidate 2' }, status: 'passedSift' },
{ id: 'row-3', application: { referenceNumber: 'app-3' }, candidate: { fullName: 'Candidate 3' }, status: 'failedSift' },
{ id: 'row-4', application: { referenceNumber: 'app-4' }, candidate: { fullName: 'Candidate 4' }, status: 'failedFirstTest' },
],
selectedItems: ['row-1'],
};
},
};
</script>

0 comments on commit 22dbdd4

Please sign in to comment.