refetch available on start change
This commit is contained in:
parent
06edeb234d
commit
e34f08ae39
4 changed files with 20 additions and 12 deletions
|
@ -41,12 +41,12 @@ export const useEquipmentStore = defineStore("equipment", {
|
||||||
this.loading = "failed";
|
this.loading = "failed";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAvailableEquipments() {
|
getAvailableEquipments(missionId: string) {
|
||||||
this.availableEquipments = [];
|
this.availableEquipments = [];
|
||||||
http
|
http
|
||||||
.get(`/admin/equipment?available=true`)
|
.get(`/admin/equipment/available/${missionId}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.availableEquipments = res.data.equipments;
|
this.availableEquipments = res.data;
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
},
|
},
|
||||||
|
|
|
@ -41,12 +41,12 @@ export const useForceStore = defineStore("force", {
|
||||||
this.loading = "failed";
|
this.loading = "failed";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAvailableForces() {
|
getAvailableForces(missionId: string) {
|
||||||
this.availableForces = [];
|
this.availableForces = [];
|
||||||
http
|
http
|
||||||
.get(`/admin/force?available=true`)
|
.get(`/admin/force/available/${missionId}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.availableForces = res.data.forces;
|
this.availableForces = res.data;
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
},
|
},
|
||||||
|
|
|
@ -41,12 +41,12 @@ export const useVehicleStore = defineStore("vehicle", {
|
||||||
this.loading = "failed";
|
this.loading = "failed";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAvailableVehicles() {
|
getAvailableVehicles(missionId: string) {
|
||||||
this.availableVehicles = [];
|
this.availableVehicles = [];
|
||||||
http
|
http
|
||||||
.get(`/admin/vehicle?available=true`)
|
.get(`/admin/vehicle/available/${missionId}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.availableVehicles = res.data.vehicles;
|
this.availableVehicles = res.data;
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
},
|
},
|
||||||
|
|
|
@ -123,12 +123,15 @@ export default defineComponent({
|
||||||
this.manageHash();
|
this.manageHash();
|
||||||
this.connectClient();
|
this.connectClient();
|
||||||
this.initialize(this.id);
|
this.initialize(this.id);
|
||||||
this.getAvailableForces();
|
this.fetchAvailability();
|
||||||
this.getAvailableEquipments();
|
|
||||||
this.getAvailableVehicles();
|
|
||||||
window.addEventListener("beforeunload", () => {
|
window.addEventListener("beforeunload", () => {
|
||||||
localStorage.removeItem("yjsDoc_timestamp");
|
localStorage.removeItem("yjsDoc_timestamp");
|
||||||
});
|
});
|
||||||
|
this.yDoc.getMap("form").observe((event) => {
|
||||||
|
event.changes.keys.forEach((change, key) => {
|
||||||
|
if (key === "start") this.fetchAvailability();
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
this.cleanup();
|
this.cleanup();
|
||||||
|
@ -144,6 +147,11 @@ export default defineComponent({
|
||||||
this.$router.replace({ hash: this.tabs[0].hash });
|
this.$router.replace({ hash: this.tabs[0].hash });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
fetchAvailability() {
|
||||||
|
this.getAvailableForces(this.id);
|
||||||
|
this.getAvailableEquipments(this.id);
|
||||||
|
this.getAvailableVehicles(this.id);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue