Skip to content

Commit

Permalink
updated batch inputs to confirm port
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunlumbcgov committed Oct 4, 2024
1 parent 1579ad3 commit fdea175
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 180 deletions.
7 changes: 6 additions & 1 deletion frontend/src/components/Batch/Forms/DistrunForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@
<ProgramInput></ProgramInput>
</v-row>
<v-row v-if="group == 'School'">
<SchoolInput></SchoolInput>
<SchoolInput
:disableSelectStudents="
getCredential == 'Blank certificate print' ||
getCredential == 'Blank transcript print'
"
></SchoolInput>
</v-row>
</v-stepper-window-item>
<v-stepper-window-item value="3">
Expand Down
31 changes: 18 additions & 13 deletions frontend/src/components/Batch/Forms/FormInputs/DateRangeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

<script>
import { required, helpers } from "@vuelidate/validators";
import { ref, watch } from "vue";
import useVuelidate from "@vuelidate/core";
import { useBatchRequestFormStore } from "../../../../store/modules/batchRequestFormStore";
import { debounce } from "lodash";
Expand Down Expand Up @@ -102,26 +103,30 @@ export default {
},
};
},
created() {
this.gradDateFrom = this.batchRequestFormStore.gradDateFrom;
this.gradDateTo = this.batchRequestFormStore.gradDateTo;
// Initialize Vuelidate
this.v$ = useVuelidate();
setup() {
const batchRequestFormStore = useBatchRequestFormStore();
const gradDateFrom = ref(batchRequestFormStore.gradDateFrom);
const gradDateTo = ref(batchRequestFormStore.gradDateTo);
watch(gradDateFrom, (newValue) => {
batchRequestFormStore.gradDateFrom = newValue;
});
watch(gradDateTo, (newValue) => {
batchRequestFormStore.gradDateTo = newValue;
});
return {
gradDateFrom,
gradDateTo,
v$: useVuelidate(),
};
},
watch: {
"batchRequestFormStore.gradDateFrom"(newValue) {
this.gradDateFrom = newValue;
},
"batchRequestFormStore.gradDateTo"(newValue) {
this.gradDateTo = newValue;
},
includeStudents(newValue) {
if (newValue === "Current Students") {
this.clearDateFields();
}
// Re-evaluate validations when the selection changes
this.v$.$reset();
},
},
methods: {
Expand Down
107 changes: 16 additions & 91 deletions frontend/src/components/Batch/Forms/FormInputs/DistrictInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
></v-select>
</v-col>
</v-row>
<v-row>
<v-row v-if="!disableSelectStudents">
<v-col md="12">
<DateRangeInput></DateRangeInput>
</v-col>
Expand Down Expand Up @@ -104,93 +104,6 @@
<div><strong>Active Flag:</strong> {{ item.info.activeFlag }}</div>
</template>
</v-data-table>

<!-- <v-data-table :items="districts" :headers="districtInputFields" striped>
<template v-slot:top>
<v-row>
<v-col sm="9"></v-col>
<v-col sm="3">
<v-btn @click="addMode = true" :disabled="addMode"
><v-icon>mdi-plus</v-icon> Add
</v-btn>
</v-col>
</v-row></template
>
<template v-slot:item.remove="{ item }">
<v-btn
v-if="schoolCategory != '09' && schoolCategory != '04'"
@click="removeDistrict(item.district)"
color="primary"
>
Remove
</v-btn>
</template>
<template v-slot:item.info="{ item }">
<div>
<strong>District Name:</strong> {{ item.info.districtName }}
</div>
<div><strong>Active Flag:</strong> {{ item.info.activeFlag }}</div>
</template>
<template v-slot:body.prepend>
<tr v-if="addMode">
<td>Include</td>
<td>
<v-row
v-if="schoolCategory !== '04' && schoolCategory !== '09'"
>
<v-col sm="12" lg="12">
<v-autocomplete
v-model="district"
:items="getDistrictList"
label="Include District"
outlined
:item-title="districtTitle"
item-value="districtNumber"
hide-details
></v-autocomplete>
</v-col>
</v-row>
<v-row>
<v-col>
<v-row v-if="districtInfo" class="float-left col-10">
<v-card>
<v-card-text>
<v-alert
v-if="validationMessage"
dismissible
type="danger"
>{{ validationMessage }}</v-alert
>
<v-overlay :value="districtValidating">
<div v-if="!districtInfo">NOT VALID</div>
<div v-else>
<strong>District:</strong>
{{ districtInfo.districtName }}<br />
<strong>Active Flag:</strong>
{{ districtInfo.activeFlag }}<br />
</div>
</v-overlay>
</v-card-text>
</v-card>
</v-row>
</v-col>
</v-row>
</td>
<td>
<v-btn
:disabled="!district"
@click="addDistrict()"
class="float-left bg-primary"
>
Add
</v-btn>
</td>
</tr>
</template>
</v-data-table> -->
</v-card-text>
</v-card>
</v-container>
Expand All @@ -211,7 +124,10 @@ export default {
const gradDateFrom = ref(batchRequestFormStore.gradDateFrom);
const gradDateTo = ref(batchRequestFormStore.gradDateTo);
const districts = ref(batchRequestFormStore.districts);
const schoolCategory = ref(batchRequestFormStore.categoryCode);
watch(schoolCategory, (newValue) => {
batchRequestFormStore.categoryCode = newValue;
});
watch(gradDateFrom, (newValue) => {
batchRequestFormStore.gradDateFrom = newValue;
});
Expand All @@ -220,6 +136,7 @@ export default {
});
return {
schoolCategory,
gradDateTo,
gradDateFrom,
districts,
Expand Down Expand Up @@ -283,7 +200,6 @@ export default {
districtInfo: "",
districtValidating: false,
validationMessage: "",
schoolCategory: "",
districtInputFields: [
{
key: "district",
Expand Down Expand Up @@ -363,11 +279,20 @@ export default {
props: {
credentialType: String,
runType: String,
disableSelectStudents: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
...mapState(useAppStore, ["getDistrictList"]),
...mapState(useBatchRequestFormStore, ["getDistricts", "getBatchRequest"]),
...mapState(useBatchRequestFormStore, [
"getDistricts",
"getBatchRequest",
"getSchoolCategory",
]),
isEmpty() {
return this.districts.length > 0;
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/Batch/Forms/FormInputs/SchoolInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<slot name="inputWarning"></slot>
</v-alert>

<v-row>
<v-row v-if="!disableSelectStudents">
<v-col sm="12">
<DateRangeInput></DateRangeInput>
</v-col>
Expand Down Expand Up @@ -270,7 +270,14 @@ export default {
}
},
},
props: {},
props: {
disableSelectStudents: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
...mapState(useAppStore, ["getSchoolsList"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
<StudentInput runType="CERT_REGEN"></StudentInput>
</v-row>
<v-row v-if="group == 'School Category'">
<DistrictInput runType="CERT_REGEN"></DistrictInput>
<DistrictInput
runType="CERT_REGEN"
disableSelectStudents
></DistrictInput>
</v-row>
</v-stepper-window-item>

Expand Down
40 changes: 25 additions & 15 deletions frontend/src/components/Batch/Forms/RegenerateSchoolReportForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<v-stepper-item
:rules="[
() =>
!v$.getBatchRequest.hasAtLeastOneGroupValue.$invalid,
!v$.getBatchRequest.hasAtLeastOneGroupValue.$invalid &&
!v$.getBatchRequest.reportTypeRequired.$invalid,
]"
complete
editable
Expand Down Expand Up @@ -75,17 +76,10 @@
/>
</v-row>
<v-row v-if="group == 'School'">
<SchoolInput>
<template #inputWarning>
<p>
This will archive current school reports, which will
become static and no longer be updated. School
reports must be archived before the new data
collection cycle begins so they are not overwritten
entirely.
</p>
</template>
</SchoolInput>
<SchoolInput> </SchoolInput>
</v-row>
<v-row v-if="group == 'School Category'">
<DistrictInput> </DistrictInput>
</v-row>
<v-row v-if="group == 'All Schools'">
<v-alert type="info" class="pb-2">
Expand Down Expand Up @@ -183,6 +177,7 @@
import { ref, watch } from "vue";
import BatchProcessingService from "@/services/BatchProcessingService.js";
import SchoolInput from "@/components/Batch/Forms/FormInputs/SchoolInput.vue";
import DistrictInput from "@/components/Batch/Forms/FormInputs/DistrictInput.vue";
import ScheduleInput from "@/components/Batch/Forms/FormInputs/ScheduleInput.vue";
import { useVuelidate } from "@vuelidate/core";
import { required, helpers } from "@vuelidate/validators";
Expand Down Expand Up @@ -228,6 +223,16 @@ export default {
),
},
getBatchRequest: {
reportTypeRequired: helpers.withMessage(
"Select a Report Type",
(value) => {
if (this.getReportType.length > 0) {
return true;
} else {
return false;
}
}
),
batchRunTimeSet: helpers.withMessage("Runtime not set", (value) => {
if (this.getBatchRunTime) {
if (this.getBatchRunTime == "Run Now") {
Expand All @@ -246,16 +251,20 @@ export default {
let isValid = false;
if (
this.group &&
["All Schools", "School"].includes(this.group)
["All Schools", "School", "School Category"].includes(
this.group
)
) {
if (this.group === "School") {
isValid =
this.getBatchRequest.schoolOfRecords &&
this.getBatchRequest.schoolOfRecords.length > 0;
} else if (this.group === "School Category") {
isValid =
this.getBatchRequest.districts &&
this.getBatchRequest.districts.length > 0;
} else if (this.group === "All Schools") {
isValid = true;
} else {
isValid = true; // Return true if none of the above conditions matched
}
return isValid;
}
Expand All @@ -270,6 +279,7 @@ export default {
components: {
ScheduleInput: ScheduleInput,
SchoolInput: SchoolInput,
DistrictInput: DistrictInput,
},
data: () => ({
step: 0,
Expand Down
Loading

0 comments on commit fdea175

Please sign in to comment.