Skip to content

Commit

Permalink
change exercise reference prefix for external and Welsh GOV
Browse files Browse the repository at this point in the history
  • Loading branch information
KoWeiJAC committed Jul 30, 2024
1 parent 1800ede commit a307ee5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/store/exercise/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import clone from 'clone';
import { getExerciseSaveData } from '@/helpers/exerciseHelper';
import { logEvent } from '@/helpers/logEvent';
import { checkNested } from '@/helpersTMP/object';
import { ADVERT_TYPES } from '@/helpers/constants';

const collectionName = 'exercises';
const collectionRef = collection(firestore, collectionName);
Expand Down Expand Up @@ -56,8 +57,15 @@ export default {
const metaDoc = await transaction.get(metaRef);
const newExercisesCount = metaDoc.data().exercisesCount + 1;
const exerciseRef = doc(collection(firestore, 'exercises'));

let prefix = 'JAC';
if (data.advertType === ADVERT_TYPES.EXTERNAL) {
prefix = 'EXT';
} else if (data.isWelshGov) {
prefix = 'GOW';
}
transaction.update(metaRef, { exercisesCount: newExercisesCount });
data.referenceNumber = `JAC${ (100000 + newExercisesCount).toString().substr(1)}`;
data.referenceNumber = `${prefix}${ (100000 + newExercisesCount).toString().substr(1)}`;
data.progress = data.progress || { started: true };
data.state = 'draft';
data.published = false;
Expand Down
23 changes: 23 additions & 0 deletions src/views/CreateExercise.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@
/>
</RadioGroup>

<RadioGroup
v-if="isAdvertTypeExternal !== null && !isAdvertTypeExternal"
id="is-a-Welsh-government-exercise"
v-model="isWelshGov"
label="Is this a Welsh government exercise"
required
:messages="{
required: 'Please specify whether the exercise a Welsh government exercise'
}"
>
<RadioItem
:value="true"
label="Yes"
/>

<RadioItem
:value="false"
label="No"
/>
</RadioGroup>

<RadioGroup
v-if="isAdvertTypeExternal !== null && !isAdvertTypeExternal"
id="is-more-info-needed"
Expand Down Expand Up @@ -197,6 +218,7 @@ export default {
return {
exerciseName: null,
isAdvertTypeExternal: null,
isWelshGov: false,
addMoreInfo: null,
addMoreInfoSelection: null,
};
Expand All @@ -214,6 +236,7 @@ export default {
name: this.exerciseName,
exerciseMailbox: this.$store.state.auth.currentUser.email,
characterChecksEnabled: true,
isWelshGov: this.isWelshGov,
};
if (this.isAdvertTypeExternal) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Exercises.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
data() {
return {
tableColumns: [
{ title: 'Reference', sort: 'referenceNumber', direction: 'asc', default: true },
{ title: 'Reference', sort: 'createdAt', direction: 'desc', default: true },
{ title: 'Name', sort: 'name' },
{ title: 'Open', sort: 'applicationOpenDate' },
{ title: 'Close', sort: 'applicationCloseDate' },
Expand Down

0 comments on commit a307ee5

Please sign in to comment.