Skip to content

Commit 182bff2

Browse files
committed
Add support for funding application flags and improve date handling
Introduces saveFundingApplicationFlags action and updates SelectedAppHeader to handle funding application routes. Adjusts ApprenticeshipTrainingForm to use classes_start_date and classes_end_date fields, and recalculates weeks when these change. Updates router and store to support sidebar visibility for funding applications and adds logging for sidebar state changes.
1 parent 6f46727 commit 182bff2

File tree

5 files changed

+33
-20
lines changed

5 files changed

+33
-20
lines changed

src/web/src/components/SelectedAppHeader.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ export default {
4848
},
4949
},
5050
methods: {
51-
...mapActions(["saveApplicationFlags"]),
51+
...mapActions(["saveApplicationFlags", "saveFundingApplicationFlags"]),
5252
saveFlags() {
53-
this.saveApplicationFlags(this.flags);
53+
54+
if (this.$route.path.includes("funding-application"))
55+
this.saveFundingApplicationFlags(this.flags);
56+
else
57+
this.saveApplicationFlags(this.flags);
5458
},
5559
},
5660
};

src/web/src/components/application/assessments/views/WUP-Apprenticeship.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,11 @@ export default {
210210
this.applicationId = this.$route.params.id;
211211
this.fundingRequestId = this.$route.params.fundingRequestId;
212212
this.assessmentId = this.$route.params.assessmentId;
213-
store.dispatch("setAppSidebar", true);
214213
215214
let storeApp = store.getters.selectedApplication;
216215
if (this.applicationId != storeApp.HISTORY_DETAIL_ID) {
217216
await store.dispatch("loadFundingApplication", this.applicationId);
218217
}
219-
store.dispatch("setAppSidebar", true);
220-
221-
222218
this.loadStatus()
223219
this.loadReasons()
224220

src/web/src/components/application/wup-funding-requests/apprenticeship-training-support/ApprenticeshipTrainingForm.vue

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@
144144
class="mt-0 mb-5" hide-details @change="saveItem" />
145145
<v-row class="mb-1">
146146
<v-col cols="12" md="3">
147-
<v-text-field :value="formatDate(fundingRequest.json_data.from_date)" label="From" dense outlined
147+
<v-text-field :value="formatDate(fundingRequest.json_data.classes_start_date)" label="From" dense outlined
148148
background-color="#ddd" append-icon="mdi-lock" hide-details readonly />
149149
</v-col>
150150
<v-col cols="12" md="3">
151-
<v-text-field :value="formatDate(fundingRequest.json_data.to_date)" label="To" dense outlined
151+
<v-text-field :value="formatDate(fundingRequest.json_data.classes_end_date)" label="To" dense outlined
152152
background-color="#ddd" append-icon="mdi-lock" hide-details readonly />
153153
</v-col>
154154
<v-col cols="12" md="3">
@@ -316,15 +316,6 @@ export default {
316316
fundingRequest() {
317317
const myRequest = this.application?.funding_requests?.find((fr) => fr.request_type_id === 51);
318318
319-
if (myRequest && myRequest.json_data != null) {
320-
myRequest.json_data.from_date = this.application.classes_start_date;
321-
myRequest.json_data.to_date = this.application.classes_end_date;
322-
myRequest.json_data.weeks = weeksBetween(
323-
this.application.classes_start_date,
324-
this.application.classes_end_date
325-
);
326-
}
327-
328319
this.hasFundingRequest = !!myRequest;
329320
return myRequest;
330321
},
@@ -334,12 +325,14 @@ export default {
334325
},
335326
},
336327
watch: {
337-
/* "fundingRequest.json_data": {
328+
"fundingRequest.json_data": {
338329
deep: true,
339330
handler(newVal) {
340-
console.log("Funding request JSON data changed:", newVal);
331+
if (newVal && newVal.classes_start_date && newVal.classes_end_date) {
332+
newVal.weeks = weeksBetween(newVal.classes_start_date, newVal.classes_end_date);
333+
}
341334
},
342-
}, */
335+
},
343336
},
344337
async mounted() {
345338
await this.loadInstitutions();

src/web/src/router/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ router.beforeEach(async (to, from, next) => {
421421
store.dispatch(
422422
"setAppSidebar",
423423
to.path.startsWith("/application") ||
424+
to.path.startsWith("/funding-application") ||
424425
to.path.startsWith("/student") ||
425426
to.path.startsWith("/communications-log")
426427
);

src/web/src/store/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ export default new Vuex.Store({
289289
},
290290
actions: {
291291
setAppSidebar(state, value) {
292+
console.log("Setting sidebar to", value);
292293
state.commit("SET_SIDEBAR", value);
293294
},
294295
setAppSideBarAdmin(state, value) {
@@ -715,6 +716,24 @@ export default new Vuex.Store({
715716
//emitter.$emit("showError", err.data.messages[0].text);
716717
});
717718
},
719+
saveFundingApplicationFlags({ state, dispatch }, vals) {
720+
let val = vals.join(",").trim();
721+
722+
axios
723+
.put(`${FUNDING_APPLICATION_URL}/${state.selectedApplicationId}`, {
724+
flags: val,
725+
})
726+
.then((resp) => {
727+
dispatch("loadFundingApplication", state.selectedApplicationId);
728+
//let message = resp.data.messages[0];
729+
//if (message.variant == "success") emitter.$emit("showSuccess", message.text);
730+
//else emitter.$emit("showError", message.text);
731+
})
732+
.catch((err) => {
733+
console.log("ERROR HAPPENED", err);
734+
//emitter.$emit("showError", err.data.messages[0].text);
735+
});
736+
},
718737
loadFlagOptions({ commit }) {
719738
axios.get(`${APPLICATION_URL}/flags`).then((resp) => {
720739
commit("SET_FLAGOPTIONS", resp.data.data);

0 commit comments

Comments
 (0)